1
- import { StaticJsonRpcProvider } from '@ethersproject/providers'
1
+ import type { StaticJsonRpcProvider as StaticJsonRpcProviderType } from '@ethersproject/providers'
2
2
3
- import {
3
+ import type {
4
4
Chain ,
5
5
ProviderAccounts ,
6
6
WalletInit ,
7
- EIP1193Provider ,
8
- ProviderRpcError ,
9
- ProviderRpcErrorCode
7
+ EIP1193Provider
10
8
} from '@web3-onboard/common'
11
9
12
10
interface WalletConnectOptions {
@@ -25,12 +23,26 @@ function walletConnect(options?: WalletConnectOptions): WalletInit {
25
23
label : 'WalletConnect' ,
26
24
getIcon : async ( ) => ( await import ( './icon.js' ) ) . default ,
27
25
getInterface : async ( { chains, EventEmitter } ) => {
28
- const { default : WalletConnect } = await import ( '@walletconnect/client' )
26
+ const { StaticJsonRpcProvider } = await import (
27
+ '@ethersproject/providers'
28
+ )
29
29
30
- const { default : QRCodeModal } = await import (
31
- '@walletconnect/qrcode-modal '
30
+ const { ProviderRpcError , ProviderRpcErrorCode } = await import (
31
+ '@web3-onboard/common '
32
32
)
33
33
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
+
34
46
const { Subject, fromEvent } = await import ( 'rxjs' )
35
47
const { takeUntil, take } = await import ( 'rxjs/operators' )
36
48
@@ -50,7 +62,7 @@ function walletConnect(options?: WalletConnectOptions): WalletInit {
50
62
public removeListener : typeof EventEmitter [ 'removeListener' ]
51
63
52
64
private disconnected$ : InstanceType < typeof Subject >
53
- private providers : Record < string , StaticJsonRpcProvider >
65
+ private providers : Record < string , StaticJsonRpcProviderType >
54
66
55
67
constructor ( {
56
68
connector,
0 commit comments