diff --git a/packages/message_transmitter/sources/attester.move b/packages/message_transmitter/sources/attester.move
index 7b89618..e670d9a 100644
--- a/packages/message_transmitter/sources/attester.move
+++ b/packages/message_transmitter/sources/attester.move
@@ -41,7 +41,7 @@ module message_transmitter::attester {
const ENOT_OWNER: u64 = 1;
const EATTESTER_ALREADY_ENABLED: u64 = 2;
const ETOO_FEW_ENABLED_ATTESTERS: u64 = 3;
- const ELOW_SIGNATURE_THRESHOLD: u64 = 4;
+ const ENUM_ATTESTERS_SHOULD_BE_GREATER_THAN_SIGNATURE_THRESHOLD: u64 = 4;
const ENOT_ATTESTER_MANAGER: u64 = 5;
const EINVALID_ATTESTER_MANAGER: u64 = 6;
const EINVALID_SIGNATURE_THRESHOLD: u64 = 7;
@@ -146,7 +146,7 @@ module message_transmitter::attester {
assert!(vector::length
(&enabled_attesters) > 1, error::invalid_state(ETOO_FEW_ENABLED_ATTESTERS));
assert!(
vector::length(&enabled_attesters) > state::get_signature_threshold(),
- error::invalid_state(ELOW_SIGNATURE_THRESHOLD)
+ error::invalid_state(ENUM_ATTESTERS_SHOULD_BE_GREATER_THAN_SIGNATURE_THRESHOLD)
);
state::remove_attester(attester);
event::emit(AttesterDisabled { attester });
@@ -186,21 +186,13 @@ module message_transmitter::attester {
event::emit(SignatureThresholdUpdated { old_signature_threshold, new_signature_threshold });
}
- // -----------------------------
- // ----- Friend Functions ------
- // -----------------------------
-
- public(friend) fun init_attester(caller: &signer, attester: address) {
- enable_attester(caller, attester);
- }
-
/// Validates the attestation for the given message
/// Aborts if:
/// - length of attestation != ATTESTATION_SIGNATURE_LENGTH * signature_threshold
/// - there are duplicate signers
/// - signer is not one of the enabled attesters
/// - addresses recovered are not in increasing order
- public(friend) fun verify_attestation_signature(message: &vector, attestation: &vector) {
+ public fun verify_attestation_signature(message: &vector, attestation: &vector) {
// Validate Attestation Size
let signature_threshold = state::get_signature_threshold();
assert!(
@@ -240,6 +232,14 @@ module message_transmitter::attester {
}
}
+ // -----------------------------
+ // ----- Friend Functions ------
+ // -----------------------------
+
+ public(friend) fun init_attester(caller: &signer, attester: address) {
+ enable_attester(caller, attester);
+ }
+
// -----------------------------
// ----- Private Functions -----
// -----------------------------
@@ -253,7 +253,7 @@ module message_transmitter::attester {
// Retrieve and validate signature id
let recovery_id = *vector::borrow(signature, SIGNATURE_LENGTH - 1) - 27;
assert!(
- vector::contains(&vector[0, 1, 2, 3], &recovery_id),
+ vector::contains(&vector[0, 1], &recovery_id),
error::invalid_argument(EINVALID_SIGNATURE)
);
@@ -286,7 +286,7 @@ module message_transmitter::attester {
let address_bytes = keccak256(*public_key);
// EVM address is the made of last 20 bytes of the hash
- let address = vector::slice(
+ let address_without_prefix = vector::slice(
&address_bytes,
vector::length(&address_bytes) - 20,
vector::length(&address_bytes)
@@ -294,7 +294,7 @@ module message_transmitter::attester {
// Add 0x0 prefix to make the address 32 bytes
let address_with_prefix = x"000000000000000000000000";
- vector::append(&mut address_with_prefix, address);
+ vector::append(&mut address_with_prefix, address_without_prefix);
from_bcs::to_address(address_with_prefix)
}
diff --git a/packages/message_transmitter/sources/message_transmitter.move b/packages/message_transmitter/sources/message_transmitter.move
index 9a84e51..b2d6379 100644
--- a/packages/message_transmitter/sources/message_transmitter.move
+++ b/packages/message_transmitter/sources/message_transmitter.move
@@ -362,7 +362,7 @@ module message_transmitter::message_transmitter {
// -----------------------------
/// Generate signer from the `ExtendRef`
- public(friend) fun get_signer(): signer acquires ObjectController {
+ fun get_signer(): signer acquires ObjectController {
let object_address = state::get_object_address();
let object_controller = borrow_global(object_address);
let object_signer = object::generate_signer_for_extending(
@@ -495,6 +495,11 @@ module message_transmitter::message_transmitter {
(message, attestation)
}
+ #[test_only]
+ public fun get_message_from_event(message_sent_event: &MessageSent): vector {
+ message_sent_event.message
+ }
+
// Message Transmitter Initialization Tests
#[test(owner = @deployer)]
diff --git a/packages/message_transmitter/sources/state.move b/packages/message_transmitter/sources/state.move
index 16b8fc5..34a9ed5 100644
--- a/packages/message_transmitter/sources/state.move
+++ b/packages/message_transmitter/sources/state.move
@@ -54,13 +54,13 @@ module message_transmitter::state {
public(friend) fun init_state(
owner: &signer,
- admin: &signer,
+ object_signer: &signer,
local_domain: u32,
version: u32,
max_message_body_size: u64
) {
move_to(
- admin,
+ object_signer,
State {
local_domain,
version,
@@ -132,10 +132,6 @@ module message_transmitter::state {
// ---------- Setters ----------
// -----------------------------
- public(friend) fun set_version(version: u32) acquires State {
- borrow_global_mut(get_object_address()).version = version
- }
-
public(friend) fun set_max_message_body_size(max_message_body_size: u64) acquires State {
borrow_global_mut(get_object_address()).max_message_body_size = max_message_body_size
}
@@ -184,7 +180,7 @@ module message_transmitter::state {
use aptos_extensions::pausable::{Self, PauseState};
#[test_only]
- public(friend) fun init_test_state(caller: &signer) {
+ public fun init_test_state(caller: &signer) {
let resource_account_address = account::create_resource_address(&@deployer, b"test_seed_mt");
let resource_account_signer = create_signer_for_test(resource_account_address);
let constructor_ref = object::create_named_object(&resource_account_signer, SEED_NAME);
@@ -204,6 +200,11 @@ module message_transmitter::state {
ownable::set_owner_for_testing(get_object_address(), owner_address);
}
+ #[test_only]
+ public fun set_version(version: u32) acquires State {
+ borrow_global_mut(get_object_address()).version = version
+ }
+
// -----------------------------
// ---------- Getters ----------
// -----------------------------
@@ -281,14 +282,6 @@ module message_transmitter::state {
// ---------- Setters ----------
// -----------------------------
- #[test(owner = @message_transmitter)]
- fun test_set_version(owner: &signer) acquires State {
- init_test_state(owner);
- let version = 10;
- set_version(version);
- assert!(get_version() == version, 0);
- }
-
#[test(owner = @message_transmitter)]
fun test_set_max_message_body_size(owner: &signer) acquires State {
init_test_state(owner);
diff --git a/packages/token_messenger_minter/sources/state.move b/packages/token_messenger_minter/sources/state.move
index 85bd772..4013633 100644
--- a/packages/token_messenger_minter/sources/state.move
+++ b/packages/token_messenger_minter/sources/state.move
@@ -130,6 +130,10 @@ module token_messenger_minter::state {
smart_table::length(&borrow_global(get_object_address()).remote_token_messengers)
}
+ public(friend) fun get_num_linked_tokens(): u64 acquires State {
+ smart_table::length(&borrow_global(get_object_address()).remote_tokens_to_local_tokens)
+ }
+
public(friend) fun get_object_address(): address {
object::create_object_address(&@token_messenger_minter, SEED_NAME)
}
@@ -138,10 +142,6 @@ module token_messenger_minter::state {
// ---------- Setters ----------
// -----------------------------
- public(friend) fun set_message_body_version(message_body_version: u32) acquires State {
- borrow_global_mut(get_object_address()).message_body_version = message_body_version;
- }
-
public(friend) fun add_remote_token_messenger(domain: u32, token_messenger: address) acquires State {
smart_table::add(
&mut borrow_global_mut(get_object_address()).remote_token_messengers,
@@ -210,7 +210,7 @@ module token_messenger_minter::state {
// -----------------------------
#[test_only]
- public(friend) fun init_test_state(caller: &signer) {
+ public fun init_test_state(caller: &signer) {
let resource_account_address = account::create_resource_address(&@deployer, b"test_seed_tmm");
let resource_account_signer = create_signer_for_test(resource_account_address);
let constructor_ref = object::create_named_object(&resource_account_signer, SEED_NAME);
@@ -221,10 +221,15 @@ module token_messenger_minter::state {
}
#[test_only]
- public(friend) fun set_paused(pauser: &signer) {
+ public fun set_paused(pauser: &signer) {
pausable::test_pause(pauser, object::address_to_object(get_object_address()));
}
+ #[test_only]
+ public fun set_message_body_version(message_body_version: u32) acquires State {
+ borrow_global_mut(get_object_address()).message_body_version = message_body_version;
+ }
+
// -----------------------------
// ---------- Getters ----------
// -----------------------------
@@ -342,18 +347,20 @@ module token_messenger_minter::state {
assert!(hash == @0x8ae28a8d79ea231bafe63fb643c45dce060b33a1c2e122d161c4d8b75997436, 0);
}
+ #[test(owner = @token_messenger_minter)]
+ fun test_get_num_linked_tokens(owner: &signer) acquires State {
+ init_test_state(owner);
+ smart_table::add(
+ &mut borrow_global_mut(get_object_address()).remote_tokens_to_local_tokens, @0x100, @0x101
+ );
+ assert!(get_num_linked_tokens() == 1, 0)
+ }
+
// -----------------------------
// ---------- Setters ----------
// -----------------------------
- #[test(owner = @token_messenger_minter)]
- fun test_set_message_body_version(owner: &signer) acquires State {
- init_test_state(owner);
- set_message_body_version(5);
- assert!(get_message_body_version() == 5, 0);
- }
-
#[test(owner = @token_messenger_minter)]
fun test_add_remote_token_messenger(owner: &signer) acquires State {
init_test_state(owner);
diff --git a/packages/token_messenger_minter/sources/token_messenger/token_messenger.move b/packages/token_messenger_minter/sources/token_messenger/token_messenger.move
index a024601..7e9b8b6 100644
--- a/packages/token_messenger_minter/sources/token_messenger/token_messenger.move
+++ b/packages/token_messenger_minter/sources/token_messenger/token_messenger.move
@@ -42,11 +42,9 @@ module token_messenger_minter::token_messenger {
const ENO_TOKEN_MESSENGER_SET_FOR_DOMAIN: u64 = 6;
const ENOT_TOKEN_MESSENGER: u64 = 7;
const EINVALID_MESSAGE_BODY_VERSION: u64 = 8;
- const ENOT_LOCAL_MESSAGE_TRANSMITTER: u64 = 9;
- const ERECIPIENT_NOT_TOKEN_MESSENGER: u64 = 10;
- const ENOT_OWNER: u64 = 11;
- const EUNSUPPORTED_DESTINATION_DOAMIN: u64 = 12;
- const EINVALID_TOKEN_MESSENGER_ADDRESS: u64 = 13;
+ const ERECIPIENT_NOT_TOKEN_MESSENGER: u64 = 9;
+ const EUNSUPPORTED_DESTINATION_DOAMIN: u64 = 10;
+ const EINVALID_TOKEN_MESSENGER_ADDRESS: u64 = 11;
// Constants
const MAX_U64: u256 = 18_446_744_073_709_551_615;
@@ -105,6 +103,12 @@ module token_messenger_minter::token_messenger {
state::get_num_remote_token_messengers()
}
+ #[view]
+ public fun max_burn_amount_per_message(token: address): u64 {
+ let (_, max_burn_amount) = state::get_max_burn_limit_per_message_for_token(token);
+ max_burn_amount
+ }
+
// -----------------------------
// ----- Public Functions ------
// -----------------------------
@@ -189,22 +193,20 @@ module token_messenger_minter::token_messenger {
// Create new message body based on updated mint recipient
let mint_recipient = option::get_with_default(new_mint_recipient, old_mint_recipient);
- if (mint_recipient != old_mint_recipient) {
- assert!(mint_recipient != @0x0, error::invalid_argument(EINVALID_MINT_RECIPIENT_ADDRESS));
- let new_burn_message = burn_message::serialize(
- message_body_version(),
- burn_token,
- mint_recipient,
- amount,
- original_message_sender
- );
- option::fill(&mut message_body, new_burn_message);
- };
+ assert!(mint_recipient != @0x0, error::invalid_argument(EINVALID_MINT_RECIPIENT_ADDRESS));
+ let new_burn_message = burn_message::serialize(
+ message_body_version(),
+ burn_token,
+ mint_recipient,
+ amount,
+ original_message_sender
+ );
+ option::fill(&mut message_body, new_burn_message);
// Use Token Messenger Minter's signer for calling replace_message
- let signer = token_messenger_minter::get_signer();
+ let token_messenger_minter_signer = token_messenger_minter::get_signer();
message_transmitter::replace_message(
- &signer,
+ &token_messenger_minter_signer,
original_message,
original_attestation,
&message_body,
@@ -366,17 +368,17 @@ module token_messenger_minter::token_messenger {
destination_caller: address,
burn_message: &vector,
): u64 {
- let signer = token_messenger_minter::get_signer();
+ let token_messenger_minter_signer = token_messenger_minter::get_signer();
if (destination_caller == @0x0) {
message_transmitter::send_message(
- &signer,
+ &token_messenger_minter_signer,
destination_domain,
destination_token_messenger,
burn_message
)
} else {
message_transmitter::send_message_with_caller(
- &signer,
+ &token_messenger_minter_signer,
destination_domain,
destination_token_messenger,
destination_caller,
@@ -403,12 +405,16 @@ module token_messenger_minter::token_messenger {
#[test_only]
use std::hash;
#[test_only]
+ use std::vector;
+ #[test_only]
use aptos_std::from_bcs;
#[test_only]
use aptos_framework::account::create_signer_for_test;
#[test_only]
use aptos_extensions::pausable;
#[test_only]
+ use message_transmitter::message_transmitter::MessageSent;
+ #[test_only]
use message_transmitter::state as mt_state;
#[test_only]
use stablecoin::stablecoin::stablecoin_address;
@@ -523,7 +529,7 @@ module token_messenger_minter::token_messenger {
}
#[test(owner = @deployer)]
- #[expected_failure(abort_code = 0x1000c, location = Self)]
+ #[expected_failure(abort_code = 0x1000a, location = Self)]
fun test_deposit_for_burn_invalid_destination_domain(owner: &signer) {
init_test_token_messenger(owner);
let amount = 51;
@@ -608,7 +614,7 @@ module token_messenger_minter::token_messenger {
}
#[test(owner = @deployer)]
- #[expected_failure(abort_code = 0x1000c, location = Self)]
+ #[expected_failure(abort_code = 0x1000a, location = Self)]
fun test_deposit_for_burn_with_caller_invalid_destination_domain(owner: &signer) {
init_test_token_messenger(owner);
let amount = 12;
@@ -708,6 +714,10 @@ module token_messenger_minter::token_messenger {
destination_token_messenger: REMOTE_TOKEN_MESSENGER,
destination_caller: new_destination_caller
}), 0);
+ let message_sent_event = vector::borrow(&event::emitted_events(), 0);
+ let message = message_transmitter::get_message_from_event(message_sent_event);
+ let new_burn_message = message::get_message_body(&message);
+ assert!(burn_message::get_version(&new_burn_message) == message_body_version(), 0);
assert!(get_signer_balance(owner) == original_account_balance, 0);
}
@@ -736,6 +746,77 @@ module token_messenger_minter::token_messenger {
destination_token_messenger: REMOTE_TOKEN_MESSENGER,
destination_caller: message::get_destination_caller(&original_message)
}), 0);
+ let message_sent_event = vector::borrow(&event::emitted_events(), 0);
+ let message = message_transmitter::get_message_from_event(message_sent_event);
+ let new_burn_message = message::get_message_body(&message);
+ assert!(burn_message::get_version(&new_burn_message) == message_body_version(), 0);
+ assert!(get_signer_balance(owner) == original_account_balance, 0);
+ }
+
+ #[test(owner = @deployer)]
+ fun test_replace_deposit_for_burn_new_destination_caller_version_bump(owner: &signer) {
+ init_test_token_messenger(owner);
+ let original_account_balance = get_signer_balance(owner);
+ let new_destination_caller = @0xfab;
+ let (original_message, original_attestation) = get_valid_deposit_for_burn_message_and_attestation();
+ state::set_message_body_version(2);
+ replace_deposit_for_burn(
+ owner,
+ &original_message,
+ &original_attestation,
+ &option::some(new_destination_caller),
+ &option::none()
+ );
+
+ let burn_msg = message::get_message_body(&original_message);
+ assert!(event::was_event_emitted(&DepositForBurn {
+ nonce: message::get_nonce(&original_message),
+ burn_token: burn_message::get_burn_token(&burn_msg),
+ amount: (burn_message::get_amount(&burn_msg) as u64),
+ depositor: signer::address_of(owner),
+ mint_recipient: burn_message::get_mint_recipient(&burn_msg),
+ destination_domain: REMOTE_DOMAIN,
+ destination_token_messenger: REMOTE_TOKEN_MESSENGER,
+ destination_caller: new_destination_caller
+ }), 0);
+
+ let message_sent_event = vector::borrow(&event::emitted_events(), 0);
+ let message = message_transmitter::get_message_from_event(message_sent_event);
+ let new_burn_message = message::get_message_body(&message);
+ assert!(burn_message::get_version(&new_burn_message) == message_body_version(), 0);
+ assert!(get_signer_balance(owner) == original_account_balance, 0);
+ }
+
+ #[test(owner = @deployer)]
+ fun test_replace_deposit_for_burn_new_mint_recipient_version_bump(owner: &signer) {
+ init_test_token_messenger(owner);
+ let new_mint_recipient = @0xfab;
+ let original_account_balance = get_signer_balance(owner);
+ let (original_message, original_attestation) = get_valid_deposit_for_burn_message_and_attestation();
+ state::set_message_body_version(2);
+ replace_deposit_for_burn(
+ owner,
+ &original_message,
+ &original_attestation,
+ &option::none(),
+ &option::some(new_mint_recipient),
+ );
+
+ let burn_msg = message::get_message_body(&original_message);
+ assert!(event::was_event_emitted(&DepositForBurn {
+ nonce: message::get_nonce(&original_message),
+ burn_token: burn_message::get_burn_token(&burn_msg),
+ amount: (burn_message::get_amount(&burn_msg) as u64),
+ depositor: signer::address_of(owner),
+ mint_recipient: new_mint_recipient,
+ destination_domain: REMOTE_DOMAIN,
+ destination_token_messenger: REMOTE_TOKEN_MESSENGER,
+ destination_caller: message::get_destination_caller(&original_message)
+ }), 0);
+ let message_sent_event = vector::borrow(&event::emitted_events(), 0);
+ let message = message_transmitter::get_message_from_event(message_sent_event);
+ let new_burn_message = message::get_message_body(&message);
+ assert!(burn_message::get_version(&new_burn_message) == message_body_version(), 0);
assert!(get_signer_balance(owner) == original_account_balance, 0);
}
@@ -852,7 +933,7 @@ module token_messenger_minter::token_messenger {
}
#[test(owner = @deployer)]
- #[expected_failure(abort_code = 0x1000d, location = Self)]
+ #[expected_failure(abort_code = 0x1000b, location = Self)]
fun test_add_remote_token_messenger_zero_address(owner: &signer) {
init_test_token_messenger(owner);
add_remote_token_messenger(owner, 7, @0x0);
@@ -952,7 +1033,7 @@ module token_messenger_minter::token_messenger {
owner = @deployer,
destination_caller = @0x8a4edb71919e22728ffe9a925df33202328aca8d6e13be2c5f4e02b4370c8f71
)]
- #[expected_failure(abort_code = 0x1000a, location = Self)]
+ #[expected_failure(abort_code = 0x10009, location = Self)]
fun test_handle_receive_message_invalid_message_recipient(owner: &signer, destination_caller: &signer) {
init_test_token_messenger(owner);
let burn_message = burn_message::serialize(
@@ -1036,4 +1117,11 @@ module token_messenger_minter::token_messenger {
init_test_token_messenger(owner);
assert!(state::get_num_remote_token_messengers() == num_remote_token_messengers(), 0);
}
+
+ #[test(owner = @deployer)]
+ fun test_view_max_burn_amount_per_message(owner: &signer) {
+ init_test_token_messenger(owner);
+ let (_, max_burn_amount) = state::get_max_burn_limit_per_message_for_token(@stablecoin);
+ assert!(max_burn_amount_per_message(@stablecoin) == max_burn_amount, 0);
+ }
}
diff --git a/packages/token_messenger_minter/sources/token_minter/token_controller.move b/packages/token_messenger_minter/sources/token_minter/token_controller.move
index fecd9a7..e61af54 100644
--- a/packages/token_messenger_minter/sources/token_minter/token_controller.move
+++ b/packages/token_messenger_minter/sources/token_minter/token_controller.move
@@ -81,13 +81,18 @@ module token_messenger_minter::token_controller {
get_local_token(remote_domain, remote_token)
}
+ #[view]
+ public fun get_num_linked_tokens(): u64 {
+ state::get_num_linked_tokens()
+ }
+
// -----------------------------
// ----- Public Functions ------
// -----------------------------
/// Sets the token controller address. Emits `SetTokenController` event
/// Aborts if:
- /// - the caller is not the pauser
+ /// - the caller is not the owner
public(friend) entry fun set_token_controller(caller: &signer, new_token_controller: address) {
ownable::assert_is_owner(caller, state::get_object_address());
state::set_token_controller(new_token_controller);
@@ -97,7 +102,7 @@ module token_messenger_minter::token_controller {
/// Sets the maximum amount allowed to be burned per message/tx. Emits `SetBurnLimitPerMessage` event
/// Aborts if:
/// - the caller is not the token controller
- public(friend) entry fun set_max_burn_amount_per_message(caller: &signer, token: address, burn_limit_per_message: u64) {
+ entry fun set_max_burn_amount_per_message(caller: &signer, token: address, burn_limit_per_message: u64) {
assert_is_token_controller(caller);
state::set_max_burn_limit_per_message_for_token(token, burn_limit_per_message);
event::emit(SetBurnLimitPerMessage { token, burn_limit_per_message })
@@ -108,7 +113,7 @@ module token_messenger_minter::token_controller {
/// Aborts if:
/// - the caller is not the token controller
/// - remote token is already linked to a local token
- public(friend) entry fun link_token_pair(caller: &signer, local_token: address, remote_domain: u32, remote_token: address) {
+ entry fun link_token_pair(caller: &signer, local_token: address, remote_domain: u32, remote_token: address) {
assert_is_token_controller(caller);
assert!(
!state::local_token_exists(remote_domain, remote_token),
@@ -122,7 +127,7 @@ module token_messenger_minter::token_controller {
/// Aborts if:
/// - the caller is not the token controller
/// - no link exists for the given remote token and domain
- public(friend) entry fun unlink_token_pair(caller: &signer, remote_domain: u32, remote_token: address) {
+ entry fun unlink_token_pair(caller: &signer, remote_domain: u32, remote_token: address) {
assert_is_token_controller(caller);
assert!(
state::local_token_exists(remote_domain, remote_token),
@@ -137,8 +142,8 @@ module token_messenger_minter::token_controller {
// -----------------------------
public(friend) fun assert_amount_within_burn_limit(token: address, amount: u64) {
- let (exists, limit) = state::get_max_burn_limit_per_message_for_token(token);
- assert!(exists, error::invalid_argument(EBURN_TOKEN_NOT_SUPPORTED));
+ let (token_exists, limit) = state::get_max_burn_limit_per_message_for_token(token);
+ assert!(token_exists, error::invalid_argument(EBURN_TOKEN_NOT_SUPPORTED));
assert!(amount <= limit, error::out_of_range(EAMOUNT_EXCEEDS_BURN_LIMIT))
}
@@ -168,11 +173,26 @@ module token_messenger_minter::token_controller {
#[test_only] const TOKEN_CONTROLLER: address = @0x8e72;
#[test_only]
- public(friend) fun init_test_token_controller(owner: &signer) {
+ public fun init_test_token_controller(owner: &signer) {
state::init_test_state(owner);
set_token_controller(owner, TOKEN_CONTROLLER);
}
+ #[test_only]
+ public fun test_link_token_pair(caller: &signer, local_token: address, remote_domain: u32, remote_token: address) {
+ link_token_pair(caller, local_token, remote_domain, remote_token);
+ }
+
+ #[test_only]
+ public fun test_unlink_token_pair(caller: &signer, remote_domain: u32, remote_token: address) {
+ unlink_token_pair(caller, remote_domain, remote_token);
+ }
+
+ #[test_only]
+ public fun test_set_max_burn_amount_per_message(caller: &signer, token: address, burn_limit_per_message: u64) {
+ set_max_burn_amount_per_message(caller, token, burn_limit_per_message)
+ }
+
// Test Set Token Controller
#[test(owner = @deployer)]
@@ -340,11 +360,13 @@ module token_messenger_minter::token_controller {
fun test_view_functions(owner: &signer) {
init_test_token_controller(owner);
assert!(token_controller() == state::get_token_controller(), 0);
+ assert!(get_num_linked_tokens() == 0, 0);
let remote_token = @0xfab;
let remote_domain = 5;
let local_token = @0xfaa;
state::add_local_token_for_remote_token(remote_domain, remote_token, local_token);
assert!(get_linked_token(remote_domain, remote_token) == local_token, 1);
+ assert!(get_num_linked_tokens() == 1, 0);
}
}
diff --git a/packages/token_messenger_minter/sources/token_minter/token_minter.move b/packages/token_messenger_minter/sources/token_minter/token_minter.move
index 99f4fe9..49077d2 100644
--- a/packages/token_messenger_minter/sources/token_minter/token_minter.move
+++ b/packages/token_messenger_minter/sources/token_minter/token_minter.move
@@ -168,7 +168,7 @@ module token_messenger_minter::token_minter {
treasury::test_configure_minter(&tmm_signer, 10_000_000);
// Link the newly created FA
- token_controller::link_token_pair(
+ token_controller::test_link_token_pair(
owner,
stablecoin::stablecoin_address(),
REMOTE_DOMAIN,
@@ -176,7 +176,7 @@ module token_messenger_minter::token_minter {
);
// Set Burn Limit
- token_controller::set_max_burn_amount_per_message(
+ token_controller::test_set_max_burn_amount_per_message(
owner,
stablecoin::stablecoin_address(),
1_000_000
@@ -230,8 +230,8 @@ module token_messenger_minter::token_minter {
#[expected_failure(abort_code = 0x10001, location = Self)]
fun test_mint_unsupported_mint_token(owner: &signer) {
init_test_token_minter(owner);
- token_controller::unlink_token_pair(owner, REMOTE_DOMAIN, REMOTE_STABLECOIN_ADDRESS);
- token_controller::link_token_pair(
+ token_controller::test_unlink_token_pair(owner, REMOTE_DOMAIN, REMOTE_STABLECOIN_ADDRESS);
+ token_controller::test_link_token_pair(
owner,
@0xfac,
REMOTE_DOMAIN,