From 78f4be36a89345677ee4ede828b27e84eac78958 Mon Sep 17 00:00:00 2001 From: alenmestrov Date: Fri, 29 Nov 2024 19:48:18 +0100 Subject: [PATCH] fix: linter --- contracts/icp/context-config/src/mutate.rs | 22 ++++++------------- contracts/icp/context-config/src/types.rs | 10 +++++---- .../icp/context-config/tests/integration.rs | 7 ++---- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/contracts/icp/context-config/src/mutate.rs b/contracts/icp/context-config/src/mutate.rs index b9297a4e2..e1aba06b4 100644 --- a/contracts/icp/context-config/src/mutate.rs +++ b/contracts/icp/context-config/src/mutate.rs @@ -37,16 +37,12 @@ pub fn mutate(signed_request: ICPSigned) -> Result<(), String> { ContextRequestKind::RemoveMembers { members } => { remove_members(&request.signer_id, &context_id, members) } - ContextRequestKind::Grant { capabilities } => grant( - &request.signer_id, - &context_id, - capabilities, - ), - ContextRequestKind::Revoke { capabilities } => revoke( - &request.signer_id, - &context_id, - capabilities, - ), + ContextRequestKind::Grant { capabilities } => { + grant(&request.signer_id, &context_id, capabilities) + } + ContextRequestKind::Revoke { capabilities } => { + revoke(&request.signer_id, &context_id, capabilities) + } ContextRequestKind::UpdateProxyContract => { // TODO: Implement update_proxy_contract Ok(()) @@ -83,11 +79,7 @@ fn add_context( }; // Store context - if configs - .contexts - .insert(context_id, context) - .is_some() - { + if configs.contexts.insert(context_id, context).is_some() { return Err("context already exists".into()); } diff --git a/contracts/icp/context-config/src/types.rs b/contracts/icp/context-config/src/types.rs index f7f0d91ae..3a170409d 100644 --- a/contracts/icp/context-config/src/types.rs +++ b/contracts/icp/context-config/src/types.rs @@ -309,7 +309,7 @@ impl ICPSigned { { let bytes = candid::encode_one(payload) .map_err(|e| ICPSignedError::SerializationError(e.to_string()))?; - + let signature = sign(&bytes) .into_result() .map_err(ICPSignedError::DerivationError)?; @@ -337,10 +337,12 @@ impl ICPSigned { .rt::() .map_err(|_| ICPSignedError::InvalidPublicKey)?; - let signature_bytes: [u8; 64] = self.signature.as_slice().try_into() - .map_err(|_| ICPSignedError::SignatureError(ed25519_dalek::ed25519::Error::new()))?; + let signature_bytes: [u8; 64] = + self.signature.as_slice().try_into().map_err(|_| { + ICPSignedError::SignatureError(ed25519_dalek::ed25519::Error::new()) + })?; let signature = ed25519_dalek::Signature::from_bytes(&signature_bytes); - + key.verify(&self.payload, &signature) .map_err(|_| ICPSignedError::InvalidSignature)?; diff --git a/contracts/icp/context-config/tests/integration.rs b/contracts/icp/context-config/tests/integration.rs index 0c6427540..ace9af4aa 100644 --- a/contracts/icp/context-config/tests/integration.rs +++ b/contracts/icp/context-config/tests/integration.rs @@ -26,11 +26,8 @@ fn setup() -> (PocketIc, Principal) { } fn create_signed_request(signer_key: &SigningKey, request: Request) -> ICPSigned { - ICPSigned::new( - request, - |bytes| signer_key.sign(bytes) - ) - .expect("Failed to create signed request") + ICPSigned::new(request, |bytes| signer_key.sign(bytes)) + .expect("Failed to create signed request") } fn get_time_nanos(pic: &PocketIc) -> u64 {