Skip to content

Commit

Permalink
check available cycles and accepted cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Oct 28, 2024
1 parent b3e5e7e commit f792e6d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/dns_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ pub async fn get_dkim_public_key(
return Err("Insufficient cycles".to_string());
}
}
ic_cdk::api::call::msg_cycles_accept128(available_cycles);
let accepted_cycles = ic_cdk::api::call::msg_cycles_accept128(available_cycles);
if available_cycles != accepted_cycles {
return Err("Fail to accept all available cycles".to_string());
}
// Verify selector and domain
if !Regex::new(SELECTOR_REGEX).unwrap().is_match(&selector) {
return Err("Invalid domain".to_string());
Expand Down
10 changes: 8 additions & 2 deletions src/ic_dns_oracle_backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ pub async fn sign_dkim_public_key(
}
}
// Accept all available cycles.
ic_cdk::api::call::msg_cycles_accept128(available_cycles);
let accepted_cycles = ic_cdk::api::call::msg_cycles_accept128(available_cycles);
if available_cycles != accepted_cycles {
return Err("Fail to accept all available cycles".to_string());
}
write_log(
"sign_dkim_public_key",
&format!(
Expand Down Expand Up @@ -469,7 +472,10 @@ pub async fn revoke_dkim_public_key(
}
}
// Accept all available cycles.
ic_cdk::api::call::msg_cycles_accept128(available_cycles);
let accepted_cycles = ic_cdk::api::call::msg_cycles_accept128(available_cycles);
if available_cycles != accepted_cycles {
return Err("Fail to accept all available cycles".to_string());
}
write_log(
"revoke_dkim_public_key",
&format!(
Expand Down
5 changes: 4 additions & 1 deletion src/poseidon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ pub fn public_key_hash(public_key_hex: String) -> Result<String, String> {
}
}
// Accept all available cycles.
ic_cdk::api::call::msg_cycles_accept128(available_cycles);
let accepted_cycles = ic_cdk::api::call::msg_cycles_accept128(available_cycles);
if available_cycles != accepted_cycles {
return Err("Fail to accept all available cycles".to_string());
}
_public_key_hash(public_key_hex)
}

Expand Down

0 comments on commit f792e6d

Please sign in to comment.