33import type { Idl } from "@coral-xyz/anchor" ;
44import { Program , AnchorProvider } from "@coral-xyz/anchor" ;
55import { WalletIcon } from "@heroicons/react/24/outline" ;
6- import {
7- TransactionBuilder ,
8- sendTransactions ,
9- } from "@pythnetwork/solana-utils" ;
10- import type { AnchorWallet } from "@solana/wallet-adapter-react" ;
6+ import type { PythStakingWallet } from "@pythnetwork/staking-sdk" ;
117import { useConnection } from "@solana/wallet-adapter-react" ;
128import { useWalletModal } from "@solana/wallet-adapter-react-ui" ;
13- import { PublicKey , Connection } from "@solana/web3.js" ;
9+ import {
10+ PublicKey ,
11+ Connection ,
12+ VersionedTransaction ,
13+ TransactionMessage ,
14+ } from "@solana/web3.js" ;
1415import type { ComponentProps } from "react" ;
1516import { useCallback } from "react" ;
1617
@@ -101,7 +102,7 @@ const ConnectWallet = ({ isLoading }: { isLoading?: boolean | undefined }) => {
101102 ) ;
102103} ;
103104
104- const WalletConnected = ( { wallet } : { wallet : AnchorWallet } ) => {
105+ const WalletConnected = ( { wallet } : { wallet : PythStakingWallet } ) => {
105106 const { connection } = useConnection ( ) ;
106107
107108 const testedStatus = useData (
@@ -139,7 +140,7 @@ const WalletConnected = ({ wallet }: { wallet: AnchorWallet }) => {
139140 }
140141} ;
141142
142- const Tester = ( { wallet } : { wallet : AnchorWallet } ) => {
143+ const Tester = ( { wallet } : { wallet : PythStakingWallet } ) => {
143144 const toast = useToast ( ) ;
144145 const { connection } = useConnection ( ) ;
145146 const { state, execute } = useAsync ( ( ) => testWallet ( connection , wallet ) ) ;
@@ -195,7 +196,7 @@ const Tester = ({ wallet }: { wallet: AnchorWallet }) => {
195196
196197const getHasAlreadyTested = async (
197198 connection : Connection ,
198- wallet : AnchorWallet ,
199+ wallet : PythStakingWallet ,
199200) => {
200201 const receiptAddress = PublicKey . findProgramAddressSync (
201202 [ wallet . publicKey . toBytes ( ) ] ,
@@ -205,28 +206,28 @@ const getHasAlreadyTested = async (
205206 return { hasTested : receipt !== null } ;
206207} ;
207208
208- const testWallet = async ( connection : Connection , wallet : AnchorWallet ) => {
209+ const testWallet = async (
210+ connection : Connection ,
211+ wallet : PythStakingWallet ,
212+ ) => {
209213 const walletTester = new Program (
210214 WalletTesterIDL as Idl ,
211215 new AnchorProvider ( connection , wallet ) ,
212216 ) ;
213217 const testMethod = walletTester . methods . test ;
214218 if ( testMethod ) {
215- await sendTransactions (
216- await TransactionBuilder . batchIntoVersionedTransactions (
217- wallet . publicKey ,
218- connection ,
219- [
220- {
221- instruction : await testMethod ( ) . instruction ( ) ,
222- signers : [ ] ,
223- } ,
224- ] ,
225- { } ,
226- ) ,
227- connection ,
228- wallet ,
219+ const instruction = await testMethod ( ) . instruction ( ) ;
220+ const { blockhash } = await connection . getLatestBlockhash ( {
221+ commitment : "confirmed" ,
222+ } ) ;
223+ const transaction = new VersionedTransaction (
224+ new TransactionMessage ( {
225+ payerKey : wallet . publicKey ,
226+ recentBlockhash : blockhash ,
227+ instructions : [ instruction ] ,
228+ } ) . compileToV0Message ( ) ,
229229 ) ;
230+ await wallet . sendTransaction ( transaction , connection ) ;
230231 } else {
231232 throw new Error ( "No test method found in program" ) ;
232233 }
0 commit comments