Skip to content

Commit 7ec89b1

Browse files
committed
Allow for custom path and reset
1 parent c12aea8 commit 7ec89b1

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/modules/check/accounts.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import {
33
StateAndHelpers,
44
WalletCheckModal
55
} from '../../interfaces'
6+
import { usbIcon } from './icons'
67

78
type AccountsAndBalances = Array<{ balance: string; address: string }>
89

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
1016
let completed: boolean = false
1117
let loadingAccounts: boolean = false
1218
let accountsAndBalances: AccountsAndBalances = []
1319

14-
return async (
20+
async function checkModule(
1521
stateAndHelpers: StateAndHelpers
16-
): Promise<WalletCheckModal | undefined> => {
22+
): Promise<WalletCheckModal | undefined> {
1723
const { wallet, BigNumber } = stateAndHelpers
1824
const { provider, type } = wallet
1925

20-
if (type === 'hardware' && !completed) {
26+
if (type === 'hardware' && !completed && !provider.isCustomPath()) {
2127
if (accountsAndBalances.length === 0) {
2228
loadingAccounts = true
2329
const accounts = await provider.getAccounts()
@@ -46,8 +52,10 @@ function accountSelect(): WalletCheckModule {
4652
;(window as any).loadMoreAccounts = loadMoreAccounts
4753

4854
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:`,
5159
eventCode: 'accountSelect',
5260
html: loadingAccounts
5361
? `<div class="bn-onboard-custom bn-onboard-loading">
@@ -76,12 +84,18 @@ function accountSelect(): WalletCheckModule {
7684
},
7785
text: 'Done'
7886
},
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
8288
}
8389
}
8490
}
91+
92+
checkModule.reset = () => {
93+
completed = false
94+
accountsAndBalances = []
95+
loadingAccounts = false
96+
}
97+
98+
return checkModule
8599
}
86100

87101
export default accountSelect

0 commit comments

Comments
 (0)