From aaa663d681bf64d4d5c4d8316ee6071fc31c2e6f Mon Sep 17 00:00:00 2001 From: mraszyk <31483726+mraszyk@users.noreply.github.com> Date: Tue, 14 Feb 2023 16:18:13 +0100 Subject: [PATCH] make --proposal-path load binary encoding of the proposal candid record (#160) * make --proposal-path load binary encoding of the proposal candid record * update CHANGELOG --------- Co-authored-by: Martin Raszyk Co-authored-by: Linwei Shang --- CHANGELOG.md | 2 ++ src/commands/sns/make_proposal.rs | 12 ++++----- tests/commands/sns-make-proposal-from-file.sh | 3 +++ tests/outputs/sns-make-proposal-from-file.txt | 23 ++++++++++++++++++ tests/outputs/sns_proposal.txt | Bin 0 -> 174 bytes 5 files changed, 33 insertions(+), 7 deletions(-) create mode 100755 tests/commands/sns-make-proposal-from-file.sh create mode 100644 tests/outputs/sns-make-proposal-from-file.txt create mode 100644 tests/outputs/sns_proposal.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index a7864357..84f91260 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Changed - Require `--ticket-creation-time` in `quill sns pay`. (#159) +- `--proposal-path` in the `sns make-proposal` command expects the binary encoding + of the proposal candid record. (#160) ## [0.3.3] - 2023-02-09 diff --git a/src/commands/sns/make_proposal.rs b/src/commands/sns/make_proposal.rs index 615d05f3..57264d42 100644 --- a/src/commands/sns/make_proposal.rs +++ b/src/commands/sns/make_proposal.rs @@ -41,8 +41,8 @@ pub struct MakeProposalOpts { #[clap(long)] proposal: Option, - /// Path to a file containing the proposal. The proposal must be formatted as a string - /// wrapped candid record. + /// Path to a file containing the proposal. The proposal must be the binary encoding of + /// the proposal candid record. #[clap( long, conflicts_with = "proposal", @@ -60,14 +60,12 @@ pub fn exec( let neuron_subaccount = neuron_id.subaccount().map_err(Error::msg)?; let governance_canister_id = sns_canister_ids.governance_canister_id; - let proposal_string = if let Some(proposal) = opts.proposal { - proposal + let proposal = if let Some(proposal) = opts.proposal { + parse_proposal_from_candid_string(proposal)? } else { - fs::read_to_string(opts.proposal_path.unwrap())? + Decode!(&fs::read(opts.proposal_path.unwrap())?, Proposal)? }; - let proposal = parse_proposal_from_candid_string(proposal_string)?; - let args = Encode!(&ManageNeuron { subaccount: neuron_subaccount.to_vec(), command: Some(manage_neuron::Command::MakeProposal(proposal)) diff --git a/tests/commands/sns-make-proposal-from-file.sh b/tests/commands/sns-make-proposal-from-file.sh new file mode 100755 index 00000000..d69b19dc --- /dev/null +++ b/tests/commands/sns-make-proposal-from-file.sh @@ -0,0 +1,3 @@ +NEURON_ID=83a7d2b12f654ff58335e5a2512ccae0d7839c744b1807a47c96f5b9f3969069 +"$QUILL" sns make-proposal $NEURON_ID --proposal-path "outputs/sns_proposal.txt" --canister-ids-file ./sns_canister_ids.json --pem-file - | "$QUILL" send --dry-run - + diff --git a/tests/outputs/sns-make-proposal-from-file.txt b/tests/outputs/sns-make-proposal-from-file.txt new file mode 100644 index 00000000..6469c146 --- /dev/null +++ b/tests/outputs/sns-make-proposal-from-file.txt @@ -0,0 +1,23 @@ +Sending message with + + Call type: update + Sender: fdsgv-62ihb-nbiqv-xgic5-iefsv-3cscz-tmbzv-63qd5-vh43v-dqfrt-pae + Canister id: rrkah-fqaaa-aaaaa-aaaaq-cai + Method name: manage_neuron + Arguments: ( + record { + subaccount = blob "\83\a7\d2\b1/eO\f5\835\e5\a2Q,\ca\e0\d7\83\9ctK\18\07\a4|\96\f5\b9\f3\96\90i"; + command = opt variant { + MakeProposal = record { + url = "https://dfinity.org"; + title = "SNS Launch"; + action = opt variant { + Motion = record { + motion_text = "I hereby raise the motion that the use of the SNS shall commence"; + } + }; + summary = "A motion to start the SNS"; + } + }; + }, +) diff --git a/tests/outputs/sns_proposal.txt b/tests/outputs/sns_proposal.txt new file mode 100644 index 0000000000000000000000000000000000000000..0a208ce4751d69f74632f27f96df64f238571b01 GIT binary patch literal 174 zcmZ?qbn#)yVR?V;2~**W)o&UZ3%7lrv5Ap!*|a6?9EEvI*^Jk|9RJVHoWnS6@0OP= zg^Ucs86_nJ#a8CJ zB^jv-x%nlT`FTKQVhNaE3KY*z12aKdi!%~)aukyDb8}Pkl2aue;p+1hic1oUAbNlb E0X9fLtN;K2 literal 0 HcmV?d00001