Skip to content

Commit

Permalink
add allow_function and disallow function on ITS
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Nov 25, 2024
1 parent b68989a commit 404c3b5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
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);

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

0 comments on commit 404c3b5

Please sign in to comment.