Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(its)!: rename its to interchain_token_service #223

Merged
merged 17 commits into from
Dec 20, 2024
16 changes: 8 additions & 8 deletions move/example/sources/its/its.move
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use gas_service::gas_service::GasService;
use its::coin_info;
use its::coin_management;
use its::discovery as its_discovery;
milapsheth marked this conversation as resolved.
Show resolved Hide resolved
use its::its::{Self, ITS};
use its::interchain_token_service::{Self, InterchainTokenService};
use its::token_id::TokenId;
use relayer_discovery::discovery::RelayerDiscovery;
use relayer_discovery::transaction::{Self, Transaction};
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
48 changes: 24 additions & 24 deletions move/its/sources/discovery.move
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module its::discovery;

use abi::abi::{Self, AbiReader};
use its::its::ITS;
use its::interchain_token_service::InterchainTokenService;
milapsheth marked this conversation as resolved.
Show resolved Hide resolved
use its::token_id::{Self, TokenId};
use relayer_discovery::discovery::RelayerDiscovery;
use relayer_discovery::transaction::{Self, Transaction, package_id};
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 = its::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 = its::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 @@ -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 = its::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 @@ -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);
Expand Down Expand Up @@ -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 = its::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 @@ -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 = its::interchain_token_service::create_for_testing(ctx);

let mut writer = abi::new_writer(1);
writer.write_u256(5);
Expand Down
Loading
Loading