Skip to content

Commit 303822d

Browse files
Feat: HW wallet parameter to set zero balance threshold (#1715)
* Updated hw-common * Working as expected and version bumped * Update packages/demo/src/App.svelte * Merge in develop and bump package versions in demo * Update packages/hw-common/src/validation.ts Co-authored-by: Aaron <abarnard@protonmail.com> --------- Co-authored-by: Aaron <abarnard@protonmail.com>
1 parent 7ce4363 commit 303822d

File tree

16 files changed

+89
-31
lines changed

16 files changed

+89
-31
lines changed

packages/dcent/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/dcent",
3-
"version": "2.2.6",
3+
"version": "2.2.7-alpha.1",
44
"description": "D'CENT wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
55
"keywords": [
66
"Ethereum",
@@ -57,7 +57,7 @@
5757
},
5858
"dependencies": {
5959
"@web3-onboard/common": "^2.3.2",
60-
"@web3-onboard/hw-common": "^2.2.2",
60+
"@web3-onboard/hw-common": "^2.3.0-alpha.1",
6161
"@ethereumjs/tx": "^3.4.0",
6262
"@ethersproject/providers": "^5.5.0",
6363
"eth-dcent-keyring": "^0.2.2"

packages/dcent/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import type {
55
Platform
66
} from '@web3-onboard/common'
77

8-
import type { providers } from 'ethers'
9-
108
import type {
119
CustomNetwork,
1210
Account,

packages/demo/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@
2727
"@web3-onboard/core": "^2.18.1-alpha.2",
2828
"@web3-onboard/coinbase": "^2.2.3",
2929
"@web3-onboard/transaction-preview": "^2.0.7",
30-
"@web3-onboard/dcent": "^2.2.6",
30+
"@web3-onboard/dcent": "^2.2.7-alpha.1",
3131
"@web3-onboard/frontier": "^2.0.3",
3232
"@web3-onboard/fortmatic": "^2.0.18",
3333
"@web3-onboard/frame": "2.0.0",
3434
"@web3-onboard/gas": "^2.1.7",
3535
"@web3-onboard/gnosis": "^2.1.9",
36-
"@web3-onboard/keepkey": "^2.3.6",
37-
"@web3-onboard/keystone": "^2.3.6",
36+
"@web3-onboard/keepkey": "^2.3.7-alpha.1",
37+
"@web3-onboard/keystone": "^2.3.7-alpha.1",
3838
"@web3-onboard/ledger": "^2.4.5",
3939
"@web3-onboard/infinity-wallet": "^2.0.3",
4040
"@web3-onboard/injected-wallets": "^2.8.5",
4141
"@web3-onboard/magic": "^2.1.6",
4242
"@web3-onboard/phantom": "^2.0.1",
4343
"@web3-onboard/portis": "^2.1.6",
4444
"@web3-onboard/sequence": "^2.0.7",
45-
"@web3-onboard/trezor": "^2.4.1",
45+
"@web3-onboard/trezor": "^2.4.2-alpha.1",
4646
"@web3-onboard/trust": "^2.0.3",
4747
"@web3-onboard/torus": "^2.2.4",
4848
"@web3-onboard/taho": "^2.0.3",

packages/demo/src/App.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@
150150
151151
const trezorOptions = {
152152
email: 'test@test.com',
153-
appUrl: 'https://www.blocknative.com'
153+
appUrl: 'https://www.blocknative.com',
154+
consecutiveEmptyAccountThreshold: 10
154155
// containerElement: '#sample-container-el'
155156
}
156157
const trezor = trezorModule(trezorOptions)

packages/hw-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/hw-common",
3-
"version": "2.2.2",
3+
"version": "2.3.0-alpha.1",
44
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
55
"keywords": [
66
"Ethereum",

packages/hw-common/src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export type SelectAccountOptions = {
4444
scanAccounts: ScanAccounts
4545
supportsCustomPath?: boolean
4646
containerElement?: string
47+
/**
48+
* A number that defines the amount of consecutive empty addresses displayed
49+
* within the Account Select modal. Default is 5
50+
*/
51+
consecutiveEmptyAccountThreshold?: number
4752
}
4853

4954
export type BasePath = {

packages/hw-common/src/validation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const selectAccountOptions = Joi.object({
2929
chains: chains,
3030
scanAccounts: Joi.function().arity(1).required(),
3131
supportsCustomPath: Joi.bool(),
32+
consecutiveEmptyAccountThreshold: Joi.number(),
3233
containerElement: Joi.string()
3334
})
3435

packages/keepkey/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,23 @@ console.log(connectedWallets)
4949
```
5050

5151
Initialization options:
52+
5253
```typescript
5354
type keepkeyInitOptions = {
5455
containerElement?: string
5556
filter?: Platform
57+
/**
58+
* A number that defines the amount of consecutive empty addresses displayed
59+
* within the Account Select modal. Default is 5
60+
*/
61+
consecutiveEmptyAccountThreshold?: number
5662
}
5763
```
5864
5965
The following is a list of the platforms that can be filtered:
6066
6167
```typescript
62-
type Platform = DeviceOSName | DeviceBrowserName | DeviceType | 'all';
68+
type Platform = DeviceOSName | DeviceBrowserName | DeviceType | 'all'
6369

6470
type Platform =
6571
| 'Windows Phone'

packages/keepkey/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/keepkey",
3-
"version": "2.3.6",
3+
"version": "2.3.7-alpha.1",
44
"description": "KeepKey hardware wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
55
"keywords": [
66
"Ethereum",
@@ -64,7 +64,7 @@
6464
"@shapeshiftoss/hdwallet-core": "^1.15.2",
6565
"@shapeshiftoss/hdwallet-keepkey-webusb": "^1.15.2",
6666
"@web3-onboard/common": "^2.3.2",
67-
"@web3-onboard/hw-common": "^2.2.2",
67+
"@web3-onboard/hw-common": "^2.3.0-alpha.1",
6868
"ethereumjs-util": "^7.1.3"
6969
}
7070
}

packages/keepkey/src/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,17 @@ type ErrorCode = 'busy' | 'pairing'
3838

3939
function keepkey({
4040
filter,
41-
containerElement
42-
}: { filter?: Platform[]; containerElement?: string } = {}): WalletInit {
41+
containerElement,
42+
consecutiveEmptyAccountThreshold
43+
}: {
44+
filter?: Platform[]
45+
containerElement?: string
46+
/**
47+
* A number that defines the amount of consecutive empty addresses displayed
48+
* within the Account Select modal. Default is 5
49+
*/
50+
consecutiveEmptyAccountThreshold?: number
51+
} = {}): WalletInit {
4352
const getIcon = async () => (await import('./icon.js')).default
4453

4554
return ({ device }) => {
@@ -88,6 +97,7 @@ function keepkey({
8897
const keyring = new Keyring()
8998
const keepKeyAdapter = WebUSBKeepKeyAdapter.useKeyring(keyring)
9099
const eventEmitter = new EventEmitter()
100+
const consecutiveEmptyAccounts = consecutiveEmptyAccountThreshold || 5
91101

92102
let keepKeyWallet: KeepKeyHDWallet
93103
let currentChain: Chain = chains[0]
@@ -184,7 +194,7 @@ function keepkey({
184194

185195
// Iterates until a 0 balance account is found
186196
// Then adds 4 more 0 balance accounts to the array
187-
while (zeroBalanceAccounts < 5) {
197+
while (zeroBalanceAccounts < consecutiveEmptyAccounts) {
188198
const acc = await getAccount({
189199
accountIdx: index,
190200
provider,

0 commit comments

Comments
 (0)