Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alenmestrov committed Dec 1, 2024
1 parent ce422bd commit 1031918
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 108 deletions.
9 changes: 3 additions & 6 deletions contracts/icp/context-config/src/mutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,9 @@ async fn deploy_proxy_contract(context_id: &ICContextId) -> Result<Principal, St
}),
};

let (canister_record,) = create_canister(
create_args,
500_000_000_000_000u128,
)
.await
.map_err(|e| format!("Failed to create canister: {:?}", e))?;
let (canister_record,) = create_canister(create_args, 500_000_000_000_000u128)
.await
.map_err(|e| format!("Failed to create canister: {:?}", e))?;

let canister_id = canister_record.canister_id;

Expand Down
15 changes: 9 additions & 6 deletions contracts/icp/proxy-contract/src/mutate.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
use std::collections::HashSet;

use calimero_context_config::repr::ReprTransmute;
use candid::{CandidType, Principal};
use ic_cdk::api::call::CallResult;

use crate::types::*;
use crate::PROXY_CONTRACT;

use calimero_context_config::repr::ReprTransmute;

async fn check_member(signer_id: &ICSignerId) -> Result<bool, String> {
let (context_canister_id, context_id) = PROXY_CONTRACT.with(|contract| {
(contract.borrow().context_config_id.clone(), contract.borrow().context_id.clone())
(
contract.borrow().context_config_id.clone(),
contract.borrow().context_id.clone(),
)
});

let identity = ICContextIdentity::new(signer_id.rt().expect("Invalid signer id"));

let args = candid::encode_args((context_id, identity)).expect("Failed to encode args");

let call_result: CallResult<(bool, )> = ic_cdk::call(
let call_result: CallResult<(bool,)> = ic_cdk::call(
Principal::from_text(&context_canister_id)
.map_err(|e| format!("Invalid context canister ID: {}", e))?,
"has_member",
(args,),
).await;
)
.await;

match call_result {
Ok((is_member,)) => Ok(is_member),
Err(e) => Err(format!("Error checking membership: {:?}", e))
Err(e) => Err(format!("Error checking membership: {:?}", e)),
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/icp/proxy-contract/tests/context_types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use candid::CandidType;
use serde::{Deserialize, Serialize};
use proxy_contract::types::{ICContextId, ICContextIdentity, ICSignerId};
use serde::{Deserialize, Serialize};

#[derive(CandidType, Serialize, Deserialize, Debug, Clone)]
pub struct Request {
Expand Down
Loading

0 comments on commit 1031918

Please sign in to comment.