Skip to content

Experiment: use Canpack in place of Rust canister #73

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

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
133 changes: 63 additions & 70 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ opt-level = "s"

[workspace]
resolver = "2"
members = ["canisters/ic_eth"]
members = [".canpack/motoko_rust"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Here is one way to acquire tokens and NFTs on the [Sepolia](https://www.alchemy.
- [Motoko](https://github.com/dfinity/motoko#readme): a safe and simple programming language for the Internet Computer
- [Mops](https://mops.one): an on-chain community package manager for Motoko
- [mo-dev](https://github.com/dfinity/motoko-dev-server#readme): a live reload development server for Motoko
- [Canpack](https://github.com/rvanasa/canpack#readme): call Rust functions from Motoko using a generated canister

**Ethereum Integration:**
- [Rust](https://www.rust-lang.org/): a secure, high-performance canister programming language
Expand Down
8 changes: 4 additions & 4 deletions canisters/backend/Core.mo → backend/Core.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Principal "mo:base/Principal";
import Nat64 "mo:base/Nat64";
import System "lib/System";
import Iter "lib/IterMore";
import IcEth "canister:ic_eth";
import Rust "canister:motoko_rust";
import Seq "mo:sequence/Sequence";
import Stream "mo:sequence/Stream";

Expand Down Expand Up @@ -39,7 +39,7 @@ module {

public func connectEthWallet(caller : Principal, wallet : Types.EthWallet, signedPrincipal : Types.SignedPrincipal) : async Types.Resp.ConnectEthWallet {
let log = logger.Begin(caller, #connectEthWallet(wallet, signedPrincipal));
let checkOutcome = await IcEth.verify_ecdsa(wallet, Principal.toText caller, signedPrincipal);
let checkOutcome = await Rust.ecdsa_verify(wallet, Principal.toText caller, signedPrincipal);
log.internal(#verifyEcdsaOutcome(checkOutcome));
if (checkOutcome) {
ignore (state.putWalletSignsPrincipal(wallet, caller, signedPrincipal));
Expand All @@ -58,11 +58,11 @@ module {
case (?_) {
switch (nft.tokenType) {
case (#erc721) {
let owner = await IcEth.erc721_owner_of(nft.network, nft.contract, Nat64.fromNat(nft.tokenId));
let owner = await Rust.erc721_owner_of(nft.network, nft.contract, Nat64.fromNat(nft.tokenId));
owner == nft.owner;
};
case (#erc1155) {
let balance = await IcEth.erc1155_balance_of(nft.network, nft.contract, nft.owner, Nat64.fromNat(nft.tokenId));
let balance = await Rust.erc1155_balance_of(nft.network, nft.contract, nft.owner, Nat64.fromNat(nft.tokenId));
balance > 0;
};
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion canister_ids.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"frontend": {
"ic": "xm3ir-rqaaa-aaaap-abhqq-cai"
},
"ic_eth": {
"motoko_rust": {
"ic": "xfydn-hyaaa-aaaap-abhra-cai"
}
}
20 changes: 0 additions & 20 deletions canisters/ic_eth/Cargo.toml

This file was deleted.

Loading
Loading