From fb89acd8bfc731593ac13cbb93998c7314ef9f67 Mon Sep 17 00:00:00 2001 From: enesozturk Date: Mon, 12 Aug 2024 12:20:35 +0300 Subject: [PATCH] chore: refactor syncAccount params and resetAccount logics --- packages/wagmi/src/client.ts | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/packages/wagmi/src/client.ts b/packages/wagmi/src/client.ts index 4a714e0fef..8fc03178ee 100644 --- a/packages/wagmi/src/client.ts +++ b/packages/wagmi/src/client.ts @@ -409,9 +409,7 @@ export class Web3Modal extends Web3ModalScaffold { isConnected: true, addresses: response.accounts, connector, - chainId: response.chainId, - status: 'connected', - resetAccount: false + chainId: response.chainId }) ) } @@ -461,9 +459,7 @@ export class Web3Modal extends Web3ModalScaffold { isDisconnected, chainId, connector, - addresses, - status, - resetAccount = true + addresses }: Partial< Pick< GetAccountReturnType, @@ -475,19 +471,14 @@ export class Web3Modal extends Web3ModalScaffold { | 'addresses' | 'status' > - > & { resetAccount?: boolean }) { + >) { const caipAddress: CaipAddress = `${ConstantsUtil.EIP155}:${chainId}:${address}` if (this.getCaipAddress() === caipAddress) { return } - const connected = isConnected && status === 'connected' - - if (connected && address && chainId) { - if (resetAccount) { - this.resetAccount() - } + if (isConnected && address && chainId) { this.syncNetwork(address, chainId, isConnected) this.setIsConnected(isConnected) this.setCaipAddress(caipAddress) @@ -511,9 +502,7 @@ export class Web3Modal extends Web3ModalScaffold { this.hasSyncedConnectedAccount = true } else if (isDisconnected && this.hasSyncedConnectedAccount) { - if (resetAccount) { - this.resetAccount() - } + this.resetAccount() this.resetWcConnection() this.resetNetwork() this.setAllAccounts([], this.chain) @@ -818,8 +807,7 @@ export class Web3Modal extends Web3ModalScaffold { address: address as `0x${string}`, isConnected: true, chainId: NetworkUtil.caipNetworkIdToNumber(this.getCaipNetwork()?.id), - connector, - status: 'connected' + connector }) }) }