Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use DAB proxy #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions magic_bridge/ic/src/magic_bridge/src/dab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use crate::factory::CreateCanisterParam;
use crate::{magic::STATE, types::*};

const DAB_TOKEN_ADDRESS: &str = "eclat-5qaaa-aaaaa-aaica-cai";
const DAB_PROXY_ADDRESS: &str = "tdc6j-iiaaa-aaaah-abj2q-cai";

const MAX_DAB_RETRIES: u8 = 10;

#[derive(CandidType, Deserialize, Clone, PartialEq, Debug)]
Expand Down Expand Up @@ -94,6 +96,7 @@ async fn register_dip20(
params: &CreateCanisterParam,
) -> Result<(), OperationError> {
let dab_tokens_address = ic_kit::Principal::from_str(&DAB_TOKEN_ADDRESS).unwrap();
let dab_proxy_address = ic_kit::Principal::from_str(&DAB_PROXY_ADDRESS).unwrap();

let details = vec![
(
Expand All @@ -120,16 +123,16 @@ async fn register_dip20(
details: details,
};

let canister_call: (DABResponse,) = match ic::call(dab_tokens_address, "add", (dab_args,)).await
{
Ok(res) => res,
Err((code, err)) => {
return Err(OperationError::Unknown(format!(
"RejectionCode: {:?}\n{}",
code, err
)))
}
};
let canister_call: (DABResponse,) =
match ic::call(dab_proxy_address, "add", (dab_tokens_address, dab_args)).await {
Ok(res) => res,
Err((code, err)) => {
return Err(OperationError::Unknown(format!(
"RejectionCode: {:?}\n{}",
code, err
)))
}
};

match canister_call {
(Ok(_),) => return Ok(()),
Expand Down