From fe00e66786d53c33d8cced267095a6c15bfeda03 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 1 Sep 2022 17:21:49 -0700 Subject: [PATCH 1/6] Ability to submit proposals using only quill --- candid/governance.did | 7 +++- src/commands/neuron_manage.rs | 66 +++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/candid/governance.did b/candid/governance.did index 7b3afa05..130b51b4 100644 --- a/candid/governance.did +++ b/candid/governance.did @@ -198,7 +198,12 @@ type Operation = variant { SetDissolveTimestamp : SetDissolveTimestamp; JoinCommunityFund: JoinCommunityFund; }; -type Proposal = record { url : text; action : opt Action; summary : text }; +type Proposal = record { + title : opt text; + summary : text; + url : text; + action : opt Action; +}; type ProposalData = record { id : opt NeuronId; failure_reason : opt GovernanceError; diff --git a/src/commands/neuron_manage.rs b/src/commands/neuron_manage.rs index 169f740b..19cc8683 100644 --- a/src/commands/neuron_manage.rs +++ b/src/commands/neuron_manage.rs @@ -111,6 +111,32 @@ pub struct MergeMaturity { pub percentage_to_merge: u32, } +#[derive(candid::CandidType)] +pub struct Motion { + pub motion_text: String, +} + +#[derive(candid::CandidType)] +pub enum Action { + // ManageNeuron(ManageNeuron), + // ExecuteNnsFunction(ExecuteNnsFunction), + // RewardNodeProvider(RewardNodeProvider), + // SetDefaultFollowees(SetDefaultFollowees), + // RewardNodeProviders(RewardNodeProviders), + // ManageNetworkEconomics(NetworkEconomics), + // ApproveGenesisKyc(ApproveGenesisKyc), + // AddOrRemoveNodeProvider(AddOrRemoveNodeProvider), + Motion(Motion), +} + +#[derive(candid::CandidType)] +pub struct Proposal { + pub title: Option, + pub summary: String, + pub url: String, + pub action: Option, +} + #[derive(CandidType)] pub enum Command { Configure(Configure), @@ -121,6 +147,7 @@ pub enum Command { Follow(Follow), Merge(Merge), MergeMaturity(MergeMaturity), + MakeProposal(Proposal), } #[derive(CandidType)] @@ -199,6 +226,18 @@ pub struct ManageOpts { /// Reject proposal(s). #[clap(long)] reject: bool, + + /// Submit a proposal with this title; must be used with --proposal-summary-file + #[clap(long)] + proposal_title: Option, + + /// URL to be associated with a submitted proposal + #[clap(long)] + proposal_url: Option, + + /// Submit a proposal, taking its summary from this file and title from --proposal-title + #[clap(long)] + proposal_summary_file: Option, } pub fn exec(auth: &AuthInfo, opts: ManageOpts) -> AnyhowResult> { @@ -375,6 +414,33 @@ pub fn exec(auth: &AuthInfo, opts: ManageOpts) -> AnyhowResult Date: Tue, 6 Sep 2022 16:48:50 -0700 Subject: [PATCH 2/6] Add test files for make-proposal --- tests/commands/neuron-manage-make-proposal.sh | 1 + tests/outputs/neuron-manage-make-proposal.txt | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 tests/commands/neuron-manage-make-proposal.sh create mode 100644 tests/outputs/neuron-manage-make-proposal.txt diff --git a/tests/commands/neuron-manage-make-proposal.sh b/tests/commands/neuron-manage-make-proposal.sh new file mode 100755 index 00000000..db64df8e --- /dev/null +++ b/tests/commands/neuron-manage-make-proposal.sh @@ -0,0 +1 @@ +${CARGO_TARGET_DIR:-../target}/debug/quill neuron-manage 65 --proposal-title "Hello" --proposal-summary-file commands/neuron-manage-make-proposal.sh --pem-file - | ${CARGO_TARGET_DIR:-../target}/debug/quill send --dry-run - diff --git a/tests/outputs/neuron-manage-make-proposal.txt b/tests/outputs/neuron-manage-make-proposal.txt new file mode 100644 index 00000000..e28546b7 --- /dev/null +++ b/tests/outputs/neuron-manage-make-proposal.txt @@ -0,0 +1,20 @@ +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 { + id = opt record { id = 65 : nat64 }; + command = opt variant { + MakeProposal = record { + url = ""; + title = opt "Hello"; + action = variant { Motion = record { motion_text = "Hello" } }; + summary = "${CARGO_TARGET_DIR:-../target}/debug/quill neuron-manage 65 --proposal-title \"Hello\" --proposal-summary-file commands/neuron-manage-make-proposal.sh --pem-file - | ${CARGO_TARGET_DIR:-../target}/debug/quill send --dry-run -\n"; + } + }; + neuron_id_or_subaccount = null; + }, +) From 387de353a76b05f8c483ee8d6e2a98a40afe4df3 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 6 Sep 2022 17:08:22 -0700 Subject: [PATCH 3/6] Fix the make-proposal output text --- tests/outputs/neuron-manage-make-proposal.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/outputs/neuron-manage-make-proposal.txt b/tests/outputs/neuron-manage-make-proposal.txt index e28546b7..c017a5ac 100644 --- a/tests/outputs/neuron-manage-make-proposal.txt +++ b/tests/outputs/neuron-manage-make-proposal.txt @@ -11,7 +11,7 @@ Sending message with MakeProposal = record { url = ""; title = opt "Hello"; - action = variant { Motion = record { motion_text = "Hello" } }; + action = opt variant { Motion = record { motion_text = "Hello" } }; summary = "${CARGO_TARGET_DIR:-../target}/debug/quill neuron-manage 65 --proposal-title \"Hello\" --proposal-summary-file commands/neuron-manage-make-proposal.sh --pem-file - | ${CARGO_TARGET_DIR:-../target}/debug/quill send --dry-run -\n"; } }; From 83b390482594b0bc0bacf4403a9358b11e936b96 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 6 Sep 2022 17:19:39 -0700 Subject: [PATCH 4/6] Fix clippy warnings --- src/commands/neuron_manage.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/commands/neuron_manage.rs b/src/commands/neuron_manage.rs index 19cc8683..2a4e092a 100644 --- a/src/commands/neuron_manage.rs +++ b/src/commands/neuron_manage.rs @@ -422,10 +422,9 @@ pub fn exec(auth: &AuthInfo, opts: ManageOpts) -> AnyhowResult AnyhowResult Date: Wed, 21 Sep 2022 21:45:56 -0700 Subject: [PATCH 5/6] Add support for submitting a known neuron proposal --- candid/governance.did | 6 +++++ src/commands/neuron_manage.rs | 46 ++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/candid/governance.did b/candid/governance.did index 130b51b4..b351469e 100644 --- a/candid/governance.did +++ b/candid/governance.did @@ -1,5 +1,6 @@ type AccountIdentifier = record { hash : vec nat8 }; type Action = variant { + RegisterKnownNeuron : KnownNeuron; ManageNeuron : ManageNeuron; ExecuteNnsFunction : ExecuteNnsFunction; RewardNodeProvider : RewardNodeProvider; @@ -103,6 +104,11 @@ type IncreaseDissolveDelay = record { additional_dissolve_delay_seconds : nat32; }; type JoinCommunityFund = record {}; +type KnownNeuron = record { + id : opt NeuronId; + known_neuron_data : opt KnownNeuronData; +}; +type KnownNeuronData = record { name : text; description : opt text }; type ListNeurons = record { neuron_ids : vec nat64; include_neurons_readable_by_caller : bool; diff --git a/src/commands/neuron_manage.rs b/src/commands/neuron_manage.rs index 2a4e092a..4646d33a 100644 --- a/src/commands/neuron_manage.rs +++ b/src/commands/neuron_manage.rs @@ -116,8 +116,21 @@ pub struct Motion { pub motion_text: String, } +#[derive(candid::CandidType)] +pub struct KnownNeuron { + id: Option, + known_neuron_data: Option, +} + +#[derive(candid::CandidType)] +pub struct KnownNeuronData { + name: String, + description: Option, +} + #[derive(candid::CandidType)] pub enum Action { + RegisterKnownNeuron(KnownNeuron), // ManageNeuron(ManageNeuron), // ExecuteNnsFunction(ExecuteNnsFunction), // RewardNodeProvider(RewardNodeProvider), @@ -238,6 +251,22 @@ pub struct ManageOpts { /// Submit a proposal, taking its summary from this file and title from --proposal-title #[clap(long)] proposal_summary_file: Option, + + /// The kind of proposal to be submitted: "motion", or "register-known-neuron" + #[clap(long)] + proposal_kind: Option, + + /// For a register-known-neuron proposal, the neuron id being proposed + #[clap(long)] + known_neuron_id: Option, + + /// For a register-known-neuron proposal, the name being proposed + #[clap(long)] + known_neuron_name: Option, + + /// For a register-known-neuron proposal, a brief description of the neuron + #[clap(long)] + known_neuron_desc: Option, } pub fn exec(auth: &AuthInfo, opts: ManageOpts) -> AnyhowResult> { @@ -421,7 +450,22 @@ pub fn exec(auth: &AuthInfo, opts: ManageOpts) -> AnyhowResult Action::RegisterKnownNeuron(KnownNeuron { + id: opts.known_neuron_id.map(|x| NeuronId { + id: parse_neuron_id(x.to_string()) + .expect("Could not parse known neuron id to propose") + }), + known_neuron_data: Some(KnownNeuronData { + name: opts + .known_neuron_name + .expect("Expected a known neuron name to propose") + .to_string(), + description: opts.known_neuron_desc.map(|x| x.to_string()), + }), + }), + _ => Action::Motion(Motion { motion_text: title }), + }), summary: std::fs::read_to_string(summary_file.clone()).unwrap_or_else( |_| panic!("Could not read summary file {}", summary_file.display()) ), From bdf477f830e201242184e2018231fea9491f6ae1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 24 Sep 2022 10:38:17 -0700 Subject: [PATCH 6/6] Fix several clippy warnings --- src/commands/neuron_manage.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/commands/neuron_manage.rs b/src/commands/neuron_manage.rs index b3ca41ef..c761dba1 100644 --- a/src/commands/neuron_manage.rs +++ b/src/commands/neuron_manage.rs @@ -461,15 +461,14 @@ pub fn exec(auth: &AuthInfo, opts: ManageOpts) -> AnyhowResult Action::RegisterKnownNeuron(KnownNeuron { id: opts.known_neuron_id.map(|x| NeuronId { - id: parse_neuron_id(x.to_string()) + id: parse_neuron_id(x) .expect("Could not parse known neuron id to propose") }), known_neuron_data: Some(KnownNeuronData { name: opts .known_neuron_name - .expect("Expected a known neuron name to propose") - .to_string(), - description: opts.known_neuron_desc.map(|x| x.to_string()), + .expect("Expected a known neuron name to propose"), + description: opts.known_neuron_desc, }), }), _ => Action::Motion(Motion { motion_text: title }),