Skip to content

Commit

Permalink
address comments on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Dec 11, 2024
1 parent c2beb1f commit b17a68c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
22 changes: 11 additions & 11 deletions move/its/sources/its.move
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ public fun burn_as_distributor<T>(

// This is the entrypoint for operators to set the flow limits of their tokens
// (tokenManager.setFlowLimit on EVM)
public fun set_flow_limit<T>(
public fun set_flow_limit_as_token_operator<T>(
self: &mut ITS,
channel: &Channel,
token_id: TokenId,
limit: u64,
) {
let value = self.value_mut!(b"set_flow_limit");
let value = self.value_mut!(b"set_flow_limit_as_token_operator");

value.set_flow_limit<T>(
value.set_flow_limit_as_token_operator<T>(
channel,
token_id,
limit,
Expand All @@ -280,15 +280,15 @@ public fun set_flow_limit<T>(

// This is the entrypoint for operators to set the flow limits of their tokens
// (interchainTokenService.setFlowLimits on EVM)
public fun set_flow_limit_as_operator<T>(
public fun set_flow_limit<T>(
self: &mut ITS,
_: &OperatorCap,
token_ids: TokenId,
limits: u64,
) {
let value = self.value_mut!(b"set_flow_limit_as_operator");
let value = self.value_mut!(b"set_flow_limit");

value.set_flow_limit_as_operator<T>(
value.set_flow_limit<T>(
token_ids,
limits,
);
Expand Down Expand Up @@ -371,7 +371,7 @@ fun version_control(): VersionControl {
b"remove_trusted_addresses",
b"register_transaction",
b"set_flow_limit",
b"set_flow_limit_as_operator",
b"set_flow_limit_as_token_operator",
b"allow_function",
b"disallow_function",
].map!(|function_name| function_name.to_ascii_string()),
Expand Down Expand Up @@ -914,7 +914,7 @@ fun test_set_trusted_address() {
}

#[test]
fun test_set_flow_limit() {
fun test_set_flow_limit_as_token_operator() {
let ctx = &mut tx_context::dummy();
let mut its = create_for_testing(ctx);
let symbol = b"COIN";
Expand All @@ -935,14 +935,14 @@ fun test_set_flow_limit() {
coin_management.add_operator(channel.to_address());

let token_id = register_coin(&mut its, coin_info, coin_management);
its.set_flow_limit<COIN>(&channel, token_id, limit);
its.set_flow_limit_as_token_operator<COIN>(&channel, token_id, limit);

sui::test_utils::destroy(its);
channel.destroy();
}

#[test]
fun test_set_flow_limit_as_operator() {
fun test_set_flow_limit() {
let ctx = &mut tx_context::dummy();
let mut its = create_for_testing(ctx);
let symbol = b"COIN";
Expand All @@ -962,7 +962,7 @@ fun test_set_flow_limit_as_operator() {
let operator_cap = operator_cap::create(ctx);

let token_id = register_coin(&mut its, coin_info, coin_management);
its.set_flow_limit_as_operator<COIN>(&operator_cap, token_id, limit);
its.set_flow_limit<COIN>(&operator_cap, token_id, limit);

sui::test_utils::destroy(its);
sui::test_utils::destroy(operator_cap);
Expand Down
4 changes: 2 additions & 2 deletions move/its/sources/types/coin_management.move
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ public(package) fun set_flow_limit<T>(
flow_limit: u64,
) {
assert!(self.operator.contains(&channel.to_address()), ENotOperator);
self.set_flow_limit_permissionless(flow_limit);
self.set_flow_limit_internal(flow_limit);
}

/// Adds a rate limit to the `CoinManagement`.
public(package) fun set_flow_limit_permissionless<T>(
public(package) fun set_flow_limit_internal<T>(
self: &mut CoinManagement<T>,
flow_limit: u64,
) {
Expand Down
8 changes: 4 additions & 4 deletions move/its/sources/versioned/its_v0.move
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public(package) fun burn_as_distributor<T>(
coin_management.burn(coin.into_balance());
}

public(package) fun set_flow_limit<T>(
public(package) fun set_flow_limit_as_token_operator<T>(
self: &mut ITS_v0,
channel: &Channel,
token_id: TokenId,
Expand All @@ -488,12 +488,12 @@ public(package) fun set_flow_limit<T>(
events::flow_limit_set<T>(token_id, limit);
}

public(package) fun set_flow_limit_as_operator<T>(
public(package) fun set_flow_limit<T>(
self: &mut ITS_v0,
token_id: TokenId,
limit: u64,
) {
self.coin_management_mut<T>(token_id).set_flow_limit_permissionless(limit);
self.coin_management_mut<T>(token_id).set_flow_limit_internal(limit);
events::flow_limit_set<T>(token_id, limit);
}

Expand Down Expand Up @@ -642,7 +642,7 @@ fun prepare_message(
EUntrustedChain,
);

// Check whether the ITS call should be routed via ITS hub for this
// Check whether the ITS 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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axelar-network/axelar-cgp-sui",
"version": "1.0.1",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "https://github.com/axelarnetwork/axelar-cgp-sui"
Expand Down
18 changes: 18 additions & 0 deletions test/testdata/interface_its_operator_cap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"structs": {
"OperatorCap": {
"name": "OperatorCap",
"abilities": [
"store",
"key"
],
"fields": [
{
"name": "id",
"type": "UID"
}
]
}
},
"publicFunctions": {}
}

0 comments on commit b17a68c

Please sign in to comment.