From d2872881c647f63d41b0757d0b502ec36a2130a1 Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 11 Dec 2024 13:47:21 +0200 Subject: [PATCH 01/15] rename its to interchain_token_service --- move/example/sources/its/its.move | 14 +-- move/example/sources/its/token.move | 4 +- move/its/sources/discovery.move | 26 ++--- ...its.move => interchain_token_service.move} | 74 ++++++------- move/its/sources/types/coin_management.move | 4 +- ....move => interchain_token_service_v0.move} | 102 +++++++++--------- move/squid/sources/squid/discovery.move | 6 +- move/squid/sources/squid/squid.move | 6 +- move/squid/sources/squid/transfers.move | 4 +- .../sources/squid/versioned/squid_v0.move | 4 +- src/common/bcs.ts | 8 +- test/bcs.js | 2 +- test/its.js | 4 +- test/squid.js | 4 +- test/testdata/interface_example_its.json | 4 +- test/testdata/interface_its_discovery.json | 2 +- ...rface_its_interchain_token_service_v0.json | 45 ++++++++ test/testdata/interface_its_its.json | 18 ++-- test/testdata/interface_its_its_v0.json | 4 +- test/testdata/interface_squid_discovery.json | 2 +- test/testdata/interface_squid_squid.json | 2 +- 21 files changed, 192 insertions(+), 147 deletions(-) rename move/its/sources/{its.move => interchain_token_service.move} (92%) rename move/its/sources/versioned/{its_v0.move => interchain_token_service_v0.move} (94%) create mode 100644 test/testdata/interface_its_interchain_token_service_v0.json diff --git a/move/example/sources/its/its.move b/move/example/sources/its/its.move index 8e75ab44..73ca0c02 100644 --- a/move/example/sources/its/its.move +++ b/move/example/sources/its/its.move @@ -8,7 +8,7 @@ use gas_service::gas_service::GasService; use its::coin_info; use its::coin_management; use its::discovery as its_discovery; -use its::its::{Self, ITS}; +use its::its::{Self, InterchainTokenService}; use its::token_id::TokenId; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::{Self, Transaction}; @@ -57,7 +57,7 @@ fun init(ctx: &mut TxContext) { public fun register_transaction( discovery: &mut RelayerDiscovery, singleton: &Singleton, - its: &ITS, + its: &InterchainTokenService, clock: &Clock, ) { let arguments = vector[ @@ -95,7 +95,7 @@ public fun register_transaction( public fun get_final_transaction( singleton: &Singleton, - its: &ITS, + its: &InterchainTokenService, payload: vector, clock: &Clock, ): Transaction { @@ -141,7 +141,7 @@ public fun get_final_transaction( /// This function needs to be called first to register the coin for either of /// the other two functions to work. public fun register_coin( - its: &mut ITS, + its: &mut InterchainTokenService, coin_metadata: &CoinMetadata, ): TokenId { let coin_info = coin_info::from_info( @@ -158,7 +158,7 @@ public fun register_coin( } public fun deploy_remote_interchain_token( - its: &mut ITS, + its: &mut InterchainTokenService, gateway: &mut Gateway, gas_service: &mut GasService, destination_chain: String, @@ -185,7 +185,7 @@ public fun deploy_remote_interchain_token( /// This should trigger an interchain trasnfer. public fun send_interchain_transfer_call( singleton: &Singleton, - its: &mut ITS, + its: &mut InterchainTokenService, gateway: &mut Gateway, gas_service: &mut GasService, token_id: TokenId, @@ -228,7 +228,7 @@ public fun send_interchain_transfer_call( public fun receive_interchain_transfer( approved_message: ApprovedMessage, singleton: &Singleton, - its: &mut ITS, + its: &mut InterchainTokenService, clock: &Clock, ctx: &mut TxContext, ) { diff --git a/move/example/sources/its/token.move b/move/example/sources/its/token.move index f44a8a2b..be04f4b4 100644 --- a/move/example/sources/its/token.move +++ b/move/example/sources/its/token.move @@ -14,8 +14,8 @@ fun init(witness: TOKEN, ctx: &mut TxContext) { let (treasury_cap, coin_metadata) = coin::create_currency( witness, 9, - b"ITS", - b"ITS Example Coin", + b"InterchainTokenService", + b"InterchainTokenService Example Coin", b"", option::none(), ctx, diff --git a/move/its/sources/discovery.move b/move/its/sources/discovery.move index e456e7f1..b8400f80 100644 --- a/move/its/sources/discovery.move +++ b/move/its/sources/discovery.move @@ -1,7 +1,7 @@ module its::discovery; use abi::abi::{Self, AbiReader}; -use its::its::ITS; +use its::its::InterchainTokenService; use its::token_id::{Self, TokenId}; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::{Self, Transaction, package_id}; @@ -44,7 +44,7 @@ public fun interchain_transfer_info( } public fun register_transaction( - its: &mut ITS, + its: &mut InterchainTokenService, discovery: &mut RelayerDiscovery, ) { let mut arg = vector[0]; @@ -53,7 +53,7 @@ public fun register_transaction( let arguments = vector[arg, vector[3]]; let function = transaction::new_function( - package_id(), + package_id(), ascii::string(b"discovery"), ascii::string(b"call_info"), ); @@ -73,7 +73,7 @@ public fun register_transaction( ); } -public fun call_info(its: &ITS, mut payload: vector): Transaction { +public fun call_info(its: &InterchainTokenService, mut payload: vector): Transaction { let mut reader = abi::new_reader(payload); let mut message_type = reader.read_u256(); @@ -95,7 +95,7 @@ public fun call_info(its: &ITS, mut payload: vector): Transaction { } } -fun interchain_transfer_tx(its: &ITS, reader: &mut AbiReader): Transaction { +fun interchain_transfer_tx(its: &InterchainTokenService, reader: &mut AbiReader): Transaction { let token_id = token_id::from_u256(reader.read_u256()); reader.skip_slot(); // skip source_address let destination_address = address::from_bytes(reader.read_bytes()); @@ -116,7 +116,7 @@ fun interchain_transfer_tx(its: &ITS, reader: &mut AbiReader): Transaction { vector[ transaction::new_move_call( transaction::new_function( - package_id(), + package_id(), ascii::string(b"its"), ascii::string(b"receive_interchain_transfer"), ), @@ -152,7 +152,7 @@ fun interchain_transfer_tx(its: &ITS, reader: &mut AbiReader): Transaction { } } -fun deploy_interchain_token_tx(its: &ITS, reader: &mut AbiReader): Transaction { +fun deploy_interchain_token_tx(its: &InterchainTokenService, reader: &mut AbiReader): Transaction { let mut arg = vector[0]; arg.append(object::id_address(its).to_bytes()); @@ -169,7 +169,7 @@ fun deploy_interchain_token_tx(its: &ITS, reader: &mut AbiReader): Transaction { let move_call = transaction::new_move_call( transaction::new_function( - package_id(), + package_id(), ascii::string(b"its"), ascii::string(b"receive_deploy_interchain_token"), ), @@ -185,14 +185,14 @@ fun deploy_interchain_token_tx(its: &ITS, reader: &mut AbiReader): Transaction { // === Tests === #[test_only] -fun initial_tx(its: &ITS): Transaction { +fun initial_tx(its: &InterchainTokenService): Transaction { let mut arg = vector[0]; arg.append(sui::bcs::to_bytes(&object::id(its))); let arguments = vector[arg, vector[3]]; let function = transaction::new_function( - package_id(), + package_id(), ascii::string(b"discovery"), ascii::string(b"call_info"), ); @@ -266,7 +266,7 @@ fun test_discovery_interchain_transfer() { let call_info = tx_block.move_calls().pop_back(); assert!( - call_info.function().package_id_from_function() == package_id(), + call_info.function().package_id_from_function() == package_id(), ); assert!(call_info.function().module_name() == ascii::string(b"its")); assert!( @@ -373,7 +373,7 @@ fun test_discovery_deploy_token() { assert!(move_calls.length() == 1); let call_info = move_calls.pop_back(); assert!( - call_info.function().package_id_from_function() == package_id(), + call_info.function().package_id_from_function() == package_id(), ); assert!(call_info.function().module_name() == ascii::string(b"its")); assert!( @@ -483,7 +483,7 @@ fun test_discovery_hub_message() { let call_info = tx_block.move_calls().pop_back(); assert!( - call_info.function().package_id_from_function() == package_id(), + call_info.function().package_id_from_function() == package_id(), ); assert!(call_info.function().module_name() == ascii::string(b"its")); assert!( diff --git a/move/its/sources/its.move b/move/its/sources/interchain_token_service.move similarity index 92% rename from move/its/sources/its.move rename to move/its/sources/interchain_token_service.move index 0f81905e..b61ca3a9 100644 --- a/move/its/sources/its.move +++ b/move/its/sources/interchain_token_service.move @@ -5,7 +5,7 @@ use axelar_gateway::message_ticket::MessageTicket; use its::coin_info::CoinInfo; use its::coin_management::CoinManagement; use its::interchain_transfer_ticket::{Self, InterchainTransferTicket}; -use its::its_v0::{Self, ITS_v0}; +use its::interchain_token_service_v0::{Self, InterchainTokenService_v0}; use its::owner_cap::{Self, OwnerCap}; use its::token_id::TokenId; use its::trusted_addresses::TrustedAddresses; @@ -27,7 +27,7 @@ const DATA_VERSION: u64 = 0; // ------- // Structs // ------- -public struct ITS has key { +public struct InterchainTokenService has key { id: UID, inner: Versioned, } @@ -38,7 +38,7 @@ public struct ITS has key { fun init(ctx: &mut TxContext) { let inner = versioned::create( DATA_VERSION, - its_v0::new( + interchain_token_service_v0::new( version_control(), ctx, ), @@ -46,7 +46,7 @@ fun init(ctx: &mut TxContext) { ); // Share the its object for anyone to use. - transfer::share_object(ITS { + transfer::share_object(InterchainTokenService { id: object::new(ctx), inner, }); @@ -61,17 +61,17 @@ fun init(ctx: &mut TxContext) { // Macros // ------ /// This macro also uses version control to sinplify things a bit. -macro fun value($self: &ITS, $function_name: vector): &ITS_v0 { +macro fun value($self: &InterchainTokenService, $function_name: vector): &InterchainTokenService_v0 { let its = $self; - let value = its.inner.load_value(); + let value = its.inner.load_value(); value.version_control().check(VERSION, ascii::string($function_name)); value } /// This macro also uses version control to sinplify things a bit. -macro fun value_mut($self: &mut ITS, $function_name: vector): &mut ITS_v0 { +macro fun value_mut($self: &mut InterchainTokenService, $function_name: vector): &mut InterchainTokenService_v0 { let its = $self; - let value = its.inner.load_value_mut(); + let value = its.inner.load_value_mut(); value.version_control().check(VERSION, ascii::string($function_name)); value } @@ -80,7 +80,7 @@ macro fun value_mut($self: &mut ITS, $function_name: vector): &mut ITS_v0 { // Entry Functions // --------------- entry fun allow_function( - self: &mut ITS, + self: &mut InterchainTokenService, _: &OwnerCap, version: u64, function_name: String, @@ -89,7 +89,7 @@ entry fun allow_function( } entry fun disallow_function( - self: &mut ITS, + self: &mut InterchainTokenService, _: &OwnerCap, version: u64, function_name: String, @@ -103,7 +103,7 @@ entry fun disallow_function( // Public Functions // ---------------- public fun register_coin( - self: &mut ITS, + self: &mut InterchainTokenService, coin_info: CoinInfo, coin_management: CoinManagement, ): TokenId { @@ -113,7 +113,7 @@ public fun register_coin( } public fun deploy_remote_interchain_token( - self: &ITS, + self: &InterchainTokenService, token_id: TokenId, destination_chain: String, ): MessageTicket { @@ -142,7 +142,7 @@ public fun prepare_interchain_transfer( } public fun send_interchain_transfer( - self: &mut ITS, + self: &mut InterchainTokenService, ticket: InterchainTransferTicket, clock: &Clock, ): MessageTicket { @@ -156,7 +156,7 @@ public fun send_interchain_transfer( } public fun receive_interchain_transfer( - self: &mut ITS, + self: &mut InterchainTokenService, approved_message: ApprovedMessage, clock: &Clock, ctx: &mut TxContext, @@ -167,7 +167,7 @@ public fun receive_interchain_transfer( } public fun receive_interchain_transfer_with_data( - self: &mut ITS, + self: &mut InterchainTokenService, approved_message: ApprovedMessage, channel: &Channel, clock: &Clock, @@ -184,7 +184,7 @@ public fun receive_interchain_transfer_with_data( } public fun receive_deploy_interchain_token( - self: &mut ITS, + self: &mut InterchainTokenService, approved_message: ApprovedMessage, ) { let value = self.value_mut!(b"receive_deploy_interchain_token"); @@ -195,7 +195,7 @@ public fun receive_deploy_interchain_token( // We need an coin with zero supply that has the proper decimals and typing, and // no Url. public fun give_unregistered_coin( - self: &mut ITS, + self: &mut InterchainTokenService, treasury_cap: TreasuryCap, coin_metadata: CoinMetadata, ) { @@ -205,7 +205,7 @@ public fun give_unregistered_coin( } public fun mint_as_distributor( - self: &mut ITS, + self: &mut InterchainTokenService, channel: &Channel, token_id: TokenId, amount: u64, @@ -222,7 +222,7 @@ public fun mint_as_distributor( } public fun mint_to_as_distributor( - self: &mut ITS, + self: &mut InterchainTokenService, channel: &Channel, token_id: TokenId, to: address, @@ -241,7 +241,7 @@ public fun mint_to_as_distributor( } public fun burn_as_distributor( - self: &mut ITS, + self: &mut InterchainTokenService, channel: &Channel, token_id: TokenId, coin: Coin, @@ -256,7 +256,7 @@ public fun burn_as_distributor( } public fun set_flow_limit( - self: &mut ITS, + self: &mut InterchainTokenService, channel: &Channel, token_id: TokenId, limit: u64, @@ -274,7 +274,7 @@ public fun set_flow_limit( // Owner Functions // --------------- public fun set_trusted_addresses( - self: &mut ITS, + self: &mut InterchainTokenService, _owner_cap: &OwnerCap, trusted_addresses: TrustedAddresses, ) { @@ -284,7 +284,7 @@ public fun set_trusted_addresses( } public fun remove_trusted_addresses( - self: &mut ITS, + self: &mut InterchainTokenService, _owner_cap: &OwnerCap, chain_names: vector, ) { @@ -294,25 +294,25 @@ public fun remove_trusted_addresses( } // === Getters === -public fun registered_coin_type(self: &ITS, token_id: TokenId): &TypeName { +public fun registered_coin_type(self: &InterchainTokenService, token_id: TokenId): &TypeName { self.package_value().registered_coin_type(token_id) } -public fun channel_address(self: &ITS): address { +public fun channel_address(self: &InterchainTokenService): address { self.package_value().channel_address() } // ----------------- // Package Functions // ----------------- -// This function allows the rest of the package to read information about ITS +// This function allows the rest of the package to read information about InterchainTokenService // (discovery needs this). -public(package) fun package_value(self: &ITS): &ITS_v0 { - self.inner.load_value() +public(package) fun package_value(self: &InterchainTokenService): &InterchainTokenService_v0 { + self.inner.load_value() } public(package) fun register_transaction( - self: &mut ITS, + self: &mut InterchainTokenService, discovery: &mut RelayerDiscovery, transaction: Transaction, ) { @@ -381,11 +381,11 @@ const MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN: u256 = 1; const ITS_HUB_ROUTING_IDENTIFIER: vector = b"hub"; #[test_only] -public fun create_for_testing(ctx: &mut TxContext): ITS { +public fun create_for_testing(ctx: &mut TxContext): InterchainTokenService { let mut version_control = version_control(); version_control.allowed_functions()[0].insert(b"".to_ascii_string()); - let mut value = its_v0::new( + let mut value = interchain_token_service_v0::new( version_control, ctx, ); @@ -400,7 +400,7 @@ public fun create_for_testing(ctx: &mut TxContext): ITS { ctx, ); - ITS { + InterchainTokenService { id: object::new(ctx), inner, } @@ -408,7 +408,7 @@ public fun create_for_testing(ctx: &mut TxContext): ITS { #[test_only] public(package) fun add_unregistered_coin_type_for_testing( - self: &mut ITS, + self: &mut InterchainTokenService, token_id: its::token_id::UnregisteredTokenId, type_name: std::type_name::TypeName, ) { @@ -419,7 +419,7 @@ public(package) fun add_unregistered_coin_type_for_testing( #[test_only] public(package) fun remove_unregistered_coin_type_for_testing( - self: &mut ITS, + self: &mut InterchainTokenService, token_id: its::token_id::UnregisteredTokenId, ): std::type_name::TypeName { self.value_mut!(b"").remove_unregistered_coin_type_for_testing(token_id) @@ -427,7 +427,7 @@ public(package) fun remove_unregistered_coin_type_for_testing( #[test_only] public(package) fun add_registered_coin_type_for_testing( - self: &mut ITS, + self: &mut InterchainTokenService, token_id: TokenId, type_name: std::type_name::TypeName, ) { @@ -438,7 +438,7 @@ public(package) fun add_registered_coin_type_for_testing( #[test_only] public(package) fun remove_registered_coin_type_for_testing( - self: &mut ITS, + self: &mut InterchainTokenService, token_id: TokenId, ): std::type_name::TypeName { self.value_mut!(b"").remove_registered_coin_type_for_testing(token_id) @@ -924,7 +924,7 @@ fun test_init() { ts.next_tx(@0x0); let owner_cap = ts.take_from_sender(); - let its = ts.take_shared(); + let its = ts.take_shared(); ts.return_to_sender(owner_cap); sui::test_scenario::return_shared(its); ts.end(); diff --git a/move/its/sources/types/coin_management.move b/move/its/sources/types/coin_management.move index 5f6f94ad..53e42171 100644 --- a/move/its/sources/types/coin_management.move +++ b/move/its/sources/types/coin_management.move @@ -15,7 +15,7 @@ const EDistributorNeedsTreasuryCap: vector = #[error] const ENotOperator: vector = b"channel provided is not the operator"; -/// Struct that stores information about the ITS Coin. +/// Struct that stores information about the InterchainTokenService Coin. public struct CoinManagement has store { treasury_cap: Option>, balance: Option>, @@ -75,7 +75,7 @@ public fun add_operator(self: &mut CoinManagement, operator: address) { // === Protected Methods === -/// Takes the given amount of Coins from user. Returns the amount that the ITS +/// Takes the given amount of Coins from user. Returns the amount that the InterchainTokenService /// is supposed to give on other chains. public(package) fun take_balance( self: &mut CoinManagement, diff --git a/move/its/sources/versioned/its_v0.move b/move/its/sources/versioned/interchain_token_service_v0.move similarity index 94% rename from move/its/sources/versioned/its_v0.move rename to move/its/sources/versioned/interchain_token_service_v0.move index 134d166b..a95fdd53 100644 --- a/move/its/sources/versioned/its_v0.move +++ b/move/its/sources/versioned/interchain_token_service_v0.move @@ -1,4 +1,4 @@ -module its::its_v0; +module its::interchain_token_service_v0; use abi::abi::{Self, AbiReader}; use axelar_gateway::channel::{Channel, ApprovedMessage}; @@ -72,7 +72,7 @@ const MESSAGE_TYPE_SEND_TO_HUB: u256 = 3; const MESSAGE_TYPE_RECEIVE_FROM_HUB: u256 = 4; // === HUB CONSTANTS === -// Chain name for Axelar. This is used for routing ITS calls via ITS hub on +// Chain name for Axelar. This is used for routing InterchainTokenService calls via InterchainTokenService hub on // Axelar. const ITS_HUB_CHAIN_NAME: vector = b"axelar"; // Identifier to be used as destination address for chains that route to hub. @@ -82,7 +82,7 @@ const ITS_HUB_ROUTING_IDENTIFIER: vector = b"hub"; // ----- // Types // ----- -public struct ITS_v0 has store { +public struct InterchainTokenService_v0 has store { channel: Channel, address_tracker: InterchainAddressTracker, unregistered_coin_types: Table, @@ -99,8 +99,8 @@ public struct ITS_v0 has store { public(package) fun new( version_control: VersionControl, ctx: &mut TxContext, -): ITS_v0 { - ITS_v0 { +): InterchainTokenService_v0 { + InterchainTokenService_v0 { channel: axelar_gateway::channel::new(ctx), address_tracker: address_tracker::new( ctx, @@ -115,7 +115,7 @@ public(package) fun new( } public(package) fun unregistered_coin_type( - self: &ITS_v0, + self: &InterchainTokenService_v0, symbol: &String, decimals: u8, ): &TypeName { @@ -126,30 +126,30 @@ public(package) fun unregistered_coin_type( } public(package) fun registered_coin_type( - self: &ITS_v0, + self: &InterchainTokenService_v0, token_id: TokenId, ): &TypeName { assert!(self.registered_coin_types.contains(token_id), EUnregisteredCoin); &self.registered_coin_types[token_id] } -public(package) fun channel_address(self: &ITS_v0): address { +public(package) fun channel_address(self: &InterchainTokenService_v0): address { self.channel.to_address() } public(package) fun set_relayer_discovery_id( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, relayer_discovery: &RelayerDiscovery, ) { self.relayer_discovery_id = object::id(relayer_discovery); } -public(package) fun relayer_discovery_id(self: &ITS_v0): ID { +public(package) fun relayer_discovery_id(self: &InterchainTokenService_v0): ID { self.relayer_discovery_id } public(package) fun set_trusted_address( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, chain_name: String, trusted_address: String, ) { @@ -157,14 +157,14 @@ public(package) fun set_trusted_address( } public(package) fun remove_trusted_address( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, chain_name: String, ) { self.address_tracker.remove_trusted_address(chain_name); } public(package) fun set_trusted_addresses( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, trusted_addresses: TrustedAddresses, ) { let (chain_names, trusted_addresses) = trusted_addresses.destroy(); @@ -179,7 +179,7 @@ public(package) fun set_trusted_addresses( } public(package) fun remove_trusted_addresses( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, chain_names: vector, ) { chain_names.do!( @@ -189,16 +189,16 @@ public(package) fun remove_trusted_addresses( ); } -public(package) fun channel(self: &ITS_v0): &Channel { +public(package) fun channel(self: &InterchainTokenService_v0): &Channel { &self.channel } -public(package) fun version_control(self: &ITS_v0): &VersionControl { +public(package) fun version_control(self: &InterchainTokenService_v0): &VersionControl { &self.version_control } public(package) fun register_coin( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, coin_info: CoinInfo, coin_management: CoinManagement, ): TokenId { @@ -210,7 +210,7 @@ public(package) fun register_coin( } public(package) fun deploy_remote_interchain_token( - self: &ITS_v0, + self: &InterchainTokenService_v0, token_id: TokenId, destination_chain: String, ): MessageTicket { @@ -242,7 +242,7 @@ public(package) fun deploy_remote_interchain_token( } public(package) fun send_interchain_transfer( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, ticket: InterchainTransferTicket, current_version: u64, clock: &Clock, @@ -285,7 +285,7 @@ public(package) fun send_interchain_transfer( } public(package) fun receive_interchain_transfer( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, approved_message: ApprovedMessage, clock: &Clock, ctx: &mut TxContext, @@ -325,7 +325,7 @@ public(package) fun receive_interchain_transfer( } public(package) fun receive_interchain_transfer_with_data( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, approved_message: ApprovedMessage, channel: &Channel, clock: &Clock, @@ -366,7 +366,7 @@ public(package) fun receive_interchain_transfer_with_data( } public(package) fun receive_deploy_interchain_token( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, approved_message: ApprovedMessage, ) { let (_, payload, _) = self.decode_approved_message(approved_message); @@ -399,7 +399,7 @@ public(package) fun receive_deploy_interchain_token( } public(package) fun give_unregistered_coin( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, treasury_cap: TreasuryCap, mut coin_metadata: CoinMetadata, ) { @@ -432,7 +432,7 @@ public(package) fun give_unregistered_coin( } public(package) fun mint_as_distributor( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, channel: &Channel, token_id: TokenId, amount: u64, @@ -447,7 +447,7 @@ public(package) fun mint_as_distributor( } public(package) fun mint_to_as_distributor( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, channel: &Channel, token_id: TokenId, to: address, @@ -465,7 +465,7 @@ public(package) fun mint_to_as_distributor( } public(package) fun burn_as_distributor( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, channel: &Channel, token_id: TokenId, coin: Coin, @@ -479,7 +479,7 @@ public(package) fun burn_as_distributor( } public(package) fun set_flow_limit( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, channel: &Channel, token_id: TokenId, limit: u64, @@ -489,7 +489,7 @@ public(package) fun set_flow_limit( } public(package) fun allow_function( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, version: u64, function_name: String, ) { @@ -497,7 +497,7 @@ public(package) fun allow_function( } public(package) fun disallow_function( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, version: u64, function_name: String, ) { @@ -507,17 +507,17 @@ public(package) fun disallow_function( // ----------------- // Private Functions // ----------------- -fun coin_data(self: &ITS_v0, token_id: TokenId): &CoinData { +fun coin_data(self: &InterchainTokenService_v0, token_id: TokenId): &CoinData { assert!(self.registered_coins.contains(token_id), EUnregisteredCoin); &self.registered_coins[token_id] } -fun coin_info(self: &ITS_v0, token_id: TokenId): &CoinInfo { +fun coin_info(self: &InterchainTokenService_v0, token_id: TokenId): &CoinInfo { coin_data(self, token_id).coin_info() } fun is_trusted_address( - self: &ITS_v0, + self: &InterchainTokenService_v0, source_chain: String, source_address: String, ): bool { @@ -525,7 +525,7 @@ fun is_trusted_address( } fun coin_management_mut( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: TokenId, ): &mut CoinManagement { let coin_data: &mut CoinData = &mut self.registered_coins[token_id]; @@ -533,7 +533,7 @@ fun coin_management_mut( } fun add_unregistered_coin( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: UnregisteredTokenId, treasury_cap: TreasuryCap, coin_metadata: CoinMetadata, @@ -553,7 +553,7 @@ fun add_unregistered_coin( } fun remove_unregistered_coin( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: UnregisteredTokenId, ): (TreasuryCap, CoinMetadata) { let unregistered_coins: UnregisteredCoinData = self @@ -566,12 +566,12 @@ fun remove_unregistered_coin( (treasury_cap, coin_metadata) } -fun trusted_address(self: &ITS_v0, chain_name: String): String { +fun trusted_address(self: &InterchainTokenService_v0, chain_name: String): String { *self.address_tracker.trusted_address(chain_name) } fun add_unregistered_coin_type( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: UnregisteredTokenId, type_name: TypeName, ) { @@ -579,14 +579,14 @@ fun add_unregistered_coin_type( } fun remove_unregistered_coin_type( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: UnregisteredTokenId, ): TypeName { self.unregistered_coin_types.remove(token_id) } fun add_registered_coin_type( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: TokenId, type_name: TypeName, ) { @@ -594,7 +594,7 @@ fun add_registered_coin_type( } fun add_registered_coin( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: TokenId, coin_management: CoinManagement, coin_info: CoinInfo, @@ -620,20 +620,20 @@ fun add_registered_coin( /// Send a payload to a destination chain. The destination chain needs to have a /// trusted address. fun prepare_message( - self: &ITS_v0, + self: &InterchainTokenService_v0, mut destination_chain: String, mut payload: vector, ): MessageTicket { let mut destination_address = self.trusted_address(destination_chain); - // Prevent sending directly to the ITS Hub chain. This is not supported yet, + // Prevent sending directly to the InterchainTokenService Hub chain. This is not supported yet, // so fail early to prevent the user from having their funds stuck. assert!( destination_chain.into_bytes() != ITS_HUB_CHAIN_NAME, EUntrustedChain, ); - // Check whether the ITS call should be routed via ITS hub for this + // Check whether the InterchainTokenService call should be routed via InterchainTokenService hub for this // destination chain if (destination_address.into_bytes() == ITS_HUB_ROUTING_IDENTIFIER) { let mut writer = abi::new_writer(3); @@ -655,7 +655,7 @@ fun prepare_message( /// Decode an approved call and check that the source chain is trusted. fun decode_approved_message( - self: &ITS_v0, + self: &InterchainTokenService_v0, approved_message: ApprovedMessage, ): (String, vector, String) { let (mut source_chain, message_id, source_address, mut payload) = self @@ -706,7 +706,7 @@ use axelar_gateway::channel; use its::coin::COIN; #[test_only] -fun create_for_testing(ctx: &mut TxContext): ITS_v0 { +fun create_for_testing(ctx: &mut TxContext): InterchainTokenService_v0 { let mut self = new(version_control::version_control::new(vector[]), ctx); self.set_trusted_address( @@ -719,7 +719,7 @@ fun create_for_testing(ctx: &mut TxContext): ITS_v0 { #[test_only] public fun create_unregistered_coin( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, symbol: vector, decimals: u8, ctx: &mut TxContext, @@ -739,7 +739,7 @@ public fun create_unregistered_coin( #[test_only] public(package) fun add_unregistered_coin_type_for_testing( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: UnregisteredTokenId, type_name: TypeName, ) { @@ -748,7 +748,7 @@ public(package) fun add_unregistered_coin_type_for_testing( #[test_only] public(package) fun remove_unregistered_coin_type_for_testing( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: UnregisteredTokenId, ): TypeName { self.remove_unregistered_coin_type(token_id) @@ -756,7 +756,7 @@ public(package) fun remove_unregistered_coin_type_for_testing( #[test_only] public(package) fun add_registered_coin_type_for_testing( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: TokenId, type_name: TypeName, ) { @@ -765,7 +765,7 @@ public(package) fun add_registered_coin_type_for_testing( #[test_only] public(package) fun remove_registered_coin_type_for_testing( - self: &mut ITS_v0, + self: &mut InterchainTokenService_v0, token_id: TokenId, ): TypeName { self.remove_registered_coin_type_for_testing(token_id) @@ -773,7 +773,7 @@ public(package) fun remove_registered_coin_type_for_testing( #[test_only] public(package) fun trusted_address_for_testing( - self: &ITS_v0, + self: &InterchainTokenService_v0, chain_name: String, ): String { *self.address_tracker.trusted_address(chain_name) diff --git a/move/squid/sources/squid/discovery.move b/move/squid/sources/squid/discovery.move index 3f04de07..050ff244 100644 --- a/move/squid/sources/squid/discovery.move +++ b/move/squid/sources/squid/discovery.move @@ -1,7 +1,7 @@ module squid::discovery; use axelar_gateway::gateway::Gateway; -use its::its::ITS; +use its::its::InterchainTokenService; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::{Self, MoveCall, Transaction}; use squid::deepbook_v3; @@ -16,7 +16,7 @@ const EInvalidSwapType: vector = b"swap type does not exist"; public fun register_transaction( squid: &Squid, - its: &ITS, + its: &InterchainTokenService, gateway: &Gateway, relayer_discovery: &mut RelayerDiscovery, ) { @@ -52,7 +52,7 @@ public fun register_transaction( public fun transaction( squid: &Squid, - its: &ITS, + its: &InterchainTokenService, gateway: &Gateway, payload: vector, ): Transaction { diff --git a/move/squid/sources/squid/squid.move b/move/squid/sources/squid/squid.move index 37540e0e..39ca55e2 100644 --- a/move/squid/sources/squid/squid.move +++ b/move/squid/sources/squid/squid.move @@ -1,7 +1,7 @@ module squid::squid; use axelar_gateway::channel::ApprovedMessage; -use its::its::ITS; +use its::its::InterchainTokenService; use squid::owner_cap::{Self, OwnerCap}; use squid::squid_v0::{Self, Squid_v0}; use squid::swap_info::SwapInfo; @@ -103,7 +103,7 @@ entry fun withdraw( // ---------------- public fun start_swap( self: &mut Squid, - its: &mut ITS, + its: &mut InterchainTokenService, approved_message: ApprovedMessage, clock: &Clock, ctx: &mut TxContext, @@ -194,7 +194,7 @@ fun test_start_swap() { coin_management, ); - // This gives some coin to ITS + // This gives some coin to InterchainTokenService let interchain_transfer_ticket = its::its::prepare_interchain_transfer( token_id, coin, diff --git a/move/squid/sources/squid/transfers.move b/move/squid/sources/squid/transfers.move index 712c01a7..efe48208 100644 --- a/move/squid/sources/squid/transfers.move +++ b/move/squid/sources/squid/transfers.move @@ -1,7 +1,7 @@ module squid::transfers; use axelar_gateway::gateway::Gateway; -use its::its::{Self, ITS}; +use its::its::{Self, InterchainTokenService}; use its::token_id::{Self, TokenId}; use relayer_discovery::transaction::{Self, MoveCall}; use squid::squid::Squid; @@ -124,7 +124,7 @@ public fun sui_transfer(swap_info: &mut SwapInfo, ctx: &mut TxContext) { public fun its_transfer( swap_info: &mut SwapInfo, squid: &Squid, - its: &mut ITS, + its: &mut InterchainTokenService, gateway: &Gateway, clock: &Clock, ctx: &mut TxContext, diff --git a/move/squid/sources/squid/versioned/squid_v0.move b/move/squid/sources/squid/versioned/squid_v0.move index e34a0745..992227d4 100644 --- a/move/squid/sources/squid/versioned/squid_v0.move +++ b/move/squid/sources/squid/versioned/squid_v0.move @@ -1,7 +1,7 @@ module squid::squid_v0; use axelar_gateway::channel::{Self, Channel, ApprovedMessage}; -use its::its::ITS; +use its::its::InterchainTokenService; use squid::coin_bag::{Self, CoinBag}; use squid::swap_info::{Self, SwapInfo}; use std::ascii::String; @@ -47,7 +47,7 @@ public(package) fun coin_bag_mut(self: &mut Squid_v0): &mut CoinBag { public(package) fun start_swap( self: &Squid_v0, - its: &mut ITS, + its: &mut InterchainTokenService, approved_message: ApprovedMessage, clock: &Clock, ctx: &mut TxContext, diff --git a/src/common/bcs.ts b/src/common/bcs.ts index dda7fbe2..2faea4a9 100644 --- a/src/common/bcs.ts +++ b/src/common/bcs.ts @@ -273,7 +273,7 @@ function getITSStructs() { trusted_addresses: bcs.vector(bcs.string()), }); - const ITSv0 = bcs.struct('ITS_v0', { + const InterchainTokenService_v0 = bcs.struct('InterchainTokenService_v0', { channel: Channel, address_tracker: InterchainAddressTracker, unregistered_coin_types: Table, @@ -284,15 +284,15 @@ function getITSStructs() { version_control: VersionControl, }); - const ITS = bcs.struct('ITS', { + const InterchainTokenService = bcs.struct('InterchainTokenService', { id: UID, name: bcs.u64(), - value: ITSv0, + value: InterchainTokenService_v0, }); return { InterchainAddressTracker, - ITS, + InterchainTokenService, TrustedAddresses, }; } diff --git a/test/bcs.js b/test/bcs.js index de651a42..f2763c57 100644 --- a/test/bcs.js +++ b/test/bcs.js @@ -20,7 +20,7 @@ describe('BCS', () => { expect(obj).to.deep.include({ id: expectedId, size }); }; - it('should decode ITS_v0 object successfully', () => { + it('should decode InterchainTokenService_v0 object successfully', () => { const its = bcsStructs.its.ITS.parse(fromHEX(hexData.ITSV0)).value; checkIdAndSize(its.address_tracker.trusted_addresses, '270c7f8b9757b05777d3cbf98fa1bb197e1f5a18c8ff7a8ef16e80bedf39a67f'); diff --git a/test/its.js b/test/its.js index 21cc079b..fc4de68b 100644 --- a/test/its.js +++ b/test/its.js @@ -119,8 +119,8 @@ describe('ITS', () => { singleton: findObjectId(deployments.example.publishTxn, 'its::Singleton'), tokenTreasuryCap: findObjectId(deployments.example.publishTxn, `TreasuryCap<${coinType}>`), tokenCoinMetadata: findObjectId(deployments.example.publishTxn, `CoinMetadata<${coinType}>`), - its: findObjectId(deployments.its.publishTxn, 'its::ITS'), - itsV0: findObjectId(deployments.its.publishTxn, 'its_v0::ITS_v0'), + its: findObjectId(deployments.its.publishTxn, 'interchain_token_service::InterchainTokenService'), + itsV0: findObjectId(deployments.its.publishTxn, 'interchain_token_service_v0::InterchainTokenService_v0'), relayerDiscovery: findObjectId( deployments.relayer_discovery.publishTxn, `${deployments.relayer_discovery.packageId}::discovery::RelayerDiscovery`, diff --git a/test/squid.js b/test/squid.js index 61b45ab7..0bfad588 100644 --- a/test/squid.js +++ b/test/squid.js @@ -385,8 +385,8 @@ describe('Squid', () => { ...objectIds, squid: findObjectId(deployments.squid.publishTxn, 'squid::Squid'), squidV0: findObjectId(deployments.squid.publishTxn, 'squid_v0::Squid_v0'), - its: findObjectId(deployments.its.publishTxn, 'its::ITS'), - itsV0: findObjectId(deployments.its.publishTxn, 'its_v0::ITS_v0'), + its: findObjectId(deployments.its.publishTxn, 'interchain_token_service::InterchainTokenService'), + itsV0: findObjectId(deployments.its.publishTxn, 'interchain_token_service_v0::InterchainTokenService_v0'), relayerDiscovery: findObjectId( deployments.relayer_discovery.publishTxn, `${deployments.relayer_discovery.packageId}::discovery::RelayerDiscovery`, diff --git a/test/testdata/interface_example_its.json b/test/testdata/interface_example_its.json index 4d39fd6e..38c207f4 100644 --- a/test/testdata/interface_example_its.json +++ b/test/testdata/interface_example_its.json @@ -48,7 +48,7 @@ "visibility": "public", "params": { "singleton#0#0": "&Singleton", - "its#0#0": "&ITS", + "its#0#0": "&InterchainTokenService", "payload#0#0": "vector", "clock#0#0": "&Clock" }, @@ -58,7 +58,7 @@ "name": "register_coin", "visibility": "public", "params": { - "its#0#0": "&mut ITS", + "its#0#0": "&mut InterchainTokenService", "coin_metadata#0#0": "&CoinMetadata" }, "returnType": "TokenId" diff --git a/test/testdata/interface_its_discovery.json b/test/testdata/interface_its_discovery.json index 19c2fa66..3830e9c4 100644 --- a/test/testdata/interface_its_discovery.json +++ b/test/testdata/interface_its_discovery.json @@ -13,7 +13,7 @@ "name": "call_info", "visibility": "public", "params": { - "its#0#0": "&ITS", + "its#0#0": "&InterchainTokenService", "payload#0#0": "vector" }, "returnType": "Transaction" diff --git a/test/testdata/interface_its_interchain_token_service_v0.json b/test/testdata/interface_its_interchain_token_service_v0.json new file mode 100644 index 00000000..f850013e --- /dev/null +++ b/test/testdata/interface_its_interchain_token_service_v0.json @@ -0,0 +1,45 @@ +{ + "structs": { + "InterchainTokenService_v0": { + "name": "InterchainTokenService_v0", + "abilities": [ + "store" + ], + "fields": [ + { + "name": "channel", + "type": "Channel" + }, + { + "name": "address_tracker", + "type": "InterchainAddressTracker" + }, + { + "name": "unregistered_coin_types", + "type": "Table" + }, + { + "name": "unregistered_coins", + "type": "Bag" + }, + { + "name": "registered_coin_types", + "type": "Table" + }, + { + "name": "registered_coins", + "type": "Bag" + }, + { + "name": "relayer_discovery_id", + "type": "ID" + }, + { + "name": "version_control", + "type": "VersionControl" + } + ] + } + }, + "publicFunctions": {} +} diff --git a/test/testdata/interface_its_its.json b/test/testdata/interface_its_its.json index 6405f574..c2b544b0 100644 --- a/test/testdata/interface_its_its.json +++ b/test/testdata/interface_its_its.json @@ -1,7 +1,7 @@ { "structs": { - "ITS": { - "name": "ITS", + "InterchainTokenService": { + "name": "InterchainTokenService", "abilities": [ "key" ], @@ -22,7 +22,7 @@ "name": "register_coin", "visibility": "public", "params": { - "self#0#0": "&mut ITS", + "self#0#0": "&mut InterchainTokenService", "coin_info#0#0": "CoinInfo", "coin_management#0#0": "CoinManagement" }, @@ -32,7 +32,7 @@ "name": "deploy_remote_interchain_token", "visibility": "public", "params": { - "self#0#0": "&ITS", + "self#0#0": "&InterchainTokenService", "token_id#0#0": "TokenId", "destination_chain#0#0": "String" }, @@ -55,7 +55,7 @@ "name": "send_interchain_transfer", "visibility": "public", "params": { - "self#0#0": "&mut ITS", + "self#0#0": "&mut InterchainTokenService", "ticket#0#0": "InterchainTransferTicket", "clock#0#0": "&Clock" }, @@ -65,7 +65,7 @@ "name": "receive_interchain_transfer_with_data", "visibility": "public", "params": { - "self#0#0": "&mut ITS", + "self#0#0": "&mut InterchainTokenService", "approved_message#0#0": "ApprovedMessage", "channel#0#0": "&Channel", "clock#0#0": "&Clock", @@ -77,7 +77,7 @@ "name": "mint_as_distributor", "visibility": "public", "params": { - "self#0#0": "&mut ITS", + "self#0#0": "&mut InterchainTokenService", "channel#0#0": "&Channel", "token_id#0#0": "TokenId", "amount#0#0": "u64", @@ -89,7 +89,7 @@ "name": "registered_coin_type", "visibility": "public", "params": { - "self#0#0": "&ITS", + "self#0#0": "&InterchainTokenService", "token_id#0#0": "TokenId" }, "returnType": "&TypeName" @@ -98,7 +98,7 @@ "name": "channel_address", "visibility": "public", "params": { - "self#0#0": "&ITS" + "self#0#0": "&InterchainTokenService" }, "returnType": "address" } diff --git a/test/testdata/interface_its_its_v0.json b/test/testdata/interface_its_its_v0.json index 2e209b4b..f850013e 100644 --- a/test/testdata/interface_its_its_v0.json +++ b/test/testdata/interface_its_its_v0.json @@ -1,7 +1,7 @@ { "structs": { - "ITS_v0": { - "name": "ITS_v0", + "InterchainTokenService_v0": { + "name": "InterchainTokenService_v0", "abilities": [ "store" ], diff --git a/test/testdata/interface_squid_discovery.json b/test/testdata/interface_squid_discovery.json index eb2c79d1..b6015b09 100644 --- a/test/testdata/interface_squid_discovery.json +++ b/test/testdata/interface_squid_discovery.json @@ -6,7 +6,7 @@ "visibility": "public", "params": { "squid#0#0": "&Squid", - "its#0#0": "&ITS", + "its#0#0": "&InterchainTokenService", "gateway#0#0": "&Gateway", "payload#0#0": "vector" }, diff --git a/test/testdata/interface_squid_squid.json b/test/testdata/interface_squid_squid.json index a9f3bece..04d98b6c 100644 --- a/test/testdata/interface_squid_squid.json +++ b/test/testdata/interface_squid_squid.json @@ -24,7 +24,7 @@ "visibility": "public", "params": { "self#0#0": "&mut Squid", - "its#0#0": "&mut ITS", + "its#0#0": "&mut InterchainTokenService", "approved_message#0#0": "ApprovedMessage", "clock#0#0": "&Clock", "ctx#0#0": "&mut TxContext" From 6f8e5da81c0126450faaf49cb676da87ea1aaacc Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 11 Dec 2024 15:24:30 +0200 Subject: [PATCH 02/15] lint and fix some tests --- src/common/bcs.ts | 4 ++-- test/bcs.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/common/bcs.ts b/src/common/bcs.ts index 2faea4a9..08149f5b 100644 --- a/src/common/bcs.ts +++ b/src/common/bcs.ts @@ -273,7 +273,7 @@ function getITSStructs() { trusted_addresses: bcs.vector(bcs.string()), }); - const InterchainTokenService_v0 = bcs.struct('InterchainTokenService_v0', { + const InterchainTokenServiceV0 = bcs.struct('InterchainTokenService_v0', { channel: Channel, address_tracker: InterchainAddressTracker, unregistered_coin_types: Table, @@ -287,7 +287,7 @@ function getITSStructs() { const InterchainTokenService = bcs.struct('InterchainTokenService', { id: UID, name: bcs.u64(), - value: InterchainTokenService_v0, + value: InterchainTokenServiceV0, }); return { diff --git a/test/bcs.js b/test/bcs.js index f2763c57..57a2e370 100644 --- a/test/bcs.js +++ b/test/bcs.js @@ -6,7 +6,8 @@ const { expect } = require('chai'); // The following hex data is derived from the bcs bytes from the client.getObject() call. const hexData = { - ITSV0: '7d262a840033c9b6bc7a31d8ddf12bff891c6db6253dd5b8cf331bccd531a81e00000000000000006ccb9729af3569630b9171a0c1fd3eae9797d8122794be5d8cd01061b1dfcb86270c7f8b9757b05777d3cbf98fa1bb197e1f5a18c8ff7a8ef16e80bedf39a67f000000000000000000c101dbc800d8cf853e6d21c916aba7c92e4c2692527dc951c777dae15cf474000000000000000044bacbed87a2d5f871ce96f3245a293b936fb287605330b3859649f3a2697668000000000000000013bd4dc87b61a82ce5959e3ea8c3fed1e03d9c1f7246eef82722354d8e3c0d540000000000000000e5855b758d21f521071672cbce153167d49b4d15f11f5ca47528117312c2c1fa00000000000000000000000000000000000000000000000000000000000000000000000000000000010c0d72656769737465725f636f696e1e6465706c6f795f72656d6f74655f696e746572636861696e5f746f6b656e1873656e645f696e746572636861696e5f7472616e736665721b726563656976655f696e746572636861696e5f7472616e7366657225726563656976655f696e746572636861696e5f7472616e736665725f776974685f646174611f726563656976655f6465706c6f795f696e746572636861696e5f746f6b656e16676976655f756e726567697374657265645f636f696e136d696e745f61735f6469737472696275746f72166d696e745f746f5f61735f6469737472696275746f72136275726e5f61735f6469737472696275746f72157365745f747275737465645f6164647265737365731472656769737465725f7472616e73616374696f6e', + InterchainTokenService_v0: + '7d262a840033c9b6bc7a31d8ddf12bff891c6db6253dd5b8cf331bccd531a81e00000000000000006ccb9729af3569630b9171a0c1fd3eae9797d8122794be5d8cd01061b1dfcb86270c7f8b9757b05777d3cbf98fa1bb197e1f5a18c8ff7a8ef16e80bedf39a67f000000000000000000c101dbc800d8cf853e6d21c916aba7c92e4c2692527dc951c777dae15cf474000000000000000044bacbed87a2d5f871ce96f3245a293b936fb287605330b3859649f3a2697668000000000000000013bd4dc87b61a82ce5959e3ea8c3fed1e03d9c1f7246eef82722354d8e3c0d540000000000000000e5855b758d21f521071672cbce153167d49b4d15f11f5ca47528117312c2c1fa00000000000000000000000000000000000000000000000000000000000000000000000000000000010c0d72656769737465725f636f696e1e6465706c6f795f72656d6f74655f696e746572636861696e5f746f6b656e1873656e645f696e746572636861696e5f7472616e736665721b726563656976655f696e746572636861696e5f7472616e7366657225726563656976655f696e746572636861696e5f7472616e736665725f776974685f646174611f726563656976655f6465706c6f795f696e746572636861696e5f746f6b656e16676976655f756e726567697374657265645f636f696e136d696e745f61735f6469737472696275746f72166d696e745f746f5f61735f6469737472696275746f72136275726e5f61735f6469737472696275746f72157365745f747275737465645f6164647265737365731472656769737465725f7472616e73616374696f6e', GatewayV0: 'c15879de64dc6678674e5ad1a32c47319a1e9100bf21408173590455d01f9d160000000000000000196e295da7fe769ff56d2627c38252ee603f90829ea777bce36ce676b5e3d9d5a7f4b2d4c193987e5f01122bc9cce22a791447d10bc58299ced9e4e18db4c2c503000000000000000100000000000000537d294cfaa7dc649e43cab6a2d829674ea9c11c86517fec9e3984cdedaee42501000000000000000e59feaeb543924fabfbeb667efe707290cf4de9e667796b132260f33a84c26ee803000000000000b23c626b920100000f00000000000000010610617070726f76655f6d657373616765730e726f746174655f7369676e6572731369735f6d6573736167655f617070726f7665641369735f6d6573736167655f65786563757465641574616b655f617070726f7665645f6d6573736167650c73656e645f6d657373616765', GasServiceV0: @@ -21,7 +22,7 @@ describe('BCS', () => { }; it('should decode InterchainTokenService_v0 object successfully', () => { - const its = bcsStructs.its.ITS.parse(fromHEX(hexData.ITSV0)).value; + const its = bcsStructs.its.InterchainTokenService.parse(fromHEX(hexData.InterchainTokenService_v0)).value; checkIdAndSize(its.address_tracker.trusted_addresses, '270c7f8b9757b05777d3cbf98fa1bb197e1f5a18c8ff7a8ef16e80bedf39a67f'); checkIdAndSize(its.unregistered_coin_types, '00c101dbc800d8cf853e6d21c916aba7c92e4c2692527dc951c777dae15cf474'); From e0218736c82f127a1caabb5e988851dab570bdd2 Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 11 Dec 2024 15:34:50 +0200 Subject: [PATCH 03/15] rename its module too --- move/example/sources/its/its.move | 2 +- move/its/sources/discovery.move | 14 +++++++------- move/its/sources/interchain_token_service.move | 2 +- move/squid/sources/squid/discovery.move | 2 +- move/squid/sources/squid/squid.move | 6 +++--- move/squid/sources/squid/transfers.move | 2 +- move/squid/sources/squid/versioned/squid_v0.move | 6 +++--- test/its.js | 10 +++++----- test/squid.js | 6 +++--- test/testutils.js | 2 +- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/move/example/sources/its/its.move b/move/example/sources/its/its.move index 73ca0c02..2dc2e409 100644 --- a/move/example/sources/its/its.move +++ b/move/example/sources/its/its.move @@ -8,7 +8,7 @@ use gas_service::gas_service::GasService; use its::coin_info; use its::coin_management; use its::discovery as its_discovery; -use its::its::{Self, InterchainTokenService}; +use its::interchain_token_service::{Self, InterchainTokenService}; use its::token_id::TokenId; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::{Self, Transaction}; diff --git a/move/its/sources/discovery.move b/move/its/sources/discovery.move index b8400f80..a690938a 100644 --- a/move/its/sources/discovery.move +++ b/move/its/sources/discovery.move @@ -1,7 +1,7 @@ module its::discovery; use abi::abi::{Self, AbiReader}; -use its::its::InterchainTokenService; +use its::interchain_token_service::InterchainTokenService; use its::token_id::{Self, TokenId}; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::{Self, Transaction, package_id}; @@ -212,7 +212,7 @@ fun initial_tx(its: &InterchainTokenService): Transaction { #[test] fun test_discovery_initial() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::its::create_for_testing(ctx); + let mut its = its::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -230,7 +230,7 @@ fun test_discovery_initial() { #[test] fun test_discovery_interchain_transfer() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::its::create_for_testing(ctx); + let mut its = its::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -286,7 +286,7 @@ fun test_discovery_interchain_transfer() { #[test] fun test_discovery_interchain_transfer_with_data() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::its::create_for_testing(ctx); + let mut its = its::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -333,7 +333,7 @@ fun test_discovery_interchain_transfer_with_data() { #[test] fun test_discovery_deploy_token() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::its::create_for_testing(ctx); + let mut its = its::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -444,7 +444,7 @@ fun test_interchain_transfer_info_invalid_message_type() { #[test] fun test_discovery_hub_message() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::its::create_for_testing(ctx); + let mut its = its::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -504,7 +504,7 @@ fun test_discovery_hub_message() { #[expected_failure(abort_code = EUnsupportedMessageType)] fun test_call_info_unsupported_message_type() { let ctx = &mut sui::tx_context::dummy(); - let its = its::its::create_for_testing(ctx); + let its = its::interchain_token_service::create_for_testing(ctx); let mut writer = abi::new_writer(1); writer.write_u256(5); diff --git a/move/its/sources/interchain_token_service.move b/move/its/sources/interchain_token_service.move index b61ca3a9..2d951535 100644 --- a/move/its/sources/interchain_token_service.move +++ b/move/its/sources/interchain_token_service.move @@ -1,4 +1,4 @@ -module its::its; +module its::interchain_token_service; use axelar_gateway::channel::{ApprovedMessage, Channel}; use axelar_gateway::message_ticket::MessageTicket; diff --git a/move/squid/sources/squid/discovery.move b/move/squid/sources/squid/discovery.move index 050ff244..934f384b 100644 --- a/move/squid/sources/squid/discovery.move +++ b/move/squid/sources/squid/discovery.move @@ -1,7 +1,7 @@ module squid::discovery; use axelar_gateway::gateway::Gateway; -use its::its::InterchainTokenService; +use its::interchain_token_service::InterchainTokenService; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::{Self, MoveCall, Transaction}; use squid::deepbook_v3; diff --git a/move/squid/sources/squid/squid.move b/move/squid/sources/squid/squid.move index 39ca55e2..1b202178 100644 --- a/move/squid/sources/squid/squid.move +++ b/move/squid/sources/squid/squid.move @@ -1,7 +1,7 @@ module squid::squid; use axelar_gateway::channel::ApprovedMessage; -use its::its::InterchainTokenService; +use its::interchain_token_service::InterchainTokenService; use squid::owner_cap::{Self, OwnerCap}; use squid::squid_v0::{Self, Squid_v0}; use squid::swap_info::SwapInfo; @@ -175,7 +175,7 @@ use its::coin::COIN; fun test_start_swap() { let ctx = &mut tx_context::dummy(); let clock = sui::clock::create_for_testing(ctx); - let mut its = its::its::create_for_testing(ctx); + let mut its = its::interchain_token_service::create_for_testing(ctx); let mut squid = new_for_testing(ctx); let coin_info = its::coin_info::from_info( @@ -195,7 +195,7 @@ fun test_start_swap() { ); // This gives some coin to InterchainTokenService - let interchain_transfer_ticket = its::its::prepare_interchain_transfer( + let interchain_transfer_ticket = its::interchain_token_service::prepare_interchain_transfer( token_id, coin, std::ascii::string(b"Chain Name"), diff --git a/move/squid/sources/squid/transfers.move b/move/squid/sources/squid/transfers.move index efe48208..89e0a593 100644 --- a/move/squid/sources/squid/transfers.move +++ b/move/squid/sources/squid/transfers.move @@ -1,7 +1,7 @@ module squid::transfers; use axelar_gateway::gateway::Gateway; -use its::its::{Self, InterchainTokenService}; +use its::interchain_token_service::{Self, InterchainTokenService}; use its::token_id::{Self, TokenId}; use relayer_discovery::transaction::{Self, MoveCall}; use squid::squid::Squid; diff --git a/move/squid/sources/squid/versioned/squid_v0.move b/move/squid/sources/squid/versioned/squid_v0.move index 992227d4..745fb72a 100644 --- a/move/squid/sources/squid/versioned/squid_v0.move +++ b/move/squid/sources/squid/versioned/squid_v0.move @@ -1,7 +1,7 @@ module squid::squid_v0; use axelar_gateway::channel::{Self, Channel, ApprovedMessage}; -use its::its::InterchainTokenService; +use its::interchain_token_service::InterchainTokenService; use squid::coin_bag::{Self, CoinBag}; use squid::swap_info::{Self, SwapInfo}; use std::ascii::String; @@ -114,7 +114,7 @@ use sui::test_utils::destroy; fun test_start_swap() { let ctx = &mut tx_context::dummy(); let clock = sui::clock::create_for_testing(ctx); - let mut its = its::its::create_for_testing(ctx); + let mut its = its::interchain_token_service::create_for_testing(ctx); let squid = new_for_testing(ctx); let coin_info = its::coin_info::from_info( @@ -134,7 +134,7 @@ fun test_start_swap() { ); // This gives some coin to the service. - let interchain_transfer_ticket = its::its::prepare_interchain_transfer( + let interchain_transfer_ticket = its::interchain_token_service::prepare_interchain_transfer( token_id, coin, std::ascii::string(b"Chain Name"), diff --git a/test/its.js b/test/its.js index fc4de68b..ac1285f8 100644 --- a/test/its.js +++ b/test/its.js @@ -151,7 +151,7 @@ describe('ITS', () => { const txBuilder = new TxBuilder(client); await txBuilder.moveCall({ - target: `${deployments.example.packageId}::its::register_transaction`, + target: `${deployments.example.packageId}::interchain_token_service::register_transaction`, arguments: [objectIds.relayerDiscovery, objectIds.singleton, objectIds.its, CLOCK_PACKAGE_ID], }); @@ -164,7 +164,7 @@ describe('ITS', () => { it('should register a coin successfully', async () => { const txBuilder = new TxBuilder(client); await txBuilder.moveCall({ - target: `${deployments.example.packageId}::its::register_coin`, + target: `${deployments.example.packageId}::interchain_token_service::register_coin`, arguments: [objectIds.its, objectIds.tokenCoinMetadata], typeArguments: [`${deployments.example.packageId}::token::TOKEN`], }); @@ -202,7 +202,7 @@ describe('ITS', () => { }); await txBuilder.moveCall({ - target: `${deployments.example.packageId}::its::send_interchain_transfer_call`, + target: `${deployments.example.packageId}::interchain_token_service::send_interchain_transfer_call`, arguments: [ objectIds.singleton, objectIds.its, @@ -272,7 +272,7 @@ describe('ITS', () => { }); await txBuilder.moveCall({ - target: `${deployments.example.packageId}::its::deploy_remote_interchain_token`, + target: `${deployments.example.packageId}::interchain_token_service::deploy_remote_interchain_token`, arguments: [ objectIds.its, objectIds.gateway, @@ -310,7 +310,7 @@ describe('ITS', () => { const txBuilder = new TxBuilder(client); await txBuilder.moveCall({ - target: `${deployments.its.packageId}::its::give_unregistered_coin`, + target: `${deployments.its.packageId}::interchain_token_service::give_unregistered_coin`, arguments: [objectIds.its, treasuryCap, metadata], typeArguments: [typeArg], }); diff --git a/test/squid.js b/test/squid.js index 0bfad588..8c9e3611 100644 --- a/test/squid.js +++ b/test/squid.js @@ -227,13 +227,13 @@ describe('Squid', () => { }); const interchainTransfer = await builder.moveCall({ - target: `${deployments.its.packageId}::its::prepare_interchain_transfer`, + target: `${deployments.its.packageId}::interchain_token_service::prepare_interchain_transfer`, arguments: [tokenId, input, trustedSourceChain, '0xadd1', '0x', channel], typeArguments: [coins[coinName].type], }); const messageTicket = await builder.moveCall({ - target: `${deployments.its.packageId}::its::send_interchain_transfer`, + target: `${deployments.its.packageId}::interchain_token_service::send_interchain_transfer`, arguments: [objectIds.its, interchainTransfer, CLOCK_PACKAGE_ID], typeArguments: [coins[coinName].type], }); @@ -267,7 +267,7 @@ describe('Squid', () => { typeArguments: [coins[coin].type], }); await builder.moveCall({ - target: `${deployments.its.packageId}::its::register_coin`, + target: `${deployments.its.packageId}::interchain_token_service::register_coin`, arguments: [objectIds.its, coinInfo, coinManagment], typeArguments: [coins[coin].type], }); diff --git a/test/testutils.js b/test/testutils.js index 332ad37f..2ecfde21 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -380,7 +380,7 @@ async function setupTrustedAddresses(client, keypair, objectIds, deployments, tr }); await trustedAddressTxBuilder.moveCall({ - target: `${deployments.its.packageId}::its::set_trusted_addresses`, + target: `${deployments.its.packageId}::interchain_token_service::set_trusted_addresses`, arguments: [objectIds.its, objectIds.itsOwnerCap, trustedAddressesObject], }); From 3b0993d1bce811d6fc7938a070774c605b8289ed Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 11 Dec 2024 15:43:27 +0200 Subject: [PATCH 04/15] fix squid tests --- move/squid/sources/squid/transfers.move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/move/squid/sources/squid/transfers.move b/move/squid/sources/squid/transfers.move index 89e0a593..47970080 100644 --- a/move/squid/sources/squid/transfers.move +++ b/move/squid/sources/squid/transfers.move @@ -153,7 +153,7 @@ public fun its_transfer( return }; - let interchain_transfer_ticket = its::prepare_interchain_transfer( + let interchain_transfer_ticket = interchain_token_service::prepare_interchain_transfer( swap_data.token_id, coin::from_balance(option.destroy_some(), ctx), swap_data.destination_chain, From 6b119692791eef2c2ddb18551f963732abc1bfca Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 11 Dec 2024 15:44:09 +0200 Subject: [PATCH 05/15] fix example ref --- move/example/sources/its/its.move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/move/example/sources/its/its.move b/move/example/sources/its/its.move index 2dc2e409..aac71ec5 100644 --- a/move/example/sources/its/its.move +++ b/move/example/sources/its/its.move @@ -198,7 +198,7 @@ public fun send_interchain_transfer_call( gas_params: vector, clock: &Clock, ) { - let interchain_transfer_ticket = its::prepare_interchain_transfer( + let interchain_transfer_ticket = interchain_token_service::prepare_interchain_transfer( token_id, coin, destination_chain, From b3b5866fb37e94365defc3628bd638545ef7d845 Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 11 Dec 2024 16:39:11 +0200 Subject: [PATCH 06/15] fix tests --- move/its/sources/discovery.move | 10 +++++----- test/its.js | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/move/its/sources/discovery.move b/move/its/sources/discovery.move index a690938a..3a8f9235 100644 --- a/move/its/sources/discovery.move +++ b/move/its/sources/discovery.move @@ -117,7 +117,7 @@ fun interchain_transfer_tx(its: &InterchainTokenService, reader: &mut AbiReader) transaction::new_move_call( transaction::new_function( package_id(), - ascii::string(b"its"), + ascii::string(b"interchain_token_service"), ascii::string(b"receive_interchain_transfer"), ), arguments, @@ -170,7 +170,7 @@ fun deploy_interchain_token_tx(its: &InterchainTokenService, reader: &mut AbiRea let move_call = transaction::new_move_call( transaction::new_function( package_id(), - ascii::string(b"its"), + ascii::string(b"interchain_token_service"), ascii::string(b"receive_deploy_interchain_token"), ), arguments, @@ -268,7 +268,7 @@ fun test_discovery_interchain_transfer() { assert!( call_info.function().package_id_from_function() == package_id(), ); - assert!(call_info.function().module_name() == ascii::string(b"its")); + assert!(call_info.function().module_name() == ascii::string(b"interchain_token_service")); assert!( call_info.function().name() == ascii::string(b"receive_interchain_transfer"), ); @@ -375,7 +375,7 @@ fun test_discovery_deploy_token() { assert!( call_info.function().package_id_from_function() == package_id(), ); - assert!(call_info.function().module_name() == ascii::string(b"its")); + assert!(call_info.function().module_name() == ascii::string(b"interchain_token_service")); assert!( call_info.function().name() == ascii::string(b"receive_deploy_interchain_token"), ); @@ -485,7 +485,7 @@ fun test_discovery_hub_message() { assert!( call_info.function().package_id_from_function() == package_id(), ); - assert!(call_info.function().module_name() == ascii::string(b"its")); + assert!(call_info.function().module_name() == ascii::string(b"interchain_token_service")); assert!( call_info.function().name() == ascii::string(b"receive_interchain_transfer"), ); diff --git a/test/its.js b/test/its.js index ac1285f8..ecd80a57 100644 --- a/test/its.js +++ b/test/its.js @@ -31,7 +31,7 @@ const { } = require('../dist/cjs'); const { keccak256, defaultAbiCoder, toUtf8Bytes, hexlify, randomBytes } = require('ethers/lib/utils'); -describe('ITS', () => { +describe.only('ITS', () => { // Sui Client let client; const network = process.env.NETWORK || 'localnet'; @@ -151,7 +151,7 @@ describe('ITS', () => { const txBuilder = new TxBuilder(client); await txBuilder.moveCall({ - target: `${deployments.example.packageId}::interchain_token_service::register_transaction`, + target: `${deployments.example.packageId}::its::register_transaction`, arguments: [objectIds.relayerDiscovery, objectIds.singleton, objectIds.its, CLOCK_PACKAGE_ID], }); @@ -164,7 +164,7 @@ describe('ITS', () => { it('should register a coin successfully', async () => { const txBuilder = new TxBuilder(client); await txBuilder.moveCall({ - target: `${deployments.example.packageId}::interchain_token_service::register_coin`, + target: `${deployments.example.packageId}::its::register_coin`, arguments: [objectIds.its, objectIds.tokenCoinMetadata], typeArguments: [`${deployments.example.packageId}::token::TOKEN`], }); @@ -202,7 +202,7 @@ describe('ITS', () => { }); await txBuilder.moveCall({ - target: `${deployments.example.packageId}::interchain_token_service::send_interchain_transfer_call`, + target: `${deployments.example.packageId}::its::send_interchain_transfer_call`, arguments: [ objectIds.singleton, objectIds.its, @@ -272,7 +272,7 @@ describe('ITS', () => { }); await txBuilder.moveCall({ - target: `${deployments.example.packageId}::interchain_token_service::deploy_remote_interchain_token`, + target: `${deployments.example.packageId}::its::deploy_remote_interchain_token`, arguments: [ objectIds.its, objectIds.gateway, From c4510ca03c586bd9a942a56d7b84421cb3e4c1ed Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 11 Dec 2024 16:40:23 +0200 Subject: [PATCH 07/15] lint --- test/its.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/its.js b/test/its.js index ecd80a57..20423dbc 100644 --- a/test/its.js +++ b/test/its.js @@ -31,7 +31,7 @@ const { } = require('../dist/cjs'); const { keccak256, defaultAbiCoder, toUtf8Bytes, hexlify, randomBytes } = require('ethers/lib/utils'); -describe.only('ITS', () => { +describe('ITS', () => { // Sui Client let client; const network = process.env.NETWORK || 'localnet'; From fc49e15e5863774125dfacb62d1dc852602a1dd2 Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 11 Dec 2024 17:02:44 +0200 Subject: [PATCH 08/15] fix interfaces --- ...nterface_its_interchain_token_service.json | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 test/testdata/interface_its_interchain_token_service.json diff --git a/test/testdata/interface_its_interchain_token_service.json b/test/testdata/interface_its_interchain_token_service.json new file mode 100644 index 00000000..c2b544b0 --- /dev/null +++ b/test/testdata/interface_its_interchain_token_service.json @@ -0,0 +1,106 @@ +{ + "structs": { + "InterchainTokenService": { + "name": "InterchainTokenService", + "abilities": [ + "key" + ], + "fields": [ + { + "name": "id", + "type": "UID" + }, + { + "name": "inner", + "type": "Versioned" + } + ] + } + }, + "publicFunctions": { + "register_coin": { + "name": "register_coin", + "visibility": "public", + "params": { + "self#0#0": "&mut InterchainTokenService", + "coin_info#0#0": "CoinInfo", + "coin_management#0#0": "CoinManagement" + }, + "returnType": "TokenId" + }, + "deploy_remote_interchain_token": { + "name": "deploy_remote_interchain_token", + "visibility": "public", + "params": { + "self#0#0": "&InterchainTokenService", + "token_id#0#0": "TokenId", + "destination_chain#0#0": "String" + }, + "returnType": "MessageTicket" + }, + "prepare_interchain_transfer": { + "name": "prepare_interchain_transfer", + "visibility": "public", + "params": { + "token_id#0#0": "TokenId", + "coin#0#0": "Coin", + "destination_chain#0#0": "String", + "destination_address#0#0": "vector", + "metadata#0#0": "vector", + "source_channel#0#0": "&Channel" + }, + "returnType": "InterchainTransferTicket" + }, + "send_interchain_transfer": { + "name": "send_interchain_transfer", + "visibility": "public", + "params": { + "self#0#0": "&mut InterchainTokenService", + "ticket#0#0": "InterchainTransferTicket", + "clock#0#0": "&Clock" + }, + "returnType": "MessageTicket" + }, + "receive_interchain_transfer_with_data": { + "name": "receive_interchain_transfer_with_data", + "visibility": "public", + "params": { + "self#0#0": "&mut InterchainTokenService", + "approved_message#0#0": "ApprovedMessage", + "channel#0#0": "&Channel", + "clock#0#0": "&Clock", + "ctx#0#0": "&mut TxContext" + }, + "returnType": "String * vector * vector * Coin" + }, + "mint_as_distributor": { + "name": "mint_as_distributor", + "visibility": "public", + "params": { + "self#0#0": "&mut InterchainTokenService", + "channel#0#0": "&Channel", + "token_id#0#0": "TokenId", + "amount#0#0": "u64", + "ctx#0#0": "&mut TxContext" + }, + "returnType": "Coin" + }, + "registered_coin_type": { + "name": "registered_coin_type", + "visibility": "public", + "params": { + "self#0#0": "&InterchainTokenService", + "token_id#0#0": "TokenId" + }, + "returnType": "&TypeName" + }, + "channel_address": { + "name": "channel_address", + "visibility": "public", + "params": { + "self#0#0": "&InterchainTokenService" + }, + "returnType": "address" + } + } +} From 9b4cff7b2cc7036b2e723633fe2bae2ed3a13e9e Mon Sep 17 00:00:00 2001 From: Foivos Date: Wed, 18 Dec 2024 21:22:10 +0200 Subject: [PATCH 09/15] stash --- move/example/Move.toml | 2 +- move/example/sources/its/its.move | 10 +-- .../Move.lock | 2 +- .../Move.toml | 4 +- .../sources/discovery.move | 26 +++--- .../sources/events.move | 8 +- .../sources/interchain_token_service.move | 86 +++++++++---------- .../sources/types/address_tracker.move | 4 +- .../sources/types/coin_data.move | 6 +- .../sources/types/coin_info.move | 4 +- .../sources/types/coin_management.move | 4 +- .../sources/types/flow_limit.move | 2 +- .../types/interchain_transfer_ticket.move | 4 +- .../sources/types/owner_cap.move | 2 +- .../sources/types/token_id.move | 8 +- .../sources/types/trusted_addresses.move | 2 +- .../sources/types/unregistered_coin_data.move | 2 +- .../sources/utils.move | 2 +- .../interchain_token_service_v0.move | 74 ++++++++-------- .../tests/coin.move | 2 +- .../tests/coin_init_test.move | 2 +- move/squid/Move.toml | 2 +- move/squid/sources/squid/coin_bag.move | 2 +- move/squid/sources/squid/discovery.move | 4 +- move/squid/sources/squid/squid.move | 12 +-- move/squid/sources/squid/transfers.move | 4 +- .../sources/squid/versioned/squid_v0.move | 12 +-- 27 files changed, 146 insertions(+), 146 deletions(-) rename move/{its => interchain_token_service}/Move.lock (95%) rename move/{its => interchain_token_service}/Move.toml (86%) rename move/{its => interchain_token_service}/sources/discovery.move (93%) rename move/{its => interchain_token_service}/sources/events.move (96%) rename move/{its => interchain_token_service}/sources/interchain_token_service.move (87%) rename move/{its => interchain_token_service}/sources/types/address_tracker.move (98%) rename move/{its => interchain_token_service}/sources/types/coin_data.move (79%) rename move/{its => interchain_token_service}/sources/types/coin_info.move (94%) rename move/{its => interchain_token_service}/sources/types/coin_management.move (98%) rename move/{its => interchain_token_service}/sources/types/flow_limit.move (98%) rename move/{its => interchain_token_service}/sources/types/interchain_transfer_ticket.move (92%) rename move/{its => interchain_token_service}/sources/types/owner_cap.move (81%) rename move/{its => interchain_token_service}/sources/types/token_id.move (92%) rename move/{its => interchain_token_service}/sources/types/trusted_addresses.move (96%) rename move/{its => interchain_token_service}/sources/types/unregistered_coin_data.move (92%) rename move/{its => interchain_token_service}/sources/utils.move (98%) rename move/{its => interchain_token_service}/sources/versioned/interchain_token_service_v0.move (93%) rename move/{its => interchain_token_service}/tests/coin.move (97%) rename move/{its => interchain_token_service}/tests/coin_init_test.move (92%) diff --git a/move/example/Move.toml b/move/example/Move.toml index 3af5e113..80980dc9 100644 --- a/move/example/Move.toml +++ b/move/example/Move.toml @@ -9,7 +9,7 @@ GasService = { local = "../gas_service" } AxelarGateway = { local = "../axelar_gateway" } Utils = { local = "../utils" } VersionControl = { local = "../version_control" } -ITS = { local = "../its" } +InterchainTokenService = { local = "../interchain_token_service" } RelayerDiscovery = { local = "../relayer_discovery" } [addresses] diff --git a/move/example/sources/its/its.move b/move/example/sources/its/its.move index aac71ec5..f9ac2b1f 100644 --- a/move/example/sources/its/its.move +++ b/move/example/sources/its/its.move @@ -5,11 +5,11 @@ use axelar_gateway::gateway::{Self, Gateway}; use axelar_gateway::message_ticket::MessageTicket; use example::utils::concat; use gas_service::gas_service::GasService; -use its::coin_info; -use its::coin_management; -use its::discovery as its_discovery; -use its::interchain_token_service::{Self, InterchainTokenService}; -use its::token_id::TokenId; +use interchain_token_service::coin_info; +use interchain_token_service::coin_management; +use interchain_token_service::discovery as its_discovery; +use interchain_token_service::interchain_token_service::{Self, InterchainTokenService}; +use interchain_token_service::token_id::TokenId; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::{Self, Transaction}; use std::ascii::{Self, String}; diff --git a/move/its/Move.lock b/move/interchain_token_service/Move.lock similarity index 95% rename from move/its/Move.lock rename to move/interchain_token_service/Move.lock index d93fb85b..e1d747e4 100644 --- a/move/its/Move.lock +++ b/move/interchain_token_service/Move.lock @@ -2,7 +2,7 @@ [move] version = 3 -manifest_digest = "2429DB0FDE0EAD1C15A96EA75C44454B3279EB93A32FF56518FFFDAFEF50695A" +manifest_digest = "53A52F59870BC3BA264A1763E718516ED5424853E35D0ED4E77D6C252167654A" deps_digest = "52B406A7A21811BEF51751CF88DA0E76DAEFFEAC888D4F4060B1A72BBE7D8D35" dependencies = [ { id = "Abi", name = "Abi" }, diff --git a/move/its/Move.toml b/move/interchain_token_service/Move.toml similarity index 86% rename from move/its/Move.toml rename to move/interchain_token_service/Move.toml index d5b03748..59ecbf9b 100644 --- a/move/its/Move.toml +++ b/move/interchain_token_service/Move.toml @@ -1,5 +1,5 @@ [package] -name = "ITS" +name = "InterchainTokenService" version = "0.1.0" edition = "2024" @@ -12,4 +12,4 @@ VersionControl = { local = "../version_control" } RelayerDiscovery = { local = "../relayer_discovery" } [addresses] -its = "0xa5" +interchain_token_service = "0xa5" diff --git a/move/its/sources/discovery.move b/move/interchain_token_service/sources/discovery.move similarity index 93% rename from move/its/sources/discovery.move rename to move/interchain_token_service/sources/discovery.move index 3a8f9235..139b65a7 100644 --- a/move/its/sources/discovery.move +++ b/move/interchain_token_service/sources/discovery.move @@ -1,8 +1,8 @@ -module its::discovery; +module interchain_token_service::discovery; use abi::abi::{Self, AbiReader}; -use its::interchain_token_service::InterchainTokenService; -use its::token_id::{Self, TokenId}; +use interchain_token_service::interchain_token_service::InterchainTokenService; +use interchain_token_service::token_id::{Self, TokenId}; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::{Self, Transaction, package_id}; use std::ascii; @@ -212,7 +212,7 @@ fun initial_tx(its: &InterchainTokenService): Transaction { #[test] fun test_discovery_initial() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::interchain_token_service::create_for_testing(ctx); + let mut its = interchain_token_service::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -230,7 +230,7 @@ fun test_discovery_initial() { #[test] fun test_discovery_interchain_transfer() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::interchain_token_service::create_for_testing(ctx); + let mut its = interchain_token_service::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -252,7 +252,7 @@ fun test_discovery_interchain_transfer() { let type_arg = std::type_name::get(); its.add_registered_coin_type_for_testing( - its::token_id::from_address(token_id), + interchain_token_service::token_id::from_address(token_id), type_arg, ); let tx_block = call_info(&its, payload); @@ -286,7 +286,7 @@ fun test_discovery_interchain_transfer() { #[test] fun test_discovery_interchain_transfer_with_data() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::interchain_token_service::create_for_testing(ctx); + let mut its = interchain_token_service::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -315,7 +315,7 @@ fun test_discovery_interchain_transfer_with_data() { let payload = writer.into_bytes(); its.add_registered_coin_type_for_testing( - its::token_id::from_address(token_id), + interchain_token_service::token_id::from_address(token_id), std::type_name::get(), ); @@ -333,7 +333,7 @@ fun test_discovery_interchain_transfer_with_data() { #[test] fun test_discovery_deploy_token() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::interchain_token_service::create_for_testing(ctx); + let mut its = interchain_token_service::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -355,7 +355,7 @@ fun test_discovery_deploy_token() { let type_arg = std::type_name::get(); its.add_unregistered_coin_type_for_testing( - its::token_id::unregistered_token_id( + interchain_token_service::token_id::unregistered_token_id( &ascii::string(symbol), (decimals as u8), ), @@ -444,7 +444,7 @@ fun test_interchain_transfer_info_invalid_message_type() { #[test] fun test_discovery_hub_message() { let ctx = &mut sui::tx_context::dummy(); - let mut its = its::interchain_token_service::create_for_testing(ctx); + let mut its = interchain_token_service::interchain_token_service::create_for_testing(ctx); let mut discovery = relayer_discovery::discovery::new(ctx); register_transaction(&mut its, &mut discovery); @@ -472,7 +472,7 @@ fun test_discovery_hub_message() { let type_arg = std::type_name::get(); its.add_registered_coin_type_for_testing( - its::token_id::from_address(token_id), + interchain_token_service::token_id::from_address(token_id), type_arg, ); let tx_block = call_info(&its, payload); @@ -504,7 +504,7 @@ fun test_discovery_hub_message() { #[expected_failure(abort_code = EUnsupportedMessageType)] fun test_call_info_unsupported_message_type() { let ctx = &mut sui::tx_context::dummy(); - let its = its::interchain_token_service::create_for_testing(ctx); + let its = interchain_token_service::interchain_token_service::create_for_testing(ctx); let mut writer = abi::new_writer(1); writer.write_u256(5); diff --git a/move/its/sources/events.move b/move/interchain_token_service/sources/events.move similarity index 96% rename from move/its/sources/events.move rename to move/interchain_token_service/sources/events.move index 09d1b1b4..7d2ce0d3 100644 --- a/move/its/sources/events.move +++ b/move/interchain_token_service/sources/events.move @@ -1,7 +1,7 @@ -module its::events; +module interchain_token_service::events; use axelar_gateway::bytes32::{Self, Bytes32}; -use its::token_id::{TokenId, UnregisteredTokenId}; +use interchain_token_service::token_id::{TokenId, UnregisteredTokenId}; use std::ascii::String; use std::string; use sui::address; @@ -170,9 +170,9 @@ public(package) fun flow_limit_set(token_id: TokenId, flow_limit: u64) { // Test Only // --------- #[test_only] -use its::coin::COIN; +use interchain_token_service::coin::COIN; #[test_only] -use its::token_id; +use interchain_token_service::token_id; #[test_only] use utils::utils; diff --git a/move/its/sources/interchain_token_service.move b/move/interchain_token_service/sources/interchain_token_service.move similarity index 87% rename from move/its/sources/interchain_token_service.move rename to move/interchain_token_service/sources/interchain_token_service.move index 2d951535..81b99f17 100644 --- a/move/its/sources/interchain_token_service.move +++ b/move/interchain_token_service/sources/interchain_token_service.move @@ -1,14 +1,14 @@ -module its::interchain_token_service; +module interchain_token_service::interchain_token_service; use axelar_gateway::channel::{ApprovedMessage, Channel}; use axelar_gateway::message_ticket::MessageTicket; -use its::coin_info::CoinInfo; -use its::coin_management::CoinManagement; -use its::interchain_transfer_ticket::{Self, InterchainTransferTicket}; -use its::interchain_token_service_v0::{Self, InterchainTokenService_v0}; -use its::owner_cap::{Self, OwnerCap}; -use its::token_id::TokenId; -use its::trusted_addresses::TrustedAddresses; +use interchain_token_service::coin_info::CoinInfo; +use interchain_token_service::coin_management::CoinManagement; +use interchain_token_service::interchain_transfer_ticket::{Self, InterchainTransferTicket}; +use interchain_token_service::interchain_token_service_v0::{Self, InterchainTokenService_v0}; +use interchain_token_service::owner_cap::{Self, OwnerCap}; +use interchain_token_service::token_id::TokenId; +use interchain_token_service::trusted_addresses::TrustedAddresses; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::Transaction; use std::ascii::{Self, String}; @@ -357,7 +357,7 @@ fun version_control(): VersionControl { // Test Only // --------- #[test_only] -use its::coin::COIN; +use interchain_token_service::coin::COIN; #[test_only] use axelar_gateway::channel; #[test_only] @@ -409,7 +409,7 @@ public fun create_for_testing(ctx: &mut TxContext): InterchainTokenService { #[test_only] public(package) fun add_unregistered_coin_type_for_testing( self: &mut InterchainTokenService, - token_id: its::token_id::UnregisteredTokenId, + token_id: interchain_token_service::token_id::UnregisteredTokenId, type_name: std::type_name::TypeName, ) { self @@ -420,7 +420,7 @@ public(package) fun add_unregistered_coin_type_for_testing( #[test_only] public(package) fun remove_unregistered_coin_type_for_testing( self: &mut InterchainTokenService, - token_id: its::token_id::UnregisteredTokenId, + token_id: interchain_token_service::token_id::UnregisteredTokenId, ): std::type_name::TypeName { self.value_mut!(b"").remove_unregistered_coin_type_for_testing(token_id) } @@ -452,15 +452,15 @@ fun test_register_coin() { let ctx = &mut sui::tx_context::dummy(); let mut its = create_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( string::utf8(b"Name"), ascii::string(b"Symbol"), 10, ); - let coin_management = its::coin_management::new_locked(); + let coin_management = interchain_token_service::coin_management::new_locked(); register_coin(&mut its, coin_info, coin_management); - utils::assert_event>(); + utils::assert_event>(); sui::test_utils::destroy(its); } @@ -473,12 +473,12 @@ fun test_deploy_remote_interchain_token() { let token_symbol = ascii::string(b"Symbol"); let token_decimals = 10; - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( token_name, token_symbol, token_decimals, ); - let coin_management = its::coin_management::new_locked(); + let coin_management = interchain_token_service::coin_management::new_locked(); let token_id = register_coin(&mut its, coin_info, coin_management); let destination_chain = ascii::string(b"Chain Name"); @@ -488,7 +488,7 @@ fun test_deploy_remote_interchain_token() { destination_chain, ); - utils::assert_event>(); + utils::assert_event>(); let mut writer = abi::new_writer(6); @@ -519,16 +519,16 @@ fun test_deploy_interchain_token() { let ctx = &mut tx_context::dummy(); let mut its = create_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( string::utf8(b"Name"), ascii::string(b"Symbol"), 10, ); - let coin_management = its::coin_management::new_locked(); + let coin_management = interchain_token_service::coin_management::new_locked(); let token_id = register_coin(&mut its, coin_info, coin_management); - utils::assert_event>(); + utils::assert_event>(); let amount = 1234; let coin = sui::coin::mint_for_testing(amount, ctx); @@ -552,7 +552,7 @@ fun test_deploy_interchain_token() { &clock, ); - utils::assert_event>(); + utils::assert_event>(); let mut writer = abi::new_writer(6); @@ -586,14 +586,14 @@ fun test_receive_interchain_transfer() { let clock = sui::clock::create_for_testing(ctx); let mut its = create_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( string::utf8(b"Name"), ascii::string(b"Symbol"), 10, ); let amount = 1234; - let mut coin_management = its::coin_management::new_locked(); + let mut coin_management = interchain_token_service::coin_management::new_locked(); let coin = sui::coin::mint_for_testing(amount, ctx); coin_management.take_balance(coin.into_balance(), &clock); @@ -624,7 +624,7 @@ fun test_receive_interchain_transfer() { receive_interchain_transfer(&mut its, approved_message, &clock, ctx); - utils::assert_event>(); + utils::assert_event>(); clock.destroy_for_testing(); sui::test_utils::destroy(its); @@ -636,7 +636,7 @@ fun test_receive_interchain_transfer_with_data() { let clock = sui::clock::create_for_testing(ctx); let mut its = create_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( string::utf8(b"Name"), ascii::string(b"Symbol"), 10, @@ -644,7 +644,7 @@ fun test_receive_interchain_transfer_with_data() { let amount = 1234; let data = b"some_data"; - let mut coin_management = its::coin_management::new_locked(); + let mut coin_management = interchain_token_service::coin_management::new_locked(); let coin = sui::coin::mint_for_testing(amount, ctx); coin_management.take_balance(coin.into_balance(), &clock); @@ -686,7 +686,7 @@ fun test_receive_interchain_transfer_with_data() { ctx, ); - utils::assert_event>(); + utils::assert_event>(); assert!(received_source_chain == source_chain); assert!(received_source_address == its_source_address); @@ -735,7 +735,7 @@ fun test_receive_deploy_interchain_token() { receive_deploy_interchain_token(&mut its, approved_message); - utils::assert_event>(); + utils::assert_event>(); clock.destroy_for_testing(); sui::test_utils::destroy(its); @@ -748,7 +748,7 @@ fun test_give_unregistered_coin() { let ctx = &mut tx_context::dummy(); let mut its = create_for_testing(ctx); - let (treasury_cap, coin_metadata) = its::coin::create_treasury_and_metadata( + let (treasury_cap, coin_metadata) = interchain_token_service::coin::create_treasury_and_metadata( symbol, decimals, ctx, @@ -766,15 +766,15 @@ fun test_mint_as_distributor() { let symbol = b"COIN"; let decimals = 9; - let (treasury_cap, coin_metadata) = its::coin::create_treasury_and_metadata( + let (treasury_cap, coin_metadata) = interchain_token_service::coin::create_treasury_and_metadata( symbol, decimals, ctx, ); - let coin_info = its::coin_info::from_metadata( + let coin_info = interchain_token_service::coin_info::from_metadata( coin_metadata, ); - let mut coin_management = its::coin_management::new_with_cap(treasury_cap); + let mut coin_management = interchain_token_service::coin_management::new_with_cap(treasury_cap); let channel = channel::new(ctx); coin_management.add_distributor(channel.to_address()); @@ -803,15 +803,15 @@ fun test_mint_to_as_distributor() { let symbol = b"COIN"; let decimals = 9; - let (treasury_cap, coin_metadata) = its::coin::create_treasury_and_metadata( + let (treasury_cap, coin_metadata) = interchain_token_service::coin::create_treasury_and_metadata( symbol, decimals, ctx, ); - let coin_info = its::coin_info::from_metadata( + let coin_info = interchain_token_service::coin_info::from_metadata( coin_metadata, ); - let mut coin_management = its::coin_management::new_with_cap(treasury_cap); + let mut coin_management = interchain_token_service::coin_management::new_with_cap(treasury_cap); let channel = channel::new(ctx); coin_management.add_distributor(channel.to_address()); @@ -842,12 +842,12 @@ fun test_burn_as_distributor() { let ( mut treasury_cap, coin_metadata, - ) = its::coin::create_treasury_and_metadata(symbol, decimals, ctx); + ) = interchain_token_service::coin::create_treasury_and_metadata(symbol, decimals, ctx); let coin = treasury_cap.mint(amount, ctx); - let coin_info = its::coin_info::from_metadata( + let coin_info = interchain_token_service::coin_info::from_metadata( coin_metadata, ); - let mut coin_management = its::coin_management::new_with_cap(treasury_cap); + let mut coin_management = interchain_token_service::coin_management::new_with_cap(treasury_cap); let channel = channel::new(ctx); coin_management.add_distributor(channel.to_address()); @@ -876,7 +876,7 @@ fun test_set_trusted_address() { ITS_HUB_ROUTING_IDENTIFIER, b"hub address", ].map!(|chain| chain.to_ascii_string()); - let trusted_addresses = its::trusted_addresses::new( + let trusted_addresses = interchain_token_service::trusted_addresses::new( trusted_chains, trusted_addresses, ); @@ -896,15 +896,15 @@ fun test_set_flow_limit() { let decimals = 9; let limit = 1234; - let (treasury_cap, coin_metadata) = its::coin::create_treasury_and_metadata( + let (treasury_cap, coin_metadata) = interchain_token_service::coin::create_treasury_and_metadata( symbol, decimals, ctx, ); - let coin_info = its::coin_info::from_metadata( + let coin_info = interchain_token_service::coin_info::from_metadata( coin_metadata, ); - let mut coin_management = its::coin_management::new_with_cap(treasury_cap); + let mut coin_management = interchain_token_service::coin_management::new_with_cap(treasury_cap); let channel = channel::new(ctx); coin_management.add_operator(channel.to_address()); @@ -934,7 +934,7 @@ fun test_init() { fun test_registered_coin_type() { let ctx = &mut tx_context::dummy(); let mut its = create_for_testing(ctx); - let token_id = its::token_id::from_address(@0x1); + let token_id = interchain_token_service::token_id::from_address(@0x1); its.add_registered_coin_type_for_testing( token_id, std::type_name::get(), diff --git a/move/its/sources/types/address_tracker.move b/move/interchain_token_service/sources/types/address_tracker.move similarity index 98% rename from move/its/sources/types/address_tracker.move rename to move/interchain_token_service/sources/types/address_tracker.move index a2b406d1..a90b7ab4 100644 --- a/move/its/sources/types/address_tracker.move +++ b/move/interchain_token_service/sources/types/address_tracker.move @@ -1,8 +1,8 @@ /// Q: why addresses are stored as Strings? /// Q: why chains are Strings? -module its::address_tracker; +module interchain_token_service::address_tracker; -use its::events; +use interchain_token_service::events; use std::ascii::String; use sui::table::{Self, Table}; diff --git a/move/its/sources/types/coin_data.move b/move/interchain_token_service/sources/types/coin_data.move similarity index 79% rename from move/its/sources/types/coin_data.move rename to move/interchain_token_service/sources/types/coin_data.move index 7c310230..17c4578c 100644 --- a/move/its/sources/types/coin_data.move +++ b/move/interchain_token_service/sources/types/coin_data.move @@ -1,7 +1,7 @@ -module its::coin_data; +module interchain_token_service::coin_data; -use its::coin_info::CoinInfo; -use its::coin_management::CoinManagement; +use interchain_token_service::coin_info::CoinInfo; +use interchain_token_service::coin_management::CoinManagement; // ----- // Types diff --git a/move/its/sources/types/coin_info.move b/move/interchain_token_service/sources/types/coin_info.move similarity index 94% rename from move/its/sources/types/coin_info.move rename to move/interchain_token_service/sources/types/coin_info.move index 64c3874a..dcd35068 100644 --- a/move/its/sources/types/coin_info.move +++ b/move/interchain_token_service/sources/types/coin_info.move @@ -1,6 +1,6 @@ /// Defines the `CoinInfo` type which allows to store information about a coin: /// either derived from `CoinMetadata` or manually provided. -module its::coin_info; +module interchain_token_service::coin_info; use std::ascii; use std::string::String; @@ -79,7 +79,7 @@ public fun drop(coin_info: CoinInfo) { #[test] fun test_from_metadata() { let ctx = &mut tx_context::dummy(); - let metadata = its::coin::create_metadata(b"Symbol", 8, ctx); + let metadata = interchain_token_service::coin::create_metadata(b"Symbol", 8, ctx); let metadata_bytes = sui::bcs::to_bytes(&metadata); let name = metadata.get_name(); diff --git a/move/its/sources/types/coin_management.move b/move/interchain_token_service/sources/types/coin_management.move similarity index 98% rename from move/its/sources/types/coin_management.move rename to move/interchain_token_service/sources/types/coin_management.move index 53e42171..05a78a8a 100644 --- a/move/its/sources/types/coin_management.move +++ b/move/interchain_token_service/sources/types/coin_management.move @@ -1,7 +1,7 @@ -module its::coin_management; +module interchain_token_service::coin_management; use axelar_gateway::channel::Channel; -use its::flow_limit::{Self, FlowLimit}; +use interchain_token_service::flow_limit::{Self, FlowLimit}; use sui::balance::{Self, Balance}; use sui::clock::Clock; use sui::coin::{Self, TreasuryCap, Coin}; diff --git a/move/its/sources/types/flow_limit.move b/move/interchain_token_service/sources/types/flow_limit.move similarity index 98% rename from move/its/sources/types/flow_limit.move rename to move/interchain_token_service/sources/types/flow_limit.move index 02c174ab..e8cffb1f 100644 --- a/move/its/sources/types/flow_limit.move +++ b/move/interchain_token_service/sources/types/flow_limit.move @@ -1,4 +1,4 @@ -module its::flow_limit; +module interchain_token_service::flow_limit; use sui::clock::Clock; diff --git a/move/its/sources/types/interchain_transfer_ticket.move b/move/interchain_token_service/sources/types/interchain_transfer_ticket.move similarity index 92% rename from move/its/sources/types/interchain_transfer_ticket.move rename to move/interchain_token_service/sources/types/interchain_transfer_ticket.move index b7b1dd46..ea20d423 100644 --- a/move/its/sources/types/interchain_transfer_ticket.move +++ b/move/interchain_token_service/sources/types/interchain_transfer_ticket.move @@ -1,6 +1,6 @@ -module its::interchain_transfer_ticket; +module interchain_token_service::interchain_transfer_ticket; -use its::token_id::TokenId; +use interchain_token_service::token_id::TokenId; use std::ascii::String; use sui::balance::Balance; diff --git a/move/its/sources/types/owner_cap.move b/move/interchain_token_service/sources/types/owner_cap.move similarity index 81% rename from move/its/sources/types/owner_cap.move rename to move/interchain_token_service/sources/types/owner_cap.move index f9c5db91..a27f0e5d 100644 --- a/move/its/sources/types/owner_cap.move +++ b/move/interchain_token_service/sources/types/owner_cap.move @@ -1,4 +1,4 @@ -module its::owner_cap; +module interchain_token_service::owner_cap; // ----- // Types diff --git a/move/its/sources/types/token_id.move b/move/interchain_token_service/sources/types/token_id.move similarity index 92% rename from move/its/sources/types/token_id.move rename to move/interchain_token_service/sources/types/token_id.move index a2ebddd4..f2aba8a7 100644 --- a/move/its/sources/types/token_id.move +++ b/move/interchain_token_service/sources/types/token_id.move @@ -1,7 +1,7 @@ -module its::token_id; +module interchain_token_service::token_id; -use its::coin_info::CoinInfo; -use its::coin_management::CoinManagement; +use interchain_token_service::coin_info::CoinInfo; +use interchain_token_service::coin_management::CoinManagement; use std::ascii; use std::string::String; use std::type_name; @@ -77,7 +77,7 @@ public fun unregistered_token_id( #[test] fun test() { use std::string; - use its::coin_info; + use interchain_token_service::coin_info; let prefix = address::to_u256( address::from_bytes( diff --git a/move/its/sources/types/trusted_addresses.move b/move/interchain_token_service/sources/types/trusted_addresses.move similarity index 96% rename from move/its/sources/types/trusted_addresses.move rename to move/interchain_token_service/sources/types/trusted_addresses.move index 39dd60b9..5cf5a461 100644 --- a/move/its/sources/types/trusted_addresses.move +++ b/move/interchain_token_service/sources/types/trusted_addresses.move @@ -1,4 +1,4 @@ -module its::trusted_addresses; +module interchain_token_service::trusted_addresses; use std::ascii::String; diff --git a/move/its/sources/types/unregistered_coin_data.move b/move/interchain_token_service/sources/types/unregistered_coin_data.move similarity index 92% rename from move/its/sources/types/unregistered_coin_data.move rename to move/interchain_token_service/sources/types/unregistered_coin_data.move index 2cc8f08e..c31e7abf 100644 --- a/move/its/sources/types/unregistered_coin_data.move +++ b/move/interchain_token_service/sources/types/unregistered_coin_data.move @@ -1,4 +1,4 @@ -module its::unregistered_coin_data; +module interchain_token_service::unregistered_coin_data; use sui::coin::{TreasuryCap, CoinMetadata}; diff --git a/move/its/sources/utils.move b/move/interchain_token_service/sources/utils.move similarity index 98% rename from move/its/sources/utils.move rename to move/interchain_token_service/sources/utils.move index 5b01edff..526d9ce0 100644 --- a/move/its/sources/utils.move +++ b/move/interchain_token_service/sources/utils.move @@ -1,4 +1,4 @@ -module its::utils; +module interchain_token_service::utils; use std::ascii; diff --git a/move/its/sources/versioned/interchain_token_service_v0.move b/move/interchain_token_service/sources/versioned/interchain_token_service_v0.move similarity index 93% rename from move/its/sources/versioned/interchain_token_service_v0.move rename to move/interchain_token_service/sources/versioned/interchain_token_service_v0.move index a95fdd53..88f8b6a4 100644 --- a/move/its/sources/versioned/interchain_token_service_v0.move +++ b/move/interchain_token_service/sources/versioned/interchain_token_service_v0.move @@ -1,19 +1,19 @@ -module its::interchain_token_service_v0; +module interchain_token_service::interchain_token_service_v0; use abi::abi::{Self, AbiReader}; use axelar_gateway::channel::{Channel, ApprovedMessage}; use axelar_gateway::gateway; use axelar_gateway::message_ticket::MessageTicket; -use its::address_tracker::{Self, InterchainAddressTracker}; -use its::coin_data::{Self, CoinData}; -use its::coin_info::{Self, CoinInfo}; -use its::coin_management::{Self, CoinManagement}; -use its::events; -use its::interchain_transfer_ticket::InterchainTransferTicket; -use its::token_id::{Self, TokenId, UnregisteredTokenId}; -use its::trusted_addresses::TrustedAddresses; -use its::unregistered_coin_data::{Self, UnregisteredCoinData}; -use its::utils as its_utils; +use interchain_token_service::address_tracker::{Self, InterchainAddressTracker}; +use interchain_token_service::coin_data::{Self, CoinData}; +use interchain_token_service::coin_info::{Self, CoinInfo}; +use interchain_token_service::coin_management::{Self, CoinManagement}; +use interchain_token_service::events; +use interchain_token_service::interchain_transfer_ticket::InterchainTransferTicket; +use interchain_token_service::token_id::{Self, TokenId, UnregisteredTokenId}; +use interchain_token_service::trusted_addresses::TrustedAddresses; +use interchain_token_service::unregistered_coin_data::{Self, UnregisteredCoinData}; +use interchain_token_service::utils as its_utils; use relayer_discovery::discovery::RelayerDiscovery; use std::ascii::{Self, String}; use std::string; @@ -703,7 +703,7 @@ fun read_amount(reader: &mut AbiReader): u64 { #[test_only] use axelar_gateway::channel; #[test_only] -use its::coin::COIN; +use interchain_token_service::coin::COIN; #[test_only] fun create_for_testing(ctx: &mut TxContext): InterchainTokenService_v0 { @@ -724,7 +724,7 @@ public fun create_unregistered_coin( decimals: u8, ctx: &mut TxContext, ) { - let (treasury_cap, coin_metadata) = its::coin::create_treasury_and_metadata( + let (treasury_cap, coin_metadata) = interchain_token_service::coin::create_treasury_and_metadata( symbol, decimals, ctx, @@ -999,14 +999,14 @@ fun test_receive_interchain_transfer_invalid_message_type() { let clock = sui::clock::create_for_testing(ctx); let mut self = create_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( string::utf8(b"Name"), ascii::string(b"Symbol"), 10, ); let amount = 1234; - let mut coin_management = its::coin_management::new_locked(); + let mut coin_management = interchain_token_service::coin_management::new_locked(); let coin = sui::coin::mint_for_testing(amount, ctx); coin_management.take_balance(coin.into_balance(), &clock); @@ -1048,14 +1048,14 @@ fun test_receive_interchain_transfer_passed_data() { let clock = sui::clock::create_for_testing(ctx); let mut self = create_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( string::utf8(b"Name"), ascii::string(b"Symbol"), 10, ); let amount = 1234; - let mut coin_management = its::coin_management::new_locked(); + let mut coin_management = interchain_token_service::coin_management::new_locked(); let coin = sui::coin::mint_for_testing(amount, ctx); coin_management.take_balance(coin.into_balance(), &clock); @@ -1096,14 +1096,14 @@ fun test_receive_interchain_transfer_with_data_invalid_message_type() { let ctx = &mut tx_context::dummy(); let clock = sui::clock::create_for_testing(ctx); let mut self = create_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( string::utf8(b"Name"), ascii::string(b"Symbol"), 10, ); let amount = 1234; - let mut coin_management = its::coin_management::new_locked(); + let mut coin_management = interchain_token_service::coin_management::new_locked(); let coin = sui::coin::mint_for_testing(amount, ctx); coin_management.take_balance(coin.into_balance(), &clock); @@ -1155,14 +1155,14 @@ fun test_receive_interchain_transfer_with_data_wrong_destination() { let clock = sui::clock::create_for_testing(ctx); let mut self = create_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( string::utf8(b"Name"), ascii::string(b"Symbol"), 10, ); let amount = 1234; - let mut coin_management = its::coin_management::new_locked(); + let mut coin_management = interchain_token_service::coin_management::new_locked(); let coin = sui::coin::mint_for_testing(amount, ctx); coin_management.take_balance(coin.into_balance(), &clock); @@ -1214,14 +1214,14 @@ fun test_receive_interchain_transfer_with_data_no_data() { let clock = sui::clock::create_for_testing(ctx); let mut self = create_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( string::utf8(b"Name"), ascii::string(b"Symbol"), 10, ); let amount = 1234; - let mut coin_management = its::coin_management::new_locked(); + let mut coin_management = interchain_token_service::coin_management::new_locked(); let coin = sui::coin::mint_for_testing(amount, ctx); coin_management.take_balance(coin.into_balance(), &clock); @@ -1361,7 +1361,7 @@ fun test_give_unregistered_coin_with_url() { let ( treasury_cap, coin_metadata, - ) = its::coin::create_treasury_and_metadata_custom( + ) = interchain_token_service::coin::create_treasury_and_metadata_custom( name, symbol, decimals, @@ -1386,12 +1386,12 @@ fun test_burn_as_distributor_not_distributor() { let ( mut treasury_cap, coin_metadata, - ) = its::coin::create_treasury_and_metadata(symbol, decimals, ctx); + ) = interchain_token_service::coin::create_treasury_and_metadata(symbol, decimals, ctx); let coin = treasury_cap.mint(amount, ctx); - let coin_info = its::coin_info::from_metadata( + let coin_info = interchain_token_service::coin_info::from_metadata( coin_metadata, ); - let mut coin_management = its::coin_management::new_with_cap(treasury_cap); + let mut coin_management = interchain_token_service::coin_management::new_with_cap(treasury_cap); let channel = channel::new(ctx); coin_management.add_distributor(@0x1); @@ -1414,7 +1414,7 @@ fun test_give_unregistered_coin_not_zero_total_supply() { let ( mut treasury_cap, coin_metadata, - ) = its::coin::create_treasury_and_metadata(symbol, decimals, ctx); + ) = interchain_token_service::coin::create_treasury_and_metadata(symbol, decimals, ctx); let coin = treasury_cap.mint(1, ctx); self.give_unregistered_coin(treasury_cap, coin_metadata); @@ -1431,7 +1431,7 @@ fun test_give_unregistered_coin_module_name_missmatch() { let ctx = &mut tx_context::dummy(); let mut self = create_for_testing(ctx); - let (treasury_cap, coin_metadata) = its::coin::create_treasury_and_metadata( + let (treasury_cap, coin_metadata) = interchain_token_service::coin::create_treasury_and_metadata( symbol, decimals, ctx, @@ -1450,15 +1450,15 @@ fun test_mint_as_distributor_not_distributor() { let symbol = b"COIN"; let decimals = 9; - let (treasury_cap, coin_metadata) = its::coin::create_treasury_and_metadata( + let (treasury_cap, coin_metadata) = interchain_token_service::coin::create_treasury_and_metadata( symbol, decimals, ctx, ); - let coin_info = its::coin_info::from_metadata( + let coin_info = interchain_token_service::coin_info::from_metadata( coin_metadata, ); - let mut coin_management = its::coin_management::new_with_cap(treasury_cap); + let mut coin_management = interchain_token_service::coin_management::new_with_cap(treasury_cap); let channel = channel::new(ctx); coin_management.add_distributor(@0x1); @@ -1499,15 +1499,15 @@ fun test_mint_to_as_distributor_not_distributor() { let symbol = b"COIN"; let decimals = 9; - let (treasury_cap, coin_metadata) = its::coin::create_treasury_and_metadata( + let (treasury_cap, coin_metadata) = interchain_token_service::coin::create_treasury_and_metadata( symbol, decimals, ctx, ); - let coin_info = its::coin_info::from_metadata( + let coin_info = interchain_token_service::coin_info::from_metadata( coin_metadata, ); - let mut coin_management = its::coin_management::new_with_cap(treasury_cap); + let mut coin_management = interchain_token_service::coin_management::new_with_cap(treasury_cap); let channel = channel::new(ctx); coin_management.add_distributor(@0x1); @@ -1580,7 +1580,7 @@ fun test_send_interchain_transfer_newer_ticket() { let current_version = 0; let invalid_version = 1; - let interchain_transfer_ticket = its::interchain_transfer_ticket::new( + let interchain_transfer_ticket = interchain_token_service::interchain_transfer_ticket::new( token_id, coin.into_balance(), source_channel.to_address(), @@ -1609,7 +1609,7 @@ fun test_set_trusted_addresses_mismatch_lengths() { let mut its = create_for_testing(ctx); its.set_trusted_addresses( - its::trusted_addresses::new_for_testing( + interchain_token_service::trusted_addresses::new_for_testing( vector[], vector[b"trusted address".to_ascii_string()], ), diff --git a/move/its/tests/coin.move b/move/interchain_token_service/tests/coin.move similarity index 97% rename from move/its/tests/coin.move rename to move/interchain_token_service/tests/coin.move index e924f74d..398b155c 100644 --- a/move/its/tests/coin.move +++ b/move/interchain_token_service/tests/coin.move @@ -1,5 +1,5 @@ #[test_only] -module its::coin; +module interchain_token_service::coin; use sui::coin::{Self, CoinMetadata, TreasuryCap}; use sui::url::Url; diff --git a/move/its/tests/coin_init_test.move b/move/interchain_token_service/tests/coin_init_test.move similarity index 92% rename from move/its/tests/coin_init_test.move rename to move/interchain_token_service/tests/coin_init_test.move index 9f0c069d..c1151f43 100644 --- a/move/its/tests/coin_init_test.move +++ b/move/interchain_token_service/tests/coin_init_test.move @@ -1,5 +1,5 @@ #[test_only] -module its::thecool1234coin___; +module interchain_token_service::thecool1234coin___; use sui::coin; use sui::url::Url; diff --git a/move/squid/Move.toml b/move/squid/Move.toml index 825eb127..6882b641 100644 --- a/move/squid/Move.toml +++ b/move/squid/Move.toml @@ -9,7 +9,7 @@ deepbook = { git = "https://github.com/axelarnetwork/deepbookv3.git", subdir = " token = { git = "https://github.com/axelarnetwork/deepbookv3.git", subdir = "packages/token", rev = "testnet-v1.38.2" } Utils = { local = "../utils" } AxelarGateway = { local = "../axelar_gateway" } -ITS = { local = "../its" } +InterchainTokenService = { local = "../interchain_token_service" } VersionControl = { local = "../version_control" } RelayerDiscovery = { local = "../relayer_discovery" } diff --git a/move/squid/sources/squid/coin_bag.move b/move/squid/sources/squid/coin_bag.move index 498c5f44..4aaa1206 100644 --- a/move/squid/sources/squid/coin_bag.move +++ b/move/squid/sources/squid/coin_bag.move @@ -128,7 +128,7 @@ fun estimate_key(): address { } #[test_only] -use its::coin::COIN; +use interchain_token_service::coin::COIN; #[test] fun test_balance() { diff --git a/move/squid/sources/squid/discovery.move b/move/squid/sources/squid/discovery.move index 934f384b..ae705692 100644 --- a/move/squid/sources/squid/discovery.move +++ b/move/squid/sources/squid/discovery.move @@ -1,7 +1,7 @@ module squid::discovery; use axelar_gateway::gateway::Gateway; -use its::interchain_token_service::InterchainTokenService; +use interchain_token_service::interchain_token_service::InterchainTokenService; use relayer_discovery::discovery::RelayerDiscovery; use relayer_discovery::transaction::{Self, MoveCall, Transaction}; use squid::deepbook_v3; @@ -56,7 +56,7 @@ public fun transaction( gateway: &Gateway, payload: vector, ): Transaction { - let (token_id, _, _, data) = its::discovery::interchain_transfer_info( + let (token_id, _, _, data) = interchain_token_service::discovery::interchain_transfer_info( payload, ); let type_in = (*its.registered_coin_type(token_id)).into_string(); diff --git a/move/squid/sources/squid/squid.move b/move/squid/sources/squid/squid.move index 1b202178..fbd7a4c9 100644 --- a/move/squid/sources/squid/squid.move +++ b/move/squid/sources/squid/squid.move @@ -1,7 +1,7 @@ module squid::squid; use axelar_gateway::channel::ApprovedMessage; -use its::interchain_token_service::InterchainTokenService; +use interchain_token_service::interchain_token_service::InterchainTokenService; use squid::owner_cap::{Self, OwnerCap}; use squid::squid_v0::{Self, Squid_v0}; use squid::swap_info::SwapInfo; @@ -169,16 +169,16 @@ public fun new_for_testing(ctx: &mut TxContext): Squid { } #[test_only] -use its::coin::COIN; +use interchain_token_service::coin::COIN; #[test] fun test_start_swap() { let ctx = &mut tx_context::dummy(); let clock = sui::clock::create_for_testing(ctx); - let mut its = its::interchain_token_service::create_for_testing(ctx); + let mut its = interchain_token_service::interchain_token_service::create_for_testing(ctx); let mut squid = new_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( std::string::utf8(b"Name"), std::ascii::string(b"Symbol"), 10, @@ -186,7 +186,7 @@ fun test_start_swap() { let amount = 1234; let data = std::bcs::to_bytes(&vector>[]); - let coin_management = its::coin_management::new_locked(); + let coin_management = interchain_token_service::coin_management::new_locked(); let coin = sui::coin::mint_for_testing(amount, ctx); let token_id = its.register_coin( @@ -195,7 +195,7 @@ fun test_start_swap() { ); // This gives some coin to InterchainTokenService - let interchain_transfer_ticket = its::interchain_token_service::prepare_interchain_transfer( + let interchain_transfer_ticket = interchain_token_service::interchain_token_service::prepare_interchain_transfer( token_id, coin, std::ascii::string(b"Chain Name"), diff --git a/move/squid/sources/squid/transfers.move b/move/squid/sources/squid/transfers.move index 47970080..98166fcd 100644 --- a/move/squid/sources/squid/transfers.move +++ b/move/squid/sources/squid/transfers.move @@ -1,8 +1,8 @@ module squid::transfers; use axelar_gateway::gateway::Gateway; -use its::interchain_token_service::{Self, InterchainTokenService}; -use its::token_id::{Self, TokenId}; +use interchain_token_service::interchain_token_service::{Self, InterchainTokenService}; +use interchain_token_service::token_id::{Self, TokenId}; use relayer_discovery::transaction::{Self, MoveCall}; use squid::squid::Squid; use squid::swap_info::SwapInfo; diff --git a/move/squid/sources/squid/versioned/squid_v0.move b/move/squid/sources/squid/versioned/squid_v0.move index 745fb72a..a08333a4 100644 --- a/move/squid/sources/squid/versioned/squid_v0.move +++ b/move/squid/sources/squid/versioned/squid_v0.move @@ -1,7 +1,7 @@ module squid::squid_v0; use axelar_gateway::channel::{Self, Channel, ApprovedMessage}; -use its::interchain_token_service::InterchainTokenService; +use interchain_token_service::interchain_token_service::InterchainTokenService; use squid::coin_bag::{Self, CoinBag}; use squid::swap_info::{Self, SwapInfo}; use std::ascii::String; @@ -106,7 +106,7 @@ public fun new_for_testing(ctx: &mut TxContext): Squid_v0 { } #[test_only] -use its::coin::COIN; +use interchain_token_service::coin::COIN; #[test_only] use sui::test_utils::destroy; @@ -114,10 +114,10 @@ use sui::test_utils::destroy; fun test_start_swap() { let ctx = &mut tx_context::dummy(); let clock = sui::clock::create_for_testing(ctx); - let mut its = its::interchain_token_service::create_for_testing(ctx); + let mut its = interchain_token_service::interchain_token_service::create_for_testing(ctx); let squid = new_for_testing(ctx); - let coin_info = its::coin_info::from_info( + let coin_info = interchain_token_service::coin_info::from_info( std::string::utf8(b"Name"), std::ascii::string(b"Symbol"), 10, @@ -125,7 +125,7 @@ fun test_start_swap() { let amount = 1234; let data = std::bcs::to_bytes(&vector>[]); - let coin_management = its::coin_management::new_locked(); + let coin_management = interchain_token_service::coin_management::new_locked(); let coin = sui::coin::mint_for_testing(amount, ctx); let token_id = its.register_coin( @@ -134,7 +134,7 @@ fun test_start_swap() { ); // This gives some coin to the service. - let interchain_transfer_ticket = its::interchain_token_service::prepare_interchain_transfer( + let interchain_transfer_ticket = interchain_token_service::interchain_token_service::prepare_interchain_transfer( token_id, coin, std::ascii::string(b"Chain Name"), From c124f019b5ae03f72d2a3d2fc9b79b2e3aa9fe2d Mon Sep 17 00:00:00 2001 From: Foivos Date: Thu, 19 Dec 2024 17:49:24 +0200 Subject: [PATCH 10/15] fix interfaces --- ...rchain_token_service_address_tracker.json} | 0 ...e_interchain_token_service_coin_data.json} | 0 ...e_interchain_token_service_coin_info.json} | 0 ...rchain_token_service_coin_management.json} | 0 ...e_interchain_token_service_discovery.json} | 0 ...face_interchain_token_service_events.json} | 0 ..._interchain_token_service_flow_limit.json} | 0 ...ken_service_interchain_token_service.json} | 0 ..._service_interchain_token_service_v0.json} | 0 ...n_service_interchain_transfer_ticket.json} | 0 ...e_interchain_token_service_owner_cap.json} | 0 ...ce_interchain_token_service_token_id.json} | 0 ...hain_token_service_trusted_addresses.json} | 0 ...token_service_unregistered_coin_data.json} | 0 ...rface_interchain_token_service_utils.json} | 0 test/testdata/interface_its_its.json | 106 ------------------ test/testdata/interface_its_its_v0.json | 45 -------- 17 files changed, 151 deletions(-) rename test/testdata/{interface_its_address_tracker.json => interface_interchain_token_service_address_tracker.json} (100%) rename test/testdata/{interface_its_coin_data.json => interface_interchain_token_service_coin_data.json} (100%) rename test/testdata/{interface_its_coin_info.json => interface_interchain_token_service_coin_info.json} (100%) rename test/testdata/{interface_its_coin_management.json => interface_interchain_token_service_coin_management.json} (100%) rename test/testdata/{interface_its_discovery.json => interface_interchain_token_service_discovery.json} (100%) rename test/testdata/{interface_its_events.json => interface_interchain_token_service_events.json} (100%) rename test/testdata/{interface_its_flow_limit.json => interface_interchain_token_service_flow_limit.json} (100%) rename test/testdata/{interface_its_interchain_token_service.json => interface_interchain_token_service_interchain_token_service.json} (100%) rename test/testdata/{interface_its_interchain_token_service_v0.json => interface_interchain_token_service_interchain_token_service_v0.json} (100%) rename test/testdata/{interface_its_interchain_transfer_ticket.json => interface_interchain_token_service_interchain_transfer_ticket.json} (100%) rename test/testdata/{interface_its_owner_cap.json => interface_interchain_token_service_owner_cap.json} (100%) rename test/testdata/{interface_its_token_id.json => interface_interchain_token_service_token_id.json} (100%) rename test/testdata/{interface_its_trusted_addresses.json => interface_interchain_token_service_trusted_addresses.json} (100%) rename test/testdata/{interface_its_unregistered_coin_data.json => interface_interchain_token_service_unregistered_coin_data.json} (100%) rename test/testdata/{interface_its_utils.json => interface_interchain_token_service_utils.json} (100%) delete mode 100644 test/testdata/interface_its_its.json delete mode 100644 test/testdata/interface_its_its_v0.json diff --git a/test/testdata/interface_its_address_tracker.json b/test/testdata/interface_interchain_token_service_address_tracker.json similarity index 100% rename from test/testdata/interface_its_address_tracker.json rename to test/testdata/interface_interchain_token_service_address_tracker.json diff --git a/test/testdata/interface_its_coin_data.json b/test/testdata/interface_interchain_token_service_coin_data.json similarity index 100% rename from test/testdata/interface_its_coin_data.json rename to test/testdata/interface_interchain_token_service_coin_data.json diff --git a/test/testdata/interface_its_coin_info.json b/test/testdata/interface_interchain_token_service_coin_info.json similarity index 100% rename from test/testdata/interface_its_coin_info.json rename to test/testdata/interface_interchain_token_service_coin_info.json diff --git a/test/testdata/interface_its_coin_management.json b/test/testdata/interface_interchain_token_service_coin_management.json similarity index 100% rename from test/testdata/interface_its_coin_management.json rename to test/testdata/interface_interchain_token_service_coin_management.json diff --git a/test/testdata/interface_its_discovery.json b/test/testdata/interface_interchain_token_service_discovery.json similarity index 100% rename from test/testdata/interface_its_discovery.json rename to test/testdata/interface_interchain_token_service_discovery.json diff --git a/test/testdata/interface_its_events.json b/test/testdata/interface_interchain_token_service_events.json similarity index 100% rename from test/testdata/interface_its_events.json rename to test/testdata/interface_interchain_token_service_events.json diff --git a/test/testdata/interface_its_flow_limit.json b/test/testdata/interface_interchain_token_service_flow_limit.json similarity index 100% rename from test/testdata/interface_its_flow_limit.json rename to test/testdata/interface_interchain_token_service_flow_limit.json diff --git a/test/testdata/interface_its_interchain_token_service.json b/test/testdata/interface_interchain_token_service_interchain_token_service.json similarity index 100% rename from test/testdata/interface_its_interchain_token_service.json rename to test/testdata/interface_interchain_token_service_interchain_token_service.json diff --git a/test/testdata/interface_its_interchain_token_service_v0.json b/test/testdata/interface_interchain_token_service_interchain_token_service_v0.json similarity index 100% rename from test/testdata/interface_its_interchain_token_service_v0.json rename to test/testdata/interface_interchain_token_service_interchain_token_service_v0.json diff --git a/test/testdata/interface_its_interchain_transfer_ticket.json b/test/testdata/interface_interchain_token_service_interchain_transfer_ticket.json similarity index 100% rename from test/testdata/interface_its_interchain_transfer_ticket.json rename to test/testdata/interface_interchain_token_service_interchain_transfer_ticket.json diff --git a/test/testdata/interface_its_owner_cap.json b/test/testdata/interface_interchain_token_service_owner_cap.json similarity index 100% rename from test/testdata/interface_its_owner_cap.json rename to test/testdata/interface_interchain_token_service_owner_cap.json diff --git a/test/testdata/interface_its_token_id.json b/test/testdata/interface_interchain_token_service_token_id.json similarity index 100% rename from test/testdata/interface_its_token_id.json rename to test/testdata/interface_interchain_token_service_token_id.json diff --git a/test/testdata/interface_its_trusted_addresses.json b/test/testdata/interface_interchain_token_service_trusted_addresses.json similarity index 100% rename from test/testdata/interface_its_trusted_addresses.json rename to test/testdata/interface_interchain_token_service_trusted_addresses.json diff --git a/test/testdata/interface_its_unregistered_coin_data.json b/test/testdata/interface_interchain_token_service_unregistered_coin_data.json similarity index 100% rename from test/testdata/interface_its_unregistered_coin_data.json rename to test/testdata/interface_interchain_token_service_unregistered_coin_data.json diff --git a/test/testdata/interface_its_utils.json b/test/testdata/interface_interchain_token_service_utils.json similarity index 100% rename from test/testdata/interface_its_utils.json rename to test/testdata/interface_interchain_token_service_utils.json diff --git a/test/testdata/interface_its_its.json b/test/testdata/interface_its_its.json deleted file mode 100644 index c2b544b0..00000000 --- a/test/testdata/interface_its_its.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "structs": { - "InterchainTokenService": { - "name": "InterchainTokenService", - "abilities": [ - "key" - ], - "fields": [ - { - "name": "id", - "type": "UID" - }, - { - "name": "inner", - "type": "Versioned" - } - ] - } - }, - "publicFunctions": { - "register_coin": { - "name": "register_coin", - "visibility": "public", - "params": { - "self#0#0": "&mut InterchainTokenService", - "coin_info#0#0": "CoinInfo", - "coin_management#0#0": "CoinManagement" - }, - "returnType": "TokenId" - }, - "deploy_remote_interchain_token": { - "name": "deploy_remote_interchain_token", - "visibility": "public", - "params": { - "self#0#0": "&InterchainTokenService", - "token_id#0#0": "TokenId", - "destination_chain#0#0": "String" - }, - "returnType": "MessageTicket" - }, - "prepare_interchain_transfer": { - "name": "prepare_interchain_transfer", - "visibility": "public", - "params": { - "token_id#0#0": "TokenId", - "coin#0#0": "Coin", - "destination_chain#0#0": "String", - "destination_address#0#0": "vector", - "metadata#0#0": "vector", - "source_channel#0#0": "&Channel" - }, - "returnType": "InterchainTransferTicket" - }, - "send_interchain_transfer": { - "name": "send_interchain_transfer", - "visibility": "public", - "params": { - "self#0#0": "&mut InterchainTokenService", - "ticket#0#0": "InterchainTransferTicket", - "clock#0#0": "&Clock" - }, - "returnType": "MessageTicket" - }, - "receive_interchain_transfer_with_data": { - "name": "receive_interchain_transfer_with_data", - "visibility": "public", - "params": { - "self#0#0": "&mut InterchainTokenService", - "approved_message#0#0": "ApprovedMessage", - "channel#0#0": "&Channel", - "clock#0#0": "&Clock", - "ctx#0#0": "&mut TxContext" - }, - "returnType": "String * vector * vector * Coin" - }, - "mint_as_distributor": { - "name": "mint_as_distributor", - "visibility": "public", - "params": { - "self#0#0": "&mut InterchainTokenService", - "channel#0#0": "&Channel", - "token_id#0#0": "TokenId", - "amount#0#0": "u64", - "ctx#0#0": "&mut TxContext" - }, - "returnType": "Coin" - }, - "registered_coin_type": { - "name": "registered_coin_type", - "visibility": "public", - "params": { - "self#0#0": "&InterchainTokenService", - "token_id#0#0": "TokenId" - }, - "returnType": "&TypeName" - }, - "channel_address": { - "name": "channel_address", - "visibility": "public", - "params": { - "self#0#0": "&InterchainTokenService" - }, - "returnType": "address" - } - } -} diff --git a/test/testdata/interface_its_its_v0.json b/test/testdata/interface_its_its_v0.json deleted file mode 100644 index f850013e..00000000 --- a/test/testdata/interface_its_its_v0.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "structs": { - "InterchainTokenService_v0": { - "name": "InterchainTokenService_v0", - "abilities": [ - "store" - ], - "fields": [ - { - "name": "channel", - "type": "Channel" - }, - { - "name": "address_tracker", - "type": "InterchainAddressTracker" - }, - { - "name": "unregistered_coin_types", - "type": "Table" - }, - { - "name": "unregistered_coins", - "type": "Bag" - }, - { - "name": "registered_coin_types", - "type": "Table" - }, - { - "name": "registered_coins", - "type": "Bag" - }, - { - "name": "relayer_discovery_id", - "type": "ID" - }, - { - "name": "version_control", - "type": "VersionControl" - } - ] - } - }, - "publicFunctions": {} -} From d4c5d135e6ba0f309cc6d8bb06f956425cdf6ca2 Mon Sep 17 00:00:00 2001 From: Foivos Date: Thu, 19 Dec 2024 18:07:07 +0200 Subject: [PATCH 11/15] fix tests --- test/axelar-gateway.js | 2 +- test/its.js | 14 +++++++------- test/squid.js | 22 +++++++++++----------- test/testutils.js | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/axelar-gateway.js b/test/axelar-gateway.js index 645be93a..cd598086 100644 --- a/test/axelar-gateway.js +++ b/test/axelar-gateway.js @@ -274,7 +274,7 @@ describe('Axelar Gateway', () => { await publishPackage(client, keypair, 'gas_service'); await publishPackage(client, keypair, 'abi'); await publishPackage(client, keypair, 'governance'); - await publishPackage(client, keypair, 'its'); + await publishPackage(client, keypair, 'interchain_token_service'); const result = await publishPackage(client, keypair, 'example'); const testId = result.packageId; diff --git a/test/its.js b/test/its.js index 20423dbc..e99b78a2 100644 --- a/test/its.js +++ b/test/its.js @@ -93,7 +93,7 @@ describe('ITS', () => { const registerTransactionBuilder = new TxBuilder(client); await registerTransactionBuilder.moveCall({ - target: `${deployments.its.packageId}::discovery::register_transaction`, + target: `${deployments.interchain_token_service.packageId}::discovery::register_transaction`, arguments: [objectIds.its, objectIds.relayerDiscovery], }); @@ -119,15 +119,15 @@ describe('ITS', () => { singleton: findObjectId(deployments.example.publishTxn, 'its::Singleton'), tokenTreasuryCap: findObjectId(deployments.example.publishTxn, `TreasuryCap<${coinType}>`), tokenCoinMetadata: findObjectId(deployments.example.publishTxn, `CoinMetadata<${coinType}>`), - its: findObjectId(deployments.its.publishTxn, 'interchain_token_service::InterchainTokenService'), - itsV0: findObjectId(deployments.its.publishTxn, 'interchain_token_service_v0::InterchainTokenService_v0'), + its: findObjectId(deployments.interchain_token_service.publishTxn, 'interchain_token_service::InterchainTokenService'), + itsV0: findObjectId(deployments.interchain_token_service.publishTxn, 'interchain_token_service_v0::InterchainTokenService_v0'), relayerDiscovery: findObjectId( deployments.relayer_discovery.publishTxn, `${deployments.relayer_discovery.packageId}::discovery::RelayerDiscovery`, ), gasService: findObjectId(deployments.gas_service.publishTxn, `${deployments.gas_service.packageId}::gas_service::GasService`), creatorCap: findObjectId(deployments.axelar_gateway.publishTxn, 'OwnerCap'), - itsOwnerCap: findObjectId(deployments.its.publishTxn, `${deployments.its.packageId}::owner_cap::OwnerCap`), + itsOwnerCap: findObjectId(deployments.interchain_token_service.publishTxn, `${deployments.interchain_token_service.packageId}::owner_cap::OwnerCap`), }; // Mint some coins for tests const tokenTxBuilder = new TxBuilder(client); @@ -197,7 +197,7 @@ describe('ITS', () => { const gas = tx.splitCoins(tx.gas, [1e8]); const TokenId = await txBuilder.moveCall({ - target: `${deployments.its.packageId}::token_id::from_u256`, + target: `${deployments.interchain_token_service.packageId}::token_id::from_u256`, arguments: [objectIds.tokenId], }); @@ -267,7 +267,7 @@ describe('ITS', () => { const gas = tx.splitCoins(tx.gas, [1e8]); const TokenId = await txBuilder.moveCall({ - target: `${deployments.its.packageId}::token_id::from_u256`, + target: `${deployments.interchain_token_service.packageId}::token_id::from_u256`, arguments: [objectIds.tokenId], }); @@ -310,7 +310,7 @@ describe('ITS', () => { const txBuilder = new TxBuilder(client); await txBuilder.moveCall({ - target: `${deployments.its.packageId}::interchain_token_service::give_unregistered_coin`, + target: `${deployments.interchain_token_service.packageId}::interchain_token_service::give_unregistered_coin`, arguments: [objectIds.its, treasuryCap, metadata], typeArguments: [typeArg], }); diff --git a/test/squid.js b/test/squid.js index 8c9e3611..74042ca7 100644 --- a/test/squid.js +++ b/test/squid.js @@ -93,7 +93,7 @@ describe('Squid', () => { const registerTransactionBuilder = new TxBuilder(client); await registerTransactionBuilder.moveCall({ - target: `${deployments.its.packageId}::discovery::register_transaction`, + target: `${deployments.interchain_token_service.packageId}::discovery::register_transaction`, arguments: [objectIds.its, objectIds.relayerDiscovery], }); @@ -221,19 +221,19 @@ describe('Squid', () => { }); const tokenId = await builder.moveCall({ - target: `${deployments.its.packageId}::token_id::from_address`, + target: `${deployments.interchain_token_service.packageId}::token_id::from_address`, arguments: [objectIds.tokenId], typeArguments: [], }); const interchainTransfer = await builder.moveCall({ - target: `${deployments.its.packageId}::interchain_token_service::prepare_interchain_transfer`, + target: `${deployments.interchain_token_service.packageId}::interchain_token_service::prepare_interchain_transfer`, arguments: [tokenId, input, trustedSourceChain, '0xadd1', '0x', channel], typeArguments: [coins[coinName].type], }); const messageTicket = await builder.moveCall({ - target: `${deployments.its.packageId}::interchain_token_service::send_interchain_transfer`, + target: `${deployments.interchain_token_service.packageId}::interchain_token_service::send_interchain_transfer`, arguments: [objectIds.its, interchainTransfer, CLOCK_PACKAGE_ID], typeArguments: [coins[coinName].type], }); @@ -257,17 +257,17 @@ describe('Squid', () => { const builder = new TxBuilder(client); const coinInfo = await builder.moveCall({ - target: `${deployments.its.packageId}::coin_info::from_metadata`, + target: `${deployments.interchain_token_service.packageId}::coin_info::from_metadata`, arguments: [coins[coin].coinMetadata], typeArguments: [coins[coin].type], }); const coinManagment = await builder.moveCall({ - target: `${deployments.its.packageId}::coin_management::new_locked`, + target: `${deployments.interchain_token_service.packageId}::coin_management::new_locked`, arguments: [], typeArguments: [coins[coin].type], }); await builder.moveCall({ - target: `${deployments.its.packageId}::interchain_token_service::register_coin`, + target: `${deployments.interchain_token_service.packageId}::interchain_token_service::register_coin`, arguments: [objectIds.its, coinInfo, coinManagment], typeArguments: [coins[coin].type], }); @@ -385,16 +385,16 @@ describe('Squid', () => { ...objectIds, squid: findObjectId(deployments.squid.publishTxn, 'squid::Squid'), squidV0: findObjectId(deployments.squid.publishTxn, 'squid_v0::Squid_v0'), - its: findObjectId(deployments.its.publishTxn, 'interchain_token_service::InterchainTokenService'), - itsV0: findObjectId(deployments.its.publishTxn, 'interchain_token_service_v0::InterchainTokenService_v0'), + its: findObjectId(deployments.interchain_token_service.publishTxn, 'interchain_token_service::InterchainTokenService'), + itsV0: findObjectId(deployments.interchain_token_service.publishTxn, 'interchain_token_service_v0::InterchainTokenService_v0'), relayerDiscovery: findObjectId( deployments.relayer_discovery.publishTxn, `${deployments.relayer_discovery.packageId}::discovery::RelayerDiscovery`, ), gasService: findObjectId(deployments.gas_service.publishTxn, `${deployments.gas_service.packageId}::gas_service::GasService`), creatorCap: findObjectId(deployments.axelar_gateway.publishTxn, 'OwnerCap'), - itsOwnerCap: findObjectId(deployments.its.publishTxn, `${deployments.its.packageId}::owner_cap::OwnerCap`), - gateway: findObjectId(deployments.its.publishTxn, `${deployments.axelar_gateway.packageId}::gateway::Gateway`), + itsOwnerCap: findObjectId(deployments.interchain_token_service.publishTxn, `${deployments.interchain_token_service.packageId}::owner_cap::OwnerCap`), + gateway: findObjectId(deployments.interchain_token_service.publishTxn, `${deployments.axelar_gateway.packageId}::gateway::Gateway`), }; // Find the object ids from the publish transactions objectIds = { diff --git a/test/testutils.js b/test/testutils.js index 2ecfde21..20e9f51b 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -375,12 +375,12 @@ async function setupTrustedAddresses(client, keypair, objectIds, deployments, tr const trustedAddressTxBuilder = new TxBuilder(client); const trustedAddressesObject = await trustedAddressTxBuilder.moveCall({ - target: `${deployments.its.packageId}::trusted_addresses::new`, + target: `${deployments.interchain_token_service.packageId}::trusted_addresses::new`, arguments: [trustedChains, trustedAddresses], }); await trustedAddressTxBuilder.moveCall({ - target: `${deployments.its.packageId}::interchain_token_service::set_trusted_addresses`, + target: `${deployments.interchain_token_service.packageId}::interchain_token_service::set_trusted_addresses`, arguments: [objectIds.its, objectIds.itsOwnerCap, trustedAddressesObject], }); From 9c14b8b3e7a5d5670efb56e3a6f11c5c404a6c8a Mon Sep 17 00:00:00 2001 From: Foivos Date: Thu, 19 Dec 2024 18:10:30 +0200 Subject: [PATCH 12/15] prettier --- test/its.js | 5 ++++- test/squid.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/its.js b/test/its.js index e99b78a2..3073ac33 100644 --- a/test/its.js +++ b/test/its.js @@ -127,7 +127,10 @@ describe('ITS', () => { ), gasService: findObjectId(deployments.gas_service.publishTxn, `${deployments.gas_service.packageId}::gas_service::GasService`), creatorCap: findObjectId(deployments.axelar_gateway.publishTxn, 'OwnerCap'), - itsOwnerCap: findObjectId(deployments.interchain_token_service.publishTxn, `${deployments.interchain_token_service.packageId}::owner_cap::OwnerCap`), + itsOwnerCap: findObjectId( + deployments.interchain_token_service.publishTxn, + `${deployments.interchain_token_service.packageId}::owner_cap::OwnerCap`, + ), }; // Mint some coins for tests const tokenTxBuilder = new TxBuilder(client); diff --git a/test/squid.js b/test/squid.js index 74042ca7..aad660be 100644 --- a/test/squid.js +++ b/test/squid.js @@ -393,8 +393,14 @@ describe('Squid', () => { ), gasService: findObjectId(deployments.gas_service.publishTxn, `${deployments.gas_service.packageId}::gas_service::GasService`), creatorCap: findObjectId(deployments.axelar_gateway.publishTxn, 'OwnerCap'), - itsOwnerCap: findObjectId(deployments.interchain_token_service.publishTxn, `${deployments.interchain_token_service.packageId}::owner_cap::OwnerCap`), - gateway: findObjectId(deployments.interchain_token_service.publishTxn, `${deployments.axelar_gateway.packageId}::gateway::Gateway`), + itsOwnerCap: findObjectId( + deployments.interchain_token_service.publishTxn, + `${deployments.interchain_token_service.packageId}::owner_cap::OwnerCap`, + ), + gateway: findObjectId( + deployments.interchain_token_service.publishTxn, + `${deployments.axelar_gateway.packageId}::gateway::Gateway`, + ), }; // Find the object ids from the publish transactions objectIds = { From 732c402ab35052132aaa12ee220609afae1e3835 Mon Sep 17 00:00:00 2001 From: Foivos Date: Fri, 20 Dec 2024 17:48:25 +0200 Subject: [PATCH 13/15] fix tests --- .../sources/interchain_token_service.move | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/move/interchain_token_service/sources/interchain_token_service.move b/move/interchain_token_service/sources/interchain_token_service.move index 26f954c0..efa73f95 100644 --- a/move/interchain_token_service/sources/interchain_token_service.move +++ b/move/interchain_token_service/sources/interchain_token_service.move @@ -7,6 +7,7 @@ use interchain_token_service::coin_management::CoinManagement; use interchain_token_service::interchain_transfer_ticket::{Self, InterchainTransferTicket}; use interchain_token_service::interchain_token_service_v0::{Self, InterchainTokenService_v0}; use interchain_token_service::owner_cap::{Self, OwnerCap}; +use interchain_token_service::operator_cap::{Self, OperatorCap}; use interchain_token_service::token_id::TokenId; use interchain_token_service::trusted_addresses::TrustedAddresses; use relayer_discovery::discovery::RelayerDiscovery; @@ -948,15 +949,15 @@ fun test_set_flow_limit() { let decimals = 9; let limit = 1234; - let (treasury_cap, coin_metadata) = its::coin::create_treasury_and_metadata( + let (treasury_cap, coin_metadata) = interchain_token_service::coin::create_treasury_and_metadata( symbol, decimals, ctx, ); - let coin_info = its::coin_info::from_metadata( + let coin_info = interchain_token_service::coin_info::from_metadata( coin_metadata, ); - let coin_management = its::coin_management::new_with_cap(treasury_cap); + let coin_management = interchain_token_service::coin_management::new_with_cap(treasury_cap); let operator_cap = operator_cap::create(ctx); From 52342a606fb71586842ddb21bd8cd5c1d1e8fba2 Mon Sep 17 00:00:00 2001 From: Foivos Date: Fri, 20 Dec 2024 19:06:20 +0200 Subject: [PATCH 14/15] update interface --- ..._interchain_token_service_operator_cap.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/testdata/interface_interchain_token_service_operator_cap.json diff --git a/test/testdata/interface_interchain_token_service_operator_cap.json b/test/testdata/interface_interchain_token_service_operator_cap.json new file mode 100644 index 00000000..43a4728b --- /dev/null +++ b/test/testdata/interface_interchain_token_service_operator_cap.json @@ -0,0 +1,18 @@ +{ + "structs": { + "OperatorCap": { + "name": "OperatorCap", + "abilities": [ + "store", + "key" + ], + "fields": [ + { + "name": "id", + "type": "UID" + } + ] + } + }, + "publicFunctions": {} +} From 0fa66dd944ff7f35404f573e1569254d18ea75c4 Mon Sep 17 00:00:00 2001 From: Foivos Date: Fri, 20 Dec 2024 19:45:47 +0200 Subject: [PATCH 15/15] cs --- .changeset/red-pumpkins-explain.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/red-pumpkins-explain.md diff --git a/.changeset/red-pumpkins-explain.md b/.changeset/red-pumpkins-explain.md new file mode 100644 index 00000000..b3fe493e --- /dev/null +++ b/.changeset/red-pumpkins-explain.md @@ -0,0 +1,5 @@ +--- +'@axelar-network/axelar-cgp-sui': minor +--- + +rename its to interchain_token_service everywhere