File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
src/modules/select/wallets Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
- import { WalletConnectOptions , WalletModule } from '../../../interfaces'
1
+ import {
2
+ WalletConnectOptions ,
3
+ WalletModule ,
4
+ Helpers
5
+ } from '../../../interfaces'
2
6
3
7
import walletConnectIcon from '../wallet-icons/icon-wallet-connect'
4
8
@@ -9,7 +13,9 @@ function walletConnect(options: WalletConnectOptions): WalletModule {
9
13
name : label || 'WalletConnect' ,
10
14
svg : svg || walletConnectIcon ,
11
15
iconSrc,
12
- wallet : async ( ) => {
16
+ wallet : async ( helpers : Helpers ) => {
17
+ const { resetWalletState } = helpers
18
+
13
19
const { default : WalletConnectProvider } = await import (
14
20
'@walletconnect/web3-provider'
15
21
)
@@ -20,6 +26,10 @@ function walletConnect(options: WalletConnectOptions): WalletModule {
20
26
21
27
provider . autoRefreshOnNetworkChange = false
22
28
29
+ provider . wc . on ( 'disconnect' , ( ) => {
30
+ resetWalletState ( true )
31
+ } )
32
+
23
33
return {
24
34
provider,
25
35
interface : {
@@ -40,7 +50,7 @@ function walletConnect(options: WalletConnectOptions): WalletModule {
40
50
onChange : func => {
41
51
provider
42
52
. send ( 'eth_accounts' )
43
- . then ( ( accounts : string [ ] ) => func ( accounts [ 0 ] ) )
53
+ . then ( ( accounts : string [ ] ) => accounts [ 0 ] && func ( accounts [ 0 ] ) )
44
54
provider . on ( 'accountsChanged' , ( accounts : string [ ] ) =>
45
55
func ( accounts [ 0 ] )
46
56
)
@@ -65,7 +75,8 @@ function walletConnect(options: WalletConnectOptions): WalletModule {
65
75
'latest'
66
76
] )
67
77
} )
68
- }
78
+ } ,
79
+ disconnect : ( ) => provider . close ( )
69
80
}
70
81
}
71
82
} ,
You can’t perform that action at this time.
0 commit comments