-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path013_initializeSpokeAirlock.ts
45 lines (39 loc) · 1.24 KB
/
013_initializeSpokeAirlock.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Usage: npx ts-node app/deploy/013_initializeSpokeAirlock.ts
import * as anchor from "@coral-xyz/anchor";
import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
import { Connection, PublicKey, SystemProgram } from "@solana/web3.js";
import { DEPLOYER_AUTHORITY_KEYPAIR, RPC_NODE } from "./devnet_consts";
import { Staking } from "../../target/types/staking";
import fs from "fs";
async function main() {
try {
const DEBUG = true;
const connection = new Connection(RPC_NODE);
const provider = new AnchorProvider(
connection,
new Wallet(DEPLOYER_AUTHORITY_KEYPAIR),
{},
);
let program: Program<Staking>;
program = new Program(
JSON.parse(fs.readFileSync("./target/idl/staking.json").toString()),
provider,
);
const airlockPDA: PublicKey = PublicKey.findProgramAddressSync(
[Buffer.from("airlock")],
program.programId,
)[0];
await program.methods
.initializeSpokeAirlock()
.accounts({
payer: DEPLOYER_AUTHORITY_KEYPAIR.publicKey,
// @ts-ignore
airlock: airlockPDA,
systemProgram: SystemProgram.programId,
})
.rpc({ skipPreflight: DEBUG });
} catch (err) {
console.error("Error:", err);
}
}
main();