@@ -2,15 +2,16 @@ use std::{fs::File, io::Write, time::SystemTime};
2
2
3
3
use axelar_solana_its:: state;
4
4
use clap:: { Parser , Subcommand } ;
5
- use serde:: { Deserialize , Serialize } ;
5
+ use serde:: Deserialize ;
6
6
use solana_sdk:: instruction:: Instruction ;
7
7
use solana_sdk:: pubkey:: Pubkey ;
8
8
9
9
use crate :: config:: Config ;
10
10
use crate :: types:: ChainNameOnAxelar ;
11
11
use crate :: utils:: {
12
- self , read_json_file_from_path, ADDRESS_KEY , AXELAR_KEY , CHAINS_KEY , CONFIG_ACCOUNT_KEY ,
13
- CONTRACTS_KEY , GAS_SERVICE_KEY , ITS_KEY ,
12
+ encode_its_destination, read_json_file_from_path, write_json_to_file_path, ADDRESS_KEY ,
13
+ AXELAR_KEY , CHAINS_KEY , CONFIG_ACCOUNT_KEY , CONTRACTS_KEY , GAS_SERVICE_KEY , ITS_KEY ,
14
+ OPERATOR_KEY , UPGRADE_AUTHORITY_KEY ,
14
15
} ;
15
16
16
17
#[ derive( Subcommand , Debug ) ]
@@ -656,15 +657,6 @@ pub(crate) async fn build_instruction(
656
657
}
657
658
}
658
659
659
- #[ derive( Serialize , Deserialize , Debug ) ]
660
- struct ItsInfo {
661
- address : String ,
662
- #[ serde( rename = "configAccount" ) ]
663
- config_account : String ,
664
- #[ serde( rename = "upgradeAuthority" ) ]
665
- upgrade_authority : String ,
666
- }
667
-
668
660
async fn init (
669
661
fee_payer : & Pubkey ,
670
662
init_args : InitArgs ,
@@ -673,21 +665,20 @@ async fn init(
673
665
let mut chains_info: serde_json:: Value = read_json_file_from_path ( & config. chains_info_file ) ?;
674
666
let its_hub_address =
675
667
String :: deserialize ( & chains_info[ AXELAR_KEY ] [ CONTRACTS_KEY ] [ ITS_KEY ] [ ADDRESS_KEY ] ) ?;
676
-
677
- let its_info = ItsInfo {
678
- address : axelar_solana_its:: id ( ) . to_string ( ) ,
679
- config_account : axelar_solana_its:: find_its_root_pda (
680
- & axelar_solana_gateway:: get_gateway_root_config_pda ( ) . 0 ,
681
- )
682
- . 0
683
- . to_string ( ) ,
684
- upgrade_authority : fee_payer. to_string ( ) ,
685
- } ;
668
+ let its_root_config = axelar_solana_its:: find_its_root_pda (
669
+ & axelar_solana_gateway:: get_gateway_root_config_pda ( ) . 0 ,
670
+ )
671
+ . 0 ;
686
672
687
673
chains_info[ CHAINS_KEY ] [ ChainNameOnAxelar :: from ( config. network_type ) . 0 ] [ CONTRACTS_KEY ]
688
- [ ITS_KEY ] = serde_json:: json!( its_info) ;
674
+ [ ITS_KEY ] = serde_json:: json!( {
675
+ ADDRESS_KEY : axelar_solana_gateway:: id( ) . to_string( ) ,
676
+ CONFIG_ACCOUNT_KEY : its_root_config. to_string( ) ,
677
+ UPGRADE_AUTHORITY_KEY : fee_payer. to_string( ) ,
678
+ OPERATOR_KEY : init_args. operator. to_string( ) ,
679
+ } ) ;
689
680
690
- utils :: write_json_to_file_path ( & chains_info, & config. chains_info_file ) ?;
681
+ write_json_to_file_path ( & chains_info, & config. chains_info_file ) ?;
691
682
692
683
Ok ( axelar_solana_its:: instruction:: initialize (
693
684
* fee_payer,
@@ -734,7 +725,7 @@ async fn approve_deploy_remote_interchain_token(
734
725
config : & Config ,
735
726
) -> eyre:: Result < Instruction > {
736
727
let chains_info: serde_json:: Value = read_json_file_from_path ( & config. chains_info_file ) ?;
737
- let destination_minter = utils :: encode_its_destination (
728
+ let destination_minter = encode_its_destination (
738
729
& chains_info,
739
730
& args. destination_chain ,
740
731
args. destination_minter ,
@@ -845,7 +836,7 @@ async fn deploy_remote_interchain_token_with_minter(
845
836
let gas_service = try_infer_gas_service_id ( args. gas_service , config) ?;
846
837
let gas_config_account = try_infer_gas_service_config_account ( args. gas_config_account , config) ?;
847
838
let chains_info: serde_json:: Value = read_json_file_from_path ( & config. chains_info_file ) ?;
848
- let destination_minter = utils :: encode_its_destination (
839
+ let destination_minter = encode_its_destination (
849
840
& chains_info,
850
841
& args. destination_chain ,
851
842
args. destination_minter ,
@@ -932,7 +923,7 @@ async fn interchain_transfer(
932
923
. try_into ( ) ?;
933
924
934
925
let chains_info: serde_json:: Value = read_json_file_from_path ( & config. chains_info_file ) ?;
935
- let destination_address = utils :: encode_its_destination (
926
+ let destination_address = encode_its_destination (
936
927
& chains_info,
937
928
& args. destination_chain ,
938
929
args. destination_address ,
@@ -967,7 +958,7 @@ async fn call_contract_with_interchain_token(
967
958
. as_secs ( )
968
959
. try_into ( ) ?;
969
960
let chains_info: serde_json:: Value = read_json_file_from_path ( & config. chains_info_file ) ?;
970
- let destination_address = utils :: encode_its_destination (
961
+ let destination_address = encode_its_destination (
971
962
& chains_info,
972
963
& args. destination_chain ,
973
964
args. destination_address ,
@@ -1004,7 +995,7 @@ async fn call_contract_with_interchain_token_offchain_data(
1004
995
. as_secs ( )
1005
996
. try_into ( ) ?;
1006
997
let chains_info: serde_json:: Value = read_json_file_from_path ( & config. chains_info_file ) ?;
1007
- let destination_address = utils :: encode_its_destination (
998
+ let destination_address = encode_its_destination (
1008
999
& chains_info,
1009
1000
& args. destination_chain ,
1010
1001
args. destination_address ,
0 commit comments