Skip to content

Commit

Permalink
feat(proposal_cli): FI-1571: Do not write the args.hex file from prop…
Browse files Browse the repository at this point in the history
…osal-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.
  • Loading branch information
mbjorkqvist authored Nov 6, 2024
1 parent 0a835cc commit c57a842
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 25 deletions.
4 changes: 0 additions & 4 deletions rs/cross-chain/proposal-cli/src/candid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
4 changes: 2 additions & 2 deletions rs/cross-chain/proposal-cli/src/candid/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
9 changes: 0 additions & 9 deletions rs/cross-chain/proposal-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,6 @@ fn write_to_disk<P: Into<ProposalTemplate>>(
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());
Expand Down
10 changes: 0 additions & 10 deletions rs/cross-chain/proposal-cli/src/proposal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ impl ProposalTemplate {
.expect("failed to write binary args");
}

pub fn write_hex_args<W: Write>(&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(),
Expand Down

0 comments on commit c57a842

Please sign in to comment.