File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
packages/thirdweb/src/wallets Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -190,10 +190,7 @@ export function createWallet<const ID extends WalletId>(
190190 const emitter = createWalletEmitter < ID > ( ) ;
191191 let account : Account | undefined = undefined ;
192192 let chain : Chain | undefined = undefined ;
193-
194- const unsubscribeChain = emitter . subscribe ( "chainChanged" , ( newChain ) => {
195- chain = newChain ;
196- } ) ;
193+ let unsubscribeChain : ( ( ) => void ) | undefined = undefined ;
197194
198195 function reset ( ) {
199196 account = undefined ;
@@ -204,7 +201,7 @@ export function createWallet<const ID extends WalletId>(
204201
205202 const unsubscribeDisconnect = emitter . subscribe ( "disconnect" , ( ) => {
206203 reset ( ) ;
207- unsubscribeChain ( ) ;
204+ unsubscribeChain ?. ( ) ;
208205 unsubscribeDisconnect ( ) ;
209206 } ) ;
210207
@@ -263,6 +260,9 @@ export function createWallet<const ID extends WalletId>(
263260 chain = connectedChain ;
264261 handleDisconnect = doDisconnect ;
265262 handleSwitchChain = doSwitchChain ;
263+ unsubscribeChain = emitter . subscribe ( "chainChanged" , ( newChain ) => {
264+ chain = newChain ;
265+ } ) ;
266266 trackConnect ( {
267267 client : options . client ,
268268 walletType : id ,
@@ -377,6 +377,9 @@ export function createWallet<const ID extends WalletId>(
377377 chain = connectedChain ;
378378 handleDisconnect = doDisconnect ;
379379 handleSwitchChain = doSwitchChain ;
380+ unsubscribeChain = emitter . subscribe ( "chainChanged" , ( newChain ) => {
381+ chain = newChain ;
382+ } ) ;
380383 trackConnect ( {
381384 client : options . client ,
382385 walletType : id ,
You can’t perform that action at this time.
0 commit comments