Skip to content

Commit fe42ec7

Browse files
committed
fix: fix validation function for SNS proposal
1 parent 502cb07 commit fe42ec7

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ strip = true
1515
opt-level = 's'
1616

1717
[workspace.package]
18-
version = "1.2.0"
18+
version = "1.2.1"
1919
edition = "2021"
2020
repository = "https://github.com/ldclabs/idempotent-proxy"
2121
keywords = ["idempotent", "reverse", "proxy", "icp"]

src/idempotent-proxy-canister/idempotent-proxy-canister.did

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type InitArgs = record {
3030
};
3131
type Result = variant { Ok : bool; Err : text };
3232
type Result_1 = variant { Ok; Err : text };
33+
type Result_2 = variant { Ok : text; Err : text };
3334
type StateInfo = record {
3435
proxy_token_public_key : text;
3536
service_fee : nat64;
@@ -68,6 +69,9 @@ service : (opt ChainArgs) -> {
6869
proxy_http_request : (CanisterHttpRequestArgument) -> (HttpResponse);
6970
proxy_http_request_cost : (CanisterHttpRequestArgument) -> (nat) query;
7071
state_info : () -> (StateInfo) query;
72+
validate2_admin_add_managers : (vec principal) -> (Result_2);
73+
validate2_admin_remove_managers : (vec principal) -> (Result_2);
74+
validate2_admin_set_agents : (vec Agent) -> (Result_2);
7175
validate_admin_add_managers : (vec principal) -> (Result_1);
7276
validate_admin_remove_managers : (vec principal) -> (Result_1);
7377
validate_admin_set_agents : (vec Agent) -> (Result_1);

src/idempotent-proxy-canister/src/api_admin.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,33 @@ async fn admin_set_agents(agents: Vec<agent::Agent>) -> Result<(), String> {
6767
Ok(())
6868
}
6969

70+
// Use validate2_admin_add_managers instead of validate_admin_add_managers
7071
#[ic_cdk::update]
7172
fn validate_admin_add_managers(args: BTreeSet<Principal>) -> Result<(), String> {
7273
validate_principals(&args)?;
7374
Ok(())
7475
}
7576

77+
#[ic_cdk::update]
78+
fn validate2_admin_add_managers(args: BTreeSet<Principal>) -> Result<String, String> {
79+
validate_principals(&args)?;
80+
Ok("ok".to_string())
81+
}
82+
83+
// Use validate2_admin_remove_managers instead of validate_admin_remove_managers
7684
#[ic_cdk::update]
7785
fn validate_admin_remove_managers(args: BTreeSet<Principal>) -> Result<(), String> {
7886
validate_principals(&args)?;
7987
Ok(())
8088
}
8189

90+
#[ic_cdk::update]
91+
fn validate2_admin_remove_managers(args: BTreeSet<Principal>) -> Result<String, String> {
92+
validate_principals(&args)?;
93+
Ok("ok".to_string())
94+
}
95+
96+
// Use validate2_admin_set_agents instead of validate_admin_set_agents
8297
#[ic_cdk::update]
8398
fn validate_admin_set_agents(agents: Vec<agent::Agent>) -> Result<(), String> {
8499
if agents.is_empty() {
@@ -87,3 +102,12 @@ fn validate_admin_set_agents(agents: Vec<agent::Agent>) -> Result<(), String> {
87102

88103
Ok(())
89104
}
105+
106+
#[ic_cdk::update]
107+
fn validate2_admin_set_agents(agents: Vec<agent::Agent>) -> Result<String, String> {
108+
if agents.is_empty() {
109+
return Err("agents cannot be empty".to_string());
110+
}
111+
112+
Ok("ok".to_string())
113+
}

0 commit comments

Comments
 (0)