-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path022_updateGovernanceAuthority.ts
46 lines (40 loc) · 1.27 KB
/
022_updateGovernanceAuthority.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
// Usage: npx ts-node app/deploy/022_updateGovernanceAuthority.ts
import * as anchor from "@coral-xyz/anchor";
import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
import { Connection } from "@solana/web3.js";
import { DEPLOYER_AUTHORITY_KEYPAIR, GOVERNANCE_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,
);
await program.methods
.updateGovernanceAuthority()
.accounts({
governanceSigner: DEPLOYER_AUTHORITY_KEYPAIR.publicKey,
newAuthority: GOVERNANCE_AUTHORITY_KEYPAIR.publicKey,
})
.rpc();
await program.methods
.claimGovernanceAuthority()
.accounts({
newAuthority: GOVERNANCE_AUTHORITY_KEYPAIR.publicKey,
})
.signers([GOVERNANCE_AUTHORITY_KEYPAIR])
.rpc();
} catch (err) {
console.error("Error:", err);
}
}
main();