Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ability to leave community fund #135

Merged
merged 6 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions candid/governance.did
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type IncreaseDissolveDelay = record {
additional_dissolve_delay_seconds : nat32;
};
type JoinCommunityFund = record {};
type LeaveCommunityFund = record {};
type ListNeurons = record {
neuron_ids : vec nat64;
include_neurons_readable_by_caller : bool;
Expand Down Expand Up @@ -197,6 +198,7 @@ type Operation = variant {
IncreaseDissolveDelay : IncreaseDissolveDelay;
SetDissolveTimestamp : SetDissolveTimestamp;
JoinCommunityFund: JoinCommunityFund;
LeaveCommunityFund: LeaveCommunityFund;
};
type Proposal = record { url : text; action : opt Action; summary : text };
type ProposalData = record {
Expand Down
21 changes: 20 additions & 1 deletion src/commands/neuron_manage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ pub struct AddHotKey {
#[derive(CandidType)]
pub struct JoinCommunityFund {}

#[derive(CandidType)]
pub struct LeaveCommunityFund {}

#[derive(CandidType)]
pub struct ProposalId {
pub id: u64,
Expand All @@ -68,6 +71,7 @@ pub enum Operation {
AddHotKey(AddHotKey),
IncreaseDissolveDelay(IncreaseDissolveDelay),
JoinCommunityFund(JoinCommunityFund),
LeaveCommunityFund(LeaveCommunityFund),
}

#[derive(CandidType)]
Expand Down Expand Up @@ -180,10 +184,14 @@ pub struct ManageOpts {
#[clap(long)]
merge_maturity: Option<u32>,

/// Join the Internet Computer's community fund with this neuron's entire stake. Caution: this operation is not reversible.
/// Join the Internet Computer's community fund with this neuron's entire stake.
#[clap(long)]
join_community_fund: bool,

/// Leave the Internet Computer's community fund.
#[clap(long, conflicts_with("join-community-fund"))]
leave_community_fund: bool,

/// Defines the topic of a follow rule.
#[clap(long)]
follow_topic: Option<i32>,
Expand Down Expand Up @@ -386,6 +394,17 @@ pub fn exec(auth: &AuthInfo, opts: ManageOpts) -> AnyhowResult<Vec<IngressWithRe
msgs.push(args);
};

if opts.leave_community_fund {
let args = Encode!(&ManageNeuron {
id,
command: Some(Command::Configure(Configure {
operation: Some(Operation::LeaveCommunityFund(LeaveCommunityFund {}))
})),
neuron_id_or_subaccount: None,
})?;
msgs.push(args);
}

if let Some(proposals) = opts.register_vote {
for proposal in proposals {
let args = Encode!(&ManageNeuron {
Expand Down
1 change: 1 addition & 0 deletions tests/commands/neuron-manage-leave-community-fund.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${CARGO_TARGET_DIR:-../target}/debug/quill neuron-manage 2313380519530470538 --leave-community-fund --pem-file - | ${CARGO_TARGET_DIR:-../target}/debug/quill send --dry-run -
17 changes: 17 additions & 0 deletions tests/outputs/neuron-manage-leave-community-fund.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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 = 2_313_380_519_530_470_538 : nat64 };
command = opt variant {
Configure = record {
operation = opt variant { LeaveCommunityFund = record {} };
}
};
neuron_id_or_subaccount = null;
},
)