Skip to content

Commit

Permalink
fix: fix validation function for SNS proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Sep 26, 2024
1 parent 502cb07 commit fe42ec7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ strip = true
opt-level = 's'

[workspace.package]
version = "1.2.0"
version = "1.2.1"
edition = "2021"
repository = "https://github.com/ldclabs/idempotent-proxy"
keywords = ["idempotent", "reverse", "proxy", "icp"]
Expand Down
4 changes: 4 additions & 0 deletions src/idempotent-proxy-canister/idempotent-proxy-canister.did
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type InitArgs = record {
};
type Result = variant { Ok : bool; Err : text };
type Result_1 = variant { Ok; Err : text };
type Result_2 = variant { Ok : text; Err : text };
type StateInfo = record {
proxy_token_public_key : text;
service_fee : nat64;
Expand Down Expand Up @@ -68,6 +69,9 @@ service : (opt ChainArgs) -> {
proxy_http_request : (CanisterHttpRequestArgument) -> (HttpResponse);
proxy_http_request_cost : (CanisterHttpRequestArgument) -> (nat) query;
state_info : () -> (StateInfo) query;
validate2_admin_add_managers : (vec principal) -> (Result_2);
validate2_admin_remove_managers : (vec principal) -> (Result_2);
validate2_admin_set_agents : (vec Agent) -> (Result_2);
validate_admin_add_managers : (vec principal) -> (Result_1);
validate_admin_remove_managers : (vec principal) -> (Result_1);
validate_admin_set_agents : (vec Agent) -> (Result_1);
Expand Down
24 changes: 24 additions & 0 deletions src/idempotent-proxy-canister/src/api_admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,33 @@ async fn admin_set_agents(agents: Vec<agent::Agent>) -> Result<(), String> {
Ok(())
}

// Use validate2_admin_add_managers instead of validate_admin_add_managers
#[ic_cdk::update]
fn validate_admin_add_managers(args: BTreeSet<Principal>) -> Result<(), String> {
validate_principals(&args)?;
Ok(())
}

#[ic_cdk::update]
fn validate2_admin_add_managers(args: BTreeSet<Principal>) -> Result<String, String> {
validate_principals(&args)?;
Ok("ok".to_string())
}

// Use validate2_admin_remove_managers instead of validate_admin_remove_managers
#[ic_cdk::update]
fn validate_admin_remove_managers(args: BTreeSet<Principal>) -> Result<(), String> {
validate_principals(&args)?;
Ok(())
}

#[ic_cdk::update]
fn validate2_admin_remove_managers(args: BTreeSet<Principal>) -> Result<String, String> {
validate_principals(&args)?;
Ok("ok".to_string())
}

// Use validate2_admin_set_agents instead of validate_admin_set_agents
#[ic_cdk::update]
fn validate_admin_set_agents(agents: Vec<agent::Agent>) -> Result<(), String> {
if agents.is_empty() {
Expand All @@ -87,3 +102,12 @@ fn validate_admin_set_agents(agents: Vec<agent::Agent>) -> Result<(), String> {

Ok(())
}

#[ic_cdk::update]
fn validate2_admin_set_agents(agents: Vec<agent::Agent>) -> Result<String, String> {
if agents.is_empty() {
return Err("agents cannot be empty".to_string());
}

Ok("ok".to_string())
}

0 comments on commit fe42ec7

Please sign in to comment.