Skip to content

Commit 3de3593

Browse files
Fixes walletconnect import issues for some build tools (#1057)
* Fixes walletconnect import issues for some build tools * version bump
1 parent faee8bd commit 3de3593

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

packages/walletconnect/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/walletconnect",
3-
"version": "2.0.1",
3+
"version": "2.0.2-alpha.1",
44
"description": "WalletConnect module for web3-onboard",
55
"module": "dist/index.js",
66
"browser": "dist/index.js",

packages/walletconnect/src/index.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { StaticJsonRpcProvider } from '@ethersproject/providers'
1+
import type { StaticJsonRpcProvider as StaticJsonRpcProviderType } from '@ethersproject/providers'
22

3-
import {
3+
import type {
44
Chain,
55
ProviderAccounts,
66
WalletInit,
7-
EIP1193Provider,
8-
ProviderRpcError,
9-
ProviderRpcErrorCode
7+
EIP1193Provider
108
} from '@web3-onboard/common'
119

1210
interface WalletConnectOptions {
@@ -25,12 +23,26 @@ function walletConnect(options?: WalletConnectOptions): WalletInit {
2523
label: 'WalletConnect',
2624
getIcon: async () => (await import('./icon.js')).default,
2725
getInterface: async ({ chains, EventEmitter }) => {
28-
const { default: WalletConnect } = await import('@walletconnect/client')
26+
const { StaticJsonRpcProvider } = await import(
27+
'@ethersproject/providers'
28+
)
2929

30-
const { default: QRCodeModal } = await import(
31-
'@walletconnect/qrcode-modal'
30+
const { ProviderRpcError, ProviderRpcErrorCode } = await import(
31+
'@web3-onboard/common'
3232
)
3333

34+
const { default: WalletConnect } = await import('@walletconnect/client')
35+
36+
// This is a cjs module and therefor depending on build tooling
37+
// sometimes it will be nested in the { default } object and
38+
// other times it will be the actual import
39+
// @ts-ignore - It thinks it is missing properties since it expect it to be nested under default
40+
let QRCodeModal: typeof import('@walletconnect/qrcode-modal').default =
41+
await import('@walletconnect/qrcode-modal')
42+
43+
// @ts-ignore - TS thinks that there is no default property on the `QRCodeModal` but sometimes there is
44+
QRCodeModal = QRCodeModal.default || QRCodeModal
45+
3446
const { Subject, fromEvent } = await import('rxjs')
3547
const { takeUntil, take } = await import('rxjs/operators')
3648

@@ -50,7 +62,7 @@ function walletConnect(options?: WalletConnectOptions): WalletInit {
5062
public removeListener: typeof EventEmitter['removeListener']
5163

5264
private disconnected$: InstanceType<typeof Subject>
53-
private providers: Record<string, StaticJsonRpcProvider>
65+
private providers: Record<string, StaticJsonRpcProviderType>
5466

5567
constructor({
5668
connector,

0 commit comments

Comments
 (0)