Skip to content

Commit e2b896b

Browse files
author
Yasir
authored
Merge pull request #79 from bitfinity-network/chore/EPROD-589-update-signature-client
[EPROD-589] Update Signature Verification Client endpoints
2 parents c8dec1b + 256b59f commit e2b896b

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

src/did/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,6 @@ pub enum SignatureVerificationError {
230230
RecoveryError { expected: H160, recovered: H160 },
231231
#[error("failed to verify signature: {0}")]
232232
InternalError(String),
233+
#[error("unauthorized principal")]
234+
Unauthorized,
233235
}

src/signature-verification-canister-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ ic-agent-client = ["ic-canister-client/ic-agent-client"]
2020
[dependencies]
2121
did = { path = "../did" }
2222
ic-canister-client = { workspace = true }
23+
candid = { workspace = true }

src/signature-verification-canister-client/src/client.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use candid::Principal;
12
use did::error::SignatureVerificationError;
23
use did::{Transaction, H160};
34
use ic_canister_client::{CanisterClient, CanisterClientResult};
@@ -31,4 +32,38 @@ impl<C: CanisterClient> SignatureVerificationCanisterClient<C> {
3132
) -> CanisterClientResult<SignatureVerificationResult<H160>> {
3233
self.client.query("verify_signature", (transaction,)).await
3334
}
35+
36+
/// Add principal to the access control list
37+
pub async fn add_principal_to_access_list(
38+
&self,
39+
principal: Principal,
40+
) -> CanisterClientResult<SignatureVerificationResult<()>> {
41+
self.client.update("add_access", (principal,)).await
42+
}
43+
44+
/// Remove principal from the access control list
45+
pub async fn remove_principal_from_access_list(
46+
&self,
47+
principal: Principal,
48+
) -> CanisterClientResult<SignatureVerificationResult<()>> {
49+
self.client.update("remove_access", (principal,)).await
50+
}
51+
52+
/// Get the owner of the canister
53+
pub async fn get_owner(&self) -> CanisterClientResult<Principal> {
54+
self.client.query("get_owner", ()).await
55+
}
56+
57+
/// Set the owner of the canister
58+
pub async fn set_owner(
59+
&self,
60+
principal: Principal,
61+
) -> CanisterClientResult<SignatureVerificationResult<()>> {
62+
self.client.update("set_owner", (principal,)).await
63+
}
64+
65+
/// Get the access control list
66+
pub async fn get_access_list(&self) -> CanisterClientResult<Vec<Principal>> {
67+
self.client.query("get_access_list", ()).await
68+
}
3469
}

0 commit comments

Comments
 (0)