Skip to content

Commit

Permalink
refactor: updated walletconnect connector (#3277)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignaciosantise authored Dec 7, 2023
1 parent c9f5a39 commit 0777d0b
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions packages/connectors/src/walletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import {
normalizeChainId,
} from '@wagmi/core'
import type { Evaluate, ExactPartial, Omit } from '@wagmi/core/internal'
import {
EthereumProvider,
OPTIONAL_EVENTS,
OPTIONAL_METHODS,
} from '@walletconnect/ethereum-provider'
import { EthereumProvider } from '@walletconnect/ethereum-provider'
import {
type Address,
type ProviderConnectInfo,
Expand Down Expand Up @@ -137,8 +133,7 @@ export function walletConnect(parameters: WalletConnectParameters) {
.filter((chain) => chain.id !== targetChainId)
.map((optionalChain) => optionalChain.id)
await provider.connect({
chains: [targetChainId],
optionalChains,
optionalChains: [targetChainId, ...optionalChains],
...('pairingTopic' in rest
? { pairingTopic: rest.pairingTopic }
: {}),
Expand Down Expand Up @@ -198,14 +193,11 @@ export function walletConnect(parameters: WalletConnectParameters) {
},
async getProvider({ chainId } = {}) {
async function initProvider() {
const [defaultChain, ...optionalChains] = config.chains.map((x) => x.id)
if (!defaultChain) return
const optionalChains = config.chains.map((x) => x.id) as [number]
if (!optionalChains.length) return
return await EthereumProvider.init({
...parameters,
chains: [defaultChain],
disableProviderPing: true,
optionalMethods: OPTIONAL_METHODS,
optionalEvents: OPTIONAL_EVENTS,
optionalChains,
projectId: parameters.projectId,
rpcMap: Object.fromEntries(
Expand Down

0 comments on commit 0777d0b

Please sign in to comment.