diff --git a/Cargo.lock b/Cargo.lock index f3d0620a3..1f8c0579d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1961,7 +1961,7 @@ dependencies = [ [[package]] name = "helium-sub-daos" -version = "0.1.6" +version = "0.1.7" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/packages/helium-admin-cli/src/set-dc-onboarding-fees-paid.ts b/packages/helium-admin-cli/src/set-dc-onboarding-fees-paid.ts new file mode 100644 index 000000000..dfc7288e4 --- /dev/null +++ b/packages/helium-admin-cli/src/set-dc-onboarding-fees-paid.ts @@ -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: [], + }); +} diff --git a/programs/helium-entity-manager/src/instructions/onboard_data_only_iot_hotspot_v0.rs b/programs/helium-entity-manager/src/instructions/onboard_data_only_iot_hotspot_v0.rs index 52992fabd..442957f66 100644 --- a/programs/helium-entity-manager/src/instructions/onboard_data_only_iot_hotspot_v0.rs +++ b/programs/helium-entity-manager/src/instructions/onboard_data_only_iot_hotspot_v0.rs @@ -161,24 +161,6 @@ pub fn handler<'info>( dc_onboarding_fee_paid: dc_fee, }); - track_dc_onboarding_fees_v0( - CpiContext::new_with_signer( - ctx.accounts.helium_sub_daos_program.to_account_info(), - TrackDcOnboardingFeesV0 { - hem_auth: ctx.accounts.rewardable_entity_config.to_account_info(), - sub_dao: ctx.accounts.sub_dao.to_account_info(), - }, - &[rewardable_entity_config_seeds!( - ctx.accounts.rewardable_entity_config - )], - ), - TrackDcOnboardingFeesArgsV0 { - amount: dc_fee, - add: true, - symbol: ctx.accounts.rewardable_entity_config.symbol.clone(), - }, - )?; - if let ( Some(location), ConfigSettingsV0::IotConfig { diff --git a/programs/helium-entity-manager/src/instructions/onboard_iot_hotspot_v0.rs b/programs/helium-entity-manager/src/instructions/onboard_iot_hotspot_v0.rs index 1f3366a6a..fd583d5ed 100644 --- a/programs/helium-entity-manager/src/instructions/onboard_iot_hotspot_v0.rs +++ b/programs/helium-entity-manager/src/instructions/onboard_iot_hotspot_v0.rs @@ -161,23 +161,6 @@ pub fn handler<'info>( is_active: false, dc_onboarding_fee_paid: dc_fee, }); - track_dc_onboarding_fees_v0( - CpiContext::new_with_signer( - ctx.accounts.helium_sub_daos_program.to_account_info(), - TrackDcOnboardingFeesV0 { - hem_auth: ctx.accounts.rewardable_entity_config.to_account_info(), - sub_dao: ctx.accounts.sub_dao.to_account_info(), - }, - &[rewardable_entity_config_seeds!( - ctx.accounts.rewardable_entity_config - )], - ), - TrackDcOnboardingFeesArgsV0 { - amount: dc_fee, - add: true, - symbol: ctx.accounts.rewardable_entity_config.symbol.clone(), - }, - )?; if let ( Some(location), diff --git a/programs/helium-entity-manager/src/instructions/onboard_mobile_hotspot_v0.rs b/programs/helium-entity-manager/src/instructions/onboard_mobile_hotspot_v0.rs index e6db1c2f7..6194e2580 100644 --- a/programs/helium-entity-manager/src/instructions/onboard_mobile_hotspot_v0.rs +++ b/programs/helium-entity-manager/src/instructions/onboard_mobile_hotspot_v0.rs @@ -210,27 +210,6 @@ pub fn handler<'info>( .unwrap(); } - track_dc_onboarding_fees_v0( - CpiContext::new_with_signer( - ctx.accounts.helium_sub_daos_program.to_account_info(), - TrackDcOnboardingFeesV0 { - hem_auth: ctx.accounts.rewardable_entity_config.to_account_info(), - sub_dao: ctx.accounts.sub_dao.to_account_info(), - }, - &[&[ - "rewardable_entity_config".as_bytes(), - ctx.accounts.sub_dao.key().as_ref(), - ctx.accounts.rewardable_entity_config.symbol.as_bytes(), - &[ctx.accounts.rewardable_entity_config.bump_seed], - ]], - ), - TrackDcOnboardingFeesArgsV0 { - amount: fees.dc_onboarding_fee, - add: true, - symbol: ctx.accounts.rewardable_entity_config.symbol.clone(), - }, - )?; - // burn the dc tokens burn_without_tracking_v0( ctx.accounts.burn_ctx(), diff --git a/programs/helium-sub-daos/Cargo.toml b/programs/helium-sub-daos/Cargo.toml index 117e7d43f..7ee6772a9 100644 --- a/programs/helium-sub-daos/Cargo.toml +++ b/programs/helium-sub-daos/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "helium-sub-daos" -version = "0.1.6" +version = "0.1.7" description = "Created with Anchor" edition = "2021" diff --git a/programs/helium-sub-daos/src/instructions/admin_set_dc_onboarding_fees_paid.rs b/programs/helium-sub-daos/src/instructions/admin_set_dc_onboarding_fees_paid.rs new file mode 100644 index 000000000..021a5f3dd --- /dev/null +++ b/programs/helium-sub-daos/src/instructions/admin_set_dc_onboarding_fees_paid.rs @@ -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, + args: AdminSetDcOnboardingFeesPaidArgs, +) -> Result<()> { + ctx.accounts.sub_dao.dc_onboarding_fees_paid = args.dc_onboarding_fees_paid; + Ok(()) +} diff --git a/programs/helium-sub-daos/src/instructions/mod.rs b/programs/helium-sub-daos/src/instructions/mod.rs index a0c09ceea..fadef531c 100644 --- a/programs/helium-sub-daos/src/instructions/mod.rs +++ b/programs/helium-sub-daos/src/instructions/mod.rs @@ -1,3 +1,4 @@ +pub mod admin_set_dc_onboarding_fees_paid; pub mod calculate_utility_score_v0; pub mod delegation; pub mod initialize_dao_v0; @@ -11,6 +12,7 @@ pub mod update_dao_v0; pub mod update_sub_dao_v0; pub mod update_sub_dao_vehnt_v0; +pub use admin_set_dc_onboarding_fees_paid::*; pub use calculate_utility_score_v0::*; pub use delegation::*; pub use initialize_dao_v0::*; diff --git a/programs/helium-sub-daos/src/lib.rs b/programs/helium-sub-daos/src/lib.rs index bff9fa9dc..1627057d9 100644 --- a/programs/helium-sub-daos/src/lib.rs +++ b/programs/helium-sub-daos/src/lib.rs @@ -113,4 +113,11 @@ pub mod helium_sub_daos { ) -> Result<()> { track_dc_onboarding_fees_v0::handler(ctx, args) } + + pub fn admin_set_dc_onboarding_fees_paid( + ctx: Context, + args: AdminSetDcOnboardingFeesPaidArgs, + ) -> Result<()> { + admin_set_dc_onboarding_fees_paid::handler(ctx, args) + } }