Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[solana] Update scripts for update and claim vesting admin #258

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions solana/app/deploy/devnet/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ export const VESTING_ADMIN_KEYPAIR = loadKeypair(
homedir() + VESTING_ADMIN_PATH,
);

export const NEW_VESTING_ADMIN_PATH = "/.config/solana/newVestingAdmin.json";
export const NEW_VESTING_ADMIN_KEYPAIR = loadKeypair(
homedir() + NEW_VESTING_ADMIN_PATH,
);

export const USER_AUTHORITY_PATH = "/.config/solana/user.json";
export const USER_AUTHORITY_KEYPAIR = loadKeypair(
homedir() + USER_AUTHORITY_PATH,
Expand Down
37 changes: 37 additions & 0 deletions solana/app/deploy/devnet/update/claimVestingAdmin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Usage: npx ts-node app/deploy/devnet/update/claimVestingAdmin.ts

import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
import { Connection } from "@solana/web3.js";
import {
RPC_NODE,
NEW_VESTING_ADMIN_KEYPAIR,
} from "../constants";
import { Staking } from "../../../../target/types/staking";
import fs from "fs";

async function main() {
try {
const connection = new Connection(RPC_NODE);
const provider = new AnchorProvider(
connection,
new Wallet(NEW_VESTING_ADMIN_KEYPAIR),
{},
);

let program: Program<Staking>;
program = new Program(
JSON.parse(fs.readFileSync("./target/idl/staking.json").toString()),
provider,
);

await program.methods
.claimVestingAdmin()
.accounts({ newVestingAdmin: NEW_VESTING_ADMIN_KEYPAIR.publicKey })
.signers([NEW_VESTING_ADMIN_KEYPAIR])
.rpc();
} catch (err) {
console.error("Error:", err);
}
}

main();
43 changes: 43 additions & 0 deletions solana/app/deploy/devnet/update/updateAndClaimVestingAdmin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Usage: npx ts-node app/deploy/devnet/update/updateAndClaimVestingAdmin.ts

import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
import { Connection } from "@solana/web3.js";
import {
DEPLOYER_AUTHORITY_KEYPAIR,
RPC_NODE,
VESTING_ADMIN_KEYPAIR,
} from "../constants";
import { Staking } from "../../../../target/types/staking";
import fs from "fs";

async function main() {
try {
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
.updateVestingAdmin()
.accounts({ newVestingAdmin: VESTING_ADMIN_KEYPAIR.publicKey })
.rpc();

await program.methods
.claimVestingAdmin()
.accounts({ newVestingAdmin: VESTING_ADMIN_KEYPAIR.publicKey })
.signers([VESTING_ADMIN_KEYPAIR])
.rpc();
} catch (err) {
console.error("Error:", err);
}
}

main();
19 changes: 8 additions & 11 deletions solana/app/deploy/devnet/update/updateVestingAdmin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Usage: npx ts-node app/deploy/devnet/update/updateVestingAdmin.ts

import { AnchorProvider, Program, Wallet } from "@coral-xyz/anchor";
import { Connection } from "@solana/web3.js";
import { Connection, PublicKey } from "@solana/web3.js";
import {
DEPLOYER_AUTHORITY_KEYPAIR,
RPC_NODE,
VESTING_ADMIN_KEYPAIR,
RPC_NODE,
} from "../constants";
import { Staking } from "../../../../target/types/staking";
import fs from "fs";
Expand All @@ -15,7 +14,7 @@ async function main() {
const connection = new Connection(RPC_NODE);
const provider = new AnchorProvider(
connection,
new Wallet(DEPLOYER_AUTHORITY_KEYPAIR),
new Wallet(VESTING_ADMIN_KEYPAIR),
{},
);

Expand All @@ -25,15 +24,13 @@ async function main() {
provider,
);

await program.methods
.updateVestingAdmin()
.accounts({ newVestingAdmin: VESTING_ADMIN_KEYPAIR.publicKey })
.rpc();
const NEW_VESTING_ADMIN_ADDRESS = new PublicKey(
"E1R3XdHgEYmsoLdZSQmhWrcD979bn5qK1bzr7pqMn2UQ",
);

await program.methods
.claimVestingAdmin()
.accounts({ newVestingAdmin: VESTING_ADMIN_KEYPAIR.publicKey })
.signers([VESTING_ADMIN_KEYPAIR])
.updateVestingAdmin()
.accounts({ newVestingAdmin: NEW_VESTING_ADMIN_ADDRESS })
.rpc();
} catch (err) {
console.error("Error:", err);
Expand Down