@@ -3,21 +3,27 @@ import {
3
3
StateAndHelpers ,
4
4
WalletCheckModal
5
5
} from '../../interfaces'
6
+ import { usbIcon } from './icons'
6
7
7
8
type AccountsAndBalances = Array < { balance : string ; address : string } >
8
9
9
- function accountSelect ( ) : WalletCheckModule {
10
+ function accountSelect ( options : {
11
+ heading : string
12
+ description : string
13
+ icon : string
14
+ } ) : WalletCheckModule {
15
+ const { heading, description, icon } = options
10
16
let completed : boolean = false
11
17
let loadingAccounts : boolean = false
12
18
let accountsAndBalances : AccountsAndBalances = [ ]
13
19
14
- return async (
20
+ async function checkModule (
15
21
stateAndHelpers : StateAndHelpers
16
- ) : Promise < WalletCheckModal | undefined > => {
22
+ ) : Promise < WalletCheckModal | undefined > {
17
23
const { wallet, BigNumber } = stateAndHelpers
18
24
const { provider, type } = wallet
19
25
20
- if ( type === 'hardware' && ! completed ) {
26
+ if ( type === 'hardware' && ! completed && ! provider . isCustomPath ( ) ) {
21
27
if ( accountsAndBalances . length === 0 ) {
22
28
loadingAccounts = true
23
29
const accounts = await provider . getAccounts ( )
@@ -46,8 +52,10 @@ function accountSelect(): WalletCheckModule {
46
52
; ( window as any ) . loadMoreAccounts = loadMoreAccounts
47
53
48
54
return {
49
- heading : 'Select Account' ,
50
- description : `Please select which account you would like to use with this Dapp:` ,
55
+ heading : heading || 'Select Account' ,
56
+ description :
57
+ description ||
58
+ `Please select which account you would like to use with this Dapp:` ,
51
59
eventCode : 'accountSelect' ,
52
60
html : loadingAccounts
53
61
? `<div class="bn-onboard-custom bn-onboard-loading">
@@ -76,12 +84,18 @@ function accountSelect(): WalletCheckModule {
76
84
} ,
77
85
text : 'Done'
78
86
} ,
79
- icon : `
80
- <svg height="18" viewBox="0 0 18 18" width="18" xmlns="http://www.w3.org/2000/svg"><path d="m13.375 28c-1.86075 0-3.375-1.51425-3.375-3.375s1.51425-3.375 3.375-3.375 3.375 1.51425 3.375 3.375-1.51425 3.375-3.375 3.375zm0-4.5c-.619875 0-1.125.504-1.125 1.125s.505125 1.125 1.125 1.125 1.125-.504 1.125-1.125-.505125-1.125-1.125-1.125zm0-6.75c-1.86075 0-3.375-1.51425-3.375-3.375s1.51425-3.375 3.375-3.375 3.375 1.51425 3.375 3.375-1.51425 3.375-3.375 3.375zm0-4.5c-.619875 0-1.125.505125-1.125 1.125s.505125 1.125 1.125 1.125 1.125-.505125 1.125-1.125-.505125-1.125-1.125-1.125zm11.25 4.5c-1.86075 0-3.375-1.51425-3.375-3.375s1.51425-3.375 3.375-3.375 3.375 1.51425 3.375 3.375-1.51425 3.375-3.375 3.375zm0-4.5c-.621 0-1.125.505125-1.125 1.125s.504 1.125 1.125 1.125 1.125-.505125 1.125-1.125-.504-1.125-1.125-1.125zm-11.25 10.117125h-.014625c-.615375-.007875-1.110375-.50175-1.110375-1.117125 0-1.35675.898875-3.375 3.375-3.375h6.75c.50625-.0135 1.125-.219375 1.125-1.125v-1.125c0-.621.502875-1.125 1.125-1.125s1.125.504 1.125 1.125v1.125c0 2.476125-2.01825 3.375-3.375 3.375h-6.75c-.905625 0-1.1115.61875-1.125 1.1385-.01575.610875-.51525 1.103625-1.125 1.103625zm0 1.132875c-.621 0-1.125-.502875-1.125-1.125v-6.75c0-.621.504-1.125 1.125-1.125s1.125.504 1.125 1.125v6.75c0 .622125-.504 1.125-1.125 1.125z" fill="currentColor" transform="translate(-10 -10)"/></svg>
81
- `
87
+ icon : icon || usbIcon
82
88
}
83
89
}
84
90
}
91
+
92
+ checkModule . reset = ( ) => {
93
+ completed = false
94
+ accountsAndBalances = [ ]
95
+ loadingAccounts = false
96
+ }
97
+
98
+ return checkModule
85
99
}
86
100
87
101
export default accountSelect
0 commit comments