Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6b969be
add cap as storage service to eth_proxy
Sep 9, 2022
b609899
add cap storage service for claimable message on dip20_proxy
Sep 20, 2022
05942ac
upgrade cap_cdk and use insert_sync on eth_proxy
Sep 21, 2022
0d16aac
upgrade cap_cdk and use insert_sync on dip20_proxy
Sep 21, 2022
d618c7d
rename trait ToEvent to ToCapEvent
Sep 21, 2022
d769dba
remove claimable_assets candid methods from dip20_proxy
Sep 21, 2022
f9450c4
use archive() fn on upgrade
Sep 23, 2022
db17315
use archive() fn on upgrade eth_proxy
Sep 23, 2022
c19a962
eth_proxy: add caller to claimable message
Oct 18, 2022
69c0b08
dip20_proxy: add caller to claimable message
Oct 18, 2022
f6cc64c
add eth_contract_address to withdraw payload
Sep 22, 2022
bb5b837
add claimable_asset in withdraw for dip20_proxy
Sep 22, 2022
3281179
add claimable_asset in withdraw for eth_proxy
Sep 22, 2022
cebc5e8
use eth address as principal to keep balance
Sep 23, 2022
230b663
return Ok(balance) on eth_proxy.withdraw
Sep 23, 2022
b7fa4ce
add withdrawable struct to eth_proxy
Sep 27, 2022
b56a20c
add withdrawable struct to dip20_proxy
Sep 27, 2022
9f82039
remove token_id from withdrawable balance on eth_proxy
Sep 27, 2022
eca1bfa
Fix typo TokendId -> TokenId
Sep 28, 2022
5af4f7e
dip20_proxy: replace Vec for hashmap to store usertx
Sep 29, 2022
a810f52
eth_proxy: replace Vec for hashmap to store usertx
Sep 29, 2022
1889726
dip20_proxy: add operation failure on burn and withdraw
Oct 6, 2022
c933397
eth_proxy: add operation failure on burn and withdraw
Oct 6, 2022
ec846e3
dip20_proxy: refactor pending balance logic
Oct 12, 2022
c312ecf
eth_proxy: refactor pending balance logic
Oct 12, 2022
44d66f9
add caller to claimable message on withdraw
Oct 18, 2022
8f32e39
chore: out going message store (#38)
fcavazzoli Oct 18, 2022
0f3e67e
add account contract (#68)
fcavazzoli Oct 31, 2022
a2d95dc
starknet: increase max fee (#70)
fcavazzoli Nov 3, 2022
8342d37
core: add nonce_exist candid method
Nov 4, 2022
f674f32
dip20_proxy: add message_exist candid method query
Nov 4, 2022
756fbf7
dip20_proxy: update candid file
Nov 4, 2022
0b896dd
solve master conflicts
Nov 10, 2022
91b35b8
fix upgrade with Option<>
Nov 10, 2022
fbc0b7f
resolve merge conflict
Nov 11, 2022
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
6 changes: 6 additions & 0 deletions core/ic/src/tera/src/api/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ use crate::{common::types::Nonce, tera::STATE};
fn get_nonces() -> Vec<Nonce> {
STATE.with(|s| s.get_nonces())
}

#[query(name = "nonce_exist")]
#[candid_method(query, rename = "nonce_exist")]
fn nonce_exist(nonce: Nonce) -> bool {
STATE.with(|s| s.nonce_exists(&nonce))
}
1 change: 1 addition & 0 deletions core/ic/src/tera/tera.did
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ service : {
get_messages : () -> (vec OutgoingMessagePair);
get_messages_count : () -> (nat32) query;
get_nonces : () -> (vec nat) query;
nonce_exist : (nat) -> (bool) query;
remove_messages : (vec OutgoingMessagePair) -> (ConsumeMessageResponse);
send_message : (principal, vec nat) -> (SendMessageResponse);
store_message : (principal, principal, nat, vec nat) -> (
Expand Down
2 changes: 2 additions & 0 deletions magic_bridge/ic/src/dip20_proxy/dip20_proxy.did
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type ClaimableMessage = record {
amount : nat;
token_name : text;
};
type MessageStatus = variant { ConsumedNotMinted; Consuming };
type OperationFailure = variant {
SendMessage : opt TxError;
Burn : opt TxError;
Expand Down Expand Up @@ -40,6 +41,7 @@ service : {
get_all_token_balance : () -> (Result_1);
get_balance : (principal, principal, nat) -> (opt nat);
handle_message : (principal, nat, vec nat) -> (Result_2);
message_exist : (text) -> (opt MessageStatus) query;
mint : (principal, nat, vec nat) -> (Result_2);
perform_handshake : () -> (Result_3);
remove_claimable : (principal, principal, nat) -> (Result_4);
Expand Down
2 changes: 1 addition & 1 deletion magic_bridge/ic/src/dip20_proxy/src/api/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async fn burn(
});

insert_claimable_asset(ClaimableMessage {
from: caller,
from: Some(caller),
owner: eth_addr.clone(),
msg_hash: outgoing_message.msg_hash.clone(),
msg_key: Some(outgoing_message.msg_key.clone()),
Expand Down
10 changes: 10 additions & 0 deletions magic_bridge/ic/src/dip20_proxy/src/api/messages.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use candid::candid_method;
use ic_cdk_macros::query;

use crate::{common::types::MessageStatus, proxy::STATE};

#[query(name = "message_exist")]
#[candid_method(query, rename = "message_exist")]
fn message_exist(msg_hash: String) -> Option<MessageStatus> {
STATE.with(|s| s.get_message(&msg_hash))
}
1 change: 1 addition & 0 deletions magic_bridge/ic/src/dip20_proxy/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod claimable_assets;
mod get_balance;
mod handle_message;
mod init;
mod messages;
mod mint;
mod upgrade;
mod withdraw;
2 changes: 1 addition & 1 deletion magic_bridge/ic/src/dip20_proxy/src/api/withdraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub async fn withdraw(
});

insert_claimable_asset(ClaimableMessage {
from: caller,
from: Some(caller),
owner: eth_addr.clone(),
msg_hash: outgoing_message.msg_hash.clone(),
msg_key: Some(outgoing_message.msg_key.clone()),
Expand Down
2 changes: 1 addition & 1 deletion magic_bridge/ic/src/dip20_proxy/src/common/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct ClaimableMessage {
pub token_name: String,
pub token: TokenId,
pub amount: Nat,
pub from: Principal,
pub from: Option<Principal>,
}

#[derive(CandidType, Deserialize, Default)]
Expand Down
9 changes: 7 additions & 2 deletions magic_bridge/ic/src/dip20_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,19 @@ impl ToCapEvent for ClaimableMessage {
} else {
[0; 32]
};
let from = if self.from.is_some() {
self.from.unwrap()
} else {
Principal::anonymous()
};
let details = DetailsBuilder::default()
.insert("owner", self.owner)
.insert("ethContractAddress", self.token)
.insert("msgHash", self.msg_hash.clone())
.insert("msgHashKey", hash_key.to_nat())
.insert("amount", self.amount.clone())
.insert("name", self.token_name.clone())
.insert("from", self.from.clone())
.insert("from", from)
.build();

IndefiniteEventBuilder::new()
Expand All @@ -317,7 +322,7 @@ impl From<IndefiniteEvent> for ClaimableMessage {
let from: Principal = event.details[6].1.clone().try_into().unwrap();

ClaimableMessage {
from: from,
from: Some(from),
owner: event.caller,
msg_key: Some(msg_key.to_nonce_bytes()),
msg_hash: msg_hash,
Expand Down