-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug double adding dc onboarding fees and add an endpoint to corre…
…ct the fees (#686)
- Loading branch information
1 parent
3f5a4be
commit 6eb3edc
Showing
9 changed files
with
128 additions
and
58 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
packages/helium-admin-cli/src/set-dc-onboarding-fees-paid.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import * as anchor from "@coral-xyz/anchor"; | ||
import { init as initHsd, subDaoKey } from "@helium/helium-sub-daos-sdk"; | ||
import { MOBILE_MINT } from "@helium/spl-utils"; | ||
import { PublicKey, TransactionInstruction } from "@solana/web3.js"; | ||
import Squads from "@sqds/sdk"; | ||
import os from "os"; | ||
import yargs from "yargs/yargs"; | ||
import { loadKeypair, sendInstructionsOrSquads } from "./utils"; | ||
|
||
export async function run(args: any = process.argv) { | ||
const yarg = yargs(args).options({ | ||
wallet: { | ||
alias: "k", | ||
describe: "Anchor wallet keypair", | ||
default: `${os.homedir()}/.config/solana/id.json`, | ||
}, | ||
url: { | ||
alias: "u", | ||
default: "http://127.0.0.1:8899", | ||
describe: "The solana url", | ||
}, | ||
executeTransaction: { | ||
type: "boolean", | ||
}, | ||
multisig: { | ||
type: "string", | ||
describe: | ||
"Address of the squads multisig to be authority. If not provided, your wallet will be the authority", | ||
}, | ||
authorityIndex: { | ||
type: "number", | ||
describe: "Authority index for squads. Defaults to 1", | ||
default: 1, | ||
}, | ||
minimumPeriods: { | ||
type: "number", | ||
describe: "The new minimum number of periods", | ||
}, | ||
dcOnboardingFeesPaid: { | ||
type: "string", | ||
required: true, | ||
describe: "The new dc onboarding fees paid", | ||
}, | ||
dntMint: { | ||
type: "string", | ||
describe: "DNT mint of the boost config", | ||
default: MOBILE_MINT.toBase58(), | ||
}, | ||
}); | ||
const argv = await yarg.argv; | ||
process.env.ANCHOR_WALLET = argv.wallet; | ||
process.env.ANCHOR_PROVIDER_URL = argv.url; | ||
anchor.setProvider(anchor.AnchorProvider.local(argv.url)); | ||
const provider = anchor.getProvider() as anchor.AnchorProvider; | ||
const wallet = new anchor.Wallet(loadKeypair(argv.wallet)); | ||
const hsdProgram = await initHsd(provider); | ||
|
||
const instructions: TransactionInstruction[] = []; | ||
|
||
const dntMint = new PublicKey(argv.dntMint); | ||
const subDaoK = subDaoKey(dntMint)[0]; | ||
|
||
instructions.push( | ||
await hsdProgram.methods | ||
.adminSetDcOnboardingFeesPaid({ | ||
dcOnboardingFeesPaid: new anchor.BN(argv.dcOnboardingFeesPaid), | ||
}) | ||
.accounts({ | ||
subDao: subDaoK, | ||
}) | ||
.instruction() | ||
); | ||
|
||
const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { | ||
commitmentOrConfig: "finalized", | ||
}); | ||
|
||
await sendInstructionsOrSquads({ | ||
provider, | ||
instructions, | ||
executeTransaction: argv.executeTransaction, | ||
squads, | ||
multisig: argv.multisig ? new PublicKey(argv.multisig) : undefined, | ||
authorityIndex: argv.authorityIndex, | ||
signers: [], | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
programs/helium-sub-daos/src/instructions/admin_set_dc_onboarding_fees_paid.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
use crate::{DaoV0, SubDaoV0}; | ||
|
||
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] | ||
pub struct AdminSetDcOnboardingFeesPaidArgs { | ||
pub dc_onboarding_fees_paid: u64, | ||
} | ||
|
||
#[derive(Accounts)] | ||
pub struct AdminSetDcOnboardingFeesPaid<'info> { | ||
#[account( | ||
has_one = authority, | ||
)] | ||
pub dao: Account<'info, DaoV0>, | ||
#[account( | ||
mut, | ||
has_one = dao, | ||
)] | ||
pub sub_dao: Account<'info, SubDaoV0>, | ||
pub authority: Signer<'info>, | ||
} | ||
|
||
pub fn handler( | ||
ctx: Context<AdminSetDcOnboardingFeesPaid>, | ||
args: AdminSetDcOnboardingFeesPaidArgs, | ||
) -> Result<()> { | ||
ctx.accounts.sub_dao.dc_onboarding_fees_paid = args.dc_onboarding_fees_paid; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters