Skip to content

Commit e3d1ca1

Browse files
authored
Update scripts for update and claim vesting admin (#258)
1 parent 6c30d6a commit e3d1ca1

File tree

4 files changed

+93
-11
lines changed

4 files changed

+93
-11
lines changed

solana/app/deploy/devnet/constants.ts

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ export const VESTING_ADMIN_KEYPAIR = loadKeypair(
8282
homedir() + VESTING_ADMIN_PATH,
8383
);
8484

85+
export const NEW_VESTING_ADMIN_PATH = "/.config/solana/newVestingAdmin.json";
86+
export const NEW_VESTING_ADMIN_KEYPAIR = loadKeypair(
87+
homedir() + NEW_VESTING_ADMIN_PATH,
88+
);
89+
8590
export const USER_AUTHORITY_PATH = "/.config/solana/user.json";
8691
export const USER_AUTHORITY_KEYPAIR = loadKeypair(
8792
homedir() + USER_AUTHORITY_PATH,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Usage: npx ts-node app/deploy/devnet/update/claimVestingAdmin.ts
2+
3+
import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
4+
import { Connection } from "@solana/web3.js";
5+
import {
6+
RPC_NODE,
7+
NEW_VESTING_ADMIN_KEYPAIR,
8+
} from "../constants";
9+
import { Staking } from "../../../../target/types/staking";
10+
import fs from "fs";
11+
12+
async function main() {
13+
try {
14+
const connection = new Connection(RPC_NODE);
15+
const provider = new AnchorProvider(
16+
connection,
17+
new Wallet(NEW_VESTING_ADMIN_KEYPAIR),
18+
{},
19+
);
20+
21+
let program: Program<Staking>;
22+
program = new Program(
23+
JSON.parse(fs.readFileSync("./target/idl/staking.json").toString()),
24+
provider,
25+
);
26+
27+
await program.methods
28+
.claimVestingAdmin()
29+
.accounts({ newVestingAdmin: NEW_VESTING_ADMIN_KEYPAIR.publicKey })
30+
.signers([NEW_VESTING_ADMIN_KEYPAIR])
31+
.rpc();
32+
} catch (err) {
33+
console.error("Error:", err);
34+
}
35+
}
36+
37+
main();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Usage: npx ts-node app/deploy/devnet/update/updateAndClaimVestingAdmin.ts
2+
3+
import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
4+
import { Connection } from "@solana/web3.js";
5+
import {
6+
DEPLOYER_AUTHORITY_KEYPAIR,
7+
RPC_NODE,
8+
VESTING_ADMIN_KEYPAIR,
9+
} from "../constants";
10+
import { Staking } from "../../../../target/types/staking";
11+
import fs from "fs";
12+
13+
async function main() {
14+
try {
15+
const connection = new Connection(RPC_NODE);
16+
const provider = new AnchorProvider(
17+
connection,
18+
new Wallet(DEPLOYER_AUTHORITY_KEYPAIR),
19+
{},
20+
);
21+
22+
let program: Program<Staking>;
23+
program = new Program(
24+
JSON.parse(fs.readFileSync("./target/idl/staking.json").toString()),
25+
provider,
26+
);
27+
28+
await program.methods
29+
.updateVestingAdmin()
30+
.accounts({ newVestingAdmin: VESTING_ADMIN_KEYPAIR.publicKey })
31+
.rpc();
32+
33+
await program.methods
34+
.claimVestingAdmin()
35+
.accounts({ newVestingAdmin: VESTING_ADMIN_KEYPAIR.publicKey })
36+
.signers([VESTING_ADMIN_KEYPAIR])
37+
.rpc();
38+
} catch (err) {
39+
console.error("Error:", err);
40+
}
41+
}
42+
43+
main();

solana/app/deploy/devnet/update/updateVestingAdmin.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// Usage: npx ts-node app/deploy/devnet/update/updateVestingAdmin.ts
22

33
import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
4-
import { Connection } from "@solana/web3.js";
4+
import { Connection, PublicKey } from "@solana/web3.js";
55
import {
6-
DEPLOYER_AUTHORITY_KEYPAIR,
7-
RPC_NODE,
86
VESTING_ADMIN_KEYPAIR,
7+
RPC_NODE,
98
} from "../constants";
109
import { Staking } from "../../../../target/types/staking";
1110
import fs from "fs";
@@ -15,7 +14,7 @@ async function main() {
1514
const connection = new Connection(RPC_NODE);
1615
const provider = new AnchorProvider(
1716
connection,
18-
new Wallet(DEPLOYER_AUTHORITY_KEYPAIR),
17+
new Wallet(VESTING_ADMIN_KEYPAIR),
1918
{},
2019
);
2120

@@ -25,15 +24,13 @@ async function main() {
2524
provider,
2625
);
2726

28-
await program.methods
29-
.updateVestingAdmin()
30-
.accounts({ newVestingAdmin: VESTING_ADMIN_KEYPAIR.publicKey })
31-
.rpc();
27+
const NEW_VESTING_ADMIN_ADDRESS = new PublicKey(
28+
"E1R3XdHgEYmsoLdZSQmhWrcD979bn5qK1bzr7pqMn2UQ",
29+
);
3230

3331
await program.methods
34-
.claimVestingAdmin()
35-
.accounts({ newVestingAdmin: VESTING_ADMIN_KEYPAIR.publicKey })
36-
.signers([VESTING_ADMIN_KEYPAIR])
32+
.updateVestingAdmin()
33+
.accounts({ newVestingAdmin: NEW_VESTING_ADMIN_ADDRESS })
3734
.rpc();
3835
} catch (err) {
3936
console.error("Error:", err);

0 commit comments

Comments
 (0)