From c0b15ca8cdb4c018e351248c35a075f7578139b9 Mon Sep 17 00:00:00 2001 From: veeso Date: Mon, 19 Feb 2024 21:20:05 +0100 Subject: [PATCH] fix: renamed ekoke to ekoke-ledger --- Cargo.lock | 2 +- Cargo.toml | 2 +- Makefile.toml | 15 +- dfx.json | 6 +- integration-tests/src/client/ekoke.rs | 4 +- integration-tests/src/lib.rs | 32 +- integration-tests/src/wasm.rs | 6 +- integration-tests/tests/http/ekoke.rs | 6 +- integration-tests/tests/inspect/deferred.rs | 4 +- integration-tests/tests/inspect/ekoke.rs | 44 +-- .../tests/use_case/buy_marketplace_nft.rs | 13 +- .../tests/use_case/icrc2_spend.rs | 2 +- scripts/deploy_functions.sh | 12 +- scripts/deploy_local.sh | 8 +- scripts/integration-tests.sh | 3 +- src/declarations/deferred/deferred.did.d.ts | 4 +- src/declarations/deferred/deferred.did.js | 6 +- .../ekoke-ledger/ekoke-ledger.did.d.ts | 231 +++++++++++++ .../ekoke-ledger/ekoke-ledger.did.js | 306 ++++++++++++++++++ src/declarations/ekoke-ledger/index.d.ts | 50 +++ src/declarations/ekoke-ledger/index.js | 43 +++ .../marketplace/marketplace.did.d.ts | 4 +- .../marketplace/marketplace.did.js | 6 +- src/deferred/deferred.did | 4 +- src/deferred/src/app.rs | 15 +- src/deferred/src/app/configuration.rs | 28 +- src/deferred/src/app/memory.rs | 2 +- src/deferred/src/app/minter.rs | 2 +- src/deferred/src/lib.rs | 4 +- src/did/src/deferred/canister.rs | 2 +- src/did/src/marketplace.rs | 2 +- src/{ekoke => ekoke_ledger}/Cargo.toml | 4 +- .../ekoke-ledger.did} | 0 src/{ekoke => ekoke_ledger}/src/abi.rs | 0 .../src/abi/ekoke.json | 0 src/{ekoke => ekoke_ledger}/src/app.rs | 0 .../src/app/balance.rs | 0 .../src/app/balance/account_balance.rs | 0 .../src/app/configuration.rs | 0 .../src/app/erc20_bridge.rs | 0 .../src/app/erc20_bridge/cketh_withdrawal.rs | 0 .../src/app/erc20_bridge/eth_rpc.rs | 0 .../app/erc20_bridge/eth_rpc/ekoke_swapped.rs | 0 .../src/app/erc20_bridge/eth_rpc/response.rs | 0 .../src/app/erc20_bridge/eth_wallet.rs | 0 .../src/app/erc20_bridge/gas_station.rs | 0 .../src/app/erc20_bridge/swap_fee.rs | 0 .../src/app/erc20_bridge/swap_pool.rs | 0 .../src/app/inspect.rs | 0 .../src/app/liquidity_pool.rs | 0 .../src/app/liquidity_pool/xrc.rs | 0 src/{ekoke => ekoke_ledger}/src/app/memory.rs | 0 src/{ekoke => ekoke_ledger}/src/app/pool.rs | 0 .../src/app/register.rs | 0 src/{ekoke => ekoke_ledger}/src/app/reward.rs | 0 src/{ekoke => ekoke_ledger}/src/app/roles.rs | 0 .../src/app/spend_allowance.rs | 0 .../src/app/spend_allowance/key.rs | 0 .../src/app/spend_allowance/spend.rs | 0 .../src/app/test_utils.rs | 0 src/{ekoke => ekoke_ledger}/src/constants.rs | 0 src/{ekoke => ekoke_ledger}/src/http.rs | 0 src/{ekoke => ekoke_ledger}/src/inspect.rs | 0 src/{ekoke => ekoke_ledger}/src/lib.rs | 0 src/{ekoke => ekoke_ledger}/src/utils.rs | 0 src/marketplace/marketplace.did | 4 +- src/marketplace/src/app.rs | 28 +- src/marketplace/src/app/configuration.rs | 28 +- src/marketplace/src/app/memory.rs | 2 +- src/marketplace/src/app/test_utils.rs | 2 +- src/marketplace/src/client/ekoke.rs | 12 +- src/marketplace/src/lib.rs | 4 +- 72 files changed, 802 insertions(+), 150 deletions(-) create mode 100644 src/declarations/ekoke-ledger/ekoke-ledger.did.d.ts create mode 100644 src/declarations/ekoke-ledger/ekoke-ledger.did.js create mode 100644 src/declarations/ekoke-ledger/index.d.ts create mode 100644 src/declarations/ekoke-ledger/index.js rename src/{ekoke => ekoke_ledger}/Cargo.toml (96%) rename src/{ekoke/ekoke.did => ekoke_ledger/ekoke-ledger.did} (100%) rename src/{ekoke => ekoke_ledger}/src/abi.rs (100%) rename src/{ekoke => ekoke_ledger}/src/abi/ekoke.json (100%) rename src/{ekoke => ekoke_ledger}/src/app.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/balance.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/balance/account_balance.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/configuration.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/erc20_bridge.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/erc20_bridge/cketh_withdrawal.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/erc20_bridge/eth_rpc.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/erc20_bridge/eth_rpc/ekoke_swapped.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/erc20_bridge/eth_rpc/response.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/erc20_bridge/eth_wallet.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/erc20_bridge/gas_station.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/erc20_bridge/swap_fee.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/erc20_bridge/swap_pool.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/inspect.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/liquidity_pool.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/liquidity_pool/xrc.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/memory.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/pool.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/register.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/reward.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/roles.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/spend_allowance.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/spend_allowance/key.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/spend_allowance/spend.rs (100%) rename src/{ekoke => ekoke_ledger}/src/app/test_utils.rs (100%) rename src/{ekoke => ekoke_ledger}/src/constants.rs (100%) rename src/{ekoke => ekoke_ledger}/src/http.rs (100%) rename src/{ekoke => ekoke_ledger}/src/inspect.rs (100%) rename src/{ekoke => ekoke_ledger}/src/lib.rs (100%) rename src/{ekoke => ekoke_ledger}/src/utils.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 6156c9d..a086e88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -651,7 +651,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] -name = "ekoke" +name = "ekoke_ledger" version = "0.1.0" dependencies = [ "bytes", diff --git a/Cargo.toml b/Cargo.toml index 9c283ea..1b9ad74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "src/did", "src/dip721", "src/deferred", - "src/ekoke", + "src/ekoke_ledger", "src/icrc", "src/marketplace", "src/xrc", diff --git a/Makefile.toml b/Makefile.toml index 59d25ad..ffdb387 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -52,7 +52,12 @@ args = ["fmt", "--all", "--", "--check"] [tasks.did] description = "Generate did files" -dependencies = ["deferred-did", "ekoke-did", "marketplace-did", "dfx-generate"] +dependencies = [ + "deferred-did", + "ekoke-ledger-did", + "marketplace-did", + "dfx-generate", +] workspace = false [tasks.deferred-did] @@ -60,9 +65,9 @@ description = "Generate did files for deferred" script = "cargo run --bin deferred-did --features did > src/deferred/deferred.did" workspace = false -[tasks.ekoke-did] -description = "Generate did files for ekoke" -script = "cargo run --bin ekoke-did --features did > src/ekoke/ekoke.did" +[tasks.ekoke-ledger-did] +description = "Generate did files for ekoke-ledger" +script = "cargo run --bin ekoke-ledger-did --features did > src/ekoke_ledger/ekoke-ledger.did" workspace = false [tasks.marketplace-did] @@ -78,5 +83,5 @@ workspace = false [tasks.dfx-setup] description = "setup dfx" -script = "dfx stop; dfx start --background; dfx canister create deferred; dfx canister create ekoke; dfx canister create marketplace" +script = "dfx stop; dfx start --background; dfx canister create deferred; dfx canister create ekoke-ledger; dfx canister create marketplace" workspace = false diff --git a/dfx.json b/dfx.json index 614c57f..d1d333a 100644 --- a/dfx.json +++ b/dfx.json @@ -5,9 +5,9 @@ "package": "deferred", "type": "rust" }, - "ekoke": { - "candid": "src/ekoke/ekoke.did", - "package": "ekoke", + "ekoke-ledger": { + "candid": "src/ekoke_ledger/ekoke-ledger.did", + "package": "ekoke_ledger", "type": "rust" }, "marketplace": { diff --git a/integration-tests/src/client/ekoke.rs b/integration-tests/src/client/ekoke.rs index 0bdfd1b..96e9621 100644 --- a/integration-tests/src/client/ekoke.rs +++ b/integration-tests/src/client/ekoke.rs @@ -28,7 +28,7 @@ impl<'a> EkokeClient<'a> { ) -> EkokeResult { self.env .update( - self.env.ekoke_id, + self.env.ekoke_ledger_id, from.owner, "reserve_pool", Encode!(&contract_id, &picoekoke_amount, &from.subaccount).unwrap(), @@ -39,7 +39,7 @@ impl<'a> EkokeClient<'a> { pub fn send_reward(&self, contract_id: ID, amount: PicoEkoke, to: Account) -> EkokeResult<()> { self.env .update( - self.env.ekoke_id, + self.env.ekoke_ledger_id, self.env.marketplace_id, "send_reward", Encode!(&contract_id, &amount, &to).unwrap(), diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 6c534dd..1b92e25 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -32,7 +32,7 @@ pub struct TestEnv { pub cketh_minter_id: Principal, pub ckbtc_id: Principal, pub deferred_id: Principal, - pub ekoke_id: Principal, + pub ekoke_ledger_id: Principal, pub icp_ledger_id: Principal, pub marketplace_id: Principal, pub xrc_id: Principal, @@ -103,7 +103,7 @@ impl TestEnv { let cketh_minter_id = pic.create_canister(); let xrc_id = pic.create_canister(); let deferred_id = pic.create_canister(); - let ekoke_id = pic.create_canister(); + let ekoke_ledger_id = pic.create_canister(); let marketplace_id = pic.create_canister(); // install deferred canister @@ -111,11 +111,11 @@ impl TestEnv { Self::install_icrc2(&pic, ckbtc_id, "ckBTC", "ckBTC", 8); Self::install_icrc2(&pic, cketh_ledger_id, "ckETH", "ckETH", 18); // TODO: install ckETH minter - Self::install_deferred(&pic, deferred_id, ekoke_id, marketplace_id); + Self::install_deferred(&pic, deferred_id, ekoke_ledger_id, marketplace_id); Self::install_xrc(&pic, xrc_id); - Self::install_ekoke( + Self::install_ekoke_ledger( &pic, - ekoke_id, + ekoke_ledger_id, deferred_id, marketplace_id, xrc_id, @@ -128,7 +128,7 @@ impl TestEnv { &pic, marketplace_id, deferred_id, - ekoke_id, + ekoke_ledger_id, xrc_id, icp_ledger_id, ); @@ -140,7 +140,7 @@ impl TestEnv { ckbtc_id, deferred_id, icp_ledger_id, - ekoke_id, + ekoke_ledger_id, marketplace_id, xrc_id, } @@ -229,7 +229,7 @@ impl TestEnv { fn install_deferred( pic: &PocketIc, deferred_id: Principal, - ekoke_id: Principal, + ekoke_ledger_id: Principal, marketplace_id: Principal, ) { pic.add_cycles(deferred_id, DEFAULT_CYCLES); @@ -237,7 +237,7 @@ impl TestEnv { let init_arg = DeferredInitData { custodians: vec![actor::admin()], - ekoke_canister: ekoke_id, + ekoke_ledger_canister: ekoke_ledger_id, marketplace_canister: marketplace_id, }; let init_arg = Encode!(&init_arg).unwrap(); @@ -246,9 +246,9 @@ impl TestEnv { } #[allow(clippy::too_many_arguments)] - fn install_ekoke( + fn install_ekoke_ledger( pic: &PocketIc, - ekoke_id: Principal, + ekoke_ledger_id: Principal, deferred_id: Principal, marketplace_id: Principal, xrc_canister: Principal, @@ -257,8 +257,8 @@ impl TestEnv { cketh_ledger_canister: Principal, cketh_minter_canister: Principal, ) { - pic.add_cycles(ekoke_id, DEFAULT_CYCLES); - let wasm_bytes = Self::load_wasm(Canister::Ekoke); + pic.add_cycles(ekoke_ledger_id, DEFAULT_CYCLES); + let wasm_bytes = Self::load_wasm(Canister::EkokeLedger); let init_arg = EkokeInitData { admins: vec![actor::admin()], @@ -283,14 +283,14 @@ impl TestEnv { }; let init_arg = Encode!(&init_arg).unwrap(); - pic.install_canister(ekoke_id, wasm_bytes, init_arg, None); + pic.install_canister(ekoke_ledger_id, wasm_bytes, init_arg, None); } fn install_marketplace( pic: &PocketIc, marketplace_id: Principal, deferred_id: Principal, - ekoke_id: Principal, + ekoke_ledger_id: Principal, xrc_canister: Principal, icp_ledger_canister: Principal, ) { @@ -300,7 +300,7 @@ impl TestEnv { let init_arg = MarketplaceInitData { admins: vec![actor::admin()], deferred_canister: deferred_id, - ekoke_canister: ekoke_id, + ekoke_ledger_canister: ekoke_ledger_id, xrc_canister, icp_ledger_canister, }; diff --git a/integration-tests/src/wasm.rs b/integration-tests/src/wasm.rs index 53797ef..aec20fb 100644 --- a/integration-tests/src/wasm.rs +++ b/integration-tests/src/wasm.rs @@ -18,7 +18,7 @@ pub struct Icrc2InitArgs { pub enum Canister { Deferred, - Ekoke, + EkokeLedger, Icrc2, Marketplace, Xrc, @@ -28,7 +28,9 @@ impl Canister { pub fn as_path(&self) -> &'static Path { match self { Canister::Deferred => Path::new("../.dfx/local/canisters/deferred/deferred.wasm"), - Canister::Ekoke => Path::new("../.dfx/local/canisters/ekoke/ekoke.wasm"), + Canister::EkokeLedger => { + Path::new("../.dfx/local/canisters/ekoke-ledger/ekoke-ledger.wasm") + } Canister::Marketplace => { Path::new("../.dfx/local/canisters/marketplace/marketplace.wasm") } diff --git a/integration-tests/tests/http/ekoke.rs b/integration-tests/tests/http/ekoke.rs index 465b6f8..766e3ae 100644 --- a/integration-tests/tests/http/ekoke.rs +++ b/integration-tests/tests/http/ekoke.rs @@ -7,12 +7,12 @@ use integration_tests::TestEnv; fn test_should_get_liquidity_pool_accounts_and_balance() { let env = TestEnv::init(); - let http_client = HttpClient::new(env.ekoke_id, &env); + let http_client = HttpClient::new(env.ekoke_ledger_id, &env); let liquidity_pool_accounts: LiquidityPoolAccounts = http_client.http_request("liquidityPoolAccounts", serde_json::json!({})); - assert_eq!(liquidity_pool_accounts.ckbtc.owner, env.ekoke_id); - assert_eq!(liquidity_pool_accounts.icp.owner, env.ekoke_id); + assert_eq!(liquidity_pool_accounts.ckbtc.owner, env.ekoke_ledger_id); + assert_eq!(liquidity_pool_accounts.icp.owner, env.ekoke_ledger_id); let liquidity_pool_balance: LiquidityPoolBalance = http_client.http_request("liquidityPoolBalance", serde_json::json!({})); diff --git a/integration-tests/tests/inspect/deferred.rs b/integration-tests/tests/inspect/deferred.rs index 8226814..9bf2347 100644 --- a/integration-tests/tests/inspect/deferred.rs +++ b/integration-tests/tests/inspect/deferred.rs @@ -15,7 +15,7 @@ fn test_should_inspect_is_admin() { .update::<()>( env.deferred_id, admin(), - "admin_set_ekoke_canister", + "admin_set_ekoke_ledger_canister", Encode!(&env.marketplace_id).unwrap(), ) .is_ok()); @@ -30,7 +30,7 @@ fn test_should_inspect_admin_not_admin() { .update::<()>( env.deferred_id, bob(), - "admin_set_ekoke_canister", + "admin_set_ekoke_ledger_canister", Encode!(&env.marketplace_id).unwrap(), ) .is_err()); diff --git a/integration-tests/tests/inspect/ekoke.rs b/integration-tests/tests/inspect/ekoke.rs index e5dab47..92c00b1 100644 --- a/integration-tests/tests/inspect/ekoke.rs +++ b/integration-tests/tests/inspect/ekoke.rs @@ -15,7 +15,7 @@ fn test_should_inspect_is_admin() { assert!(env .update::<()>( - env.ekoke_id, + env.ekoke_ledger_id, admin(), "admin_set_xrc_canister", Encode!(&env.xrc_id).unwrap(), @@ -30,7 +30,7 @@ fn test_should_fail_inspect_admin() { // not an admin assert!(env .update::<()>( - env.ekoke_id, + env.ekoke_ledger_id, bob(), "admin_set_xrc_canister", Encode!(&env.xrc_id).unwrap(), @@ -45,7 +45,7 @@ fn test_should_inspect_get_contract_reward() { // is deferred canister assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, env.deferred_id, "get_contract_reward", Encode!(&Nat::from(1_u64), &10u64).unwrap(), @@ -60,7 +60,7 @@ fn test_should_fail_inspect_get_contract_reward() { // is a random guy assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "get_contract_reward", Encode!(&Nat::from(1_u64), &10u64).unwrap(), @@ -87,7 +87,7 @@ fn test_should_inspect_send_reward() { // inspect send reward assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, env.marketplace_id, "send_reward", Encode!(&contract_id, &ekoke_to_picoekoke(10), &bob_account()).unwrap(), @@ -114,7 +114,7 @@ fn test_should_fail_inspect_send_reward() { // inspect send reward (fails because it's not a marketplace canister) assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "send_reward", Encode!(&contract_id, &ekoke_to_picoekoke(100), &bob_account()).unwrap(), @@ -139,7 +139,7 @@ fn test_should_inspect_icrc1_transfer() { // inspect icrc1_transfer assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc1_transfer", Encode!(&transfer).unwrap() @@ -165,7 +165,7 @@ fn test_should_fail_inspect_icrc1_transfer() { // inspect icrc1_transfer assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc1_transfer", Encode!(&transfer).unwrap() @@ -185,7 +185,7 @@ fn test_should_fail_inspect_icrc1_transfer() { // inspect icrc1_transfer assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc1_transfer", Encode!(&transfer).unwrap() @@ -205,7 +205,7 @@ fn test_should_fail_inspect_icrc1_transfer() { // inspect icrc1_transfer assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc1_transfer", Encode!(&transfer).unwrap() @@ -232,7 +232,7 @@ fn test_should_inspect_icrc2_approve() { // inspect icrc2_approve assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc2_approve", Encode!(&args).unwrap() @@ -259,7 +259,7 @@ fn test_should_fail_inspect_icrc2_approve() { assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, bob(), "icrc2_approve", Encode!(&args).unwrap() @@ -280,7 +280,7 @@ fn test_should_fail_inspect_icrc2_approve() { assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc2_approve", Encode!(&args).unwrap() @@ -301,7 +301,7 @@ fn test_should_fail_inspect_icrc2_approve() { assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc2_approve", Encode!(&args).unwrap() @@ -322,7 +322,7 @@ fn test_should_fail_inspect_icrc2_approve() { assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc2_approve", Encode!(&args).unwrap() @@ -343,7 +343,7 @@ fn test_should_fail_inspect_icrc2_approve() { assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc2_approve", Encode!(&args).unwrap() @@ -369,7 +369,7 @@ fn test_should_inspect_icrc2_transfer_from() { }; assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc2_approve", Encode!(&approve_args).unwrap() @@ -389,7 +389,7 @@ fn test_should_inspect_icrc2_transfer_from() { assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, admin(), "icrc2_transfer_from", Encode!(&args).unwrap() @@ -415,7 +415,7 @@ fn test_should_fail_inspect_icrc2_transfer_from() { }; assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, alice(), "icrc2_approve", Encode!(&approve_args).unwrap() @@ -435,7 +435,7 @@ fn test_should_fail_inspect_icrc2_transfer_from() { assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, admin(), "icrc2_transfer_from", Encode!(&args).unwrap() @@ -455,7 +455,7 @@ fn test_should_fail_inspect_icrc2_transfer_from() { assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, admin(), "icrc2_transfer_from", Encode!(&args).unwrap() @@ -475,7 +475,7 @@ fn test_should_fail_inspect_icrc2_transfer_from() { assert!(env .update::>( - env.ekoke_id, + env.ekoke_ledger_id, admin(), "icrc2_transfer_from", Encode!(&args).unwrap() diff --git a/integration-tests/tests/use_case/buy_marketplace_nft.rs b/integration-tests/tests/use_case/buy_marketplace_nft.rs index bed5451..a092c0d 100644 --- a/integration-tests/tests/use_case/buy_marketplace_nft.rs +++ b/integration-tests/tests/use_case/buy_marketplace_nft.rs @@ -13,7 +13,7 @@ fn test_should_buy_marketplace_nft_as_non_contract_buyer() { let deferred_client = DeferredClient::from(&env); let marketplace_client = MarketplaceClient::from(&env); - let ekoke_ledger_client = IcrcLedgerClient::new(env.ekoke_id, &env); + let ekoke_ledger_client = IcrcLedgerClient::new(env.ekoke_ledger_id, &env); let icp_ledger_client = IcrcLedgerClient::new(env.icp_ledger_id, &env); // get initial ekoke balance for charlie @@ -29,16 +29,17 @@ fn test_should_buy_marketplace_nft_as_non_contract_buyer() { assert_ne!(icp_price, 0); // approve on icp ledger client a spend for token price to marketplace canister - assert!(icp_ledger_client + let allowance = icp_ledger_client .icrc2_approve( charlie(), Account::from(env.marketplace_id), icp_price.into(), - None + charlie_account().subaccount, ) - .is_ok()); + .unwrap(); + assert_eq!(icp_price, allowance); let allowance = - icp_ledger_client.icrc2_allowance(alice_account(), Account::from(env.marketplace_id)); + icp_ledger_client.icrc2_allowance(charlie_account(), Account::from(env.marketplace_id)); assert_eq!(icp_price, allowance.allowance); // buy token @@ -64,7 +65,7 @@ fn test_should_buy_marketplace_nft_as_contract_buyer() { let deferred_client = DeferredClient::from(&env); let marketplace_client = MarketplaceClient::from(&env); - let ekoke_ledger_client = IcrcLedgerClient::new(env.ekoke_id, &env); + let ekoke_ledger_client = IcrcLedgerClient::new(env.ekoke_ledger_id, &env); let icp_ledger_client = IcrcLedgerClient::new(env.icp_ledger_id, &env); // get initial ekoke balance for charlie diff --git a/integration-tests/tests/use_case/icrc2_spend.rs b/integration-tests/tests/use_case/icrc2_spend.rs index a0d25a5..8e974f0 100644 --- a/integration-tests/tests/use_case/icrc2_spend.rs +++ b/integration-tests/tests/use_case/icrc2_spend.rs @@ -10,7 +10,7 @@ fn test_should_spend_approved_funds_on_ekoke() { const EKOKE_FEE: u64 = 10_000; let env = TestEnv::init(); - let ekoke_client = IcrcLedgerClient::new(env.ekoke_id, &env); + let ekoke_client = IcrcLedgerClient::new(env.ekoke_ledger_id, &env); let amount = Nat::from(1_000u64); let allowance = amount.clone() + EKOKE_FEE; let total_spent_by_alice = allowance.clone() + EKOKE_FEE; // Fee is paid for approval as well diff --git a/scripts/deploy_functions.sh b/scripts/deploy_functions.sh index 61e7888..94eb525 100644 --- a/scripts/deploy_functions.sh +++ b/scripts/deploy_functions.sh @@ -6,14 +6,14 @@ deploy_deferred() {\ INSTALL_MODE="$1" NETWORK="$2" DEFERRED_PRINCIPAL="$3" - EKOKE_PRINCIPAL="$4" + EKOKE_LEDGER_PRINCIPAL="$4" MARKETPLACE_PRINCIPAL="$5" ADMIN_PRINCIPAL="$6" echo "deploying deferred canister $DEFERRED_PRINCIPAL" deferred_init_args="(record { - ekoke_canister = principal \"$EKOKE_PRINCIPAL\"; + ekoke_ledger_canister = principal \"$EKOKE_LEDGER_PRINCIPAL\"; marketplace_canister = principal \"$MARKETPLACE_PRINCIPAL\"; custodians = vec { principal \"$ADMIN_PRINCIPAL\" }; })" @@ -25,7 +25,7 @@ deploy_deferred() {\ deploy_ekoke() { INSTALL_MODE="$1" NETWORK="$2" - EKOKE_PRINCIPAL="$3" + EKOKE_LEDGER_PRINCIPAL="$3" ADMINS="$4" TOTAL_SUPPLY="$5" INITIAL_BALANCES="$6" @@ -37,7 +37,7 @@ deploy_ekoke() { ERC20_SWAP_FEE="${12}" ERC20_NETWORK="${13}" - echo "deploying ekoke canister $EKOKE_PRINCIPAL" + echo "deploying ekoke canister $EKOKE_LEDGER_PRINCIPAL" ekoke_init_args="(record { deferred_canister = principal \"$DEFERRED_PRINCIPAL\"; @@ -66,14 +66,14 @@ deploy_marketplace() { NETWORK="$2" MARKETPLACE_PRINCIPAL="$3" DEFERRED_PRINCIPAL="$4" - EKOKE_PRINCIPAL="$5" + EKOKE_LEDGER_PRINCIPAL="$5" ADMINS="$6" echo "deploying marketplace canister $MARKETPLACE_PRINCIPAL" marketplace_init_args="(record { deferred_canister = principal \"$DEFERRED_PRINCIPAL\"; - ekoke_canister = principal \"$EKOKE_PRINCIPAL\"; + ekoke_ledger_canister = principal \"$EKOKE_LEDGER_PRINCIPAL\"; xrc_canister = principal \"uf6dk-hyaaa-aaaaq-qaaaq-cai\"; admins = vec { $(for admin in $ADMINS; do echo "principal \"$admin\";"; done) }; icp_ledger_canister = principal \"ryjl3-tyaaa-aaaaa-aaaba-cai\"; diff --git a/scripts/deploy_local.sh b/scripts/deploy_local.sh index 06fe2b4..464d52a 100755 --- a/scripts/deploy_local.sh +++ b/scripts/deploy_local.sh @@ -4,7 +4,7 @@ cd "$(dirname "$0")" || exit 1 CANISTER_IDS="../.dfx/local/canister_ids.json" DEFERRED_PRINCIPAL="$(cat "$CANISTER_IDS" | jq -r '.deferred.local')" -EKOKE_PRINCIPAL="$(cat "$CANISTER_IDS" | jq -r '.ekoke.local')" +EKOKE_LEDGER_PRINCIPAL="$(cat "$CANISTER_IDS" | jq -r '.ekoke.local')" MARKETPLACE_PRINCIPAL="$(cat "$CANISTER_IDS" | jq -r '.marketplace.local')" source ./deploy_functions.sh @@ -24,9 +24,9 @@ dfx start --background cd ../ -deploy_deferred "reinstall" "local" "$DEFERRED_PRINCIPAL" "$EKOKE_PRINCIPAL" "$MARKETPLACE_PRINCIPAL" "$ADMIN_PRINCIPAL" -deploy_ekoke "reinstall" "local" "$EKOKE_PRINCIPAL" "$ADMIN_PRINCIPAL" "$INITIAL_SUPPLY" "$EKOKE_INITIAL_BALANCES" "$DEFERRED_PRINCIPAL" "$MARKETPLACE_PRINCIPAL" "$SWAP_ACCOUNT" "$EKOKE_MINTING_ACCOUNT" "$ERC20_BRIDGE_ADDRESS" "$ERC20_SWAP_FEE" "$ERC20_NETWORK" -deploy_marketplace "reinstall" "local" "$MARKETPLACE_PRINCIPAL" "$DEFERRED_PRINCIPAL" "$EKOKE_PRINCIPAL" "$ADMIN_PRINCIPAL" +deploy_deferred "reinstall" "local" "$DEFERRED_PRINCIPAL" "$EKOKE_LEDGER_PRINCIPAL" "$MARKETPLACE_PRINCIPAL" "$ADMIN_PRINCIPAL" +deploy_ekoke "reinstall" "local" "$EKOKE_LEDGER_PRINCIPAL" "$ADMIN_PRINCIPAL" "$INITIAL_SUPPLY" "$EKOKE_INITIAL_BALANCES" "$DEFERRED_PRINCIPAL" "$MARKETPLACE_PRINCIPAL" "$SWAP_ACCOUNT" "$EKOKE_MINTING_ACCOUNT" "$ERC20_BRIDGE_ADDRESS" "$ERC20_SWAP_FEE" "$ERC20_NETWORK" +deploy_marketplace "reinstall" "local" "$MARKETPLACE_PRINCIPAL" "$DEFERRED_PRINCIPAL" "$EKOKE_LEDGER_PRINCIPAL" "$ADMIN_PRINCIPAL" dfx stop diff --git a/scripts/integration-tests.sh b/scripts/integration-tests.sh index 41842cd..3a06daa 100755 --- a/scripts/integration-tests.sh +++ b/scripts/integration-tests.sh @@ -1,8 +1,9 @@ #!/bin/bash cargo test --test integration_tests $@ +RC=$? killall pocket-ic || true rm -rf /tmp/.tmp* || true -exit 0 +exit $RC diff --git a/src/declarations/deferred/deferred.did.d.ts b/src/declarations/deferred/deferred.did.d.ts index 8143ac4..5bc0aee 100644 --- a/src/declarations/deferred/deferred.did.d.ts +++ b/src/declarations/deferred/deferred.did.d.ts @@ -80,8 +80,8 @@ export type DeferredError = { 'Nft' : NftError } | { 'StorageError' : null } | { 'CanisterCall' : [RejectionCode, string] }; export interface DeferredInitData { - 'ekoke_canister' : Principal, 'custodians' : Array, + 'ekoke_ledger_canister' : Principal, 'marketplace_canister' : Principal, } export type EcdsaError = { 'RecoveryIdError' : null } | @@ -289,7 +289,7 @@ export interface _SERVICE { 'admin_get_unsigned_contracts' : ActorMethod<[], Array>, 'admin_register_agency' : ActorMethod<[Principal, Agency], undefined>, 'admin_remove_role' : ActorMethod<[Principal, Role], Result>, - 'admin_set_ekoke_canister' : ActorMethod<[Principal], undefined>, + 'admin_set_ekoke_ledger_canister' : ActorMethod<[Principal], undefined>, 'admin_set_marketplace_canister' : ActorMethod<[Principal], undefined>, 'admin_set_role' : ActorMethod<[Principal, Role], undefined>, 'admin_sign_contract' : ActorMethod<[bigint], Result>, diff --git a/src/declarations/deferred/deferred.did.js b/src/declarations/deferred/deferred.did.js index bfc3614..cc82600 100644 --- a/src/declarations/deferred/deferred.did.js +++ b/src/declarations/deferred/deferred.did.js @@ -1,8 +1,8 @@ export const idlFactory = ({ IDL }) => { const Vec = IDL.Rec(); const DeferredInitData = IDL.Record({ - 'ekoke_canister' : IDL.Principal, 'custodians' : IDL.Vec(IDL.Principal), + 'ekoke_ledger_canister' : IDL.Principal, 'marketplace_canister' : IDL.Principal, }); const Continent = IDL.Variant({ @@ -333,7 +333,7 @@ export const idlFactory = ({ IDL }) => { ), 'admin_register_agency' : IDL.Func([IDL.Principal, Agency], [], []), 'admin_remove_role' : IDL.Func([IDL.Principal, Role], [Result], []), - 'admin_set_ekoke_canister' : IDL.Func([IDL.Principal], [], []), + 'admin_set_ekoke_ledger_canister' : IDL.Func([IDL.Principal], [], []), 'admin_set_marketplace_canister' : IDL.Func([IDL.Principal], [], []), 'admin_set_role' : IDL.Func([IDL.Principal, Role], [], []), 'admin_sign_contract' : IDL.Func([IDL.Nat], [Result], []), @@ -426,8 +426,8 @@ export const idlFactory = ({ IDL }) => { }; export const init = ({ IDL }) => { const DeferredInitData = IDL.Record({ - 'ekoke_canister' : IDL.Principal, 'custodians' : IDL.Vec(IDL.Principal), + 'ekoke_ledger_canister' : IDL.Principal, 'marketplace_canister' : IDL.Principal, }); return [DeferredInitData]; diff --git a/src/declarations/ekoke-ledger/ekoke-ledger.did.d.ts b/src/declarations/ekoke-ledger/ekoke-ledger.did.d.ts new file mode 100644 index 0000000..0006129 --- /dev/null +++ b/src/declarations/ekoke-ledger/ekoke-ledger.did.d.ts @@ -0,0 +1,231 @@ +import type { Principal } from '@dfinity/principal'; +import type { ActorMethod } from '@dfinity/agent'; +import type { IDL } from '@dfinity/candid'; + +export interface Account { + 'owner' : Principal, + 'subaccount' : [] | [Uint8Array | number[]], +} +export interface Allowance { + 'allowance' : bigint, + 'expires_at' : [] | [bigint], +} +export interface AllowanceArgs { 'account' : Account, 'spender' : Account } +export type AllowanceError = { 'AllowanceNotFound' : null } | + { 'BadSpender' : null } | + { 'AllowanceChanged' : null } | + { 'BadExpiration' : null } | + { 'AllowanceExpired' : null } | + { 'InsufficientFunds' : null }; +export interface ApproveArgs { + 'fee' : [] | [bigint], + 'memo' : [] | [Uint8Array | number[]], + 'from_subaccount' : [] | [Uint8Array | number[]], + 'created_at_time' : [] | [bigint], + 'amount' : bigint, + 'expected_allowance' : [] | [bigint], + 'expires_at' : [] | [bigint], + 'spender' : Account, +} +export type ApproveError = { + 'GenericError' : { 'message' : string, 'error_code' : bigint } + } | + { 'TemporarilyUnavailable' : null } | + { 'Duplicate' : { 'duplicate_of' : bigint } } | + { 'BadFee' : { 'expected_fee' : bigint } } | + { 'AllowanceChanged' : { 'current_allowance' : bigint } } | + { 'CreatedInFuture' : { 'ledger_time' : bigint } } | + { 'TooOld' : null } | + { 'Expired' : { 'ledger_time' : bigint } } | + { 'InsufficientFunds' : { 'balance' : bigint } }; +export type BalanceError = { 'AccountNotFound' : null } | + { 'InsufficientBalance' : null }; +export type ConfigurationError = { 'AdminsCantBeEmpty' : null } | + { 'AnonymousAdmin' : null }; +export type EcdsaError = { 'RecoveryIdError' : null } | + { 'InvalidSignature' : null } | + { 'InvalidPublicKey' : null }; +export type EkokeError = { 'Configuration' : ConfigurationError } | + { 'Icrc2Approve' : ApproveError } | + { 'Icrc1Transfer' : TransferError } | + { 'Pool' : PoolError } | + { 'Allowance' : AllowanceError } | + { 'Register' : RegisterError } | + { 'EthRpcError' : [number, string] } | + { 'XrcError' : null } | + { 'StorageError' : null } | + { 'CanisterCall' : [RejectionCode, string] } | + { 'Balance' : BalanceError } | + { 'Icrc2Transfer' : TransferFromError } | + { 'Ecdsa' : EcdsaError }; +export interface EkokeInitData { + 'deferred_canister' : Principal, + 'icp_ledger_canister' : Principal, + 'cketh_ledger_canister' : Principal, + 'minting_account' : Account, + 'ckbtc_canister' : Principal, + 'erc20_bridge_address' : string, + 'erc20_network' : EthNetwork, + 'initial_balances' : Array<[Account, bigint]>, + 'swap_account' : Account, + 'xrc_canister' : Principal, + 'marketplace_canister' : Principal, + 'admins' : Array, + 'erc20_gas_price' : bigint, + 'cketh_minter_canister' : Principal, + 'total_supply' : bigint, +} +export type EthNetwork = { 'Ethereum' : null } | + { 'Goerli' : null } | + { 'Sepolia' : null }; +export interface HttpHeader { 'value' : string, 'name' : string } +export interface HttpRequest { + 'url' : string, + 'method' : string, + 'body' : Uint8Array | number[], + 'headers' : Array<[string, string]>, +} +export interface HttpResponse { + 'body' : Uint8Array | number[], + 'headers' : Array<[string, string]>, + 'upgrade' : [] | [boolean], + 'status_code' : number, +} +export interface HttpResponse_1 { + 'status' : bigint, + 'body' : Uint8Array | number[], + 'headers' : Array, +} +export interface LiquidityPoolAccounts { 'icp' : Account, 'ckbtc' : Account } +export interface LiquidityPoolBalance { 'icp' : bigint, 'ckbtc' : bigint } +export type MetadataValue = { 'Int' : bigint } | + { 'Nat' : bigint } | + { 'Blob' : Uint8Array | number[] } | + { 'Text' : string }; +export type PoolError = { 'PoolNotFound' : bigint } | + { 'NotEnoughTokens' : null }; +export type RegisterError = { 'TransactionNotFound' : null }; +export type RejectionCode = { 'NoError' : null } | + { 'CanisterError' : null } | + { 'SysTransient' : null } | + { 'DestinationInvalid' : null } | + { 'Unknown' : null } | + { 'SysFatal' : null } | + { 'CanisterReject' : null }; +export type Result = { 'Ok' : null } | + { 'Err' : EkokeError }; +export type Result_1 = { 'Ok' : string } | + { 'Err' : EkokeError }; +export type Result_2 = { 'Ok' : bigint } | + { 'Err' : EkokeError }; +export type Result_3 = { 'Ok' : bigint } | + { 'Err' : EkokeError }; +export type Result_4 = { 'Ok' : Transaction } | + { 'Err' : EkokeError }; +export type Result_5 = { 'Ok' : bigint } | + { 'Err' : TransferError }; +export type Result_6 = { 'Ok' : bigint } | + { 'Err' : ApproveError }; +export type Result_7 = { 'Ok' : bigint } | + { 'Err' : TransferFromError }; +export type Result_8 = { 'Ok' : LiquidityPoolBalance } | + { 'Err' : EkokeError }; +export type Role = { 'DeferredCanister' : null } | + { 'MarketplaceCanister' : null } | + { 'Admin' : null }; +export interface TokenExtension { 'url' : string, 'name' : string } +export interface Transaction { + 'to' : Account, + 'fee' : bigint, + 'from' : Account, + 'memo' : [] | [Uint8Array | number[]], + 'created_at' : bigint, + 'amount' : bigint, +} +export interface TransferArg { + 'to' : Account, + 'fee' : [] | [bigint], + 'memo' : [] | [Uint8Array | number[]], + 'from_subaccount' : [] | [Uint8Array | number[]], + 'created_at_time' : [] | [bigint], + 'amount' : bigint, +} +export type TransferError = { + 'GenericError' : { 'message' : string, 'error_code' : bigint } + } | + { 'TemporarilyUnavailable' : null } | + { 'BadBurn' : { 'min_burn_amount' : bigint } } | + { 'Duplicate' : { 'duplicate_of' : bigint } } | + { 'BadFee' : { 'expected_fee' : bigint } } | + { 'CreatedInFuture' : { 'ledger_time' : bigint } } | + { 'TooOld' : null } | + { 'InsufficientFunds' : { 'balance' : bigint } }; +export interface TransferFromArgs { + 'to' : Account, + 'fee' : [] | [bigint], + 'spender_subaccount' : [] | [Uint8Array | number[]], + 'from' : Account, + 'memo' : [] | [Uint8Array | number[]], + 'created_at_time' : [] | [bigint], + 'amount' : bigint, +} +export type TransferFromError = { + 'GenericError' : { 'message' : string, 'error_code' : bigint } + } | + { 'TemporarilyUnavailable' : null } | + { 'InsufficientAllowance' : { 'allowance' : bigint } } | + { 'BadBurn' : { 'min_burn_amount' : bigint } } | + { 'Duplicate' : { 'duplicate_of' : bigint } } | + { 'BadFee' : { 'expected_fee' : bigint } } | + { 'CreatedInFuture' : { 'ledger_time' : bigint } } | + { 'TooOld' : null } | + { 'InsufficientFunds' : { 'balance' : bigint } }; +export interface TransformArgs { + 'context' : Uint8Array | number[], + 'response' : HttpResponse_1, +} +export interface _SERVICE { + 'admin_burn' : ActorMethod<[bigint], Result>, + 'admin_cycles' : ActorMethod<[], bigint>, + 'admin_eth_wallet_address' : ActorMethod<[], string>, + 'admin_remove_role' : ActorMethod<[Principal, Role], Result>, + 'admin_set_ckbtc_canister' : ActorMethod<[Principal], undefined>, + 'admin_set_cketh_ledger_canister' : ActorMethod<[Principal], undefined>, + 'admin_set_cketh_minter_canister' : ActorMethod<[Principal], undefined>, + 'admin_set_erc20_bridge_address' : ActorMethod<[string], undefined>, + 'admin_set_erc20_gas_price' : ActorMethod<[bigint], undefined>, + 'admin_set_icp_ledger_canister' : ActorMethod<[Principal], undefined>, + 'admin_set_role' : ActorMethod<[Principal, Role], undefined>, + 'admin_set_swap_account' : ActorMethod<[Account], undefined>, + 'admin_set_xrc_canister' : ActorMethod<[Principal], undefined>, + 'erc20_swap' : ActorMethod< + [string, bigint, [] | [Uint8Array | number[]]], + Result_1 + >, + 'erc20_swap_fee' : ActorMethod<[], Result_2>, + 'get_contract_reward' : ActorMethod<[bigint, bigint], Result_3>, + 'get_transaction' : ActorMethod<[bigint], Result_4>, + 'http_request' : ActorMethod<[HttpRequest], HttpResponse>, + 'http_transform_send_tx' : ActorMethod<[TransformArgs], HttpResponse_1>, + 'icrc1_balance_of' : ActorMethod<[Account], bigint>, + 'icrc1_decimals' : ActorMethod<[], number>, + 'icrc1_fee' : ActorMethod<[], bigint>, + 'icrc1_metadata' : ActorMethod<[], Array<[string, MetadataValue]>>, + 'icrc1_name' : ActorMethod<[], string>, + 'icrc1_supported_standards' : ActorMethod<[], Array>, + 'icrc1_symbol' : ActorMethod<[], string>, + 'icrc1_total_supply' : ActorMethod<[], bigint>, + 'icrc1_transfer' : ActorMethod<[TransferArg], Result_5>, + 'icrc2_allowance' : ActorMethod<[AllowanceArgs], Allowance>, + 'icrc2_approve' : ActorMethod<[ApproveArgs], Result_6>, + 'icrc2_transfer_from' : ActorMethod<[TransferFromArgs], Result_7>, + 'liquidity_pool_accounts' : ActorMethod<[], LiquidityPoolAccounts>, + 'liquidity_pool_balance' : ActorMethod<[], Result_8>, + 'reserve_pool' : ActorMethod< + [bigint, bigint, [] | [Uint8Array | number[]]], + Result_3 + >, + 'send_reward' : ActorMethod<[bigint, bigint, Account], Result>, +} +export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/src/declarations/ekoke-ledger/ekoke-ledger.did.js b/src/declarations/ekoke-ledger/ekoke-ledger.did.js new file mode 100644 index 0000000..3ab264b --- /dev/null +++ b/src/declarations/ekoke-ledger/ekoke-ledger.did.js @@ -0,0 +1,306 @@ +export const idlFactory = ({ IDL }) => { + const Account = IDL.Record({ + 'owner' : IDL.Principal, + 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)), + }); + const EthNetwork = IDL.Variant({ + 'Ethereum' : IDL.Null, + 'Goerli' : IDL.Null, + 'Sepolia' : IDL.Null, + }); + const EkokeInitData = IDL.Record({ + 'deferred_canister' : IDL.Principal, + 'icp_ledger_canister' : IDL.Principal, + 'cketh_ledger_canister' : IDL.Principal, + 'minting_account' : Account, + 'ckbtc_canister' : IDL.Principal, + 'erc20_bridge_address' : IDL.Text, + 'erc20_network' : EthNetwork, + 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)), + 'swap_account' : Account, + 'xrc_canister' : IDL.Principal, + 'marketplace_canister' : IDL.Principal, + 'admins' : IDL.Vec(IDL.Principal), + 'erc20_gas_price' : IDL.Nat64, + 'cketh_minter_canister' : IDL.Principal, + 'total_supply' : IDL.Nat, + }); + const ConfigurationError = IDL.Variant({ + 'AdminsCantBeEmpty' : IDL.Null, + 'AnonymousAdmin' : IDL.Null, + }); + const ApproveError = IDL.Variant({ + 'GenericError' : IDL.Record({ + 'message' : IDL.Text, + 'error_code' : IDL.Nat, + }), + 'TemporarilyUnavailable' : IDL.Null, + 'Duplicate' : IDL.Record({ 'duplicate_of' : IDL.Nat }), + 'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }), + 'AllowanceChanged' : IDL.Record({ 'current_allowance' : IDL.Nat }), + 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }), + 'TooOld' : IDL.Null, + 'Expired' : IDL.Record({ 'ledger_time' : IDL.Nat64 }), + 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }), + }); + const TransferError = IDL.Variant({ + 'GenericError' : IDL.Record({ + 'message' : IDL.Text, + 'error_code' : IDL.Nat, + }), + 'TemporarilyUnavailable' : IDL.Null, + 'BadBurn' : IDL.Record({ 'min_burn_amount' : IDL.Nat }), + 'Duplicate' : IDL.Record({ 'duplicate_of' : IDL.Nat }), + 'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }), + 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }), + 'TooOld' : IDL.Null, + 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }), + }); + const PoolError = IDL.Variant({ + 'PoolNotFound' : IDL.Nat, + 'NotEnoughTokens' : IDL.Null, + }); + const AllowanceError = IDL.Variant({ + 'AllowanceNotFound' : IDL.Null, + 'BadSpender' : IDL.Null, + 'AllowanceChanged' : IDL.Null, + 'BadExpiration' : IDL.Null, + 'AllowanceExpired' : IDL.Null, + 'InsufficientFunds' : IDL.Null, + }); + const RegisterError = IDL.Variant({ 'TransactionNotFound' : IDL.Null }); + const RejectionCode = IDL.Variant({ + 'NoError' : IDL.Null, + 'CanisterError' : IDL.Null, + 'SysTransient' : IDL.Null, + 'DestinationInvalid' : IDL.Null, + 'Unknown' : IDL.Null, + 'SysFatal' : IDL.Null, + 'CanisterReject' : IDL.Null, + }); + const BalanceError = IDL.Variant({ + 'AccountNotFound' : IDL.Null, + 'InsufficientBalance' : IDL.Null, + }); + const TransferFromError = IDL.Variant({ + 'GenericError' : IDL.Record({ + 'message' : IDL.Text, + 'error_code' : IDL.Nat, + }), + 'TemporarilyUnavailable' : IDL.Null, + 'InsufficientAllowance' : IDL.Record({ 'allowance' : IDL.Nat }), + 'BadBurn' : IDL.Record({ 'min_burn_amount' : IDL.Nat }), + 'Duplicate' : IDL.Record({ 'duplicate_of' : IDL.Nat }), + 'BadFee' : IDL.Record({ 'expected_fee' : IDL.Nat }), + 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }), + 'TooOld' : IDL.Null, + 'InsufficientFunds' : IDL.Record({ 'balance' : IDL.Nat }), + }); + const EcdsaError = IDL.Variant({ + 'RecoveryIdError' : IDL.Null, + 'InvalidSignature' : IDL.Null, + 'InvalidPublicKey' : IDL.Null, + }); + const EkokeError = IDL.Variant({ + 'Configuration' : ConfigurationError, + 'Icrc2Approve' : ApproveError, + 'Icrc1Transfer' : TransferError, + 'Pool' : PoolError, + 'Allowance' : AllowanceError, + 'Register' : RegisterError, + 'EthRpcError' : IDL.Tuple(IDL.Int32, IDL.Text), + 'XrcError' : IDL.Null, + 'StorageError' : IDL.Null, + 'CanisterCall' : IDL.Tuple(RejectionCode, IDL.Text), + 'Balance' : BalanceError, + 'Icrc2Transfer' : TransferFromError, + 'Ecdsa' : EcdsaError, + }); + const Result = IDL.Variant({ 'Ok' : IDL.Null, 'Err' : EkokeError }); + const Role = IDL.Variant({ + 'DeferredCanister' : IDL.Null, + 'MarketplaceCanister' : IDL.Null, + 'Admin' : IDL.Null, + }); + const Result_1 = IDL.Variant({ 'Ok' : IDL.Text, 'Err' : EkokeError }); + const Result_2 = IDL.Variant({ 'Ok' : IDL.Nat64, 'Err' : EkokeError }); + const Result_3 = IDL.Variant({ 'Ok' : IDL.Nat, 'Err' : EkokeError }); + const Transaction = IDL.Record({ + 'to' : Account, + 'fee' : IDL.Nat, + 'from' : Account, + 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'created_at' : IDL.Nat64, + 'amount' : IDL.Nat, + }); + const Result_4 = IDL.Variant({ 'Ok' : Transaction, 'Err' : EkokeError }); + const HttpRequest = IDL.Record({ + 'url' : IDL.Text, + 'method' : IDL.Text, + 'body' : IDL.Vec(IDL.Nat8), + 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + }); + const HttpResponse = IDL.Record({ + 'body' : IDL.Vec(IDL.Nat8), + 'headers' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)), + 'upgrade' : IDL.Opt(IDL.Bool), + 'status_code' : IDL.Nat16, + }); + const HttpHeader = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text }); + const HttpResponse_1 = IDL.Record({ + 'status' : IDL.Nat, + 'body' : IDL.Vec(IDL.Nat8), + 'headers' : IDL.Vec(HttpHeader), + }); + const TransformArgs = IDL.Record({ + 'context' : IDL.Vec(IDL.Nat8), + 'response' : HttpResponse_1, + }); + const MetadataValue = IDL.Variant({ + 'Int' : IDL.Int, + 'Nat' : IDL.Nat, + 'Blob' : IDL.Vec(IDL.Nat8), + 'Text' : IDL.Text, + }); + const TokenExtension = IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text }); + const TransferArg = IDL.Record({ + 'to' : Account, + 'fee' : IDL.Opt(IDL.Nat), + 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'created_at_time' : IDL.Opt(IDL.Nat64), + 'amount' : IDL.Nat, + }); + const Result_5 = IDL.Variant({ 'Ok' : IDL.Nat, 'Err' : TransferError }); + const AllowanceArgs = IDL.Record({ + 'account' : Account, + 'spender' : Account, + }); + const Allowance = IDL.Record({ + 'allowance' : IDL.Nat, + 'expires_at' : IDL.Opt(IDL.Nat64), + }); + const ApproveArgs = IDL.Record({ + 'fee' : IDL.Opt(IDL.Nat), + 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'from_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'created_at_time' : IDL.Opt(IDL.Nat64), + 'amount' : IDL.Nat, + 'expected_allowance' : IDL.Opt(IDL.Nat), + 'expires_at' : IDL.Opt(IDL.Nat64), + 'spender' : Account, + }); + const Result_6 = IDL.Variant({ 'Ok' : IDL.Nat, 'Err' : ApproveError }); + const TransferFromArgs = IDL.Record({ + 'to' : Account, + 'fee' : IDL.Opt(IDL.Nat), + 'spender_subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'from' : Account, + 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'created_at_time' : IDL.Opt(IDL.Nat64), + 'amount' : IDL.Nat, + }); + const Result_7 = IDL.Variant({ 'Ok' : IDL.Nat, 'Err' : TransferFromError }); + const LiquidityPoolAccounts = IDL.Record({ + 'icp' : Account, + 'ckbtc' : Account, + }); + const LiquidityPoolBalance = IDL.Record({ + 'icp' : IDL.Nat, + 'ckbtc' : IDL.Nat, + }); + const Result_8 = IDL.Variant({ + 'Ok' : LiquidityPoolBalance, + 'Err' : EkokeError, + }); + return IDL.Service({ + 'admin_burn' : IDL.Func([IDL.Nat], [Result], []), + 'admin_cycles' : IDL.Func([], [IDL.Nat], ['query']), + 'admin_eth_wallet_address' : IDL.Func([], [IDL.Text], ['query']), + 'admin_remove_role' : IDL.Func([IDL.Principal, Role], [Result], []), + 'admin_set_ckbtc_canister' : IDL.Func([IDL.Principal], [], []), + 'admin_set_cketh_ledger_canister' : IDL.Func([IDL.Principal], [], []), + 'admin_set_cketh_minter_canister' : IDL.Func([IDL.Principal], [], []), + 'admin_set_erc20_bridge_address' : IDL.Func([IDL.Text], [], []), + 'admin_set_erc20_gas_price' : IDL.Func([IDL.Nat64], [], []), + 'admin_set_icp_ledger_canister' : IDL.Func([IDL.Principal], [], []), + 'admin_set_role' : IDL.Func([IDL.Principal, Role], [], []), + 'admin_set_swap_account' : IDL.Func([Account], [], []), + 'admin_set_xrc_canister' : IDL.Func([IDL.Principal], [], []), + 'erc20_swap' : IDL.Func( + [IDL.Text, IDL.Nat, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_1], + [], + ), + 'erc20_swap_fee' : IDL.Func([], [Result_2], []), + 'get_contract_reward' : IDL.Func([IDL.Nat, IDL.Nat64], [Result_3], []), + 'get_transaction' : IDL.Func([IDL.Nat64], [Result_4], ['query']), + 'http_request' : IDL.Func([HttpRequest], [HttpResponse], ['query']), + 'http_transform_send_tx' : IDL.Func( + [TransformArgs], + [HttpResponse_1], + ['query'], + ), + 'icrc1_balance_of' : IDL.Func([Account], [IDL.Nat], ['query']), + 'icrc1_decimals' : IDL.Func([], [IDL.Nat8], ['query']), + 'icrc1_fee' : IDL.Func([], [IDL.Nat], ['query']), + 'icrc1_metadata' : IDL.Func( + [], + [IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))], + ['query'], + ), + 'icrc1_name' : IDL.Func([], [IDL.Text], ['query']), + 'icrc1_supported_standards' : IDL.Func( + [], + [IDL.Vec(TokenExtension)], + ['query'], + ), + 'icrc1_symbol' : IDL.Func([], [IDL.Text], ['query']), + 'icrc1_total_supply' : IDL.Func([], [IDL.Nat], ['query']), + 'icrc1_transfer' : IDL.Func([TransferArg], [Result_5], []), + 'icrc2_allowance' : IDL.Func([AllowanceArgs], [Allowance], ['query']), + 'icrc2_approve' : IDL.Func([ApproveArgs], [Result_6], []), + 'icrc2_transfer_from' : IDL.Func([TransferFromArgs], [Result_7], []), + 'liquidity_pool_accounts' : IDL.Func( + [], + [LiquidityPoolAccounts], + ['query'], + ), + 'liquidity_pool_balance' : IDL.Func([], [Result_8], ['query']), + 'reserve_pool' : IDL.Func( + [IDL.Nat, IDL.Nat, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_3], + [], + ), + 'send_reward' : IDL.Func([IDL.Nat, IDL.Nat, Account], [Result], []), + }); +}; +export const init = ({ IDL }) => { + const Account = IDL.Record({ + 'owner' : IDL.Principal, + 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)), + }); + const EthNetwork = IDL.Variant({ + 'Ethereum' : IDL.Null, + 'Goerli' : IDL.Null, + 'Sepolia' : IDL.Null, + }); + const EkokeInitData = IDL.Record({ + 'deferred_canister' : IDL.Principal, + 'icp_ledger_canister' : IDL.Principal, + 'cketh_ledger_canister' : IDL.Principal, + 'minting_account' : Account, + 'ckbtc_canister' : IDL.Principal, + 'erc20_bridge_address' : IDL.Text, + 'erc20_network' : EthNetwork, + 'initial_balances' : IDL.Vec(IDL.Tuple(Account, IDL.Nat)), + 'swap_account' : Account, + 'xrc_canister' : IDL.Principal, + 'marketplace_canister' : IDL.Principal, + 'admins' : IDL.Vec(IDL.Principal), + 'erc20_gas_price' : IDL.Nat64, + 'cketh_minter_canister' : IDL.Principal, + 'total_supply' : IDL.Nat, + }); + return [EkokeInitData]; +}; diff --git a/src/declarations/ekoke-ledger/index.d.ts b/src/declarations/ekoke-ledger/index.d.ts new file mode 100644 index 0000000..e97f046 --- /dev/null +++ b/src/declarations/ekoke-ledger/index.d.ts @@ -0,0 +1,50 @@ +import type { + ActorSubclass, + HttpAgentOptions, + ActorConfig, + Agent, +} from "@dfinity/agent"; +import type { Principal } from "@dfinity/principal"; +import type { IDL } from "@dfinity/candid"; + +import { _SERVICE } from './ekoke-ledger.did'; + +export declare const idlFactory: IDL.InterfaceFactory; +export declare const canisterId: string; + +export declare interface CreateActorOptions { + /** + * @see {@link Agent} + */ + agent?: Agent; + /** + * @see {@link HttpAgentOptions} + */ + agentOptions?: HttpAgentOptions; + /** + * @see {@link ActorConfig} + */ + actorOptions?: ActorConfig; +} + +/** + * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. + * @constructs {@link ActorSubClass} + * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to + * @param {CreateActorOptions} options - see {@link CreateActorOptions} + * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions + * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent + * @see {@link HttpAgentOptions} + * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor + * @see {@link ActorConfig} + */ +export declare const createActor: ( + canisterId: string | Principal, + options?: CreateActorOptions +) => ActorSubclass<_SERVICE>; + +/** + * Intialized Actor using default settings, ready to talk to a canister using its candid interface + * @constructs {@link ActorSubClass} + */ +export declare const ekoke-ledger: ActorSubclass<_SERVICE>; diff --git a/src/declarations/ekoke-ledger/index.js b/src/declarations/ekoke-ledger/index.js new file mode 100644 index 0000000..b820d9f --- /dev/null +++ b/src/declarations/ekoke-ledger/index.js @@ -0,0 +1,43 @@ +import { Actor, HttpAgent } from "@dfinity/agent"; + +// Imports and re-exports candid interface +import { idlFactory } from "./ekoke-ledger.did.js"; +export { idlFactory } from "./ekoke-ledger.did.js"; + +/* CANISTER_ID is replaced by webpack based on node environment + * Note: canister environment variable will be standardized as + * process.env.CANISTER_ID_ + * beginning in dfx 0.15.0 + */ +export const canisterId = + process.env.CANISTER_ID_EKOKE-LEDGER || + process.env.EKOKE-LEDGER_CANISTER_ID; + +export const createActor = (canisterId, options = {}) => { + const agent = options.agent || new HttpAgent({ ...options.agentOptions }); + + if (options.agent && options.agentOptions) { + console.warn( + "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." + ); + } + + // Fetch root key for certificate validation during development + if (process.env.DFX_NETWORK !== "ic") { + agent.fetchRootKey().catch((err) => { + console.warn( + "Unable to fetch root key. Check to ensure that your local replica is running" + ); + console.error(err); + }); + } + + // Creates an actor with using the candid interface and the HttpAgent + return Actor.createActor(idlFactory, { + agent, + canisterId, + ...options.actorOptions, + }); +}; + +export const ekoke-ledger = canisterId ? createActor(canisterId) : undefined; diff --git a/src/declarations/marketplace/marketplace.did.d.ts b/src/declarations/marketplace/marketplace.did.d.ts index e686900..e71fda7 100644 --- a/src/declarations/marketplace/marketplace.did.d.ts +++ b/src/declarations/marketplace/marketplace.did.d.ts @@ -64,10 +64,10 @@ export type MarketplaceError = { 'Buy' : BuyError } | { 'Dip721' : NftError } | { 'Icrc2Transfer' : TransferFromError }; export interface MarketplaceInitData { - 'ekoke_canister' : Principal, 'deferred_canister' : Principal, 'icp_ledger_canister' : Principal, 'xrc_canister' : Principal, + 'ekoke_ledger_canister' : Principal, 'admins' : Array, } export type NftError = { 'UnauthorizedOperator' : null } | @@ -136,7 +136,7 @@ export interface _SERVICE { 'admin_cycles' : ActorMethod<[], bigint>, 'admin_set_admins' : ActorMethod<[Array], Result>, 'admin_set_deferred_canister' : ActorMethod<[Principal], undefined>, - 'admin_set_ekoke_canister' : ActorMethod<[Principal], Result>, + 'admin_set_ekoke_ledger_canister' : ActorMethod<[Principal], Result>, 'admin_set_icp_ledger_canister' : ActorMethod<[Principal], undefined>, 'admin_set_interest_rate_for_buyer' : ActorMethod<[number], undefined>, 'admin_set_xrc_canister' : ActorMethod<[Principal], undefined>, diff --git a/src/declarations/marketplace/marketplace.did.js b/src/declarations/marketplace/marketplace.did.js index a6d4e01..7cc0bed 100644 --- a/src/declarations/marketplace/marketplace.did.js +++ b/src/declarations/marketplace/marketplace.did.js @@ -1,9 +1,9 @@ export const idlFactory = ({ IDL }) => { const MarketplaceInitData = IDL.Record({ - 'ekoke_canister' : IDL.Principal, 'deferred_canister' : IDL.Principal, 'icp_ledger_canister' : IDL.Principal, 'xrc_canister' : IDL.Principal, + 'ekoke_ledger_canister' : IDL.Principal, 'admins' : IDL.Vec(IDL.Principal), }); const BuyError = IDL.Variant({ @@ -166,7 +166,7 @@ export const idlFactory = ({ IDL }) => { 'admin_cycles' : IDL.Func([], [IDL.Nat], ['query']), 'admin_set_admins' : IDL.Func([IDL.Vec(IDL.Principal)], [Result], []), 'admin_set_deferred_canister' : IDL.Func([IDL.Principal], [], []), - 'admin_set_ekoke_canister' : IDL.Func([IDL.Principal], [Result], []), + 'admin_set_ekoke_ledger_canister' : IDL.Func([IDL.Principal], [Result], []), 'admin_set_icp_ledger_canister' : IDL.Func([IDL.Principal], [], []), 'admin_set_interest_rate_for_buyer' : IDL.Func([IDL.Float64], [], []), 'admin_set_xrc_canister' : IDL.Func([IDL.Principal], [], []), @@ -176,10 +176,10 @@ export const idlFactory = ({ IDL }) => { }; export const init = ({ IDL }) => { const MarketplaceInitData = IDL.Record({ - 'ekoke_canister' : IDL.Principal, 'deferred_canister' : IDL.Principal, 'icp_ledger_canister' : IDL.Principal, 'xrc_canister' : IDL.Principal, + 'ekoke_ledger_canister' : IDL.Principal, 'admins' : IDL.Vec(IDL.Principal), }); return [MarketplaceInitData]; diff --git a/src/deferred/deferred.did b/src/deferred/deferred.did index 5ef2db1..f72bb45 100644 --- a/src/deferred/deferred.did +++ b/src/deferred/deferred.did @@ -81,8 +81,8 @@ type DeferredError = variant { CanisterCall : record { RejectionCode; text }; }; type DeferredInitData = record { - ekoke_canister : principal; custodians : vec principal; + ekoke_ledger_canister : principal; marketplace_canister : principal; }; type EcdsaError = variant { @@ -288,7 +288,7 @@ service : (DeferredInitData) -> { admin_get_unsigned_contracts : () -> (vec nat) query; admin_register_agency : (principal, Agency) -> (); admin_remove_role : (principal, Role) -> (Result); - admin_set_ekoke_canister : (principal) -> (); + admin_set_ekoke_ledger_canister : (principal) -> (); admin_set_marketplace_canister : (principal) -> (); admin_set_role : (principal, Role) -> (); admin_sign_contract : (nat) -> (Result); diff --git a/src/deferred/src/app.rs b/src/deferred/src/app.rs index 0748eb7..7fc1aeb 100644 --- a/src/deferred/src/app.rs +++ b/src/deferred/src/app.rs @@ -38,7 +38,8 @@ impl Deferred { /// On init set custodians and canisters ids pub fn init(init_data: DeferredInitData) { RolesManager::set_custodians(init_data.custodians).expect("storage error"); - Configuration::set_ekoke_canister(init_data.ekoke_canister).expect("storage error"); + Configuration::set_ekoke_ledger_canister(init_data.ekoke_ledger_canister) + .expect("storage error"); Configuration::set_marketplace_canister(init_data.marketplace_canister) .expect("storage error"); } @@ -205,13 +206,13 @@ impl Deferred { } } - /// Update ekoke canister id - pub fn admin_set_ekoke_canister(canister: Principal) { + /// Update ekoke ledger canister id + pub fn admin_set_ekoke_ledger_canister(canister: Principal) { if !Inspect::inspect_is_custodian(caller()) { ic_cdk::trap("Unauthorized"); } - if let Err(err) = Configuration::set_ekoke_canister(canister) { + if let Err(err) = Configuration::set_ekoke_ledger_canister(canister) { ic_cdk::trap(&err.to_string()); } } @@ -558,12 +559,12 @@ mod test { fn test_should_init_canister() { Deferred::init(DeferredInitData { custodians: vec![caller()], - ekoke_canister: caller(), + ekoke_ledger_canister: caller(), marketplace_canister: caller(), }); assert_eq!(Deferred::custodians(), vec![caller()]); - assert_eq!(Configuration::get_ekoke_canister(), caller()); + assert_eq!(Configuration::get_ekoke_ledger_canister(), caller()); assert_eq!(Configuration::get_marketplace_canister(), caller()); } @@ -989,7 +990,7 @@ mod test { fn init_canister() { Deferred::init(DeferredInitData { custodians: vec![caller()], - ekoke_canister: caller(), + ekoke_ledger_canister: caller(), marketplace_canister: caller(), }); } diff --git a/src/deferred/src/app/configuration.rs b/src/deferred/src/app/configuration.rs index 9d900e3..dfa0aea 100644 --- a/src/deferred/src/app/configuration.rs +++ b/src/deferred/src/app/configuration.rs @@ -7,15 +7,16 @@ use ic_stable_structures::memory_manager::VirtualMemory; use ic_stable_structures::{DefaultMemoryImpl, StableCell}; use crate::app::memory::{ - CREATED_AT_MEMORY_ID, EKOKE_CANISTER_MEMORY_ID, LOGO_MEMORY_ID, MARKETPLACE_CANISTER_MEMORY_ID, - MEMORY_MANAGER, NAME_MEMORY_ID, SYMBOL_MEMORY_ID, UPGRADED_AT_MEMORY_ID, + CREATED_AT_MEMORY_ID, EKOKE_LEDGER_CANISTER_MEMORY_ID, LOGO_MEMORY_ID, + MARKETPLACE_CANISTER_MEMORY_ID, MEMORY_MANAGER, NAME_MEMORY_ID, SYMBOL_MEMORY_ID, + UPGRADED_AT_MEMORY_ID, }; use crate::constants::{DEFAULT_LOGO, DEFAULT_NAME, DEFAULT_SYMBOL}; thread_local! { /// Ekoke Canister principal - static EKOKE_CANISTER: RefCell>> = - RefCell::new(StableCell::new(MEMORY_MANAGER.with(|mm| mm.get(EKOKE_CANISTER_MEMORY_ID)), Principal::anonymous().into()).unwrap() + static EKOKE_LEDGER_CANISTER: RefCell>> = + RefCell::new(StableCell::new(MEMORY_MANAGER.with(|mm| mm.get(EKOKE_LEDGER_CANISTER_MEMORY_ID)), Principal::anonymous().into()).unwrap() ); /// Marketplace Canister principal @@ -105,12 +106,12 @@ impl Configuration { Ok(()) } - pub fn get_ekoke_canister() -> Principal { - EKOKE_CANISTER.with_borrow(|cell| *cell.get().as_principal()) + pub fn get_ekoke_ledger_canister() -> Principal { + EKOKE_LEDGER_CANISTER.with_borrow(|cell| *cell.get().as_principal()) } - pub fn set_ekoke_canister(canister: Principal) -> DeferredResult<()> { - EKOKE_CANISTER + pub fn set_ekoke_ledger_canister(canister: Principal) -> DeferredResult<()> { + EKOKE_LEDGER_CANISTER .with_borrow_mut(|cell| cell.set(StorablePrincipal::from(canister))) .map_err(|_| DeferredError::StorageError)?; @@ -178,13 +179,16 @@ mod test { } #[test] - fn test_should_get_and_set_ekoke_canister() { + fn test_should_get_and_set_ekoke_ledger_canister() { let principal = Principal::from_text("zrrb4-gyxmq-nx67d-wmbky-k6xyt-byhmw-tr5ct-vsxu4-nuv2g-6rr65-aae") .unwrap(); - assert_eq!(Configuration::get_ekoke_canister(), Principal::anonymous()); - assert!(Configuration::set_ekoke_canister(principal).is_ok()); - assert_eq!(Configuration::get_ekoke_canister(), principal); + assert_eq!( + Configuration::get_ekoke_ledger_canister(), + Principal::anonymous() + ); + assert!(Configuration::set_ekoke_ledger_canister(principal).is_ok()); + assert_eq!(Configuration::get_ekoke_ledger_canister(), principal); } #[test] diff --git a/src/deferred/src/app/memory.rs b/src/deferred/src/app/memory.rs index 27e31e6..1a2eddb 100644 --- a/src/deferred/src/app/memory.rs +++ b/src/deferred/src/app/memory.rs @@ -11,7 +11,7 @@ pub const NAME_MEMORY_ID: MemoryId = MemoryId::new(21); pub const SYMBOL_MEMORY_ID: MemoryId = MemoryId::new(22); pub const CREATED_AT_MEMORY_ID: MemoryId = MemoryId::new(23); pub const UPGRADED_AT_MEMORY_ID: MemoryId = MemoryId::new(24); -pub const EKOKE_CANISTER_MEMORY_ID: MemoryId = MemoryId::new(25); +pub const EKOKE_LEDGER_CANISTER_MEMORY_ID: MemoryId = MemoryId::new(25); pub const MARKETPLACE_CANISTER_MEMORY_ID: MemoryId = MemoryId::new(26); pub const ROLES_MEMORY_ID: MemoryId = MemoryId::new(30); diff --git a/src/deferred/src/app/minter.rs b/src/deferred/src/app/minter.rs index d977b5f..cfa660e 100644 --- a/src/deferred/src/app/minter.rs +++ b/src/deferred/src/app/minter.rs @@ -17,7 +17,7 @@ impl Minter { contract_value: u64, ) -> DeferredResult<(Vec, Vec)> { // get reward for contract - let picoekoke_reward = ekoke_client(Configuration::get_ekoke_canister()) + let picoekoke_reward = ekoke_client(Configuration::get_ekoke_ledger_canister()) .get_contract_reward(contract_id.clone(), installments) .await?; diff --git a/src/deferred/src/lib.rs b/src/deferred/src/lib.rs index b30cc58..68ac4ac 100644 --- a/src/deferred/src/lib.rs +++ b/src/deferred/src/lib.rs @@ -109,8 +109,8 @@ pub fn update_contract_buyers(contract_id: ID, buyers: Vec) -> Deferr #[update] #[candid_method(update)] -pub fn admin_set_ekoke_canister(canister_id: Principal) { - Deferred::admin_set_ekoke_canister(canister_id) +pub fn admin_set_ekoke_ledger_canister(canister_id: Principal) { + Deferred::admin_set_ekoke_ledger_canister(canister_id) } #[update] diff --git a/src/did/src/deferred/canister.rs b/src/did/src/deferred/canister.rs index d3bdc62..591c2d3 100644 --- a/src/did/src/deferred/canister.rs +++ b/src/did/src/deferred/canister.rs @@ -7,7 +7,7 @@ use ic_stable_structures::Storable; #[derive(Debug, Clone, CandidType, Deserialize)] pub struct DeferredInitData { pub custodians: Vec, - pub ekoke_canister: Principal, + pub ekoke_ledger_canister: Principal, pub marketplace_canister: Principal, } diff --git a/src/did/src/marketplace.rs b/src/did/src/marketplace.rs index a318381..4be0483 100644 --- a/src/did/src/marketplace.rs +++ b/src/did/src/marketplace.rs @@ -84,7 +84,7 @@ pub struct MarketplaceInitData { /// Deferred canister pub deferred_canister: Principal, /// Ekoke canister - pub ekoke_canister: Principal, + pub ekoke_ledger_canister: Principal, /// ICP ledger canister pub icp_ledger_canister: Principal, /// XRC canister diff --git a/src/ekoke/Cargo.toml b/src/ekoke_ledger/Cargo.toml similarity index 96% rename from src/ekoke/Cargo.toml rename to src/ekoke_ledger/Cargo.toml index 9426db2..1dca154 100644 --- a/src/ekoke/Cargo.toml +++ b/src/ekoke_ledger/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ekoke" +name = "ekoke_ledger" version = { workspace = true } authors = { workspace = true } edition = { workspace = true } @@ -7,7 +7,7 @@ license = { workspace = true } repository = { workspace = true } [[bin]] -name = "ekoke-did" +name = "ekoke-ledger-did" path = "src/lib.rs" [lib] diff --git a/src/ekoke/ekoke.did b/src/ekoke_ledger/ekoke-ledger.did similarity index 100% rename from src/ekoke/ekoke.did rename to src/ekoke_ledger/ekoke-ledger.did diff --git a/src/ekoke/src/abi.rs b/src/ekoke_ledger/src/abi.rs similarity index 100% rename from src/ekoke/src/abi.rs rename to src/ekoke_ledger/src/abi.rs diff --git a/src/ekoke/src/abi/ekoke.json b/src/ekoke_ledger/src/abi/ekoke.json similarity index 100% rename from src/ekoke/src/abi/ekoke.json rename to src/ekoke_ledger/src/abi/ekoke.json diff --git a/src/ekoke/src/app.rs b/src/ekoke_ledger/src/app.rs similarity index 100% rename from src/ekoke/src/app.rs rename to src/ekoke_ledger/src/app.rs diff --git a/src/ekoke/src/app/balance.rs b/src/ekoke_ledger/src/app/balance.rs similarity index 100% rename from src/ekoke/src/app/balance.rs rename to src/ekoke_ledger/src/app/balance.rs diff --git a/src/ekoke/src/app/balance/account_balance.rs b/src/ekoke_ledger/src/app/balance/account_balance.rs similarity index 100% rename from src/ekoke/src/app/balance/account_balance.rs rename to src/ekoke_ledger/src/app/balance/account_balance.rs diff --git a/src/ekoke/src/app/configuration.rs b/src/ekoke_ledger/src/app/configuration.rs similarity index 100% rename from src/ekoke/src/app/configuration.rs rename to src/ekoke_ledger/src/app/configuration.rs diff --git a/src/ekoke/src/app/erc20_bridge.rs b/src/ekoke_ledger/src/app/erc20_bridge.rs similarity index 100% rename from src/ekoke/src/app/erc20_bridge.rs rename to src/ekoke_ledger/src/app/erc20_bridge.rs diff --git a/src/ekoke/src/app/erc20_bridge/cketh_withdrawal.rs b/src/ekoke_ledger/src/app/erc20_bridge/cketh_withdrawal.rs similarity index 100% rename from src/ekoke/src/app/erc20_bridge/cketh_withdrawal.rs rename to src/ekoke_ledger/src/app/erc20_bridge/cketh_withdrawal.rs diff --git a/src/ekoke/src/app/erc20_bridge/eth_rpc.rs b/src/ekoke_ledger/src/app/erc20_bridge/eth_rpc.rs similarity index 100% rename from src/ekoke/src/app/erc20_bridge/eth_rpc.rs rename to src/ekoke_ledger/src/app/erc20_bridge/eth_rpc.rs diff --git a/src/ekoke/src/app/erc20_bridge/eth_rpc/ekoke_swapped.rs b/src/ekoke_ledger/src/app/erc20_bridge/eth_rpc/ekoke_swapped.rs similarity index 100% rename from src/ekoke/src/app/erc20_bridge/eth_rpc/ekoke_swapped.rs rename to src/ekoke_ledger/src/app/erc20_bridge/eth_rpc/ekoke_swapped.rs diff --git a/src/ekoke/src/app/erc20_bridge/eth_rpc/response.rs b/src/ekoke_ledger/src/app/erc20_bridge/eth_rpc/response.rs similarity index 100% rename from src/ekoke/src/app/erc20_bridge/eth_rpc/response.rs rename to src/ekoke_ledger/src/app/erc20_bridge/eth_rpc/response.rs diff --git a/src/ekoke/src/app/erc20_bridge/eth_wallet.rs b/src/ekoke_ledger/src/app/erc20_bridge/eth_wallet.rs similarity index 100% rename from src/ekoke/src/app/erc20_bridge/eth_wallet.rs rename to src/ekoke_ledger/src/app/erc20_bridge/eth_wallet.rs diff --git a/src/ekoke/src/app/erc20_bridge/gas_station.rs b/src/ekoke_ledger/src/app/erc20_bridge/gas_station.rs similarity index 100% rename from src/ekoke/src/app/erc20_bridge/gas_station.rs rename to src/ekoke_ledger/src/app/erc20_bridge/gas_station.rs diff --git a/src/ekoke/src/app/erc20_bridge/swap_fee.rs b/src/ekoke_ledger/src/app/erc20_bridge/swap_fee.rs similarity index 100% rename from src/ekoke/src/app/erc20_bridge/swap_fee.rs rename to src/ekoke_ledger/src/app/erc20_bridge/swap_fee.rs diff --git a/src/ekoke/src/app/erc20_bridge/swap_pool.rs b/src/ekoke_ledger/src/app/erc20_bridge/swap_pool.rs similarity index 100% rename from src/ekoke/src/app/erc20_bridge/swap_pool.rs rename to src/ekoke_ledger/src/app/erc20_bridge/swap_pool.rs diff --git a/src/ekoke/src/app/inspect.rs b/src/ekoke_ledger/src/app/inspect.rs similarity index 100% rename from src/ekoke/src/app/inspect.rs rename to src/ekoke_ledger/src/app/inspect.rs diff --git a/src/ekoke/src/app/liquidity_pool.rs b/src/ekoke_ledger/src/app/liquidity_pool.rs similarity index 100% rename from src/ekoke/src/app/liquidity_pool.rs rename to src/ekoke_ledger/src/app/liquidity_pool.rs diff --git a/src/ekoke/src/app/liquidity_pool/xrc.rs b/src/ekoke_ledger/src/app/liquidity_pool/xrc.rs similarity index 100% rename from src/ekoke/src/app/liquidity_pool/xrc.rs rename to src/ekoke_ledger/src/app/liquidity_pool/xrc.rs diff --git a/src/ekoke/src/app/memory.rs b/src/ekoke_ledger/src/app/memory.rs similarity index 100% rename from src/ekoke/src/app/memory.rs rename to src/ekoke_ledger/src/app/memory.rs diff --git a/src/ekoke/src/app/pool.rs b/src/ekoke_ledger/src/app/pool.rs similarity index 100% rename from src/ekoke/src/app/pool.rs rename to src/ekoke_ledger/src/app/pool.rs diff --git a/src/ekoke/src/app/register.rs b/src/ekoke_ledger/src/app/register.rs similarity index 100% rename from src/ekoke/src/app/register.rs rename to src/ekoke_ledger/src/app/register.rs diff --git a/src/ekoke/src/app/reward.rs b/src/ekoke_ledger/src/app/reward.rs similarity index 100% rename from src/ekoke/src/app/reward.rs rename to src/ekoke_ledger/src/app/reward.rs diff --git a/src/ekoke/src/app/roles.rs b/src/ekoke_ledger/src/app/roles.rs similarity index 100% rename from src/ekoke/src/app/roles.rs rename to src/ekoke_ledger/src/app/roles.rs diff --git a/src/ekoke/src/app/spend_allowance.rs b/src/ekoke_ledger/src/app/spend_allowance.rs similarity index 100% rename from src/ekoke/src/app/spend_allowance.rs rename to src/ekoke_ledger/src/app/spend_allowance.rs diff --git a/src/ekoke/src/app/spend_allowance/key.rs b/src/ekoke_ledger/src/app/spend_allowance/key.rs similarity index 100% rename from src/ekoke/src/app/spend_allowance/key.rs rename to src/ekoke_ledger/src/app/spend_allowance/key.rs diff --git a/src/ekoke/src/app/spend_allowance/spend.rs b/src/ekoke_ledger/src/app/spend_allowance/spend.rs similarity index 100% rename from src/ekoke/src/app/spend_allowance/spend.rs rename to src/ekoke_ledger/src/app/spend_allowance/spend.rs diff --git a/src/ekoke/src/app/test_utils.rs b/src/ekoke_ledger/src/app/test_utils.rs similarity index 100% rename from src/ekoke/src/app/test_utils.rs rename to src/ekoke_ledger/src/app/test_utils.rs diff --git a/src/ekoke/src/constants.rs b/src/ekoke_ledger/src/constants.rs similarity index 100% rename from src/ekoke/src/constants.rs rename to src/ekoke_ledger/src/constants.rs diff --git a/src/ekoke/src/http.rs b/src/ekoke_ledger/src/http.rs similarity index 100% rename from src/ekoke/src/http.rs rename to src/ekoke_ledger/src/http.rs diff --git a/src/ekoke/src/inspect.rs b/src/ekoke_ledger/src/inspect.rs similarity index 100% rename from src/ekoke/src/inspect.rs rename to src/ekoke_ledger/src/inspect.rs diff --git a/src/ekoke/src/lib.rs b/src/ekoke_ledger/src/lib.rs similarity index 100% rename from src/ekoke/src/lib.rs rename to src/ekoke_ledger/src/lib.rs diff --git a/src/ekoke/src/utils.rs b/src/ekoke_ledger/src/utils.rs similarity index 100% rename from src/ekoke/src/utils.rs rename to src/ekoke_ledger/src/utils.rs diff --git a/src/marketplace/marketplace.did b/src/marketplace/marketplace.did index 2b33600..be92047 100644 --- a/src/marketplace/marketplace.did +++ b/src/marketplace/marketplace.did @@ -72,10 +72,10 @@ type MarketplaceError = variant { Icrc2Transfer : TransferFromError; }; type MarketplaceInitData = record { - ekoke_canister : principal; deferred_canister : principal; icp_ledger_canister : principal; xrc_canister : principal; + ekoke_ledger_canister : principal; admins : vec principal; }; type NftError = variant { @@ -147,7 +147,7 @@ service : (MarketplaceInitData) -> { admin_cycles : () -> (nat) query; admin_set_admins : (vec principal) -> (Result); admin_set_deferred_canister : (principal) -> (); - admin_set_ekoke_canister : (principal) -> (Result); + admin_set_ekoke_ledger_canister : (principal) -> (Result); admin_set_icp_ledger_canister : (principal) -> (); admin_set_interest_rate_for_buyer : (float64) -> (); admin_set_xrc_canister : (principal) -> (); diff --git a/src/marketplace/src/app.rs b/src/marketplace/src/app.rs index 2f3a9a6..888739d 100644 --- a/src/marketplace/src/app.rs +++ b/src/marketplace/src/app.rs @@ -39,7 +39,7 @@ pub struct Marketplace; impl Marketplace { pub fn init(data: MarketplaceInitData) { Configuration::set_deferred_canister(data.deferred_canister); - Configuration::set_ekoke_canister(data.ekoke_canister); + Configuration::set_ekoke_ledger_canister(data.ekoke_ledger_canister); Configuration::set_xrc_canister(data.xrc_canister); Configuration::set_icp_ledger_canister(data.icp_ledger_canister); RolesManager::set_admins(data.admins).unwrap(); @@ -67,11 +67,11 @@ impl Marketplace { Configuration::set_deferred_canister(canister) } - pub async fn admin_set_ekoke_canister(canister: Principal) -> MarketplaceResult<()> { + pub async fn admin_set_ekoke_ledger_canister(canister: Principal) -> MarketplaceResult<()> { if !Inspect::inspect_is_admin(caller()) { ic_cdk::trap("unauthorized"); } - Configuration::set_ekoke_canister(canister); + Configuration::set_ekoke_ledger_canister(canister); // update liquidity pool canister Configuration::update_ekoke_liquidity_pool_account().await?; @@ -131,7 +131,7 @@ impl Marketplace { ) -> MarketplaceResult<()> { let caller_account = Self::caller_account(subaccount); let deferred_client = DeferredClient::from(Configuration::get_deferred_canister()); - let ekoke_client = EkokeClient::from(Configuration::get_ekoke_canister()); + let ekoke_client = EkokeClient::from(Configuration::get_ekoke_ledger_canister()); // get token info let info = Self::get_token_info_with_price(&token_id).await?; // 0. checks whether already owns the token @@ -314,7 +314,7 @@ mod test { use std::str::FromStr as _; - use super::test_utils::{deferred_canister, ekoke_canister}; + use super::test_utils::{deferred_canister, ekoke_ledger_canister}; use super::*; use crate::utils::caller; @@ -322,7 +322,10 @@ mod test { fn test_should_init_canister() { init_canister(); assert_eq!(Configuration::get_deferred_canister(), deferred_canister()); - assert_eq!(Configuration::get_ekoke_canister(), ekoke_canister()); + assert_eq!( + Configuration::get_ekoke_ledger_canister(), + ekoke_ledger_canister() + ); assert_eq!(RolesManager::get_admins(), vec![caller()]); // check canisters @@ -331,13 +334,16 @@ mod test { } #[tokio::test] - async fn test_should_change_ekoke_canister() { + async fn test_should_change_ekoke_ledger_canister() { init_canister(); - let new_ekoke_canister = Principal::anonymous(); - Marketplace::admin_set_ekoke_canister(new_ekoke_canister) + let new_ekoke_ledger_canister = Principal::anonymous(); + Marketplace::admin_set_ekoke_ledger_canister(new_ekoke_ledger_canister) .await .unwrap(); - assert_eq!(Configuration::get_ekoke_canister(), new_ekoke_canister); + assert_eq!( + Configuration::get_ekoke_ledger_canister(), + new_ekoke_ledger_canister + ); assert_eq!( Configuration::get_ekoke_liquidity_pool_account() .await @@ -516,7 +522,7 @@ mod test { fn init_canister() { let data = MarketplaceInitData { deferred_canister: deferred_canister(), - ekoke_canister: ekoke_canister(), + ekoke_ledger_canister: ekoke_ledger_canister(), icp_ledger_canister: caller(), admins: vec![caller()], xrc_canister: caller(), diff --git a/src/marketplace/src/app/configuration.rs b/src/marketplace/src/app/configuration.rs index b0a257b..967c9da 100644 --- a/src/marketplace/src/app/configuration.rs +++ b/src/marketplace/src/app/configuration.rs @@ -12,17 +12,17 @@ use ic_stable_structures::{DefaultMemoryImpl, StableCell}; use icrc::icrc1::account::Account; use crate::app::memory::{ - DEFERRED_CANISTER_MEMORY_ID, EKOKE_CANISTER_MEMORY_ID, EKOKE_LIQUIDITY_POOL_ACCOUNT_MEMORY_ID, - ICP_LEDGER_CANISTER_MEMORY_ID, INTEREST_FOR_BUYER_MEMORY_ID, MEMORY_MANAGER, - XRC_CANISTER_MEMORY_ID, + DEFERRED_CANISTER_MEMORY_ID, EKOKE_LEDGER_CANISTER_MEMORY_ID, + EKOKE_LIQUIDITY_POOL_ACCOUNT_MEMORY_ID, ICP_LEDGER_CANISTER_MEMORY_ID, + INTEREST_FOR_BUYER_MEMORY_ID, MEMORY_MANAGER, XRC_CANISTER_MEMORY_ID, }; use crate::client::EkokeClient; use crate::constants::DEFAULT_INTEREST_MULTIPLIER_FOR_BUYER; thread_local! { /// Ekoke canister - static EKOKE_CANISTER: RefCell>> = - RefCell::new(StableCell::new(MEMORY_MANAGER.with(|mm| mm.get(EKOKE_CANISTER_MEMORY_ID)), + static EKOKE_LEDGER_CANISTER: RefCell>> = + RefCell::new(StableCell::new(MEMORY_MANAGER.with(|mm| mm.get(EKOKE_LEDGER_CANISTER_MEMORY_ID)), Principal::anonymous().into()).unwrap() ); @@ -65,9 +65,9 @@ pub struct Configuration; impl Configuration { /// Set minting account - pub fn set_ekoke_canister(ekoke_canister: Principal) { - EKOKE_CANISTER.with_borrow_mut(|cell| { - cell.set(ekoke_canister.into()).unwrap(); + pub fn set_ekoke_ledger_canister(ekoke_ledger_canister: Principal) { + EKOKE_LEDGER_CANISTER.with_borrow_mut(|cell| { + cell.set(ekoke_ledger_canister.into()).unwrap(); }); } @@ -86,8 +86,8 @@ impl Configuration { } /// Get minting account address - pub fn get_ekoke_canister() -> Principal { - EKOKE_CANISTER.with(|ma| ma.borrow().get().0) + pub fn get_ekoke_ledger_canister() -> Principal { + EKOKE_LEDGER_CANISTER.with(|ma| ma.borrow().get().0) } /// Get swap account address @@ -113,7 +113,7 @@ impl Configuration { /// Update ekoke liquidity pool account pub async fn update_ekoke_liquidity_pool_account() -> MarketplaceResult { // call ekoke - let liquidity_pool_account = EkokeClient::from(Configuration::get_ekoke_canister()) + let liquidity_pool_account = EkokeClient::from(Configuration::get_ekoke_ledger_canister()) .liquidity_pool_accounts() .await? .icp; @@ -167,10 +167,10 @@ mod test { } #[test] - fn test_should_set_ekoke_canister() { + fn test_should_set_ekoke_ledger_canister() { let canister = id(); - Configuration::set_ekoke_canister(canister); - assert_eq!(Configuration::get_ekoke_canister(), canister); + Configuration::set_ekoke_ledger_canister(canister); + assert_eq!(Configuration::get_ekoke_ledger_canister(), canister); } #[test] diff --git a/src/marketplace/src/app/memory.rs b/src/marketplace/src/app/memory.rs index a4a99a5..d2cb448 100644 --- a/src/marketplace/src/app/memory.rs +++ b/src/marketplace/src/app/memory.rs @@ -4,7 +4,7 @@ use ic_stable_structures::DefaultMemoryImpl; // Configuration pub const ROLES_MEMORY_ID: MemoryId = MemoryId::new(20); pub const DEFERRED_CANISTER_MEMORY_ID: MemoryId = MemoryId::new(21); -pub const EKOKE_CANISTER_MEMORY_ID: MemoryId = MemoryId::new(22); +pub const EKOKE_LEDGER_CANISTER_MEMORY_ID: MemoryId = MemoryId::new(22); pub const INTEREST_FOR_BUYER_MEMORY_ID: MemoryId = MemoryId::new(23); pub const EKOKE_LIQUIDITY_POOL_ACCOUNT_MEMORY_ID: MemoryId = MemoryId::new(24); pub const XRC_CANISTER_MEMORY_ID: MemoryId = MemoryId::new(25); diff --git a/src/marketplace/src/app/test_utils.rs b/src/marketplace/src/app/test_utils.rs index 12aa83f..b47a0e0 100644 --- a/src/marketplace/src/app/test_utils.rs +++ b/src/marketplace/src/app/test_utils.rs @@ -1,6 +1,6 @@ use candid::Principal; -pub fn ekoke_canister() -> Principal { +pub fn ekoke_ledger_canister() -> Principal { Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai").unwrap() } diff --git a/src/marketplace/src/client/ekoke.rs b/src/marketplace/src/client/ekoke.rs index 50b449b..6cea0d7 100644 --- a/src/marketplace/src/client/ekoke.rs +++ b/src/marketplace/src/client/ekoke.rs @@ -10,12 +10,14 @@ use icrc::icrc1::account::Account; #[allow(dead_code)] pub struct EkokeClient { - ekoke_canister: Principal, + ekoke_ledger_canister: Principal, } impl From for EkokeClient { - fn from(ekoke_canister: Principal) -> Self { - Self { ekoke_canister } + fn from(ekoke_ledger_canister: Principal) -> Self { + Self { + ekoke_ledger_canister, + } } } @@ -39,7 +41,7 @@ impl EkokeClient { #[cfg(target_arch = "wasm32")] { let result: (LiquidityPoolAccounts,) = - ic_cdk::api::call::call(self.ekoke_canister, "liquidity_pool_accounts", ()) + ic_cdk::api::call::call(self.ekoke_ledger_canister, "liquidity_pool_accounts", ()) .await .map_err(|(code, err)| MarketplaceError::CanisterCall(code, err))?; Ok(result.0) @@ -60,7 +62,7 @@ impl EkokeClient { #[cfg(target_arch = "wasm32")] { let result: (EkokeResult<()>,) = ic_cdk::api::call::call( - self.ekoke_canister, + self.ekoke_ledger_canister, "send_reward", (contract_id, amount, account), ) diff --git a/src/marketplace/src/lib.rs b/src/marketplace/src/lib.rs index 58f67d7..7b31860 100644 --- a/src/marketplace/src/lib.rs +++ b/src/marketplace/src/lib.rs @@ -49,8 +49,8 @@ pub fn admin_set_icp_ledger_canister(canister: Principal) { #[update] #[candid_method(update)] -pub async fn admin_set_ekoke_canister(canister: Principal) -> MarketplaceResult<()> { - Marketplace::admin_set_ekoke_canister(canister).await +pub async fn admin_set_ekoke_ledger_canister(canister: Principal) -> MarketplaceResult<()> { + Marketplace::admin_set_ekoke_ledger_canister(canister).await } #[update]