@@ -4,7 +4,7 @@ import { HermesClient } from "@pythnetwork/hermes-client";
44import  {  PythnetClient ,  PythStakingClient  }  from  "@pythnetwork/staking-sdk" ; 
55import  {  useLocalStorageValue  }  from  "@react-hookz/web" ; 
66import  {  useConnection ,  useWallet  }  from  "@solana/wallet-adapter-react" ; 
7- import  {  Connection ,  type   PublicKey  }  from  "@solana/web3.js" ; 
7+ import  {  Connection ,  PublicKey  }  from  "@solana/web3.js" ; 
88import  {  type  ComponentProps ,  createContext ,  useContext ,  useMemo  }  from  "react" ; 
99import  {  useSWRConfig  }  from  "swr" ; 
1010
@@ -65,6 +65,7 @@ const State = {
6565    pythnetClient : PythnetClient , 
6666    hermesClient : HermesClient , 
6767    account : PublicKey , 
68+     simulationPayer : string  |  undefined , 
6869    allAccounts : [ PublicKey ,  ...PublicKey [ ] ] , 
6970    selectAccount : ( account : PublicKey )  =>  void , 
7071    mutate : ReturnType < typeof  useSWRConfig > [ "mutate" ] , 
@@ -95,7 +96,7 @@ const State = {
9596      dashboardDataCacheKey, 
9697
9798      loadData : ( )  => 
98-         api . loadData ( client ,  pythnetClient ,  hermesClient ,  account ) , 
99+         api . loadData ( client ,  pythnetClient ,  hermesClient ,  account ,   simulationPayer  ?  new   PublicKey ( simulationPayer )  :  undefined ) , 
99100
100101      claim : bindApi ( api . claim ) , 
101102      deposit : bindApi ( api . deposit ) , 
@@ -131,19 +132,21 @@ type ApiProviderProps = Omit<
131132>  &  { 
132133  pythnetRpcUrl : string ; 
133134  hermesUrl : string ; 
135+   simulationPayer : string  |  undefined ; 
134136} ; 
135137
136138export  const  ApiProvider  =  ( { 
137139  hermesUrl, 
138140  pythnetRpcUrl, 
141+   simulationPayer, 
139142  ...props 
140143} : ApiProviderProps )  =>  { 
141-   const  state  =  useApiContext ( hermesUrl ,  pythnetRpcUrl ) ; 
144+   const  state  =  useApiContext ( hermesUrl ,  pythnetRpcUrl ,   simulationPayer ) ; 
142145
143146  return  < ApiContext . Provider  value = { state }  { ...props }  /> ; 
144147} ; 
145148
146- const  useApiContext  =  ( hermesUrl : string ,  pythnetRpcUrl : string )  =>  { 
149+ const  useApiContext  =  ( hermesUrl : string ,  pythnetRpcUrl : string ,   simulationPayer :  string   |   undefined )  =>  { 
147150  const  wallet  =  useWallet ( ) ; 
148151  const  {  connection }  =  useConnection ( ) ; 
149152  const  {  isMainnet }  =  useNetwork ( ) ; 
@@ -235,6 +238,7 @@ const useApiContext = (hermesUrl: string, pythnetRpcUrl: string) => {
235238                pythnetClient , 
236239                hermesClient , 
237240                selectedAccount  ??  firstAccount , 
241+                 simulationPayer , 
238242                [ firstAccount ,  ...otherAccounts ] , 
239243                ( account : PublicKey )  =>  { 
240244                  localStorageValue . set ( account . toBase58 ( ) ) ; 
0 commit comments