Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
JFrankfurt committed Aug 4, 2023
1 parent 0977b59 commit abbd9fc
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/walletconnect-v2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,6 @@ export class WalletConnect extends Connector {
this.optionalChains = optionalChains
}

private handleProviderEvents(provider: WalletConnectProvider): WalletConnectProvider {
return provider
.on('disconnect', this.disconnectListener)
.on('chainChanged', this.chainChangedListener)
.on('accountsChanged', this.accountsChangedListener)
.on('display_uri', this.URIListener)
}

private disconnectListener = (error: ProviderRpcError) => {
this.actions.resetState()
if (error) this.onError?.(error)
Expand All @@ -117,13 +109,18 @@ export class WalletConnect extends Connector {
const rpcMap = this.rpcMap ? getBestUrlMap(this.rpcMap, this.timeout) : undefined
const chainProps = this.getChainProps(this.chains, this.optionalChains, desiredChainId)

this.provider = (await import('@walletconnect/ethereum-provider')).default.init({
const ethProviderModule = await import('@walletconnect/ethereum-provider')
this.provider = await ethProviderModule.default.init({
...this.options,
...chainProps,
rpcMap: await rpcMap,
})

return this.handleProviderEvents(this.provider)
return this.provider
.on('disconnect', this.disconnectListener)
.on('chainChanged', this.chainChangedListener)
.on('accountsChanged', this.accountsChangedListener)
.on('display_uri', this.URIListener)
}

private getChainProps(
Expand Down

0 comments on commit abbd9fc

Please sign in to comment.