Skip to content

Commit

Permalink
Add command to refresh following
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity committed Dec 11, 2024
1 parent a440514 commit f129ec6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Added `quill neuron-manage --refresh-followers`.

## [0.5.2] - 2024-12-05

- Fixed the display format of SNS sale tickets.
Expand Down
17 changes: 16 additions & 1 deletion src/commands/neuron_manage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use candid::{CandidType, Encode, Principal};
use clap::{Parser, ValueEnum};
use ic_base_types::PrincipalId;
use ic_nns_common::pb::v1::{NeuronId, ProposalId};
use ic_nns_governance::pb::v1::manage_neuron::RefreshVotingPower;
use ic_nns_governance::pb::v1::{
manage_neuron::{
configure::Operation, disburse::Amount, AddHotKey, ChangeAutoStakeMaturity, Command,
Expand Down Expand Up @@ -138,6 +139,11 @@ pub struct ManageOpts {
/// a limited subset (Private).
#[arg(long)]
set_visibility: Option<NativeVisibility>,

/// Refresh the neuron's voting power by reaffirming the current list of followers.
/// This must be done every so often to avoid neurons diminishing in voting power.
#[arg(long)]
refresh_followers: bool,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
Expand All @@ -152,7 +158,7 @@ pub fn exec(auth: &AuthInfo, opts: ManageOpts) -> AnyhowResult<Vec<IngressWithRe
opts.add_hot_key.is_none() && opts.remove_hot_key.is_none() && !opts.disburse && opts.disburse_amount.is_none() && opts.disburse_to.is_none()
&& !opts.clear_manage_neuron_followees && !opts.join_community_fund && !opts.leave_community_fund
&& opts.follow_topic.is_none() && opts.follow_neurons.is_none() && opts.register_vote.is_none() && !opts.reject
&& opts.set_visibility.is_none(),
&& opts.set_visibility.is_none() && !opts.refresh_followers,
"\
Cannot use --ledger with these flags. This version of quill only supports the following neuron-manage operations with a Ledger device:
--additional-dissolve-delay-seconds, --start-dissolving, --stop-dissolving, --split, --merge-from-neuron, --spawn, --stake-maturity, --auto-stake-maturity"
Expand Down Expand Up @@ -416,6 +422,15 @@ Cannot use --ledger with these flags. This version of quill only supports the fo
msgs.push(args);
}

if opts.refresh_followers {
let args = Encode!(&ManageNeuron {
command: Some(Command::RefreshVotingPower(RefreshVotingPower {})),
neuron_id_or_subaccount: id.clone(),
id: None,
})?;
msgs.push(args);
}

if msgs.is_empty() {
return Err(anyhow!("No instructions provided"));
}
Expand Down
15 changes: 15 additions & 0 deletions tests/output/default/neuron_manage/refresh_followers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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 = null;
command = opt variant { RefreshVotingPower = record {} };
neuron_id_or_subaccount = opt variant {
NeuronId = record { id = 2_313_380_519_530_470_538 : nat64 }
};
},
)
6 changes: 6 additions & 0 deletions tests/output/neuron_manage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,9 @@ fn set_visibility() {
))
.diff("neuron_manage/set_visibility.txt")
}

#[test]
fn refresh_followers() {
quill_send(&format!("neuron-manage {NEURON_ID} --refresh-followers"))
.diff("neuron_manage/refresh_followers.txt")
}

0 comments on commit f129ec6

Please sign in to comment.