Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
"lint": "next lint"
},
"dependencies": {
"@coral-xyz/anchor": "^0.29.0",
"@helium/account-fetch-cache": "^0.9.33",
"@helium/account-fetch-cache-hooks": "^0.9.33",
"@helium/helium-react-hooks": "^0.9.33",
"@helium/modular-governance-hooks": "^0.0.13",
"@helium/modular-governance-idls": "^0.0.13",
"@helium/no-emit-sdk": "^0.9.33",
"@helium/organization-sdk": "^0.0.13",
"@helium/spl-utils": "^0.9.33",
"@helium/state-controller-sdk": "^0.0.13",
"@helium/voter-stake-registry-hooks": "^0.9.33",
"@helium/voter-stake-registry-sdk": "^0.9.33",
"@coral-xyz/anchor": "^0.31.0",
"@helium/account-fetch-cache": "^0.10.6",
"@helium/account-fetch-cache-hooks": "^0.10.6",
"@helium/helium-react-hooks": "^0.10.6",
"@helium/hpl-crons-sdk": "^0.10.6",
"@helium/modular-governance-hooks": "^0.1.5",
"@helium/modular-governance-idls": "^0.1.5",
"@helium/no-emit-sdk": "^0.10.6",
"@helium/organization-sdk": "^0.1.5",
"@helium/spl-utils": "^0.10.6",
"@helium/state-controller-sdk": "^0.1.5",
"@helium/tuktuk-sdk": "^0.0.6",
"@helium/voter-stake-registry-hooks": "^0.10.6",
"@helium/voter-stake-registry-sdk": "^0.10.6",
"@hookform/resolvers": "^3.3.4",
"@metaplex-foundation/mpl-token-metadata": "2.10.0",
"@project-serum/anchor": "^0.26.0",
Expand Down Expand Up @@ -75,15 +77,15 @@
"resolutions": {
"@tanstack/react-query": "5.45.1",
"@solana/web3.js": "^1.90.0",
"@helium/account-fetch-cache": "^0.9.33",
"@helium/account-fetch-cache-hooks": "^0.9.33",
"@helium/helium-react-hooks": "^0.9.33",
"@helium/voter-stake-registry-hooks": "^0.9.33",
"@helium/modular-governance-idls": "^0.0.13",
"@helium/spl-utils": "^0.9.33",
"@helium/modular-governance-hooks": "^0.0.13",
"@helium/account-fetch-cache": "^0.10.6",
"@helium/account-fetch-cache-hooks": "^0.10.6",
"@helium/helium-react-hooks": "^0.10.6",
"@helium/voter-stake-registry-hooks": "^0.10.6",
"@helium/modular-governance-idls": "^0.1.5",
"@helium/spl-utils": "^0.10.6",
"@helium/modular-governance-hooks": "^0.1.5",
"@solana/wallet-adapter-react": "^0.15.35",
"@helium/voter-stake-registry-sdk": "^0.9.33"
"@helium/voter-stake-registry-sdk": "^0.10.6"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.10",
Expand Down
90 changes: 90 additions & 0 deletions scripts/add-crons-to-proposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import * as anchor from "@coral-xyz/anchor";
import os from "os";
import yargs from "yargs/yargs";
import { init as initProposal } from "@helium/proposal-sdk";
import { PublicKey, SystemProgram } from "@solana/web3.js";
import { loadKeypair, sendInstructionsOrSquads } from "./utils";
import { init as initTuktuk, taskKey } from "@helium/tuktuk-sdk";
import { init as initHsd, daoKey } from "@helium/helium-sub-daos-sdk";
import {
nextAvailableTaskIds,
queueAuthorityKey,
TASK_QUEUE_ID,
} from "@helium/hpl-crons-sdk";
import { init as initHplCrons } from "@helium/hpl-crons-sdk";
import { HNT_MINT, sendInstructions } from "@helium/spl-utils";

export async function run(args: any = process.argv) {
const yarg = yargs(args).options({
wallet: {
alias: "k",
describe: "Anchor wallet keypair",
default: `${os.homedir()}/.config/solana/id.json`,
},
url: {
alias: "u",
default: "http://127.0.0.1:8899",
describe: "The solana url",
},
proposal: {
required: true,
type: "string",
describe: "The proposal public key",
},
});

const argv = await yarg.argv;
process.env.ANCHOR_WALLET = argv.wallet;
process.env.ANCHOR_PROVIDER_URL = argv.url;
anchor.setProvider(anchor.AnchorProvider.local(argv.url));

const provider = anchor.getProvider() as anchor.AnchorProvider;
const proposalProgram = await initProposal(provider);
const tuktukProgram = await initTuktuk(provider);
const hplCronsProgram = await initHplCrons(provider);
const hsdProgram = await initHsd(provider);

const proposal = new PublicKey(argv.proposal);
const proposalAcc = await proposalProgram.account.proposalV0.fetch(proposal);
const proposalConfigAcc = await proposalProgram.account.proposalConfigV0.fetch(
proposalAcc.proposalConfig
);

const queueAuthority = queueAuthorityKey()[0];
console.log(
`Queue authority: ${queueAuthority.toBase58()} (Fund with Sol to pay task rent)`
);

const queue = await tuktukProgram.account.taskQueueV0.fetch(TASK_QUEUE_ID);
const freeTask = nextAvailableTaskIds(queue.taskBitmap, 1)[0];

const resolveIx = await hplCronsProgram.methods
.queueResolveProposalV0({
freeTaskId: freeTask,
})
.accountsPartial({
proposal,
taskQueue: TASK_QUEUE_ID,
task: taskKey(TASK_QUEUE_ID, freeTask)[0],
proposalConfig: proposalAcc.proposalConfig,
stateController: proposalConfigAcc.stateController,
payer: provider.wallet.publicKey,
systemProgram: SystemProgram.programId,
queueAuthority,
tuktukProgram: tuktukProgram.programId,
namespace: proposalAcc.namespace,
})
.instruction();

const addRecentProposalToDaoIx = await hsdProgram.methods
.addRecentProposalToDaoV0()
.accounts({
dao: daoKey(HNT_MINT)[0],
proposal,
})
.instruction();

await sendInstructions(provider, [resolveIx, addRecentProposalToDaoIx]);

console.log(`Proposal resolve queued and added to recent: ${proposal.toBase58()}`);
}
2 changes: 1 addition & 1 deletion scripts/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export async function run(args: any = process.argv) {
uri: null,
authority,
})
.accounts({ organization, authority: organizationAcc.authority })
.accountsPartial({ organization, authority: organizationAcc.authority })
.instruction();

await sendInstructionsOrSquads({
Expand Down
82 changes: 77 additions & 5 deletions scripts/bulk-create-proposal.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import * as anchor from "@coral-xyz/anchor";
import { init as initOrg, organizationKey, proposalKey } from "@helium/organization-sdk";
import {
init as initOrg,
organizationKey,
proposalKey,
} from "@helium/organization-sdk";
import os from "os";
import yargs from "yargs/yargs";
import { init as initState } from "@helium/state-controller-sdk";
import Squads from "@sqds/sdk";
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
import {
PublicKey,
SystemProgram,
TransactionInstruction,
} from "@solana/web3.js";
import { loadKeypair, sendInstructionsOrSquads } from "./utils";
import fs from "fs";
import { init as initTuktuk, taskKey } from "@helium/tuktuk-sdk";
import {
nextAvailableTaskIds,
TASK_QUEUE_ID,
init as initHplCrons,
queueAuthorityKey,
} from "@helium/hpl-crons-sdk";
import { init as initHsd, daoKey } from "@helium/helium-sub-daos-sdk";
import { HNT_MINT } from "@helium/spl-utils";

interface Choice {
uri: string;
Expand Down Expand Up @@ -66,6 +83,8 @@ export async function run(args: any = process.argv) {
const wallet = new anchor.Wallet(walletKP);
const orgProgram = await initOrg(provider);
const stateProgram = await initState(provider);
const hsdProgram = await initHsd(provider);
const dao = daoKey(HNT_MINT)[0];

const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, {
commitmentOrConfig: "finalized",
Expand All @@ -79,11 +98,31 @@ export async function run(args: any = process.argv) {
const fileData = fs.readFileSync(argv.file, "utf8");
const proposals: Proposal[] = JSON.parse(fileData);

const queueAuthority = queueAuthorityKey()[0];
console.log(
`Queue authority: ${queueAuthority.toBase58()} (Fund with Sol to pay task rent)`
);

const instructions: TransactionInstruction[] = [];
const organizationK = organizationKey(argv.orgName)[0];
const organization = await orgProgram.account.organizationV0.fetch(
organizationK
);
const tuktukProgram = await initTuktuk(provider);
const hplCronsProgram = await initHplCrons(provider);

const queue = await tuktukProgram.account.taskQueueV0.fetch(TASK_QUEUE_ID);
const freeTasks = nextAvailableTaskIds(
queue.taskBitmap,
proposals.length - organization.numProposals
)[0];
let freeTaskIdx = 0;
const proposalConfig = argv.proposalConfig
? new PublicKey(argv.proposalConfig)
: organization.defaultProposalConfig;
const proposalConfigAcc = await stateProgram.account.proposalConfigV0.fetch(
proposalConfig
);

let i = 0;
for (const proposalData of proposals) {
Expand All @@ -93,7 +132,7 @@ export async function run(args: any = process.argv) {
pubkeys: { proposal },
} = await orgProgram.methods
.initializeProposalV0(proposalData)
.accounts({
.accountsPartial({
organization: organizationK,
owner: authority,
authority,
Expand All @@ -103,10 +142,11 @@ export async function run(args: any = process.argv) {
.prepare();

const { instruction: setState } = await stateProgram.methods
// @ts-ignore
.updateStateV0({
newState: { voting: {} },
})
.accounts({
.accountsPartial({
proposal,
owner: authority,
proposalConfig: proposalData.proposalConfig
Expand All @@ -116,7 +156,39 @@ export async function run(args: any = process.argv) {
})
.prepare();

instructions.push(instruction, setState);
const resolveIx = await hplCronsProgram.methods
.queueResolveProposalV0({
freeTaskId: freeTasks[freeTaskIdx],
})
.accountsPartial({
proposal: proposal!,
taskQueue: TASK_QUEUE_ID,
namespace: organizationK,
task: taskKey(TASK_QUEUE_ID, freeTasks[freeTaskIdx])[0],
proposalConfig,
stateController: proposalConfigAcc.stateController,
payer: authority,
systemProgram: SystemProgram.programId,
queueAuthority,
tuktukProgram: tuktukProgram.programId,
})
.instruction();

const addRecentProposalToDaoIx = await hsdProgram.methods
.addRecentProposalToDaoV0()
.accounts({
dao,
proposal: proposal!,
})
.instruction();

freeTaskIdx++;
instructions.push(
instruction,
setState,
resolveIx,
addRecentProposalToDaoIx
);
}
i++;
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/cancel-proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function run(args: any = process.argv) {
.updateStateV0({
newState: { cancelled: {} },
})
.accounts({
.accountsPartial({
proposal,
owner,
})
Expand Down
Loading