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)!: add allow_function and disallow_function on ITS #211

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rich-comics-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@axelar-network/axelar-cgp-sui': minor
---

add allow and disallow functions in ITS
41 changes: 41 additions & 0 deletions move/its/sources/its.move
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ macro fun value_mut($self: &mut ITS, $function_name: vector<u8>): &mut ITS_v0 {
value
}

// ---------------
// Entry Functions
// ---------------
entry fun allow_function(self: &mut ITS, _: &OwnerCap, version: u64, function_name: String) {
self.value_mut!(b"allow_function").allow_function(version, function_name);
}

entry fun disallow_function(self: &mut ITS, _: &OwnerCap, version: u64, function_name: String) {
self.value_mut!(b"disallow_function").disallow_function(version, function_name);
}

// ----------------
// Public Functions
// ----------------
Expand Down Expand Up @@ -324,6 +335,8 @@ fun version_control(): VersionControl {
b"remove_trusted_addresses",
b"register_transaction",
b"set_flow_limit",
b"allow_function",
b"disallow_function",
].map!(|function_name| function_name.to_ascii_string()),
])
}
Expand Down Expand Up @@ -927,3 +940,31 @@ fun test_channel_address() {

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

#[test]
fun test_allow_function() {
let ctx = &mut sui::tx_context::dummy();
let mut self = create_for_testing(ctx);
let owner_cap = owner_cap::create(ctx);
let version = 0;
let function_name = b"function_name".to_ascii_string();

self.allow_function(&owner_cap, version, function_name);
milapsheth marked this conversation as resolved.
Show resolved Hide resolved

sui::test_utils::destroy(self);
sui::test_utils::destroy(owner_cap);
}

#[test]
fun test_disallow_function() {
let ctx = &mut sui::tx_context::dummy();
let mut self = create_for_testing(ctx);
let owner_cap = owner_cap::create(ctx);
let version = 0;
let function_name = b"send_interchain_transfer".to_ascii_string();

self.disallow_function(&owner_cap, version, function_name);

sui::test_utils::destroy(self);
sui::test_utils::destroy(owner_cap);
}
8 changes: 8 additions & 0 deletions move/its/sources/versioned/its_v0.move
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,14 @@ public(package) fun set_flow_limit<T>(
events::flow_limit_set<T>(token_id, limit);
}

public(package) fun allow_function(self: &mut ITS_v0, version: u64, function_name: String) {
self.version_control.allow_function(version, function_name);
}

public(package) fun disallow_function(self: &mut ITS_v0, version: u64, function_name: String) {
self.version_control.disallow_function(version, function_name);
}

// -----------------
// Private Functions
// -----------------
Expand Down