|
| 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