-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path016_initializeSpokeMessageExecutor.ts
56 lines (50 loc) · 1.66 KB
/
016_initializeSpokeMessageExecutor.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
46
47
48
49
50
51
52
53
54
55
56
// Usage: npx ts-node app/deploy/016_initializeSpokeMessageExecutor.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 {
hubSolanaMessageDispatcherPublicKey,
HUB_CHAIN_ID,
} from "../constants";
import { DEPLOYER_AUTHORITY_KEYPAIR, RPC_NODE } from "./devnet_consts";
import { Staking } from "../../target/types/staking";
import fs from "fs";
import { wasm } from "../StakeConnection";
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 messageExecutorPDA: PublicKey = PublicKey.findProgramAddressSync(
[Buffer.from("spoke_message_executor")],
program.programId,
)[0];
const config: PublicKey = PublicKey.findProgramAddressSync(
[Buffer.from(wasm.Constants.CONFIG_SEED())],
program.programId,
)[0];
await program.methods
.initializeSpokeMessageExecutor(HUB_CHAIN_ID)
.accounts({
governanceAuthority: DEPLOYER_AUTHORITY_KEYPAIR.publicKey,
// @ts-ignore
executor: messageExecutorPDA,
config: config,
hubDispatcher: hubSolanaMessageDispatcherPublicKey,
systemProgram: SystemProgram.programId,
})
.rpc({ skipPreflight: DEBUG });
} catch (err) {
console.error("Error:", err);
}
}
main();