From 907865e07a1a6aa6e5924e2e9948ec2d3edf9e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Bj=C3=B6rkqvist?= Date: Wed, 6 Nov 2024 14:46:10 +0100 Subject: [PATCH] feat(proposal-cli): Add support for the cycles-ledger and exchange-rate-canister (#2464) Add `proposal-cli` support for the cycles-ledger and exchange-rate-canister. --- .../proposal-cli/src/candid/tests.rs | 2 + .../proposal-cli/src/canister/mod.rs | 41 ++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/rs/cross-chain/proposal-cli/src/candid/tests.rs b/rs/cross-chain/proposal-cli/src/candid/tests.rs index 4ed6d09aad6..6d490bf2f99 100644 --- a/rs/cross-chain/proposal-cli/src/candid/tests.rs +++ b/rs/cross-chain/proposal-cli/src/candid/tests.rs @@ -40,6 +40,8 @@ fn should_parse_constructor_parameters() { || canister == TargetCanister::IcpArchive3 //canister lives outside the monorepo || canister == TargetCanister::EvmRpc + || canister == TargetCanister::CyclesLedger + || canister == TargetCanister::ExchangeRateCanister { continue; } diff --git a/rs/cross-chain/proposal-cli/src/canister/mod.rs b/rs/cross-chain/proposal-cli/src/canister/mod.rs index a14d0416f65..cb64c652c0d 100644 --- a/rs/cross-chain/proposal-cli/src/canister/mod.rs +++ b/rs/cross-chain/proposal-cli/src/canister/mod.rs @@ -26,6 +26,8 @@ pub enum TargetCanister { IcpLedger, LedgerSuiteOrchestrator, EvmRpc, + CyclesLedger, + ExchangeRateCanister, } impl TargetCanister { @@ -43,6 +45,8 @@ impl TargetCanister { TargetCanister::IcpLedger => "icp-ledger", TargetCanister::LedgerSuiteOrchestrator => "orchestrator", TargetCanister::EvmRpc => "evm_rpc", + TargetCanister::CyclesLedger => "cycles-ledger", + TargetCanister::ExchangeRateCanister => "xrc", } } @@ -66,6 +70,10 @@ impl TargetCanister { TargetCanister::EvmRpc => { "https://github.com/internet-computer-protocol/evm-rpc-canister.git" } + TargetCanister::CyclesLedger => "https://github.com/dfinity/cycles-ledger.git", + TargetCanister::ExchangeRateCanister => { + "https://github.com/dfinity/exchange-rate-canister.git" + } } } @@ -98,6 +106,8 @@ impl TargetCanister { PathBuf::from("rs/ethereum/ledger-suite-orchestrator/ledger_suite_orchestrator.did") } TargetCanister::EvmRpc => PathBuf::from("candid/evm_rpc.did"), + TargetCanister::CyclesLedger => PathBuf::from("cycles-ledger/cycles-ledger.did"), + TargetCanister::ExchangeRateCanister => PathBuf::from("src/xrc/xrc.did"), } } @@ -120,7 +130,9 @@ impl TargetCanister { | TargetCanister::LedgerSuiteOrchestrator => { Some(self.candid_file().parent().unwrap().to_path_buf()) } - TargetCanister::EvmRpc => None, + TargetCanister::EvmRpc + | TargetCanister::CyclesLedger + | TargetCanister::ExchangeRateCanister => None, } } @@ -167,7 +179,9 @@ impl TargetCanister { | TargetCanister::CkEthLedger | TargetCanister::CkEthMinter | TargetCanister::LedgerSuiteOrchestrator - | TargetCanister::EvmRpc => self.repo_dir().into_iter().collect(), + | TargetCanister::EvmRpc + | TargetCanister::CyclesLedger + | TargetCanister::ExchangeRateCanister => self.repo_dir().into_iter().collect(), } } @@ -190,7 +204,9 @@ impl TargetCanister { | TargetCanister::LedgerSuiteOrchestrator => { PathBuf::from("artifacts/canisters").join(self.artifact_file_name()) } - TargetCanister::EvmRpc => PathBuf::from(self.artifact_file_name()), + TargetCanister::EvmRpc + | TargetCanister::CyclesLedger + | TargetCanister::ExchangeRateCanister => PathBuf::from(self.artifact_file_name()), } } @@ -214,6 +230,8 @@ impl TargetCanister { "ic-ledger-suite-orchestrator-canister.wasm.gz" } TargetCanister::EvmRpc => "evm_rpc.wasm.gz", + TargetCanister::CyclesLedger => "cycles-ledger.wasm.gz", + TargetCanister::ExchangeRateCanister => "xrc.wasm.gz", } } @@ -238,7 +256,14 @@ impl TargetCanister { cmd.arg("--canisters"); cmd } - TargetCanister::EvmRpc => Command::new("./scripts/docker-build"), + TargetCanister::EvmRpc | TargetCanister::CyclesLedger => { + Command::new("./scripts/docker-build") + } + TargetCanister::ExchangeRateCanister => { + let mut cmd = Command::new("./scripts/docker-build"); + cmd.env("IP_SUPPORT", "ipv4"); + cmd + } } } @@ -267,7 +292,9 @@ impl TargetCanister { | TargetCanister::IcpArchive3 | TargetCanister::IcpIndex | TargetCanister::IcpLedger => PathBuf::from("rs/ledger_suite/icp/canister_ids.json"), - TargetCanister::EvmRpc => PathBuf::from("canister_ids.json"), + TargetCanister::EvmRpc + | TargetCanister::CyclesLedger + | TargetCanister::ExchangeRateCanister => PathBuf::from("canister_ids.json"), } } @@ -300,6 +327,8 @@ impl FromStr for TargetCanister { ["icp", "index"] => Ok(TargetCanister::IcpIndex), ["icp", "ledger"] => Ok(TargetCanister::IcpLedger), ["evm", "rpc"] => Ok(TargetCanister::EvmRpc), + ["cycles", "ledger"] => Ok(TargetCanister::CyclesLedger), + ["exchange", "rate"] => Ok(TargetCanister::ExchangeRateCanister), _ => Err(format!("Unknown canister name: {}", canister)), } } @@ -324,6 +353,8 @@ impl Display for TargetCanister { TargetCanister::IcpLedger => write!(f, "ICP ledger"), TargetCanister::LedgerSuiteOrchestrator => write!(f, "ledger suite orchestrator"), TargetCanister::EvmRpc => write!(f, "EVM RPC"), + TargetCanister::CyclesLedger => write!(f, "cycles ledger"), + TargetCanister::ExchangeRateCanister => write!(f, "exchange rate canister"), } } }