43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { Connection, PublicKey, Keypair, clusterApiUrl, LAMPORTS_PER_SOL, SystemProgram } from "@solana/web3.js";
|
|
import { Bets } from "./bets";
|
|
import { AnchorProvider, BN, Program, Wallet } from "@coral-xyz/anchor";
|
|
import { clusterUrl, cocSk, feeWallet, getRandomInt, testerSk } from "./shared";
|
|
import { getAssociatedTokenAddress } from "@solana/spl-token";
|
|
const IDL = require('./bets.json');
|
|
|
|
async function close(){
|
|
const keypair = Keypair.fromSecretKey(Uint8Array.from(cocSk));
|
|
|
|
const connection = new Connection(clusterUrl, {
|
|
commitment: 'confirmed',
|
|
confirmTransactionInitialTimeout: 60000
|
|
});
|
|
const provider = new AnchorProvider(connection, new Wallet(keypair), {
|
|
commitment: 'confirmed',
|
|
preflightCommitment: 'confirmed',
|
|
});
|
|
const program:Program<Bets> = new Program<Bets>(IDL, provider);
|
|
|
|
let solBalance = (await connection.getBalance(keypair.publicKey))/ LAMPORTS_PER_SOL;
|
|
console.log(`Tester ${keypair.publicKey} has ${solBalance} SOL`);
|
|
|
|
const [bet_list_pda] = await PublicKey.findProgramAddress([Buffer.from("bets_list")], program.programId);
|
|
console.log(`Bets list PDA : ${bet_list_pda}`);
|
|
|
|
const tx = await program.methods.clearBetsList().accounts({
|
|
}).rpc();
|
|
console.log(`clear tx: ${tx}`);
|
|
|
|
const confirmation = await connection.confirmTransaction(tx);
|
|
|
|
if (confirmation.value.err) {
|
|
console.error(`Transaction failed: ${confirmation.value.err}`);
|
|
}
|
|
|
|
console.log(`tx complete: ${tx}`);
|
|
}
|
|
|
|
close().catch(err => {
|
|
console.error('Fatal error:', err);
|
|
process.exit(1);
|
|
}); |