Skip to content

Commit

Permalink
Allow updating net emission cap (fixes #286) (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChewingGlass committed Jun 21, 2023
1 parent 390ed6a commit 14382e9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/helium-admin-cli/src/create-dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ export async function run(args: any = process.argv) {
emissionSchedule: hntEmission,
hstEmissionSchedule: hstEmission,
hstPool: null,
netEmissionsCap: null,
})
.accounts({
dao,
Expand Down
7 changes: 7 additions & 0 deletions packages/helium-admin-cli/src/update-dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export async function run(args: any = process.argv) {
type: "string",
default: null,
},
newNetEmissionsCap: {
required: false,
describe: "New net emissions cap, without decimals",
type: "string",
default: null
},
newHstPool: {
required: false,
describe: "New HST Pool",
Expand Down Expand Up @@ -92,6 +98,7 @@ export async function run(args: any = process.argv) {
authority: argv.newAuthority ? new PublicKey(argv.newAuthority) : null,
emissionSchedule: argv.newEmissionsSchedulePath ? await parseEmissionsSchedule(argv.newEmissionsSchedulePath) : null,
hstEmissionSchedule: argv.newHstEmissionsSchedulePath ? await parseEmissionsSchedule(argv.newHstEmissionsSchedulePath) : null,
netEmissionsCap: argv.newNetEmissionsCap ? new anchor.BN(argv.newNetEmissionsCap) : null,
hstPool: argv.newHstPool ? new PublicKey(argv.newHstPool) : null,
}).accounts({
dao,
Expand Down
2 changes: 1 addition & 1 deletion programs/helium-sub-daos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "helium-sub-daos"
version = "0.0.10"
version = "0.0.11"
description = "Created with Anchor"
edition = "2021"

Expand Down
5 changes: 5 additions & 0 deletions programs/helium-sub-daos/src/instructions/update_dao_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub struct UpdateDaoArgsV0 {
pub emission_schedule: Option<Vec<EmissionScheduleItem>>,
pub hst_emission_schedule: Option<Vec<PercentItem>>,
pub hst_pool: Option<Pubkey>,
pub net_emissions_cap: Option<u64>,
}

#[derive(Accounts)]
Expand Down Expand Up @@ -35,6 +36,10 @@ pub fn handler(ctx: Context<UpdateDaoV0>, args: UpdateDaoArgsV0) -> Result<()> {
ctx.accounts.dao.hst_emission_schedule = hst_emission_schedule;
}

if let Some(net_emissions_cap) = args.net_emissions_cap {
ctx.accounts.dao.net_emissions_cap = net_emissions_cap;
}

if let Some(emission_schedule) = args.emission_schedule {
ctx.accounts.dao.emission_schedule = emission_schedule;

Expand Down
1 change: 1 addition & 0 deletions tests/helium-sub-daos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ describe("helium-sub-daos", () => {
emissionSchedule: null,
hstEmissionSchedule: null,
hstPool: null,
netEmissionsCap: null,
})
.accounts({
dao,
Expand Down

0 comments on commit 14382e9

Please sign in to comment.