diff --git a/packages/scripts-ts/accounts_ref.md b/packages/scripts-ts/accounts_ref.md index 384b73feb..aca0dd644 100644 --- a/packages/scripts-ts/accounts_ref.md +++ b/packages/scripts-ts/accounts_ref.md @@ -22,3 +22,8 @@ TODO list of common banks and groups... ## MINTS * UXD - 7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFT * USDT - Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB + + +## VALIDATORS +* Cavey Cool - CooLbbZy5Xmdt7DiHPQ3ss2uRXawnTXXVgpMS8E8jDzr +* Cavey Cool Single Pool - AvS4oXtxWdrJGCJwDbcZ7DqpSqNQtKjyXnbkDbrSk6Fq \ No newline at end of file diff --git a/packages/scripts-ts/init_single_pool.ts b/packages/scripts-ts/init_single_pool.ts index 0ce2bc71b..75b085786 100644 --- a/packages/scripts-ts/init_single_pool.ts +++ b/packages/scripts-ts/init_single_pool.ts @@ -1,9 +1,17 @@ // NOTE: you will need to change package resolution or overrides to use `"@solana/web3.js": // "^1.91.6"`, unless Solana foundation updates this... -import { Connection, PublicKey, sendAndConfirmTransaction } from "@solana/web3.js"; +import { + Connection, + Keypair, + LAMPORTS_PER_SOL, + PublicKey, + sendAndConfirmTransaction, + SystemProgram, + Transaction, +} from "@solana/web3.js"; import { AnchorProvider } from "@coral-xyz/anchor"; import { loadKeypairFromFile, SINGLE_POOL_PROGRAM_ID } from "./utils"; -import { findPoolAddress, SinglePoolProgram } from "@solana/spl-single-pool-classic"; +import { findPoolAddress, findPoolStakeAddress, SinglePoolProgram } from "@solana/spl-single-pool-classic"; type Config = { VALIDATOR_VOTE_ACC: PublicKey; @@ -14,22 +22,43 @@ const config: Config = { async function main() { const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed"); - const wallet = loadKeypairFromFile(process.env.HOME + "/.config/solana/id.json"); + const wallet = loadKeypairFromFile(process.env.HOME + "/keys/staging-deploy.json"); + console.log("payer: " + wallet.publicKey); + + const poolKey = await findPoolAddress(SINGLE_POOL_PROGRAM_ID, config.VALIDATOR_VOTE_ACC); + const poolStake = await findPoolStakeAddress(SINGLE_POOL_PROGRAM_ID, poolKey); // @ts-ignore const provider = new AnchorProvider(connection, wallet, { preflightCommitment: "confirmed", }); - let tx = await SinglePoolProgram.initialize(provider.connection, config.VALIDATOR_VOTE_ACC, wallet.publicKey, true); + let tx = new Transaction(); + tx.add( + SystemProgram.transfer({ + fromPubkey: wallet.publicKey, + toPubkey: poolStake, + // TODO + /* + NO IDEA HOW MUCH IS ACTUALLY NEEDED HERE, SOLANA'S REFERENCE IMPLEMENTATION DOESN'T + SEND ENOUGH, BUT THIS IS LIKELY TOO MUCH + */ + lamports: LAMPORTS_PER_SOL * 1.1, + }) + ); + + tx.add( + ...(await SinglePoolProgram.initialize(provider.connection, config.VALIDATOR_VOTE_ACC, wallet.publicKey, true)) + .instructions + ); try { const signature = await sendAndConfirmTransaction(connection, tx, [wallet]); console.log("Transaction signature:", signature); - const poolKey = await findPoolAddress(SINGLE_POOL_PROGRAM_ID, config.VALIDATOR_VOTE_ACC); - console.log("Pool key: " + poolKey); } catch (error) { console.error("Transaction failed:", error); } + + console.log("pool key: " + poolKey); } main().catch((err) => { diff --git a/packages/scripts-ts/init_validator.ts b/packages/scripts-ts/init_validator.ts index fcb82d401..7f694987c 100644 --- a/packages/scripts-ts/init_validator.ts +++ b/packages/scripts-ts/init_validator.ts @@ -9,7 +9,7 @@ import { VoteProgram, } from "@solana/web3.js"; import { AnchorProvider } from "@coral-xyz/anchor"; -import { loadKeypairFromFile, SINGLE_POOL_PROGRAM_ID } from "./utils"; +import { loadKeypairFromFile } from "./utils"; type Config = { /**