diff --git a/packages/helium-admin-cli/src/approve-carrier.ts b/packages/helium-admin-cli/src/approve-carrier.ts index dc27f56ff..21e3a2ba7 100644 --- a/packages/helium-admin-cli/src/approve-carrier.ts +++ b/packages/helium-admin-cli/src/approve-carrier.ts @@ -1,47 +1,47 @@ -import * as anchor from '@coral-xyz/anchor'; -import { carrierKey, init as initMem } from '@helium/mobile-entity-manager-sdk'; -import { subDaoKey, init as initHsd } from '@helium/helium-sub-daos-sdk'; -import { Keypair, 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'; -import { MOBILE_MINT } from '@helium/spl-utils'; +import * as anchor from "@coral-xyz/anchor"; +import { carrierKey, init as initMem } from "@helium/mobile-entity-manager-sdk"; +import { subDaoKey, init as initHsd } from "@helium/helium-sub-daos-sdk"; +import { Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { MOBILE_MINT, sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, dntMint: { - type: 'string', - describe: 'DNT mint of the subdao to approve on', + type: "string", + describe: "DNT mint of the subdao to approve on", default: MOBILE_MINT.toBase58(), }, name: { - alias: 'n', - type: 'string', + alias: "n", + type: "string", required: true, - describe: 'Name of the carrier to approve, case sensitive', + describe: "Name of the carrier to approve, case sensitive", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -72,7 +72,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ diff --git a/packages/helium-admin-cli/src/approve-program.ts b/packages/helium-admin-cli/src/approve-program.ts index c1e5e7b9e..0888dc156 100644 --- a/packages/helium-admin-cli/src/approve-program.ts +++ b/packages/helium-admin-cli/src/approve-program.ts @@ -1,46 +1,46 @@ -import * as anchor from '@coral-xyz/anchor'; -import { init as initHem } from '@helium/helium-entity-manager-sdk'; -import { daoKey, init as initHsd } from '@helium/helium-sub-daos-sdk'; -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'; -import { HNT_MINT } from '@helium/spl-utils'; +import * as anchor from "@coral-xyz/anchor"; +import { init as initHem } from "@helium/helium-entity-manager-sdk"; +import { daoKey, init as initHsd } from "@helium/helium-sub-daos-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { HNT_MINT, sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, hntMint: { - type: 'string', - describe: 'HNT mint of the dao to be updated', + type: "string", + describe: "HNT mint of the dao to be updated", default: HNT_MINT.toBase58(), }, programId: { - type: 'string', - describe: 'Program ID to allow', + type: "string", + describe: "Program ID to allow", required: true, }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -74,7 +74,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ diff --git a/packages/helium-admin-cli/src/close-buffers.ts b/packages/helium-admin-cli/src/close-buffers.ts index c7380c282..6903af297 100644 --- a/packages/helium-admin-cli/src/close-buffers.ts +++ b/packages/helium-admin-cli/src/close-buffers.ts @@ -1,43 +1,40 @@ -import * as anchor from '@coral-xyz/anchor'; -import { PublicKey } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { - createCloseBufferInstruction, - loadKeypair, - sendInstructionsOrSquads, -} from './utils'; -import { BPF_UPGRADE_LOADER_ID } from '@solana/spl-governance'; -import bs58 from 'bs58'; +import * as anchor from "@coral-xyz/anchor"; +import { PublicKey } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { createCloseBufferInstruction, loadKeypair } from "./utils"; +import { BPF_UPGRADE_LOADER_ID } from "@solana/spl-governance"; +import bs58 from "bs58"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, programId: { - type: 'string', + type: "string", required: true, }, }); @@ -49,7 +46,7 @@ export async function run(args: any = process.argv) { const wallet = new anchor.Wallet(loadKeypair(argv.wallet)); const connection = provider.connection; const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); let authority = provider.wallet.publicKey; let multisig = argv.multisig ? new PublicKey(argv.multisig) : null; diff --git a/packages/helium-admin-cli/src/close-canopy.ts b/packages/helium-admin-cli/src/close-canopy.ts index d85b2ed1a..c03a8778e 100644 --- a/packages/helium-admin-cli/src/close-canopy.ts +++ b/packages/helium-admin-cli/src/close-canopy.ts @@ -1,44 +1,41 @@ -import * as anchor from '@coral-xyz/anchor'; -import { daoKey, init as initHsd } from '@helium/helium-sub-daos-sdk'; -import { PublicKey, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { - loadKeypair, - parseEmissionsSchedule, - sendInstructionsOrSquads, -} from './utils'; -import { init, lazyTransactionsKey } from '@helium/lazy-transactions-sdk'; +import * as anchor from "@coral-xyz/anchor"; +import { daoKey, init as initHsd } from "@helium/helium-sub-daos-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair, parseEmissionsSchedule } from "./utils"; +import { init, lazyTransactionsKey } from "@helium/lazy-transactions-sdk"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, name: { required: true, - type: 'string', - describe: 'Lazy dist name', + type: "string", + describe: "Lazy dist name", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -64,7 +61,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ provider, diff --git a/packages/helium-admin-cli/src/create-boost-config.ts b/packages/helium-admin-cli/src/create-boost-config.ts index ce4a1cbba..4f24cc15f 100644 --- a/packages/helium-admin-cli/src/create-boost-config.ts +++ b/packages/helium-admin-cli/src/create-boost-config.ts @@ -5,10 +5,11 @@ import { HNT_MINT, MOBILE_MINT, toBN } from "@helium/spl-utils"; import { PublicKey } from "@solana/web3.js"; import os from "os"; import yargs from "yargs/yargs"; -import { loadKeypair, sendInstructionsOrSquads } from "./utils"; +import { loadKeypair } from "./utils"; import { init as initHsd } from "@helium/helium-sub-daos-sdk"; import { getMint } from "@solana/spl-token"; import Squads from "@sqds/sdk"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ @@ -90,7 +91,8 @@ export async function run(args: any = process.argv) { const mint = await getMint(program.provider.connection, dntMint); const subDao = (await subDaoKey(dntMint))[0]; - const subDaoAuth = (await hsdProgram.account.subDaoV0.fetch(subDao)).authority + const subDaoAuth = (await hsdProgram.account.subDaoV0.fetch(subDao)) + .authority; const instructions = [ await program.methods .initializeBoostConfigV0({ @@ -104,7 +106,7 @@ export async function run(args: any = process.argv) { rentReclaimAuthority: new PublicKey(argv.rentReclaimAuthority), authority: subDaoAuth, subDao, - startAuthority: new PublicKey(argv.startAuthority) + startAuthority: new PublicKey(argv.startAuthority), }) .instruction(), ]; diff --git a/packages/helium-admin-cli/src/create-dao.ts b/packages/helium-admin-cli/src/create-dao.ts index 71ef16c83..6c687826b 100644 --- a/packages/helium-admin-cli/src/create-dao.ts +++ b/packages/helium-admin-cli/src/create-dao.ts @@ -1,26 +1,26 @@ -import * as anchor from '@coral-xyz/anchor'; -import { ThresholdType } from '@helium/circuit-breaker-sdk'; +import * as anchor from "@coral-xyz/anchor"; +import { ThresholdType } from "@helium/circuit-breaker-sdk"; import { PROGRAM_ID, accountPayerKey, dataCreditsKey, init as initDc, -} from '@helium/data-credits-sdk'; -import { fanoutKey } from '@helium/fanout-sdk'; +} from "@helium/data-credits-sdk"; +import { fanoutKey } from "@helium/fanout-sdk"; import { dataOnlyConfigKey, init as initHem, -} from '@helium/helium-entity-manager-sdk'; +} from "@helium/helium-entity-manager-sdk"; import { daoKey, init as initDao } from "@helium/helium-sub-daos-sdk"; -import { sendInstructions, toBN } from '@helium/spl-utils'; +import { sendInstructions, toBN } from "@helium/spl-utils"; import { init as initVsr, registrarKey, -} from '@helium/voter-stake-registry-sdk'; +} from "@helium/voter-stake-registry-sdk"; import { SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, getConcurrentMerkleTreeAccountSize, -} from '@solana/spl-account-compression'; +} from "@solana/spl-account-compression"; import { GoverningTokenConfigAccountArgs, GoverningTokenType, @@ -29,11 +29,11 @@ import { getGovernanceProgramVersion, withCreateRealm, withSetRealmAuthority, -} from '@solana/spl-governance'; +} from "@solana/spl-governance"; import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, -} from '@solana/spl-token'; +} from "@solana/spl-token"; import { ComputeBudgetProgram, Connection, @@ -43,19 +43,19 @@ import { SystemProgram, Transaction, TransactionInstruction, -} from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import { BN } from 'bn.js'; -import fs from 'fs'; -import os from 'os'; -import yargs from 'yargs/yargs'; +} from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import { BN } from "bn.js"; +import fs from "fs"; +import os from "os"; +import yargs from "yargs/yargs"; import { createAndMint, isLocalhost, loadKeypair, parseEmissionsSchedule, - sendInstructionsOrSquads, -} from './utils'; +} from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; const SECS_PER_DAY = 86400; const SECS_PER_YEAR = 365 * SECS_PER_DAY; @@ -73,106 +73,106 @@ async function exists( export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, hntKeypair: { - type: 'string', - describe: 'Keypair of the HNT token', + type: "string", + describe: "Keypair of the HNT token", default: `${__dirname}/../../keypairs/hnt.json`, }, dcKeypair: { - type: 'string', - describe: 'Keypair of the Data Credit token', + type: "string", + describe: "Keypair of the Data Credit token", default: `${__dirname}/../../keypairs/dc.json`, }, numHnt: { - type: 'number', + type: "number", describe: - 'Number of HNT tokens to pre mint before assigning authority to lazy distributor', + "Number of HNT tokens to pre mint before assigning authority to lazy distributor", default: 0, }, numDc: { - type: 'number', + type: "number", describe: - 'Number of DC tokens to pre mint before assigning authority to lazy distributor', + "Number of DC tokens to pre mint before assigning authority to lazy distributor", default: 1000, }, bucket: { - type: 'string', - describe: 'Bucket URL prefix holding all of the metadata jsons', + type: "string", + describe: "Bucket URL prefix holding all of the metadata jsons", default: - 'https://shdw-drive.genesysgo.net/6tcnBSybPG7piEDShBcrVtYJDPSvGrDbVvXmXKpzBvWP', + "https://shdw-drive.genesysgo.net/6tcnBSybPG7piEDShBcrVtYJDPSvGrDbVvXmXKpzBvWP", }, emissionSchedulePath: { required: true, - describe: 'Path to file that contains the hnt emissions schedule', - type: 'string', + describe: "Path to file that contains the hnt emissions schedule", + type: "string", default: `${__dirname}/../../emissions/hnt.json`, }, hstEmissionSchedulePath: { required: true, - describe: 'Path to file that contains the hst emissions schedule', - type: 'string', + describe: "Path to file that contains the hst emissions schedule", + type: "string", default: `${__dirname}/../../emissions/hst.json`, }, govProgramId: { - type: 'string', - describe: 'Pubkey of the GOV program', - default: 'hgovkRU6Ghe1Qoyb54HdSLdqN7VtxaifBzRmh9jtd3S', + type: "string", + describe: "Pubkey of the GOV program", + default: "hgovkRU6Ghe1Qoyb54HdSLdqN7VtxaifBzRmh9jtd3S", }, realmName: { - type: 'string', - describe: 'Name of the realm to be generated', - default: 'Helium', + type: "string", + describe: "Name of the realm to be generated", + default: "Helium", }, councilKeypair: { - type: 'string', - describe: 'Keypair of gov council token', + type: "string", + describe: "Keypair of gov council token", default: `${__dirname}/../../keypairs/council.json`, }, councilWallet: { - type: 'string', - describe: 'Pubkey for holding/distributing council tokens', + type: "string", + describe: "Pubkey for holding/distributing council tokens", default: await loadKeypair( `${os.homedir()}/.config/solana/id.json` ).publicKey.toBase58(), }, numCouncil: { - type: 'number', + type: "number", describe: - 'Number of Gov Council tokens to pre mint before assigning authority to dao', + "Number of Gov Council tokens to pre mint before assigning authority to dao", default: 10, }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to control the dao. If not provided, your wallet will be the authority', + "Address of the squads multisig to control the dao. If not provided, your wallet will be the authority", }, authorityIndex: { - type: 'number', - describe: 'Authority index for squads. Defaults to 1', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, hntPriceOracle: { - type: 'string', + type: "string", required: true, }, numHst: { - type: 'number', + type: "number", describe: - 'Number of HST tokens to pre mint before assigning authority to lazy distributor', + "Number of HST tokens to pre mint before assigning authority to lazy distributor", default: 0, }, merklePath: { - type: 'string', - describe: 'Path to the merkle keypair', + type: "string", + describe: "Path to the merkle keypair", default: `${__dirname}/../../keypairs/data-only-merkle.json`, }, }); @@ -198,18 +198,18 @@ export async function run(args: any = process.argv) { const me = provider.wallet.publicKey; const dao = daoKey(hntKeypair.publicKey)[0]; - console.log('HNT', hntKeypair.publicKey.toBase58()); - console.log('DC', dcKeypair.publicKey.toBase58()); - console.log('GOV PID', govProgramId.toBase58()); - console.log('COUNCIL', councilKeypair.publicKey.toBase58()); - console.log('COUNCIL WALLET', councilWallet.toBase58()); + console.log("HNT", hntKeypair.publicKey.toBase58()); + console.log("DC", dcKeypair.publicKey.toBase58()); + console.log("GOV PID", govProgramId.toBase58()); + console.log("COUNCIL", councilKeypair.publicKey.toBase58()); + console.log("COUNCIL WALLET", councilWallet.toBase58()); - console.log('DAO', dao.toString()); + console.log("DAO", dao.toString()); const conn = provider.connection; const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); let authority = provider.wallet.publicKey; let multisig = argv.multisig ? new PublicKey(argv.multisig) : null; @@ -218,7 +218,7 @@ export async function run(args: any = process.argv) { // Fund authority const authAcc = await provider.connection.getAccountInfo(authority); if (!authAcc || authAcc.lamports < LAMPORTS_PER_SOL) { - console.log('Funding multisig...'); + console.log("Funding multisig..."); await sendInstructions(provider, [ await SystemProgram.transfer({ fromPubkey: me, @@ -260,19 +260,19 @@ export async function run(args: any = process.argv) { const govProgramVersion = await getGovernanceProgramVersion( conn, govProgramId, - isLocalhost(provider) ? 'localnet' : undefined + isLocalhost(provider) ? "localnet" : undefined ); const realmName = argv.realmName; const realm = await PublicKey.findProgramAddressSync( - [Buffer.from('governance', 'utf-8'), Buffer.from(realmName, 'utf-8')], + [Buffer.from("governance", "utf-8"), Buffer.from(realmName, "utf-8")], govProgramId )[0]; - console.log('Realm, ', realm.toBase58()); + console.log("Realm, ", realm.toBase58()); const needRealmCreate = !(await exists(conn, realm)); if (needRealmCreate) { - console.log('Initializing Realm'); + console.log("Initializing Realm"); await withCreateRealm( instructions, govProgramId, @@ -303,7 +303,7 @@ export async function run(args: any = process.argv) { const registrar = (await registrarKey(realm, hntKeypair.publicKey))[0]; if (!(await exists(conn, registrar))) { - console.log('Initializing VSR Registrar'); + console.log("Initializing VSR Registrar"); instructions.push( ComputeBudgetProgram.setComputeUnitLimit({ units: 800000 }) ); @@ -322,7 +322,7 @@ export async function run(args: any = process.argv) { instructions = []; } - console.log('Configuring VSR voting mint at [0]'); + console.log("Configuring VSR voting mint at [0]"); instructions.push( await heliumVsrProgram.methods .configureVotingMintV0({ @@ -331,7 +331,7 @@ export async function run(args: any = process.argv) { maxExtraLockupVoteWeightScaledFactor: new anchor.BN(SCALE * 1e9), genesisVotePowerMultiplier: GENESIS_MULTIPLIER, // April 28th, 23:59:59 UTC - genesisVotePowerMultiplierExpirationTs: new anchor.BN('1682726399'), + genesisVotePowerMultiplierExpirationTs: new anchor.BN("1682726399"), lockupSaturationSecs: new anchor.BN(MAX_LOCKUP), }) .accounts({ @@ -369,7 +369,7 @@ export async function run(args: any = process.argv) { instructions = []; const dcKey = (await dataCreditsKey(dcKeypair.publicKey))[0]; - console.log('dcpid', PROGRAM_ID.toBase58()); + console.log("dcpid", PROGRAM_ID.toBase58()); if (!(await exists(conn, dcKey))) { await dataCreditsProgram.methods .initializeDataCreditsV0({ @@ -377,7 +377,7 @@ export async function run(args: any = process.argv) { config: { windowSizeSeconds: new anchor.BN(60 * 60), thresholdType: ThresholdType.Absolute as never, - threshold: new anchor.BN('1000000000000'), + threshold: new anchor.BN("1000000000000"), }, }) .accounts({ @@ -403,14 +403,14 @@ export async function run(args: any = process.argv) { } if (!(await exists(conn, dao))) { - console.log('Initializing DAO'); + console.log("Initializing DAO"); const hstEmission = await parseEmissionsSchedule( argv.hstEmissionSchedulePath ); const hntEmission = await parseEmissionsSchedule(argv.emissionSchedulePath); const currentHstEmission = hstEmission[0]; const currentHntEmission = hntEmission[0]; - const fanout = fanoutKey('HST')[0]; + const fanout = fanoutKey("HST")[0]; const hstPool = getAssociatedTokenAddressSync( hntKeypair.publicKey, fanout, @@ -509,9 +509,9 @@ export async function run(args: any = process.argv) { getConcurrentMerkleTreeAccountSize(size, buffer, canopy) ), newTreeFeeLamports: new BN(cost / 2 ** size), - name: 'DATAONLY', + name: "DATAONLY", metadataUrl: - 'https://shdw-drive.genesysgo.net/H8b1gZmA2aBqDYxicxawGpznCaNbFSEJ3YnJuawGQ2EQ/data-only.json', + "https://shdw-drive.genesysgo.net/H8b1gZmA2aBqDYxicxawGpznCaNbFSEJ3YnJuawGQ2EQ/data-only.json", }) .accounts({ dao, diff --git a/packages/helium-admin-cli/src/create-data-only-config.ts b/packages/helium-admin-cli/src/create-data-only-config.ts index d9491f134..ffb51c2d5 100644 --- a/packages/helium-admin-cli/src/create-data-only-config.ts +++ b/packages/helium-admin-cli/src/create-data-only-config.ts @@ -1,10 +1,14 @@ -import * as anchor from '@coral-xyz/anchor'; +import * as anchor from "@coral-xyz/anchor"; import { init as initHem, dataOnlyConfigKey, -} from '@helium/helium-entity-manager-sdk'; -import { HNT_MINT, sendInstructions } from '@helium/spl-utils'; -import { daoKey } from '@helium/helium-sub-daos-sdk'; +} from "@helium/helium-entity-manager-sdk"; +import { + HNT_MINT, + sendInstructions, + sendInstructionsOrSquads, +} from "@helium/spl-utils"; +import { daoKey } from "@helium/helium-sub-daos-sdk"; import { ComputeBudgetProgram, Connection, @@ -12,17 +16,17 @@ import { LAMPORTS_PER_SOL, PublicKey, SystemProgram, -} from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { loadKeypair, sendInstructionsOrSquads } from './utils'; -import fs from 'fs'; -import { BN } from 'bn.js'; +} from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import fs from "fs"; +import { BN } from "bn.js"; import { getConcurrentMerkleTreeAccountSize, SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, -} from '@solana/spl-account-compression'; +} from "@solana/spl-account-compression"; async function exists( connection: Connection, @@ -34,33 +38,33 @@ async function exists( export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, hntMint: { - type: 'string', - describe: 'HNT token mint', + type: "string", + describe: "HNT token mint", default: HNT_MINT.toString(), }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to control the dao. If not provided, your wallet will be the authority', + "Address of the squads multisig to control the dao. If not provided, your wallet will be the authority", }, authorityIndex: { - type: 'number', - describe: 'Authority index for squads. Defaults to 1', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, merklePath: { - type: 'string', - describe: 'Path to the merkle keypair', + type: "string", + describe: "Path to the merkle keypair", default: `${__dirname}/../../keypairs/data-only-merkle.json`, }, }); @@ -78,7 +82,7 @@ export async function run(args: any = process.argv) { const dao = daoKey(hntMint)[0]; const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); let authority = provider.wallet.publicKey; let multisig = argv.multisig ? new PublicKey(argv.multisig) : null; @@ -87,7 +91,7 @@ export async function run(args: any = process.argv) { // Fund authority const authAcc = await provider.connection.getAccountInfo(authority); if (!authAcc || authAcc.lamports < LAMPORTS_PER_SOL) { - console.log('Funding multisig...'); + console.log("Funding multisig..."); await sendInstructions(provider, [ SystemProgram.transfer({ fromPubkey: provider.wallet.publicKey, @@ -98,7 +102,7 @@ export async function run(args: any = process.argv) { } } if (await exists(provider.connection, dataOnlyConfigKey(dao)[0])) { - console.log('DataOnly Config already exists'); + console.log("DataOnly Config already exists"); return; } console.log(`Initializing DataOnly Config`); @@ -145,9 +149,9 @@ export async function run(args: any = process.argv) { getConcurrentMerkleTreeAccountSize(size, buffer, canopy) ), newTreeFeeLamports: new BN(cost / 2 ** size), - name: 'DATAONLY', + name: "DATAONLY", metadataUrl: - 'https://shdw-drive.genesysgo.net/H8b1gZmA2aBqDYxicxawGpznCaNbFSEJ3YnJuawGQ2EQ/data-only.json', + "https://shdw-drive.genesysgo.net/H8b1gZmA2aBqDYxicxawGpznCaNbFSEJ3YnJuawGQ2EQ/data-only.json", }) .accounts({ dao, diff --git a/packages/helium-admin-cli/src/create-maker.ts b/packages/helium-admin-cli/src/create-maker.ts index da75865f4..9c0e2adb1 100644 --- a/packages/helium-admin-cli/src/create-maker.ts +++ b/packages/helium-admin-cli/src/create-maker.ts @@ -1,108 +1,104 @@ -import Address from '@helium/address'; -import { ED25519_KEY_TYPE } from '@helium/address/build/KeyTypes'; +import Address from "@helium/address"; +import { ED25519_KEY_TYPE } from "@helium/address/build/KeyTypes"; import { init as initHem, makerKey, rewardableEntityConfigKey, makerApprovalKey, -} from '@helium/helium-entity-manager-sdk'; -import { init as initHsd, subDaoKey } from '@helium/helium-sub-daos-sdk'; -import { init as initVsr } from '@helium/voter-stake-registry-sdk'; +} from "@helium/helium-entity-manager-sdk"; +import { init as initHsd, subDaoKey } from "@helium/helium-sub-daos-sdk"; +import { init as initVsr } from "@helium/voter-stake-registry-sdk"; import { chunks, humanReadable, sendInstructions, truthy, -} from '@helium/spl-utils'; -import * as anchor from '@coral-xyz/anchor'; + sendInstructionsOrSquads, +} from "@helium/spl-utils"; +import * as anchor from "@coral-xyz/anchor"; import { getConcurrentMerkleTreeAccountSize, SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, -} from '@solana/spl-account-compression'; +} from "@solana/spl-account-compression"; import { Keypair, PublicKey, SystemProgram, TransactionInstruction, -} from '@solana/web3.js'; -import fs from 'fs'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { - exists, - loadKeypair, - sendInstructionsOrSquads, - merkleSizes, -} from './utils'; -import Squads from '@sqds/sdk'; +} from "@solana/web3.js"; +import fs from "fs"; +import os from "os"; +import yargs from "yargs/yargs"; +import { exists, loadKeypair, merkleSizes } from "./utils"; +import Squads from "@sqds/sdk"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + alias: "k", + describe: "Anchor wallet keypair", default: `${os.homedir()}/.config/solana/id.json`, }, executeTransaction: { - type: 'boolean', + type: "boolean", }, url: { - alias: 'u', - default: 'http://127.0.0.1:8899', - describe: 'The solana url', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, subdaoMint: { required: true, - describe: 'Public Key of the subdao mint', - type: 'string', + describe: "Public Key of the subdao mint", + type: "string", }, govProgramId: { - type: 'string', - describe: 'Pubkey of the GOV program', - default: 'hgovkRU6Ghe1Qoyb54HdSLdqN7VtxaifBzRmh9jtd3S', + type: "string", + describe: "Pubkey of the GOV program", + default: "hgovkRU6Ghe1Qoyb54HdSLdqN7VtxaifBzRmh9jtd3S", }, fromFile: { - describe: 'Load makers from a json file and create in bulk', + describe: "Load makers from a json file and create in bulk", required: false, - type: 'string', + type: "string", }, name: { - alias: 'n', - type: 'string', + alias: "n", + type: "string", required: false, - describe: 'The name of the maker', + describe: "The name of the maker", }, makerKey: { - alias: 'm', - type: 'string', - describe: '*Helium* Public Key of a maker', + alias: "m", + type: "string", + describe: "*Helium* Public Key of a maker", required: false, }, makerCount: { - alias: 'c', - type: 'number', - describe: 'Estimated number of hotspots this maker will have', + alias: "c", + type: "number", + describe: "Estimated number of hotspots this maker will have", required: false, }, merkleBasePath: { - type: 'string', - describe: 'Base path for merkle keypairs', + type: "string", + describe: "Base path for merkle keypairs", default: `${__dirname}/../keypairs`, }, symbol: { - alias: 's', - type: 'string', + alias: "s", + type: "string", required: true, - describe: 'The symbol of the entity config', + describe: "The symbol of the entity config", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -127,12 +123,12 @@ export async function run(args: any = process.argv) { ]; if (argv.fromFile) { - makers = JSON.parse(fs.readFileSync(argv.fromFile, 'utf-8')); + makers = JSON.parse(fs.readFileSync(argv.fromFile, "utf-8")); // Append a special fallthrough maker for hotspots that don't have a maker const solAddr = provider.wallet.publicKey; const helAddr = new Address(0, 0, ED25519_KEY_TYPE, solAddr.toBuffer()); makers.push({ - name: 'Migrated Helium Hotspot', + name: "Migrated Helium Hotspot", address: helAddr.b58, count: 50000, staked: true, @@ -154,7 +150,7 @@ export async function run(args: any = process.argv) { let subdaoPayer = provider.wallet.publicKey; let daoPayer = provider.wallet.publicKey; const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); let authority = provider.wallet.publicKey; let multisig = argv.multisig ? new PublicKey(argv.multisig) : null; @@ -162,7 +158,7 @@ export async function run(args: any = process.argv) { authority = squads.getAuthorityPDA(multisig, argv.authorityIndex); subdaoPayer = authority; daoPayer = authority; - console.log('SQUAD AUTH', authority.toBase58()); + console.log("SQUAD AUTH", authority.toBase58()); } const createInstructions: TransactionInstruction[][] = []; @@ -214,7 +210,7 @@ export async function run(args: any = process.argv) { const create = await hemProgram.methods .initializeMakerV0({ name: name!, - metadataUrl: 'todo', + metadataUrl: "todo", issuingAuthority: makerAuthority, updateAuthority, }) @@ -329,7 +325,7 @@ export async function run(args: any = process.argv) { approveInstructions.push(innerApproveInstrs); } - console.log('Total sol needed: ', humanReadable(new anchor.BN(totalSol), 9)); + console.log("Total sol needed: ", humanReadable(new anchor.BN(totalSol), 9)); if (multisig) { // Approve instructions must execute after ALL create instructions diff --git a/packages/helium-admin-cli/src/create-subdao.ts b/packages/helium-admin-cli/src/create-subdao.ts index 4b3db615e..02d96e815 100644 --- a/packages/helium-admin-cli/src/create-subdao.ts +++ b/packages/helium-admin-cli/src/create-subdao.ts @@ -1,27 +1,27 @@ -import * as anchor from '@coral-xyz/anchor'; -import { ThresholdType } from '@helium/circuit-breaker-sdk'; +import * as anchor from "@coral-xyz/anchor"; +import { ThresholdType } from "@helium/circuit-breaker-sdk"; import { init as initHem, rewardableEntityConfigKey, -} from '@helium/helium-entity-manager-sdk'; +} from "@helium/helium-entity-manager-sdk"; import { daoKey, init as initDao, subDaoKey, threadKey, delegatorRewardsPercent, -} from '@helium/helium-sub-daos-sdk'; +} from "@helium/helium-sub-daos-sdk"; import { init as initLazy, lazyDistributorKey, -} from '@helium/lazy-distributor-sdk'; -import { oracleSignerKey } from '@helium/rewards-oracle-sdk'; -import { sendInstructions, toBN } from '@helium/spl-utils'; -import { toU128 } from '@helium/treasury-management-sdk'; +} from "@helium/lazy-distributor-sdk"; +import { oracleSignerKey } from "@helium/rewards-oracle-sdk"; +import { sendInstructions, toBN } from "@helium/spl-utils"; +import { toU128 } from "@helium/treasury-management-sdk"; import { init as initVsr, registrarKey, -} from '@helium/voter-stake-registry-sdk'; +} from "@helium/voter-stake-registry-sdk"; import { getGovernanceProgramVersion, GoverningTokenConfigAccountArgs, @@ -30,17 +30,17 @@ import { SetRealmAuthorityAction, withCreateRealm, withSetRealmAuthority, -} from '@solana/spl-governance'; -import { getAssociatedTokenAddress } from '@solana/spl-token'; +} from "@solana/spl-governance"; +import { getAssociatedTokenAddress } from "@solana/spl-token"; import { LAMPORTS_PER_SOL, PublicKey, SystemProgram, TransactionInstruction, -} from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; +} from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; import { createAndMint, exists, @@ -48,9 +48,9 @@ import { isLocalhost, loadKeypair, parseEmissionsSchedule, - sendInstructionsOrSquads, -} from './utils'; -import { BN } from 'bn.js'; +} from "./utils"; +import { BN } from "bn.js"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; const SECS_PER_DAY = 86400; const SECS_PER_YEAR = 365 * SECS_PER_DAY; @@ -61,131 +61,131 @@ const SCALE = 100; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + alias: "k", + describe: "Anchor wallet keypair", default: `${os.homedir()}/.config/solana/id.json`, }, noHotspots: { - type: 'boolean', + type: "boolean", default: false, }, url: { - alias: 'u', - default: 'http://127.0.0.1:8899', - describe: 'The solana url', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, hntPubkey: { - type: 'string', - describe: 'Pubkey of the HNT token', + type: "string", + describe: "Pubkey of the HNT token", }, dcPubkey: { - type: 'string', - describe: 'Pubkey of the DC token', + type: "string", + describe: "Pubkey of the DC token", }, name: { - alias: 'n', - describe: 'The name of the subdao', - type: 'string', + alias: "n", + describe: "The name of the subdao", + type: "string", required: true, }, realmName: { - describe: 'The name of the realm', - type: 'string', + describe: "The name of the realm", + type: "string", required: true, }, subdaoKeypair: { - type: 'string', - describe: 'Keypair of the subdao token', + type: "string", + describe: "Keypair of the subdao token", required: true, }, executeTransaction: { - type: 'boolean', + type: "boolean", }, numTokens: { - type: 'number', + type: "number", describe: - 'Number of subdao tokens to pre mint before assigning authority to lazy distributor', + "Number of subdao tokens to pre mint before assigning authority to lazy distributor", default: 0, }, bucket: { - type: 'string', - describe: 'Bucket URL prefix holding all of the metadata jsons', + type: "string", + describe: "Bucket URL prefix holding all of the metadata jsons", default: - 'https://shdw-drive.genesysgo.net/6tcnBSybPG7piEDShBcrVtYJDPSvGrDbVvXmXKpzBvWP', + "https://shdw-drive.genesysgo.net/6tcnBSybPG7piEDShBcrVtYJDPSvGrDbVvXmXKpzBvWP", }, rewardsOracleUrl: { - alias: 'ro', - type: 'string', - describe: 'The rewards oracle URL', - default: 'http://localhost:8080', + alias: "ro", + type: "string", + describe: "The rewards oracle URL", + default: "http://localhost:8080", }, oracleKeypair: { - type: 'string', - describe: 'Keypair of the oracle', + type: "string", + describe: "Keypair of the oracle", default: `${__dirname}/../../keypairs/oracle.json`, }, aggregatorKeypair: { - type: 'string', - describe: 'Keypair of the aggregtor', + type: "string", + describe: "Keypair of the aggregtor", }, dcBurnAuthority: { - type: 'string', - describe: 'The authority to burn DC tokens', + type: "string", + describe: "The authority to burn DC tokens", required: true, }, queue: { - type: 'string', - describe: 'Switchbaord oracle queue', - default: 'uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX', + type: "string", + describe: "Switchbaord oracle queue", + default: "uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX", }, crank: { - type: 'string', - describe: 'Switchboard crank', - default: 'UcrnK4w2HXCEjY8z6TcQ9tysYr3c9VcFLdYAU9YQP5e', + type: "string", + describe: "Switchboard crank", + default: "UcrnK4w2HXCEjY8z6TcQ9tysYr3c9VcFLdYAU9YQP5e", }, switchboardNetwork: { - type: 'string', - describe: 'The switchboard network', - default: 'mainnet-beta', + type: "string", + describe: "The switchboard network", + default: "mainnet-beta", }, decimals: { - type: 'number', + type: "number", default: 6, }, govProgramId: { - type: 'string', - describe: 'Pubkey of the GOV program', - default: 'hgovkRU6Ghe1Qoyb54HdSLdqN7VtxaifBzRmh9jtd3S', + type: "string", + describe: "Pubkey of the GOV program", + default: "hgovkRU6Ghe1Qoyb54HdSLdqN7VtxaifBzRmh9jtd3S", }, councilKeypair: { - type: 'string', - describe: 'Keypair of gov council token', + type: "string", + describe: "Keypair of gov council token", default: `${__dirname}/../../keypairs/council.json`, }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig for subdao authority. If not provided, your wallet will be the authority', + "Address of the squads multisig for subdao authority. If not provided, your wallet will be the authority", }, authorityIndex: { - type: 'number', - describe: 'Authority index for squads. Defaults to 1', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, delegatorRewardsPercent: { - type: 'number', + type: "number", required: true, describe: - 'Percentage of rewards allocated to delegators. Must be between 0-100 and can have 8 decimal places.', + "Percentage of rewards allocated to delegators. Must be between 0-100 and can have 8 decimal places.", }, emissionSchedulePath: { required: true, - describe: 'Path to file that contains the dnt emissions schedule', - type: 'string', + describe: "Path to file that contains the dnt emissions schedule", + type: "string", }, activeDeviceAuthority: { - type: 'string', - describe: 'The authority that can set hotspot active status', + type: "string", + describe: "The authority that can set hotspot active status", }, }); const argv = await yarg.argv; @@ -216,26 +216,26 @@ export async function run(args: any = process.argv) { const councilKeypair = await loadKeypair(argv.councilKeypair); const me = provider.wallet.publicKey; - console.log('Subdao mint', subdaoKeypair.publicKey.toBase58()); - console.log('GOV PID', govProgramId.toBase58()); - console.log('COUNCIL', councilKeypair.publicKey.toBase58()); + console.log("Subdao mint", subdaoKeypair.publicKey.toBase58()); + console.log("GOV PID", govProgramId.toBase58()); + console.log("COUNCIL", councilKeypair.publicKey.toBase58()); const conn = provider.connection; const dao = (await daoKey(new PublicKey(argv.hntPubkey!)))[0]; const subdao = (await subDaoKey(subdaoKeypair.publicKey))[0]; - console.log('DAO', dao.toString()); - console.log('SUBDAO', subdao.toString()); + console.log("DAO", dao.toString()); + console.log("SUBDAO", subdao.toString()); const daoAcc = await heliumSubDaosProgram.account.daoV0.fetch(dao); - const calculateThread = threadKey(subdao, 'calculate')[0]; - const issueThread = threadKey(subdao, 'issue')[0]; + const calculateThread = threadKey(subdao, "calculate")[0]; + const issueThread = threadKey(subdao, "issue")[0]; const emissionSchedule = await parseEmissionsSchedule( argv.emissionSchedulePath ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); let authority = provider.wallet.publicKey; const multisig = argv.multisig ? new PublicKey(argv.multisig) : null; @@ -243,11 +243,9 @@ export async function run(args: any = process.argv) { authority = squads.getAuthorityPDA(multisig, argv.authorityIndex); } if (await exists(conn, subdao)) { - console.log( - `Subdao exists. Key: ${subdao.toBase58()}.` - ); - console.log('Calculate thread', calculateThread.toString()); - console.log('Issue thread', issueThread.toString()); + console.log(`Subdao exists. Key: ${subdao.toBase58()}.`); + console.log("Calculate thread", calculateThread.toString()); + console.log("Issue thread", issueThread.toString()); return; } const [lazyDist] = await lazyDistributorKey(subdaoKeypair.publicKey); @@ -261,7 +259,7 @@ export async function run(args: any = process.argv) { const auth = await provider.connection.getAccountInfo(daoAcc.authority); if (auth!.owner.equals(govProgramId)) { const daoPayer = PublicKey.findProgramAddressSync( - [Buffer.from('native-treasury', 'utf-8'), daoAcc.authority.toBuffer()], + [Buffer.from("native-treasury", "utf-8"), daoAcc.authority.toBuffer()], govProgramId )[0]; payer = daoPayer; @@ -282,18 +280,18 @@ export async function run(args: any = process.argv) { const govProgramVersion = await getGovernanceProgramVersion( conn, govProgramId, - isLocalhost(provider) ? 'localnet' : undefined + isLocalhost(provider) ? "localnet" : undefined ); const realmName = argv.realmName; const realm = await PublicKey.findProgramAddressSync( - [Buffer.from('governance', 'utf-8'), Buffer.from(realmName, 'utf-8')], + [Buffer.from("governance", "utf-8"), Buffer.from(realmName, "utf-8")], govProgramId )[0]; - console.log('Realm, ', realm.toBase58()); + console.log("Realm, ", realm.toBase58()); const isFreshRealm = !(await exists(conn, realm)); if (isFreshRealm) { - console.log('Initializing Realm'); + console.log("Initializing Realm"); await withCreateRealm( instructions, govProgramId, @@ -324,7 +322,7 @@ export async function run(args: any = process.argv) { const registrar = (await registrarKey(realm, subdaoKeypair.publicKey))[0]; if (!(await exists(conn, registrar))) { - console.log('Initializing VSR Registrar'); + console.log("Initializing VSR Registrar"); instructions.push( await heliumVsrProgram.methods .initializeRegistrarV0({ @@ -336,7 +334,7 @@ export async function run(args: any = process.argv) { }) .instruction() ); - console.log('Configuring VSR voting mint at [0]'); + console.log("Configuring VSR voting mint at [0]"); instructions.push( await heliumVsrProgram.methods .configureVotingMintV0({ @@ -431,9 +429,9 @@ export async function run(args: any = process.argv) { } as any, // $40 for iot, $0 for mobile onboardingDcFee: - name.toUpperCase() == 'IOT' ? toBN(4000000, 0) : toBN(0, 0), + name.toUpperCase() == "IOT" ? toBN(4000000, 0) : toBN(0, 0), onboardingDataOnlyDcFee: - name.toUpperCase() == 'IOT' ? toBN(1000000, 0) : toBN(0, 0), + name.toUpperCase() == "IOT" ? toBN(1000000, 0) : toBN(0, 0), delegatorRewardsPercent: delegatorRewardsPercent( argv.delegatorRewardsPercent ), @@ -512,7 +510,7 @@ export async function run(args: any = process.argv) { const instructions: TransactionInstruction[] = []; console.log(`Initalizing ${name} RewardableEntityConfig`); let settings; - if (name.toUpperCase() == 'IOT') { + if (name.toUpperCase() == "IOT") { settings = { iotConfig: { minGain: 10, diff --git a/packages/helium-admin-cli/src/issue-iot-operations-fund.ts b/packages/helium-admin-cli/src/issue-iot-operations-fund.ts index 412828c49..8000e6c75 100644 --- a/packages/helium-admin-cli/src/issue-iot-operations-fund.ts +++ b/packages/helium-admin-cli/src/issue-iot-operations-fund.ts @@ -1,48 +1,52 @@ -import * as anchor from '@coral-xyz/anchor'; -import { init } from '@helium/helium-entity-manager-sdk'; -import { init as initHsd } from '@helium/helium-sub-daos-sdk'; -import { daoKey } from '@helium/helium-sub-daos-sdk'; -import { createMintInstructions, sendInstructions } from '@helium/spl-utils'; -import { PublicKey, Keypair, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import { BN } from 'bn.js'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { loadKeypair, sendInstructionsOrSquads } from './utils'; +import * as anchor from "@coral-xyz/anchor"; +import { init } from "@helium/helium-entity-manager-sdk"; +import { init as initHsd } from "@helium/helium-sub-daos-sdk"; +import { daoKey } from "@helium/helium-sub-daos-sdk"; +import { + createMintInstructions, + sendInstructions, + sendInstructionsOrSquads, +} from "@helium/spl-utils"; +import { PublicKey, Keypair, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import { BN } from "bn.js"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, hntMint: { - type: 'string', + type: "string", required: true, - describe: 'Mint address of hnt', + describe: "Mint address of hnt", }, recipient: { - type: 'string', + type: "string", required: true, - describe: 'Recipient wallet address for the iot ops fund nft', + describe: "Recipient wallet address for the iot ops fund nft", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -86,7 +90,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ provider, diff --git a/packages/helium-admin-cli/src/reset-vsr-voting-mint.ts b/packages/helium-admin-cli/src/reset-vsr-voting-mint.ts index b13555416..3c35b0528 100644 --- a/packages/helium-admin-cli/src/reset-vsr-voting-mint.ts +++ b/packages/helium-admin-cli/src/reset-vsr-voting-mint.ts @@ -1,20 +1,16 @@ -import * as anchor from '@coral-xyz/anchor'; +import * as anchor from "@coral-xyz/anchor"; import { daoKey, init as initDao, subDaoKey, -} from '@helium/helium-sub-daos-sdk'; -import { init as initVsr } from '@helium/voter-stake-registry-sdk'; -import { PublicKey, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { - getTimestampFromDays, - getUnixTimestamp, - loadKeypair, - sendInstructionsOrSquads, -} from './utils'; +} from "@helium/helium-sub-daos-sdk"; +import { init as initVsr } from "@helium/voter-stake-registry-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { getTimestampFromDays, getUnixTimestamp, loadKeypair } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; const SECS_PER_DAY = 86400; const SECS_PER_YEAR = 365 * SECS_PER_DAY; @@ -23,46 +19,46 @@ const MAX_LOCKUP = 4 * SECS_PER_YEAR; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, hntMint: { - type: 'string', + type: "string", describe: - 'Mint of the HNT token. Only used if --resetDaoVotingMint flag is set', + "Mint of the HNT token. Only used if --resetDaoVotingMint flag is set", }, dntMint: { - type: 'string', + type: "string", describe: - 'Mint of the subdao token. Only used if --resetSubDaoVotingMint flag is set', + "Mint of the subdao token. Only used if --resetSubDaoVotingMint flag is set", }, resetDaoVotingMint: { - type: 'boolean', - describe: 'Reset the dao voting mint', + type: "boolean", + describe: "Reset the dao voting mint", default: false, }, resetSubDaoVotingMint: { - type: 'boolean', - describe: 'Reset the subdao voting mint', + type: "boolean", + describe: "Reset the subdao voting mint", default: false, }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -73,7 +69,7 @@ export async function run(args: any = process.argv) { anchor.setProvider(anchor.AnchorProvider.local(argv.url)); if (argv.resetSubDaoVotingMint && !argv.dntMint) { - console.log('dnt mint not provided'); + console.log("dnt mint not provided"); return; } @@ -86,11 +82,11 @@ export async function run(args: any = process.argv) { const instructions: TransactionInstruction[] = []; const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); if (argv.resetDaoVotingMint) { - console.log('resetting dao votingMint'); + console.log("resetting dao votingMint"); const hntMint = new PublicKey(argv.hntMint!); const dao = daoKey(hntMint)[0]; const daoAcc = await hsdProgram.account.daoV0.fetch(dao); @@ -122,7 +118,7 @@ export async function run(args: any = process.argv) { } if (argv.resetSubDaoVotingMint) { - console.log('resetting subdao votingMint'); + console.log("resetting subdao votingMint"); const dntMint = new PublicKey(argv.dntMint!); const subDao = subDaoKey(dntMint)[0]; const subdaoAcc = await hsdProgram.account.subDaoV0.fetch(subDao); diff --git a/packages/helium-admin-cli/src/update-account-circuit-breaker.ts b/packages/helium-admin-cli/src/update-account-circuit-breaker.ts index 751d0acbf..e3bf51b71 100644 --- a/packages/helium-admin-cli/src/update-account-circuit-breaker.ts +++ b/packages/helium-admin-cli/src/update-account-circuit-breaker.ts @@ -1,49 +1,50 @@ -import * as anchor from '@coral-xyz/anchor'; -import { init } from '@helium/circuit-breaker-sdk'; -import { PublicKey, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import { BN } from 'bn.js'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { loadKeypair, sendInstructionsOrSquads } from './utils'; +import * as anchor from "@coral-xyz/anchor"; +import { init } from "@helium/circuit-breaker-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import { BN } from "bn.js"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, circuitBreaker: { - type: 'string', + type: "string", required: true, - describe: 'Circuit breaker account', + describe: "Circuit breaker account", }, windowSizeSeconds: { - type: 'number', + type: "number", }, threshold: { - type: 'number', + type: "number", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "Address of the squads multisig to be authority. If not provided, your wallet will be the authority", }, newAuthority: { - type: 'string', + type: "string", }, authorityIndex: { - type: 'number', - describe: 'Authority index for squads. Defaults to 1', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -87,7 +88,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ provider, diff --git a/packages/helium-admin-cli/src/update-carrier.ts b/packages/helium-admin-cli/src/update-carrier.ts index 654904f4f..29d855b00 100644 --- a/packages/helium-admin-cli/src/update-carrier.ts +++ b/packages/helium-admin-cli/src/update-carrier.ts @@ -5,8 +5,8 @@ import { Keypair, 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"; -import { MOBILE_MINT } from "@helium/spl-utils"; +import { loadKeypair } from "./utils"; +import { MOBILE_MINT, sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ @@ -71,7 +71,7 @@ export async function run(args: any = process.argv) { const dntMint = new PublicKey(argv.dntMint); const subDao = subDaoKey(dntMint)[0]; const carrier = carrierKey(subDao, argv.name)[0]; - const carrierAcc = await program.account.carrierV0.fetch(carrier) + const carrierAcc = await program.account.carrierV0.fetch(carrier); instructions.push( await program.methods diff --git a/packages/helium-admin-cli/src/update-dao.ts b/packages/helium-admin-cli/src/update-dao.ts index 6d9ff9225..f6042b59b 100644 --- a/packages/helium-admin-cli/src/update-dao.ts +++ b/packages/helium-admin-cli/src/update-dao.ts @@ -1,77 +1,74 @@ -import * as anchor from '@coral-xyz/anchor'; +import * as anchor from "@coral-xyz/anchor"; import { init as initCb, mintWindowedBreakerKey, -} from '@helium/circuit-breaker-sdk'; -import { daoKey, init as initHsd } from '@helium/helium-sub-daos-sdk'; -import { PublicKey, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { - loadKeypair, - parseEmissionsSchedule, - sendInstructionsOrSquads, -} from './utils'; +} from "@helium/circuit-breaker-sdk"; +import { daoKey, init as initHsd } from "@helium/helium-sub-daos-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair, parseEmissionsSchedule } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, hntMint: { required: true, - type: 'string', - describe: 'HNT mint of the dao to be updated', + type: "string", + describe: "HNT mint of the dao to be updated", }, newAuthority: { required: false, - describe: 'New DAO authority', - type: 'string', + describe: "New DAO authority", + type: "string", default: null, }, newEmissionsSchedulePath: { required: false, - describe: 'Path to file that contains the new emissions schedule', - type: 'string', + describe: "Path to file that contains the new emissions schedule", + type: "string", default: null, }, newHstEmissionsSchedulePath: { required: false, - describe: 'Path to file that contains the new HST emissions schedule', - type: 'string', + describe: "Path to file that contains the new HST emissions schedule", + type: "string", default: null, }, newNetEmissionsCap: { required: false, - describe: 'New net emissions cap, without decimals', - type: 'string', + describe: "New net emissions cap, without decimals", + type: "string", default: null, }, newHstPool: { required: false, - describe: 'New HST Pool', - type: 'string', + describe: "New HST Pool", + type: "string", default: null, }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -131,7 +128,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ provider, diff --git a/packages/helium-admin-cli/src/update-data-credits.ts b/packages/helium-admin-cli/src/update-data-credits.ts index 232148d17..04089576d 100644 --- a/packages/helium-admin-cli/src/update-data-credits.ts +++ b/packages/helium-admin-cli/src/update-data-credits.ts @@ -1,49 +1,46 @@ -import * as anchor from '@coral-xyz/anchor'; -import { dataCreditsKey, init as initDc } from '@helium/data-credits-sdk'; -import { PublicKey, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { - loadKeypair, - sendInstructionsOrCreateProposal, - sendInstructionsOrSquads, -} from './utils'; +import * as anchor from "@coral-xyz/anchor"; +import { dataCreditsKey, init as initDc } from "@helium/data-credits-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, dcMint: { required: true, - type: 'string', - describe: 'Data credits mint address', + type: "string", + describe: "Data credits mint address", }, newAuthority: { - type: 'string', + type: "string", }, hntPriceOracle: { - type: 'string', + type: "string", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -59,7 +56,7 @@ export async function run(args: any = process.argv) { const dataCredits = dataCreditsKey(new PublicKey(argv.dcMint))[0]; const dataCreditsAcc = await program.account.dataCreditsV0.fetch(dataCredits); - console.log('Data Credits', dataCredits.toBase58()); + console.log("Data Credits", dataCredits.toBase58()); console.log(dataCreditsAcc.authority.toBase58()); instructions.push( @@ -81,7 +78,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ @@ -96,5 +93,5 @@ export async function run(args: any = process.argv) { } function isNull(vehntDelegated: string | undefined | null) { - return vehntDelegated === null || typeof vehntDelegated == 'undefined'; + return vehntDelegated === null || typeof vehntDelegated == "undefined"; } diff --git a/packages/helium-admin-cli/src/update-delegated-dc-subdao.ts b/packages/helium-admin-cli/src/update-delegated-dc-subdao.ts index 326e76f48..1ca6f3afa 100644 --- a/packages/helium-admin-cli/src/update-delegated-dc-subdao.ts +++ b/packages/helium-admin-cli/src/update-delegated-dc-subdao.ts @@ -1,55 +1,56 @@ -import * as anchor from '@coral-xyz/anchor'; +import * as anchor from "@coral-xyz/anchor"; import { delegatedDataCreditsKey, init as initDc, -} from '@helium/data-credits-sdk'; -import { PublicKey, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import { BN } from 'bn.js'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { loadKeypair, sendInstructionsOrSquads } from './utils'; -import { subDaoKey, init as initHsd } from '@helium/helium-sub-daos-sdk'; +} from "@helium/data-credits-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import { BN } from "bn.js"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { subDaoKey, init as initHsd } from "@helium/helium-sub-daos-sdk"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, sourceDntMint: { - type: 'string', + type: "string", required: true, }, destinationDntMint: { - type: 'string', + type: "string", required: true, }, routerKey: { - type: 'string', + type: "string", required: true, }, amount: { - type: 'number', + type: "number", required: true, }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -102,7 +103,7 @@ export async function run(args: any = process.argv) { instructions.push(await method.instruction()); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ diff --git a/packages/helium-admin-cli/src/update-lazy-distributor.ts b/packages/helium-admin-cli/src/update-lazy-distributor.ts index b62c5a5f1..7fb02adf5 100644 --- a/packages/helium-admin-cli/src/update-lazy-distributor.ts +++ b/packages/helium-admin-cli/src/update-lazy-distributor.ts @@ -1,60 +1,61 @@ -import * as anchor from '@coral-xyz/anchor'; -import {} from '@helium/helium-entity-manager-sdk'; +import * as anchor from "@coral-xyz/anchor"; +import {} from "@helium/helium-entity-manager-sdk"; import { init as initLazy, lazyDistributorKey, -} from '@helium/lazy-distributor-sdk'; -import { PublicKey } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { loadKeypair, sendInstructionsOrSquads } from './utils'; +} from "@helium/lazy-distributor-sdk"; +import { PublicKey } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, subdaoMint: { required: true, - describe: 'Public Key of the subdao mint', - type: 'string', + describe: "Public Key of the subdao mint", + type: "string", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, oracle: { - type: 'string', - describe: 'Pubkey of the oracle', + type: "string", + describe: "Pubkey of the oracle", }, rewardsOracleUrl: { - alias: 'ro', - type: 'string', - describe: 'The rewards oracle URL', + alias: "ro", + type: "string", + describe: "The rewards oracle URL", }, newAuthority: { - type: 'string', + type: "string", }, newApprover: { - type: 'string', - description: 'Pubkey of the approver pda', + type: "string", + description: "Pubkey of the approver pda", }, }); const argv = await yarg.argv; @@ -70,7 +71,7 @@ export async function run(args: any = process.argv) { lazyDist ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); const ix = await lazyDistProgram.methods diff --git a/packages/helium-admin-cli/src/update-lazy-transactions.ts b/packages/helium-admin-cli/src/update-lazy-transactions.ts index abea33b2e..59d65bdf4 100644 --- a/packages/helium-admin-cli/src/update-lazy-transactions.ts +++ b/packages/helium-admin-cli/src/update-lazy-transactions.ts @@ -1,45 +1,46 @@ -import * as anchor from '@coral-xyz/anchor'; +import * as anchor from "@coral-xyz/anchor"; import { init as initLazy, lazyTransactionsKey, -} from '@helium/lazy-transactions-sdk'; -import { PublicKey } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { loadKeypair, sendInstructionsOrSquads } from './utils'; +} from "@helium/lazy-transactions-sdk"; +import { PublicKey } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, newAuthority: { - type: 'string', + type: "string", }, name: { required: true, - type: 'string', + type: "string", }, }); const argv = await yarg.argv; @@ -54,7 +55,7 @@ export async function run(args: any = process.argv) { lazyTransactions ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); console.log(lazyTransactions.toBase58()); diff --git a/packages/helium-admin-cli/src/update-mint-circuit-breaker.ts b/packages/helium-admin-cli/src/update-mint-circuit-breaker.ts index 8493d394b..80c1a95a1 100644 --- a/packages/helium-admin-cli/src/update-mint-circuit-breaker.ts +++ b/packages/helium-admin-cli/src/update-mint-circuit-breaker.ts @@ -1,49 +1,50 @@ -import * as anchor from '@coral-xyz/anchor'; -import { init } from '@helium/circuit-breaker-sdk'; -import { PublicKey, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import { BN } from 'bn.js'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { loadKeypair, sendInstructionsOrSquads } from './utils'; +import * as anchor from "@coral-xyz/anchor"; +import { init } from "@helium/circuit-breaker-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import { BN } from "bn.js"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, circuitBreaker: { - type: 'string', + type: "string", required: true, - describe: 'Circuit breaker account', + describe: "Circuit breaker account", }, windowSizeSeconds: { - type: 'number', + type: "number", }, threshold: { - type: 'number', + type: "number", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "Address of the squads multisig to be authority. If not provided, your wallet will be the authority", }, newAuthority: { - type: 'string', + type: "string", }, authorityIndex: { - type: 'number', - describe: 'Authority index for squads. Defaults to 1', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, }); @@ -87,7 +88,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ provider, diff --git a/packages/helium-admin-cli/src/update-price-oracle.ts b/packages/helium-admin-cli/src/update-price-oracle.ts index ff5d1e053..20b279e47 100644 --- a/packages/helium-admin-cli/src/update-price-oracle.ts +++ b/packages/helium-admin-cli/src/update-price-oracle.ts @@ -1,12 +1,11 @@ import * as anchor from "@coral-xyz/anchor"; -import { - init as initPrice, -} from "@helium/price-oracle-sdk" +import { init as initPrice } from "@helium/price-oracle-sdk"; import { PublicKey } from "@solana/web3.js"; import Squads from "@sqds/sdk"; import os from "os"; import yargs from "yargs/yargs"; -import { loadKeypair, sendInstructionsOrSquads } from "./utils"; +import { loadKeypair } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ @@ -40,9 +39,9 @@ export async function run(args: any = process.argv) { }, oracles: { type: "array", - describe: 'public keys of the oracles', - required: true - } + describe: "public keys of the oracles", + required: true, + }, }); const argv = await yarg.argv; process.env.ANCHOR_WALLET = argv.wallet; @@ -54,21 +53,21 @@ export async function run(args: any = process.argv) { const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { commitmentOrConfig: "finalized", }); - const oracleKey = new PublicKey(argv.oracle) - const oracle = await program.account.priceOracleV0.fetch(oracleKey) + const oracleKey = new PublicKey(argv.oracle); + const oracle = await program.account.priceOracleV0.fetch(oracleKey); const ix = await program.methods .updatePriceOracleV0({ - oracles: argv.oracles.map(o => ({ + oracles: argv.oracles.map((o) => ({ authority: new PublicKey(o), lastSubmittedPrice: null, lastSubmittedTimestamp: null, })), - authority: null + authority: null, }) .accounts({ priceOracle: oracleKey, - authority: oracle.authority + authority: oracle.authority, }) .instruction(); diff --git a/packages/helium-admin-cli/src/update-registrar-authorities.ts b/packages/helium-admin-cli/src/update-registrar-authorities.ts index f9137fb2e..38aff0bd0 100644 --- a/packages/helium-admin-cli/src/update-registrar-authorities.ts +++ b/packages/helium-admin-cli/src/update-registrar-authorities.ts @@ -1,25 +1,26 @@ -import * as anchor from '@coral-xyz/anchor'; -import { init } from '@helium/voter-stake-registry-sdk'; -import { PublicKey } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { loadKeypair, sendInstructionsOrSquads } from './utils'; +import * as anchor from "@coral-xyz/anchor"; +import { init } from "@helium/voter-stake-registry-sdk"; +import { PublicKey } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, registrar: { - type: 'string', + type: "string", required: true, }, }); @@ -45,7 +46,7 @@ export async function run(args: any = process.argv) { ]; const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ provider, diff --git a/packages/helium-admin-cli/src/update-rewardable-entity-config.ts b/packages/helium-admin-cli/src/update-rewardable-entity-config.ts index ee7cbfa24..cc2d73f8e 100644 --- a/packages/helium-admin-cli/src/update-rewardable-entity-config.ts +++ b/packages/helium-admin-cli/src/update-rewardable-entity-config.ts @@ -8,10 +8,10 @@ import { PublicKey } from "@solana/web3.js"; import Squads from "@sqds/sdk"; import os from "os"; import yargs from "yargs/yargs"; -import { loadKeypair, sendInstructionsOrSquads } from "./utils"; +import { loadKeypair } from "./utils"; import BN from "bn.js"; import { getMint } from "@solana/spl-token"; -import { toBN } from "@helium/spl-utils"; +import { toBN, sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ @@ -65,20 +65,20 @@ export async function run(args: any = process.argv) { "The staking requirement for the entity, numeric. Decimals will be added automatically", }, cbrsDcOnboardingFee: { - type: 'number', - describe: 'The cbrs dc onboarding fee', + type: "number", + describe: "The cbrs dc onboarding fee", }, cbrsDcLocationStakingFee: { - type: 'number', - describe: 'The cbrs dc location staking fee', + type: "number", + describe: "The cbrs dc location staking fee", }, wifiDcOnboardingFee: { - type: 'number', - describe: 'The wifi dc onboarding fee', + type: "number", + describe: "The wifi dc onboarding fee", }, wifiDcLocationStakingFee: { - type: 'number', - describe: 'The wifi dc location staking fee', + type: "number", + describe: "The wifi dc location staking fee", }, }); const argv = await yarg.argv; diff --git a/packages/helium-admin-cli/src/update-subdao-vehnt.ts b/packages/helium-admin-cli/src/update-subdao-vehnt.ts index 0dd85e589..92d8e6308 100644 --- a/packages/helium-admin-cli/src/update-subdao-vehnt.ts +++ b/packages/helium-admin-cli/src/update-subdao-vehnt.ts @@ -1,71 +1,71 @@ -import * as anchor from '@coral-xyz/anchor'; -import { init as initHsd, subDaoKey } from '@helium/helium-sub-daos-sdk'; -import { PublicKey, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import AWS from 'aws-sdk'; -import { BN } from 'bn.js'; -import os from 'os'; -import { Client } from 'pg'; -import yargs from 'yargs/yargs'; -import { loadKeypair, sendInstructionsOrSquads } from './utils'; -import fs from 'fs'; +import * as anchor from "@coral-xyz/anchor"; +import { init as initHsd, subDaoKey } from "@helium/helium-sub-daos-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import AWS from "aws-sdk"; +import { BN } from "bn.js"; +import os from "os"; +import { Client } from "pg"; +import yargs from "yargs/yargs"; +import { loadKeypair } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, dntMint: { required: true, - type: 'string', - describe: 'DNT mint of the subdao to be updated', + type: "string", + describe: "DNT mint of the subdao to be updated", }, name: { - alias: 'n', - type: 'string', + alias: "n", + type: "string", required: false, - describe: 'The name of the entity config', + describe: "The name of the entity config", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, pgUser: { - default: 'postgres', + default: "postgres", }, pgPassword: { - type: 'string', + type: "string", }, pgDatabase: { - type: 'string', + type: "string", }, pgHost: { - default: 'localhost', + default: "localhost", }, pgPort: { - default: '5432', + default: "5432", }, awsRegion: { - default: 'us-east-1', + default: "us-east-1", }, noSsl: { - type: 'boolean', + type: "boolean", default: false, }, }); @@ -78,7 +78,7 @@ export async function run(args: any = process.argv) { const program = await initHsd(provider); // configure pg connection - const isRds = argv.pgHost.includes('rds.amazonaws.com'); + const isRds = argv.pgHost.includes("rds.amazonaws.com"); let password = argv.pgPassword; if (isRds && !password) { const signer = new AWS.RDS.Signer({ @@ -236,14 +236,14 @@ export async function run(args: any = process.argv) { const subDao = subDaoKey(new PublicKey(argv.dntMint))[0]; const subDaoAcc = await program.account.subDaoV0.fetch(subDao); - console.log('Subdao', subDao.toBase58()); + console.log("Subdao", subDao.toBase58()); instructions.push( await program.methods .updateSubDaoVehntV0({ - vehntDelegated: new BN(row.real_ve_tokens.split('.')[0]), + vehntDelegated: new BN(row.real_ve_tokens.split(".")[0]), vehntLastCalculatedTs: new BN(row.current_ts), - vehntFallRate: new BN(row.real_fall_rate.split('.')[0]), + vehntFallRate: new BN(row.real_fall_rate.split(".")[0]), }) .accounts({ subDao, @@ -253,7 +253,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ provider, diff --git a/packages/helium-admin-cli/src/update-subdao.ts b/packages/helium-admin-cli/src/update-subdao.ts index 8b430edf2..35e32c523 100644 --- a/packages/helium-admin-cli/src/update-subdao.ts +++ b/packages/helium-admin-cli/src/update-subdao.ts @@ -1,116 +1,113 @@ -import * as anchor from '@coral-xyz/anchor'; +import * as anchor from "@coral-xyz/anchor"; import { accountWindowedBreakerKey, init as initCb, mintWindowedBreakerKey, -} from '@helium/circuit-breaker-sdk'; +} from "@helium/circuit-breaker-sdk"; import { init as initHem, rewardableEntityConfigKey, -} from '@helium/helium-entity-manager-sdk'; +} from "@helium/helium-entity-manager-sdk"; import { init as initHsd, subDaoKey, delegatorRewardsPercent, -} from '@helium/helium-sub-daos-sdk'; -import { PublicKey, TransactionInstruction } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import { BN } from 'bn.js'; -import os from 'os'; -import yargs from 'yargs/yargs'; -import { - loadKeypair, - parseEmissionsSchedule, - sendInstructionsOrSquads, -} from './utils'; +} from "@helium/helium-sub-daos-sdk"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import { BN } from "bn.js"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair, parseEmissionsSchedule } from "./utils"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, dntMint: { required: true, - type: 'string', - describe: 'DNT mint of the subdao to be updated', + type: "string", + describe: "DNT mint of the subdao to be updated", }, name: { - alias: 'n', - type: 'string', + alias: "n", + type: "string", required: false, - describe: 'The name of the entity config', + describe: "The name of the entity config", }, newAuthority: { required: false, - describe: 'New subdao authority', - type: 'string', + describe: "New subdao authority", + type: "string", default: null, }, newEmissionsSchedulePath: { required: false, - describe: 'Path to file that contains the new emissions schedule', - type: 'string', + describe: "Path to file that contains the new emissions schedule", + type: "string", default: null, }, newDcBurnAuthority: { required: false, default: null, - type: 'string', + type: "string", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, switchboardNetwork: { - type: 'string', - describe: 'The switchboard network', - default: 'devnet', + type: "string", + describe: "The switchboard network", + default: "devnet", }, registrar: { - type: 'string', + type: "string", required: false, - describe: 'VSR Registrar of subdao', + describe: "VSR Registrar of subdao", default: null, }, delegatorRewardsPercent: { - type: 'number', + type: "number", required: false, describe: - 'Percentage of rewards allocated to delegators. Must be between 0-100 and can have 8 decimal places.', + "Percentage of rewards allocated to delegators. Must be between 0-100 and can have 8 decimal places.", default: null, }, onboardingDcFee: { - type: 'number', + type: "number", required: false, - describe: 'The data credits fee for onboarding hotspots', + describe: "The data credits fee for onboarding hotspots", default: null, }, onboardingDataOnlyDcFee: { - type: 'number', + type: "number", required: false, - describe: 'The data credits fee for onboarding data only hotspots', + describe: "The data credits fee for onboarding data only hotspots", default: null, }, activeDeviceAuthority: { - type: 'string', + type: "string", required: false, - describe: 'The authority that can set hotspot active status', + describe: "The authority that can set hotspot active status", default: null, }, }); @@ -131,7 +128,7 @@ export async function run(args: any = process.argv) { const subDaoAcc = await program.account.subDaoV0.fetch(subDao); if (argv.newAuthority) { if (!argv.name) { - throw new Error('--name is required'); + throw new Error("--name is required"); } // update entity config auth const config = rewardableEntityConfigKey( @@ -146,7 +143,7 @@ export async function run(args: any = process.argv) { .updateRewardableEntityConfigV0({ newAuthority: new PublicKey(argv.newAuthority), settings: null, - stakingRequirement: null + stakingRequirement: null, }) .accounts({ rewardableEntityConfig: config, @@ -199,7 +196,7 @@ export async function run(args: any = process.argv) { argv.delegatorRewardsPercent && (argv.delegatorRewardsPercent > 100 || argv.delegatorRewardsPercent < 0) ) { - throw new Error('Delegator rewards percent must be between 0 and 100'); + throw new Error("Delegator rewards percent must be between 0 and 100"); } instructions.push( @@ -235,7 +232,7 @@ export async function run(args: any = process.argv) { ); const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); await sendInstructionsOrSquads({ provider, diff --git a/packages/helium-admin-cli/src/upgrade-idl.ts b/packages/helium-admin-cli/src/upgrade-idl.ts index 85d0bf704..5aa75907f 100644 --- a/packages/helium-admin-cli/src/upgrade-idl.ts +++ b/packages/helium-admin-cli/src/upgrade-idl.ts @@ -1,48 +1,48 @@ -import * as anchor from '@coral-xyz/anchor'; -import { PublicKey } from '@solana/web3.js'; -import Squads from '@sqds/sdk'; -import os from 'os'; -import yargs from 'yargs/yargs'; +import * as anchor from "@coral-xyz/anchor"; +import { PublicKey } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; import { createCloseBufferInstruction, createIdlUpgradeInstruction, loadKeypair, - sendInstructionsOrSquads, -} from './utils'; -import { BPF_UPGRADE_LOADER_ID } from '@solana/spl-governance'; -import bs58 from 'bs58'; +} from "./utils"; +import { BPF_UPGRADE_LOADER_ID } from "@solana/spl-governance"; +import bs58 from "bs58"; +import { sendInstructionsOrSquads } from "@helium/spl-utils"; export async function run(args: any = process.argv) { const yarg = yargs(args).options({ wallet: { - alias: 'k', - describe: 'Anchor wallet keypair', + 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', + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", }, executeTransaction: { - type: 'boolean', + type: "boolean", }, multisig: { - type: 'string', + type: "string", describe: - 'Address of the squads multisig to be authority. If not provided, your wallet will be the authority', + "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', + type: "number", + describe: "Authority index for squads. Defaults to 1", default: 1, }, programId: { - type: 'string', + type: "string", required: true, }, bufferId: { - type: 'string', + type: "string", required: true, }, }); @@ -54,7 +54,7 @@ export async function run(args: any = process.argv) { const wallet = new anchor.Wallet(loadKeypair(argv.wallet)); const connection = provider.connection; const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { - commitmentOrConfig: 'finalized', + commitmentOrConfig: "finalized", }); let authority = provider.wallet.publicKey; let multisig = argv.multisig ? new PublicKey(argv.multisig) : null; diff --git a/packages/helium-admin-cli/src/utils.ts b/packages/helium-admin-cli/src/utils.ts index ad143f1f3..3f43b8a29 100644 --- a/packages/helium-admin-cli/src/utils.ts +++ b/packages/helium-admin-cli/src/utils.ts @@ -679,147 +679,6 @@ export async function createCloseBufferInstruction( }); } -export async function sendInstructionsOrSquads({ - provider, - instructions, - signers = [], - payer = provider.wallet.publicKey, - commitment = "confirmed", - idlErrors = new Map(), - executeTransaction = false, - squads, - multisig, - authorityIndex, -}: { - executeTransaction?: boolean; // Will execute the transaction immediately. Only works if the squads multisig is only 1 wallet threshold or signers is complete - provider: anchor.AnchorProvider; - instructions: TransactionInstruction[]; - signers?: Signer[]; - payer?: PublicKey; - commitment?: Commitment; - idlErrors?: Map; - squads: Squads; - multisig?: PublicKey; - authorityIndex?: number; -}): Promise { - if (!multisig) { - return await sendInstructions( - provider, - await withPriorityFees({ - connection: provider.connection, - computeUnits: 1000000, - instructions, - }), - signers, - payer, - commitment, - idlErrors - ); - } - - const signerSet = new Set( - instructions - .map((ix) => - ix.keys.filter((k) => k.isSigner).map((k) => k.pubkey.toBase58()) - ) - .flat() - ); - const signerKeys = Array.from(signerSet).map((k) => new PublicKey(k)); - - const nonMissingSignerIxs = instructions.filter( - (ix) => - !ix.keys.some( - (k) => k.isSigner && !k.pubkey.equals(provider.wallet.publicKey) - ) - ); - const squadsSignatures = signerKeys.filter( - (k) => - !k.equals(provider.wallet.publicKey) && - !signers.some((s) => s.publicKey.equals(k)) - ); - - if (squadsSignatures.length == 0) { - return await sendInstructions( - provider, - await withPriorityFees({ - connection: provider.connection, - computeUnits: 1000000, - instructions: nonMissingSignerIxs, - }), - signers, - payer, - commitment, - idlErrors - ); - } - - if (squadsSignatures.length >= 2) { - throw new Error("Too many missing signatures"); - } - - const txIndex = await squads.getNextTransactionIndex(multisig); - const ix = await squads.buildCreateTransaction( - multisig, - authorityIndex!, - txIndex - ); - await sendInstructions( - provider, - await withPriorityFees({ - connection: provider.connection, - instructions: [ix], - computeUnits: 200000, - }) - ); - const [txKey] = await getTxPDA( - multisig, - new BN(txIndex), - squads.multisigProgramId - ); - let index = 1; - for (const ix of instructions.filter( - (ix) => !ix.programId.equals(ComputeBudgetProgram.programId) - )) { - await sendInstructions( - provider, - await withPriorityFees({ - connection: provider.connection, - instructions: [ - await squads.buildAddInstruction( - multisig, - txKey, - ix, - index - ), - ], - computeUnits: 200000, - }) - ); - index++; - } - - const ixs: TransactionInstruction[] = [] - ixs.push(await squads.buildActivateTransaction(multisig, txKey)) - ixs.push(await squads.buildApproveTransaction(multisig, txKey)) - - if (executeTransaction) { - ixs.push(await squads.buildExecuteTransaction( - txKey, - provider.wallet.publicKey - )); - } - - await sendInstructions( - provider, - await withPriorityFees({ - connection: provider.connection, - computeUnits: 1000000, - instructions: ixs - }), - signers - ) -} - export async function parseEmissionsSchedule(filepath: string) { const json = JSON.parse(fs.readFileSync(filepath).toString()); const schedule = json.map((x) => { diff --git a/packages/spl-utils/src/transaction.ts b/packages/spl-utils/src/transaction.ts index b26660478..55faa500e 100644 --- a/packages/spl-utils/src/transaction.ts +++ b/packages/spl-utils/src/transaction.ts @@ -18,7 +18,9 @@ import { } from "@solana/web3.js"; import bs58 from "bs58"; import { ProgramError } from "./anchorError"; -import { estimatePrioritizationFee } from "./priorityFees"; +import { estimatePrioritizationFee, withPriorityFees } from "./priorityFees"; +import Squads, { getTxPDA } from "@sqds/sdk"; +import { BN } from "bn.js"; export const chunks = (array: T[], size: number): T[][] => Array.apply(0, new Array(Math.ceil(array.length / size))).map((_, index) => @@ -885,3 +887,138 @@ export async function batchParallelInstructionsWithPriorityFee( maxSignatureBatch ); } + +export async function sendInstructionsOrSquads({ + provider, + instructions, + signers = [], + payer = provider.wallet.publicKey, + commitment = "confirmed", + idlErrors = new Map(), + executeTransaction = false, + squads, + multisig, + authorityIndex, +}: { + executeTransaction?: boolean; // Will execute the transaction immediately. Only works if the squads multisig is only 1 wallet threshold or signers is complete + provider: AnchorProvider; + instructions: TransactionInstruction[]; + signers?: Signer[]; + payer?: PublicKey; + commitment?: Commitment; + idlErrors?: Map; + squads: Squads; + multisig?: PublicKey; + authorityIndex?: number; +}): Promise { + if (!multisig) { + return await sendInstructions( + provider, + await withPriorityFees({ + connection: provider.connection, + computeUnits: 1000000, + instructions, + }), + signers, + payer, + commitment, + idlErrors + ); + } + + const signerSet = new Set( + instructions + .map((ix) => + ix.keys.filter((k) => k.isSigner).map((k) => k.pubkey.toBase58()) + ) + .flat() + ); + const signerKeys = Array.from(signerSet).map((k) => new PublicKey(k)); + + const nonMissingSignerIxs = instructions.filter( + (ix) => + !ix.keys.some( + (k) => k.isSigner && !k.pubkey.equals(provider.wallet.publicKey) + ) + ); + const squadsSignatures = signerKeys.filter( + (k) => + !k.equals(provider.wallet.publicKey) && + !signers.some((s) => s.publicKey.equals(k)) + ); + + if (squadsSignatures.length == 0) { + return await sendInstructions( + provider, + await withPriorityFees({ + connection: provider.connection, + computeUnits: 1000000, + instructions: nonMissingSignerIxs, + }), + signers, + payer, + commitment, + idlErrors + ); + } + + if (squadsSignatures.length >= 2) { + throw new Error("Too many missing signatures"); + } + + const txIndex = await squads.getNextTransactionIndex(multisig); + const ix = await squads.buildCreateTransaction( + multisig, + authorityIndex!, + txIndex + ); + await sendInstructions( + provider, + await withPriorityFees({ + connection: provider.connection, + instructions: [ix], + computeUnits: 200000, + }) + ); + const [txKey] = await getTxPDA( + multisig, + new BN(txIndex), + squads.multisigProgramId + ); + let index = 1; + for (const ix of instructions.filter( + (ix) => !ix.programId.equals(ComputeBudgetProgram.programId) + )) { + await sendInstructions( + provider, + await withPriorityFees({ + connection: provider.connection, + instructions: [ + await squads.buildAddInstruction(multisig, txKey, ix, index), + ], + computeUnits: 200000, + }) + ); + index++; + } + + const ixs: TransactionInstruction[] = []; + ixs.push(await squads.buildActivateTransaction(multisig, txKey)); + ixs.push(await squads.buildApproveTransaction(multisig, txKey)); + + if (executeTransaction) { + ixs.push( + await squads.buildExecuteTransaction(txKey, provider.wallet.publicKey) + ); + } + + await sendInstructions( + provider, + await withPriorityFees({ + connection: provider.connection, + computeUnits: 1000000, + instructions: ixs, + }), + signers + ); +}