Skip to content

Commit

Permalink
make --proposal-path load binary encoding of the proposal candid reco…
Browse files Browse the repository at this point in the history
…rd (#160)

* make --proposal-path load binary encoding of the proposal candid record

* update CHANGELOG

---------

Co-authored-by: Martin Raszyk <[email protected]>
Co-authored-by: Linwei Shang <[email protected]>
  • Loading branch information
3 people authored Feb 14, 2023
1 parent 81272c9 commit aaa663d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 5 additions & 7 deletions src/commands/sns/make_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub struct MakeProposalOpts {
#[clap(long)]
proposal: Option<String>,

/// 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",
Expand All @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions tests/commands/sns-make-proposal-from-file.sh
Original file line number Diff line number Diff line change
@@ -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 -

23 changes: 23 additions & 0 deletions tests/outputs/sns-make-proposal-from-file.txt
Original file line number Diff line number Diff line change
@@ -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";
}
};
},
)
Binary file added tests/outputs/sns_proposal.txt
Binary file not shown.

0 comments on commit aaa663d

Please sign in to comment.