icrc_ledger_client_cdk/
lib.rs1use async_trait::async_trait;
2use candid::{
3 Principal,
4 utils::{ArgumentDecoder, ArgumentEncoder},
5};
6pub use icrc_ledger_client::{ICRC1Client, Runtime};
7
8pub struct CdkRuntime;
10
11#[async_trait]
12impl Runtime for CdkRuntime {
13 async fn call<In, Out>(
14 &self,
15 id: Principal,
16 method: &str,
17 args: In,
18 ) -> Result<Out, (i32, String)>
19 where
20 In: ArgumentEncoder + Send,
21 Out: for<'a> ArgumentDecoder<'a>,
22 {
23 #[allow(deprecated)]
24 ic_cdk::call(id, method, args)
25 .await
26 .map_err(|(code, msg)| (code as i32, msg))
27 }
28}