Skip to content

Commit

Permalink
Use nat Candid representation for ERC-1155 balanceOf result (#59)
Browse files Browse the repository at this point in the history
* Use 'nat' Candid representation for ERC-1155 'balanceOf' result

* Update Candid interface
  • Loading branch information
rvanasa committed Sep 13, 2023
1 parent 8ae47a3 commit 5037831
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion canisters/ic_eth/ic_eth.did
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
service : {
verify_ecdsa : (eth_address : text, message : text, signature : text) -> (bool) query;
erc721_owner_of : (network : text, contract_address : text, token_id : nat64) -> (text);
erc1155_balance_of : (network : text, contract_address : text, owner_address : text, token_id : nat64) -> (nat64);
erc1155_balance_of : (network : text, contract_address : text, owner_address : text, token_id : nat64) -> (nat);
}
6 changes: 2 additions & 4 deletions canisters/ic_eth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ pub async fn erc1155_balance_of(
contract_address: String,
owner_address: String,
token_id: u64,
) -> u64 {
// TODO: use `candid::Nat` in place of `u64`

) -> u128 {
let owner_address =
ethers_core::types::Address::from_str(&owner_address).expect("Invalid owner address");

Expand All @@ -79,7 +77,7 @@ pub async fn erc1155_balance_of(
)
.await;
match result.get(0) {
Some(Token::Uint(n)) => n.as_u64(),
Some(Token::Uint(n)) => n.as_u128(),
_ => panic!("Unexpected result"),
}
}

0 comments on commit 5037831

Please sign in to comment.