@@ -23,47 +23,67 @@ function defaults(options: SelectDefaultsOptions): WalletSelectModule {
23
23
fortmaticInit,
24
24
portisInit,
25
25
squarelinkInit,
26
- walletConnectInit
26
+ walletConnectInit,
27
+ preferredWallets
27
28
} = options
28
29
29
- const desktopModules = [ metamask ( ) , dapper ( ) , opera ( ) ]
30
- const mobileModules = [ coinbase ( ) , trust ( ) , operaTouch ( ) ]
30
+ let desktopWallets = [ metamask ( ) , dapper ( ) , opera ( ) ]
31
+ let mobileWallets = [ coinbase ( ) , trust ( ) , operaTouch ( ) ]
31
32
32
33
if ( portisInit ) {
33
- desktopModules . push ( portis ( { ...portisInit , networkId } ) )
34
- mobileModules . push ( portis ( { ...portisInit , networkId } ) )
34
+ desktopWallets . push ( portis ( { ...portisInit , networkId } ) )
35
+ mobileWallets . push ( portis ( { ...portisInit , networkId } ) )
35
36
}
36
37
37
38
if ( fortmaticInit ) {
38
- desktopModules . push ( fortmatic ( { ...fortmaticInit , networkId } ) )
39
- mobileModules . push ( fortmatic ( { ...fortmaticInit , networkId } ) )
39
+ desktopWallets . push ( fortmatic ( { ...fortmaticInit , networkId } ) )
40
+ mobileWallets . push ( fortmatic ( { ...fortmaticInit , networkId } ) )
40
41
}
41
42
42
43
if ( walletConnectInit ) {
43
- desktopModules . push (
44
+ desktopWallets . push (
44
45
walletConnect ( { infuraKey : walletConnectInit . infuraKey } )
45
46
)
46
- mobileModules . push (
47
+ mobileWallets . push (
47
48
walletConnect ( { infuraKey : walletConnectInit . infuraKey } )
48
49
)
49
50
}
50
51
51
52
if ( squarelinkInit ) {
52
- desktopModules . push ( squarelink ( { ...squarelinkInit , networkId } ) )
53
- mobileModules . push ( squarelink ( { ...squarelinkInit , networkId } ) )
53
+ desktopWallets . push ( squarelink ( { ...squarelinkInit , networkId } ) )
54
+ mobileWallets . push ( squarelink ( { ...squarelinkInit , networkId } ) )
54
55
}
55
56
56
- desktopModules . push ( authereum ( { networkId } ) )
57
- mobileModules . push ( authereum ( { networkId } ) )
57
+ desktopWallets . push ( authereum ( { networkId } ) )
58
+ mobileWallets . push ( authereum ( { networkId } ) )
59
+
60
+ //set preferred wallets if provided
61
+ if ( preferredWallets ) {
62
+ desktopWallets = desktopWallets . map ( wallet => {
63
+ if ( preferredWallets . includes ( wallet . name ) ) {
64
+ wallet . preferred = true
65
+ }
66
+
67
+ return wallet
68
+ } )
69
+
70
+ mobileWallets = mobileWallets . map ( wallet => {
71
+ if ( preferredWallets . includes ( wallet . name ) ) {
72
+ wallet . preferred = true
73
+ }
74
+
75
+ return wallet
76
+ } )
77
+ }
58
78
59
79
return {
60
80
heading : heading || "Select a Wallet" ,
61
81
description :
62
82
description ||
63
83
"Please select the wallet that you would like to use with this dapp:" ,
64
84
wallets : {
65
- mobile : mobileModules ,
66
- desktop : desktopModules
85
+ mobile : mobileWallets ,
86
+ desktop : desktopWallets
67
87
}
68
88
}
69
89
}
0 commit comments