forked from MeteoraAg/presale-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevoke_operator.ts
More file actions
46 lines (39 loc) · 1.28 KB
/
Copy pathrevoke_operator.ts
File metadata and controls
46 lines (39 loc) · 1.28 KB
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
import { clusterApiUrl, Connection, Keypair, PublicKey } from "@solana/web3.js";
import Presale from "../src/presale";
import { PRESALE_PROGRAM_ID } from "../src";
import fs from "fs";
import os from "os";
const connection = new Connection(clusterApiUrl("devnet"));
async function revokeOperator(
connection: Connection,
operatorAddress: PublicKey,
creator: Keypair
) {
const revokeOperatorTx = await Presale.revokeOperator({
operator: operatorAddress,
creator: creator.publicKey,
connection,
programId: PRESALE_PROGRAM_ID,
});
revokeOperatorTx.sign(creator);
const txSig = await connection.sendRawTransaction(
revokeOperatorTx.serialize()
);
console.log("Revoke operator transaction sent:", txSig);
await connection.confirmTransaction(
{
signature: txSig,
lastValidBlockHeight: revokeOperatorTx.lastValidBlockHeight,
blockhash: revokeOperatorTx.recentBlockhash,
},
"finalized"
);
}
const operatorAddress = new PublicKey(
"FXBXnxEEfwZJA1xnyJzKEhhJXmussKXKRdq5cAh19dbC"
);
const creatorKeypairFilepath = `${os.homedir()}/.config/solana/id.json`;
const creatorKeypair = Keypair.fromSecretKey(
new Uint8Array(JSON.parse(fs.readFileSync(creatorKeypairFilepath, "utf-8")))
);
revokeOperator(connection, operatorAddress, creatorKeypair);