Skip to content

Commit

Permalink
fix: context create
Browse files Browse the repository at this point in the history
  • Loading branch information
frdomovic committed Dec 6, 2024
1 parent 6a69271 commit 3c18039
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion contracts/icp/context-config/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn application_revision(context_id: ICRepr<ContextId>) -> u64 {
}

#[ic_cdk::query]
fn proxy_contract(context_id: ICRepr<ContextId>) -> Principal {
fn proxy_contract(context_id: ICRepr<ContextId>) -> String {
with_state(|configs| {
let context = configs
.contexts
Expand All @@ -42,6 +42,7 @@ fn proxy_contract(context_id: ICRepr<ContextId>) -> Principal {

context.proxy.clone()
})
.to_string()
}

#[ic_cdk::query]
Expand Down
12 changes: 8 additions & 4 deletions crates/context/config/src/client/env/config/mutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ impl<'a> Method<Icp> for Mutate<'a> {
}

fn decode(response: Vec<u8>) -> eyre::Result<Self::Returns> {
if !response.is_empty() {
eyre::bail!("unexpected response {:?}", response);
match candid::decode_one::<Result<(), String>>(&response) {
Ok(decoded) => match decoded {
Ok(()) => Ok(()),
Err(err_msg) => eyre::bail!("unexpected response {:?}", err_msg),
},
Err(e) => {
eyre::bail!("unexpected response {:?}", e)
}
}

Ok(())
}
}

Expand Down
6 changes: 5 additions & 1 deletion crates/context/config/src/icp/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::borrow::Cow;
use std::marker::PhantomData;
use std::time::{SystemTime, UNIX_EPOCH};

use candid::CandidType;
use ed25519_dalek::{Verifier, VerifyingKey};
Expand Down Expand Up @@ -167,7 +168,10 @@ impl ICRequest {
Self {
signer_id: ICRepr::new(signer_id),
kind,
timestamp_ms: 0, // Default timestamp for tests
timestamp_ms: SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Time went backwards")
.as_millis() as u64,
}
}
}
Expand Down

0 comments on commit 3c18039

Please sign in to comment.