Skip to content

Commit

Permalink
feat(proposal-cli): Add support for the cycles-ledger and exchange-ra…
Browse files Browse the repository at this point in the history
…te-canister (#2464)

Add `proposal-cli` support for the cycles-ledger and
exchange-rate-canister.
  • Loading branch information
mbjorkqvist authored Nov 6, 2024
1 parent 6db068e commit 907865e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
2 changes: 2 additions & 0 deletions rs/cross-chain/proposal-cli/src/candid/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
41 changes: 36 additions & 5 deletions rs/cross-chain/proposal-cli/src/canister/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub enum TargetCanister {
IcpLedger,
LedgerSuiteOrchestrator,
EvmRpc,
CyclesLedger,
ExchangeRateCanister,
}

impl TargetCanister {
Expand All @@ -43,6 +45,8 @@ impl TargetCanister {
TargetCanister::IcpLedger => "icp-ledger",
TargetCanister::LedgerSuiteOrchestrator => "orchestrator",
TargetCanister::EvmRpc => "evm_rpc",
TargetCanister::CyclesLedger => "cycles-ledger",
TargetCanister::ExchangeRateCanister => "xrc",
}
}

Expand All @@ -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"
}
}
}

Expand Down Expand Up @@ -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"),
}
}

Expand All @@ -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,
}
}

Expand Down Expand Up @@ -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(),
}
}

Expand All @@ -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()),
}
}

Expand All @@ -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",
}
}

Expand All @@ -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
}
}
}

Expand Down Expand Up @@ -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"),
}
}

Expand Down Expand Up @@ -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)),
}
}
Expand All @@ -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"),
}
}
}

0 comments on commit 907865e

Please sign in to comment.