From c57a842fd06dea5e95ab608fb00cca3c921c3da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Bj=C3=B6rkqvist?= Date: Wed, 6 Nov 2024 19:16:34 +0100 Subject: [PATCH] feat(proposal_cli): FI-1571: Do not write the args.hex file from proposal-cli (#2460) To avoid potential confusion for reviewers of proposals generated using the `proposal-cli` before they are submitted, do not write the `args.hex` file to disk. --- rs/cross-chain/proposal-cli/src/candid/mod.rs | 4 ---- rs/cross-chain/proposal-cli/src/candid/tests.rs | 4 ++-- rs/cross-chain/proposal-cli/src/main.rs | 9 --------- rs/cross-chain/proposal-cli/src/proposal/mod.rs | 10 ---------- 4 files changed, 2 insertions(+), 25 deletions(-) diff --git a/rs/cross-chain/proposal-cli/src/candid/mod.rs b/rs/cross-chain/proposal-cli/src/candid/mod.rs index 63107eb4125..51c839fef83 100644 --- a/rs/cross-chain/proposal-cli/src/candid/mod.rs +++ b/rs/cross-chain/proposal-cli/src/candid/mod.rs @@ -22,10 +22,6 @@ impl UpgradeArgs { &self.encoded_upgrade_args } - pub fn upgrade_args_hex(&self) -> String { - hex::encode(&self.encoded_upgrade_args) - } - pub fn args_sha256_hex(&self) -> String { self.args_sha256.to_string() } diff --git a/rs/cross-chain/proposal-cli/src/candid/tests.rs b/rs/cross-chain/proposal-cli/src/candid/tests.rs index 6d490bf2f99..efbf1326e1c 100644 --- a/rs/cross-chain/proposal-cli/src/candid/tests.rs +++ b/rs/cross-chain/proposal-cli/src/candid/tests.rs @@ -14,7 +14,7 @@ fn should_encode_default_upgrade_args() { let upgrade_args = encode_upgrade_args(&path, canister.default_upgrade_args()); assert_eq!( - upgrade_args.upgrade_args_hex(), + hex::encode(upgrade_args.upgrade_args_bin()), expected, "failed to encode default upgrade args for: {:?}", canister @@ -29,7 +29,7 @@ fn should_encode_non_empty_ledger_upgrade_args() { let upgrade_args = encode_upgrade_args(&path, "(variant {Upgrade})"); - assert_matches!(upgrade_args.upgrade_args_hex(), _string); + assert!(hex::encode(upgrade_args.upgrade_args_bin()).starts_with("4449444c")); } #[test] diff --git a/rs/cross-chain/proposal-cli/src/main.rs b/rs/cross-chain/proposal-cli/src/main.rs index a980cb54121..478665a270d 100644 --- a/rs/cross-chain/proposal-cli/src/main.rs +++ b/rs/cross-chain/proposal-cli/src/main.rs @@ -214,15 +214,6 @@ fn write_to_disk>( bin_args_file_path.display() ); - let hex_args_file_path = output_dir.join("args.hex"); - let mut args_file = fs::File::create(&hex_args_file_path) - .unwrap_or_else(|_| panic!("failed to create {:?}", hex_args_file_path)); - proposal.write_hex_args(&mut args_file); - println!( - "Hexadecimal upgrade args written to '{}'", - hex_args_file_path.display() - ); - let artifact = output_dir.join(proposal.target_canister().artifact_file_name()); ic_repo.copy_file(&proposal.target_canister().artifact(), &artifact); println!("Artifact written to '{}'", artifact.display()); diff --git a/rs/cross-chain/proposal-cli/src/proposal/mod.rs b/rs/cross-chain/proposal-cli/src/proposal/mod.rs index b42eff55d00..205d5ddd559 100644 --- a/rs/cross-chain/proposal-cli/src/proposal/mod.rs +++ b/rs/cross-chain/proposal-cli/src/proposal/mod.rs @@ -53,16 +53,6 @@ impl ProposalTemplate { .expect("failed to write binary args"); } - pub fn write_hex_args(&self, writer: &mut W) { - let hex_args = match self { - ProposalTemplate::Upgrade(template) => template.upgrade_args.upgrade_args_hex(), - ProposalTemplate::Install(template) => template.install_args.upgrade_args_hex(), - }; - writer - .write_all(hex_args.as_bytes()) - .expect("failed to write hex args"); - } - pub fn args_sha256_hex(&self) -> String { match self { ProposalTemplate::Upgrade(template) => template.upgrade_args.args_sha256_hex(),