File tree Expand file tree Collapse file tree 6 files changed +36
-51
lines changed Expand file tree Collapse file tree 6 files changed +36
-51
lines changed Original file line number Diff line number Diff line change @@ -24,32 +24,33 @@ function authereum(options: {
24
24
iconSrc : authereumIcon ,
25
25
wallet : async ( ) => {
26
26
const { default : Authereum } = await import ( 'authereum' )
27
- const authereum = new Authereum ( {
27
+ const instance = new Authereum ( {
28
28
networkName : networkName ( networkId ) ,
29
29
disableNotifications : true
30
30
} )
31
31
32
- const provider = authereum . getProvider ( )
32
+ const provider = instance . getProvider ( )
33
33
34
34
return {
35
35
provider,
36
+ instance,
36
37
interface : {
37
38
name : 'Authereum' ,
38
39
connect : ( ) => provider . enable ( ) ,
39
- disconnect : ( ) => authereum . logout ( ) ,
40
+ disconnect : ( ) => instance . logout ( ) ,
40
41
loading : new Promise ( ( resolve : ( ) => void ) => {
41
- authereum . on ( 'openPopup' , resolve )
42
+ instance . on ( 'openPopup' , resolve )
42
43
} ) ,
43
44
address : {
44
- get : ( ) => authereum . getAccountAddress ( )
45
+ get : ( ) => instance . getAccountAddress ( )
45
46
} ,
46
47
network : {
47
48
get : ( ) => Promise . resolve ( networkId )
48
49
} ,
49
50
balance : {
50
51
get : async ( ) => {
51
- const loggedIn = await authereum . isAuthenticated ( )
52
- return loggedIn && authereum . getBalance ( )
52
+ const loggedIn = await instance . isAuthenticated ( )
53
+ return loggedIn && instance . getBalance ( )
53
54
}
54
55
}
55
56
}
Original file line number Diff line number Diff line change @@ -30,22 +30,17 @@ function fortmatic(options: SdkWalletOptions): WalletModule {
30
30
optional : true
31
31
} )
32
32
33
- let instance : any
34
- let provider : any
35
-
36
33
return {
37
34
name : 'Fortmatic' ,
38
35
svg : fortmaticIcon ,
39
36
wallet : async ( helpers : Helpers ) => {
40
- if ( ! instance ) {
41
- const { default : Fortmatic } = await import ( 'fortmatic' )
37
+ const { default : Fortmatic } = await import ( 'fortmatic' )
42
38
43
- instance = new Fortmatic (
44
- apiKey ,
45
- networkId === 1 ? undefined : networkName ( networkId )
46
- )
47
- provider = instance . getProvider ( )
48
- }
39
+ const instance = new Fortmatic (
40
+ apiKey ,
41
+ networkId === 1 ? undefined : networkName ( networkId )
42
+ )
43
+ const provider = instance . getProvider ( )
49
44
50
45
const { BigNumber } = helpers
51
46
Original file line number Diff line number Diff line change @@ -20,18 +20,13 @@ function portis(options: SdkWalletOptions): WalletModule {
20
20
optional : true
21
21
} )
22
22
23
- let instance : any
24
- let provider : any
25
-
26
23
return {
27
24
name : 'Portis' ,
28
25
svg : portisIcon ,
29
26
wallet : async ( helpers : Helpers ) => {
30
- if ( ! instance ) {
31
- const { default : Portis } = await import ( '@portis/web3' )
32
- instance = new Portis ( apiKey , networkName ( networkId ) )
33
- provider = instance . provider
34
- }
27
+ const { default : Portis } = await import ( '@portis/web3' )
28
+ const instance = new Portis ( apiKey , networkName ( networkId ) )
29
+ const provider = instance . provider
35
30
36
31
const { BigNumber } = helpers
37
32
Original file line number Diff line number Diff line change @@ -29,22 +29,17 @@ function squarelink(options: SdkWalletOptions): WalletModule {
29
29
optional : true
30
30
} )
31
31
32
- let instance : any
33
- let provider : any
34
-
35
32
return {
36
33
name : 'Squarelink' ,
37
34
svg : sqlkIcon ,
38
35
wallet : async ( helpers : Helpers ) => {
39
- if ( ! instance ) {
40
- const { default : Squarelink } = await import ( 'squarelink' )
36
+ const { default : Squarelink } = await import ( 'squarelink' )
41
37
42
- instance = new Squarelink ( apiKey , networkName ( networkId ) , {
43
- useSync : true
44
- } )
38
+ const instance = new Squarelink ( apiKey , networkName ( networkId ) , {
39
+ useSync : true
40
+ } )
45
41
46
- provider = instance . getProviderSync ( )
47
- }
42
+ const provider = instance . getProviderSync ( )
48
43
49
44
const { BigNumber } = helpers
50
45
Original file line number Diff line number Diff line change @@ -30,23 +30,19 @@ function walletConnect(options: WalletConnectOptions): WalletModule {
30
30
optional : true
31
31
} )
32
32
33
- let provider : any
34
-
35
33
return {
36
34
name : 'WalletConnect' ,
37
35
svg : walletConnectIcon ,
38
36
wallet : async ( ) => {
39
- if ( ! provider ) {
40
- const { default : WalletConnectProvider } = await import (
41
- '@walletconnect/web3-provider'
42
- )
37
+ const { default : WalletConnectProvider } = await import (
38
+ '@walletconnect/web3-provider'
39
+ )
43
40
44
- provider = new WalletConnectProvider ( {
45
- infuraId : infuraKey
46
- } )
41
+ const provider = new WalletConnectProvider ( {
42
+ infuraId : infuraKey
43
+ } )
47
44
48
- provider . autoRefreshOnNetworkChange = false
49
- }
45
+ provider . autoRefreshOnNetworkChange = false
50
46
51
47
return {
52
48
provider,
@@ -64,10 +60,6 @@ function walletConnect(options: WalletConnectOptions): WalletModule {
64
60
} )
65
61
)
66
62
} ) ,
67
- disconnect : ( ) => {
68
- provider . close ( )
69
- provider = undefined
70
- } ,
71
63
address : {
72
64
onChange : func => {
73
65
provider
Original file line number Diff line number Diff line change 105
105
}
106
106
107
107
async function handleWalletSelect(module : WalletModule ) {
108
+ const currentWalletInterface = get (walletInterface )
109
+
110
+ if (currentWalletInterface && currentWalletInterface .name === module .name ) {
111
+ finish ({ completed: true })
112
+ return
113
+ }
114
+
108
115
loadingWallet = module .name
109
116
110
117
const {
You can’t perform that action at this time.
0 commit comments