Skip to content

Commit

Permalink
fix: do not sync rpc callbacks multiple times (#2111)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Apr 3, 2024
1 parent 3d49de8 commit 1e1408b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/wagmi/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class Web3Modal extends Web3ModalScaffold {

this.syncRequestedNetworks([...wagmiConfig.chains])
this.syncConnectors([...wagmiConfig.connectors])
this.initEmailConnectorListeners([...wagmiConfig.connectors])

watchConnectors(this.wagmiConfig, {
onChange: connectors => this.syncConnectors(connectors)
Expand Down Expand Up @@ -404,8 +405,16 @@ export class Web3Modal extends Web3ModalScaffold {
name: 'Email',
provider
})
this.listenEmailConnector(emailConnector)
this.listenModal(emailConnector)
}
}

private async initEmailConnectorListeners(
connectors: Web3ModalClientOptions<CoreConfig>['wagmiConfig']['connectors']
) {
const emailConnector = connectors.find(({ id }) => id === ConstantsUtil.EMAIL_CONNECTOR_ID)
if (emailConnector) {
await this.listenEmailConnector(emailConnector)
await this.listenModal(emailConnector)
}
}

Expand Down

0 comments on commit 1e1408b

Please sign in to comment.