Skip to content

Commit

Permalink
feat(its)!: rename its to interchain_token_service (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos authored Dec 20, 2024
1 parent e070df9 commit 2d6d8e6
Show file tree
Hide file tree
Showing 55 changed files with 351 additions and 318 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-pumpkins-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@axelar-network/axelar-cgp-sui': minor
---

rename its to interchain_token_service everywhere
2 changes: 1 addition & 1 deletion move/example/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
24 changes: 12 additions & 12 deletions move/example/sources/its/its.move
Original file line number Diff line number Diff line change
Expand Up @@ -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::its::{Self, ITS};
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};
Expand Down Expand Up @@ -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[
Expand Down Expand Up @@ -95,7 +95,7 @@ public fun register_transaction(

public fun get_final_transaction(
singleton: &Singleton,
its: &ITS,
its: &InterchainTokenService,
payload: vector<u8>,
clock: &Clock,
): Transaction {
Expand Down Expand Up @@ -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<TOKEN>(
its: &mut ITS,
its: &mut InterchainTokenService,
coin_metadata: &CoinMetadata<TOKEN>,
): TokenId {
let coin_info = coin_info::from_info<TOKEN>(
Expand All @@ -158,7 +158,7 @@ public fun register_coin<TOKEN>(
}

public fun deploy_remote_interchain_token<TOKEN>(
its: &mut ITS,
its: &mut InterchainTokenService,
gateway: &mut Gateway,
gas_service: &mut GasService,
destination_chain: String,
Expand All @@ -185,7 +185,7 @@ public fun deploy_remote_interchain_token<TOKEN>(
/// This should trigger an interchain trasnfer.
public fun send_interchain_transfer_call<TOKEN>(
singleton: &Singleton,
its: &mut ITS,
its: &mut InterchainTokenService,
gateway: &mut Gateway,
gas_service: &mut GasService,
token_id: TokenId,
Expand All @@ -198,7 +198,7 @@ public fun send_interchain_transfer_call<TOKEN>(
gas_params: vector<u8>,
clock: &Clock,
) {
let interchain_transfer_ticket = its::prepare_interchain_transfer<TOKEN>(
let interchain_transfer_ticket = interchain_token_service::prepare_interchain_transfer<TOKEN>(
token_id,
coin,
destination_chain,
Expand Down Expand Up @@ -228,7 +228,7 @@ public fun send_interchain_transfer_call<TOKEN>(
public fun receive_interchain_transfer<TOKEN>(
approved_message: ApprovedMessage,
singleton: &Singleton,
its: &mut ITS,
its: &mut InterchainTokenService,
clock: &Clock,
ctx: &mut TxContext,
) {
Expand Down
4 changes: 2 additions & 2 deletions move/example/sources/its/token.move
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[move]
version = 3
manifest_digest = "2429DB0FDE0EAD1C15A96EA75C44454B3279EB93A32FF56518FFFDAFEF50695A"
manifest_digest = "53A52F59870BC3BA264A1763E718516ED5424853E35D0ED4E77D6C252167654A"
deps_digest = "52B406A7A21811BEF51751CF88DA0E76DAEFFEAC888D4F4060B1A72BBE7D8D35"
dependencies = [
{ id = "Abi", name = "Abi" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ITS"
name = "InterchainTokenService"
version = "0.1.0"
edition = "2024"

Expand All @@ -12,4 +12,4 @@ VersionControl = { local = "../version_control" }
RelayerDiscovery = { local = "../relayer_discovery" }

[addresses]
its = "0xa5"
interchain_token_service = "0xa5"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module its::discovery;
module interchain_token_service::discovery;

use abi::abi::{Self, AbiReader};
use its::its::ITS;
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;
Expand Down Expand Up @@ -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];
Expand All @@ -53,7 +53,7 @@ public fun register_transaction(
let arguments = vector[arg, vector[3]];

let function = transaction::new_function(
package_id<ITS>(),
package_id<InterchainTokenService>(),
ascii::string(b"discovery"),
ascii::string(b"call_info"),
);
Expand All @@ -73,7 +73,7 @@ public fun register_transaction(
);
}

public fun call_info(its: &ITS, mut payload: vector<u8>): Transaction {
public fun call_info(its: &InterchainTokenService, mut payload: vector<u8>): Transaction {
let mut reader = abi::new_reader(payload);
let mut message_type = reader.read_u256();

Expand All @@ -95,7 +95,7 @@ public fun call_info(its: &ITS, mut payload: vector<u8>): 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());
Expand All @@ -116,8 +116,8 @@ fun interchain_transfer_tx(its: &ITS, reader: &mut AbiReader): Transaction {
vector[
transaction::new_move_call(
transaction::new_function(
package_id<ITS>(),
ascii::string(b"its"),
package_id<InterchainTokenService>(),
ascii::string(b"interchain_token_service"),
ascii::string(b"receive_interchain_transfer"),
),
arguments,
Expand Down Expand Up @@ -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());

Expand All @@ -169,8 +169,8 @@ fun deploy_interchain_token_tx(its: &ITS, reader: &mut AbiReader): Transaction {

let move_call = transaction::new_move_call(
transaction::new_function(
package_id<ITS>(),
ascii::string(b"its"),
package_id<InterchainTokenService>(),
ascii::string(b"interchain_token_service"),
ascii::string(b"receive_deploy_interchain_token"),
),
arguments,
Expand All @@ -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<ITS>(),
package_id<InterchainTokenService>(),
ascii::string(b"discovery"),
ascii::string(b"call_info"),
);
Expand All @@ -212,7 +212,7 @@ fun initial_tx(its: &ITS): 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 = interchain_token_service::interchain_token_service::create_for_testing(ctx);
let mut discovery = relayer_discovery::discovery::new(ctx);

register_transaction(&mut its, &mut discovery);
Expand All @@ -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 = interchain_token_service::interchain_token_service::create_for_testing(ctx);
let mut discovery = relayer_discovery::discovery::new(ctx);

register_transaction(&mut its, &mut discovery);
Expand All @@ -252,7 +252,7 @@ fun test_discovery_interchain_transfer() {

let type_arg = std::type_name::get<RelayerDiscovery>();
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);
Expand All @@ -266,9 +266,9 @@ fun test_discovery_interchain_transfer() {
let call_info = tx_block.move_calls().pop_back();

assert!(
call_info.function().package_id_from_function() == package_id<ITS>(),
call_info.function().package_id_from_function() == package_id<InterchainTokenService>(),
);
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"),
);
Expand All @@ -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 = interchain_token_service::interchain_token_service::create_for_testing(ctx);
let mut discovery = relayer_discovery::discovery::new(ctx);

register_transaction(&mut its, &mut discovery);
Expand Down Expand Up @@ -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<RelayerDiscovery>(),
);

Expand All @@ -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 = interchain_token_service::interchain_token_service::create_for_testing(ctx);
let mut discovery = relayer_discovery::discovery::new(ctx);

register_transaction(&mut its, &mut discovery);
Expand All @@ -355,7 +355,7 @@ fun test_discovery_deploy_token() {

let type_arg = std::type_name::get<RelayerDiscovery>();
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),
),
Expand All @@ -373,9 +373,9 @@ 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<ITS>(),
call_info.function().package_id_from_function() == package_id<InterchainTokenService>(),
);
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"),
);
Expand Down Expand Up @@ -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 = interchain_token_service::interchain_token_service::create_for_testing(ctx);
let mut discovery = relayer_discovery::discovery::new(ctx);

register_transaction(&mut its, &mut discovery);
Expand Down Expand Up @@ -472,7 +472,7 @@ fun test_discovery_hub_message() {

let type_arg = std::type_name::get<RelayerDiscovery>();
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);
Expand All @@ -483,9 +483,9 @@ fun test_discovery_hub_message() {
let call_info = tx_block.move_calls().pop_back();

assert!(
call_info.function().package_id_from_function() == package_id<ITS>(),
call_info.function().package_id_from_function() == package_id<InterchainTokenService>(),
);
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"),
);
Expand All @@ -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 = interchain_token_service::interchain_token_service::create_for_testing(ctx);

let mut writer = abi::new_writer(1);
writer.write_u256(5);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -170,9 +170,9 @@ public(package) fun flow_limit_set<T>(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;

Expand Down
Loading

0 comments on commit 2d6d8e6

Please sign in to comment.