11import * as web3 from "@solana/web3.js" ;
22import { RPC_ENDPOINT , PAYER_KEYPAIR , MINT_ADDRESS } from "../constants" ;
3- import { CompressedTokenProgram } from "@lightprotocol/compressed-token" ;
3+ import {
4+ CompressedTokenProgram ,
5+ getTokenPoolInfos ,
6+ selectTokenPoolInfo ,
7+ } from "@lightprotocol/compressed-token" ;
48
59import {
610 bn ,
@@ -9,6 +13,7 @@ import {
913 dedupeSigner ,
1014 pickRandomTreeAndQueue ,
1115 Rpc ,
16+ selectStateTreeInfo ,
1217 sendAndConfirmTx ,
1318} from "@lightprotocol/stateless.js" ;
1419import * as splToken from "@solana/spl-token" ;
@@ -19,10 +24,13 @@ import * as splToken from "@solana/spl-token";
1924 const mintAddress = MINT_ADDRESS ;
2025 const payer = PAYER_KEYPAIR ;
2126
22- const activeStateTrees = await connection . getCachedActiveStateTreeInfo ( ) ;
27+ const activeStateTrees = await connection . getStateTreeInfos ( ) ;
28+ const treeInfo = selectStateTreeInfo ( activeStateTrees ) ;
29+ console . log ( "Picked output state tree:" , treeInfo . tree . toBase58 ( ) ) ;
2330
24- const { tree } = pickRandomTreeAndQueue ( activeStateTrees ) ;
25- console . log ( "Picked output state tree:" , tree . toBase58 ( ) ) ;
31+ const tokenPoolInfo = selectTokenPoolInfo (
32+ await getTokenPoolInfos ( connection , mintAddress )
33+ ) ;
2634
2735 // Get the source token account for the mint address
2836 const sourceTokenAccount = await splToken . getOrCreateAssociatedTokenAccount (
@@ -78,7 +86,8 @@ import * as splToken from "@solana/spl-token";
7886 toAddress : recipientBatch ,
7987 amount : recipientBatch . map ( ( ) => amount ) ,
8088 mint : mintAddress ,
81- outputStateTree : tree ,
89+ outputStateTreeInfo : treeInfo ,
90+ tokenPoolInfo,
8291 } ) ;
8392 instructions . push ( compressIx ) ;
8493 i += maxRecipientsPerInstruction ;
0 commit comments