Skip to content

Commit 0c6e458

Browse files
committed
Add script to assign permissionless account
1 parent cbf8e30 commit 0c6e458

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

Anchor.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ add-v03-metadata = "yarn run tsx scripts/addV03Metadata.ts"
2525
add-v04-metadata = "yarn run tsx scripts/addV04Metadata.ts"
2626
create-proposal = "yarn run tsx scripts/createProposal.ts"
2727
create-v04-dao = "yarn run tsx scripts/createV04DAO.ts"
28+
assign-permissionless-account = "yarn run tsx scripts/assignPermissionlessAccount.ts"
2829
create-v04-proposal = "yarn run tsx scripts/createV04Proposal.ts"
2930
initialize-launch = "yarn run tsx scripts/initializeLaunch.ts"
3031
test = "npx mocha --import=tsx --bail tests/main.test.ts"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as anchor from "@coral-xyz/anchor";
2+
import { SystemProgram, Transaction } from "@solana/web3.js";
3+
import { AutocratClient, PERMISSIONLESS_ACCOUNT } from "@metadaoproject/futarchy/v0.5";
4+
5+
async function main() {
6+
const provider = anchor.AnchorProvider.env();
7+
const autocratProgram = AutocratClient.createClient({ provider });
8+
const payer = provider.wallet["payer"];
9+
10+
let assignIx = SystemProgram.assign({
11+
accountPubkey: PERMISSIONLESS_ACCOUNT.publicKey,
12+
programId: autocratProgram.getProgramId(),
13+
});
14+
15+
let allocateIx = SystemProgram.allocate({
16+
accountPubkey: PERMISSIONLESS_ACCOUNT.publicKey,
17+
space: 8,
18+
})
19+
20+
let transferIx = SystemProgram.transfer({
21+
fromPubkey: payer.publicKey,
22+
toPubkey: PERMISSIONLESS_ACCOUNT.publicKey,
23+
lamports: 10_000_000,
24+
})
25+
console.log("assigning permissionless account to autocrat program");
26+
let assignTx = new Transaction().add(allocateIx, assignIx, transferIx);
27+
assignTx.recentBlockhash = (await provider.connection.getLatestBlockhash())[0];
28+
assignTx.feePayer = payer.publicKey;
29+
// assignTx.sign(this.payer, PERMISSIONLESS_ACCOUNT);
30+
31+
await provider.connection.sendTransaction(assignTx, [payer, PERMISSIONLESS_ACCOUNT]);
32+
33+
}
34+
35+
main().catch((error) => {
36+
console.error(error);
37+
process.exit(1);
38+
});

0 commit comments

Comments
 (0)