@@ -16,7 +16,7 @@ import {
1616 Tooltip ,
1717} from "@chakra-ui/react" ;
1818import { useWallet } from "@solana/wallet-adapter-react" ;
19- import React from "react" ;
19+ import React , { useEffect } from "react" ;
2020import {
2121 FaCompress ,
2222 FaEllipsisV ,
@@ -26,7 +26,10 @@ import {
2626 FaPlay ,
2727 FaShareAlt ,
2828} from "react-icons/fa" ;
29- import { usePersistentStore } from "../../hooks/usePersistentStore" ;
29+ import {
30+ usePersistentStore ,
31+ useShallowPersistentStore ,
32+ } from "../../hooks/usePersistentStore" ;
3033import { useSendWeb3Transaction } from "../../hooks/useSendWeb3Transaction" ;
3134import {
3235 useShallowSessionStoreWithoutUndo ,
@@ -49,6 +52,9 @@ export const TransactionHeader: React.FC<{
4952 const [ transaction , rpcEndpoint , setSession ] = useShallowSessionStoreWithUndo (
5053 ( state ) => [ state . transaction , state . rpcEndpoint , state . set ]
5154 ) ;
55+ const rpcEndpoints = useShallowPersistentStore (
56+ ( state ) => state . appOptions . rpcEndpoints
57+ ) ;
5258
5359 const { publicKey : walletPublicKey } = useWallet ( ) ;
5460 const { send } = useSendWeb3Transaction ( {
@@ -86,6 +92,15 @@ export const TransactionHeader: React.FC<{
8692 } ) ;
8793 } ;
8894
95+ useEffect ( ( ) => {
96+ // when rpc endpoints setting change, update the current selected rpc
97+ if ( rpcEndpoints . map . hasOwnProperty ( rpcEndpoint . id ) ) {
98+ setSession ( ( state ) => {
99+ state . rpcEndpoint = rpcEndpoints . map [ rpcEndpoint . id ] ;
100+ } ) ;
101+ }
102+ } , [ rpcEndpoints , rpcEndpoint , setSession ] ) ;
103+
89104 return (
90105 < >
91106 < Flex alignItems = "center" >
0 commit comments