Skip to content
4 changes: 2 additions & 2 deletions packages/dcent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/dcent",
"version": "2.2.6",
"version": "2.2.7-alpha.1",
"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.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -57,7 +57,7 @@
},
"dependencies": {
"@web3-onboard/common": "^2.3.2",
"@web3-onboard/hw-common": "^2.2.2",
"@web3-onboard/hw-common": "^2.3.0-alpha.1",
"@ethereumjs/tx": "^3.4.0",
"@ethersproject/providers": "^5.5.0",
"eth-dcent-keyring": "^0.2.2"
Expand Down
2 changes: 0 additions & 2 deletions packages/dcent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import type {
Platform
} from '@web3-onboard/common'

import type { providers } from 'ethers'

import type {
CustomNetwork,
Account,
Expand Down
8 changes: 4 additions & 4 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@
"@web3-onboard/core": "^2.18.1-alpha.2",
"@web3-onboard/coinbase": "^2.2.3",
"@web3-onboard/transaction-preview": "^2.0.7",
"@web3-onboard/dcent": "^2.2.6",
"@web3-onboard/dcent": "^2.2.7-alpha.1",
"@web3-onboard/frontier": "^2.0.3",
"@web3-onboard/fortmatic": "^2.0.18",
"@web3-onboard/frame": "2.0.0",
"@web3-onboard/gas": "^2.1.7",
"@web3-onboard/gnosis": "^2.1.9",
"@web3-onboard/keepkey": "^2.3.6",
"@web3-onboard/keystone": "^2.3.6",
"@web3-onboard/keepkey": "^2.3.7-alpha.1",
"@web3-onboard/keystone": "^2.3.7-alpha.1",
"@web3-onboard/ledger": "^2.4.5",
"@web3-onboard/infinity-wallet": "^2.0.3",
"@web3-onboard/injected-wallets": "^2.8.5",
"@web3-onboard/magic": "^2.1.6",
"@web3-onboard/phantom": "^2.0.1",
"@web3-onboard/portis": "^2.1.6",
"@web3-onboard/sequence": "^2.0.7",
"@web3-onboard/trezor": "^2.4.1",
"@web3-onboard/trezor": "^2.4.2-alpha.1",
"@web3-onboard/trust": "^2.0.3",
"@web3-onboard/torus": "^2.2.4",
"@web3-onboard/taho": "^2.0.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@

const trezorOptions = {
email: 'test@test.com',
appUrl: 'https://www.blocknative.com'
appUrl: 'https://www.blocknative.com',
consecutiveEmptyAccountThreshold: 10
// containerElement: '#sample-container-el'
}
const trezor = trezorModule(trezorOptions)
Expand Down
2 changes: 1 addition & 1 deletion packages/hw-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/hw-common",
"version": "2.2.2",
"version": "2.3.0-alpha.1",
"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.",
"keywords": [
"Ethereum",
Expand Down
5 changes: 5 additions & 0 deletions packages/hw-common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export type SelectAccountOptions = {
scanAccounts: ScanAccounts
supportsCustomPath?: boolean
containerElement?: string
/**
* A number that defines the amount of consecutive empty addresses displayed
* within the Account Select modal. Default is 5
*/
consecutiveEmptyAccountThreshold?: number
}

export type BasePath = {
Expand Down
1 change: 1 addition & 0 deletions packages/hw-common/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const selectAccountOptions = Joi.object({
chains: chains,
scanAccounts: Joi.function().arity(1).required(),
supportsCustomPath: Joi.bool(),
consecutiveEmptyAccountThreshold: Joi.number(),
containerElement: Joi.string()
})

Expand Down
8 changes: 7 additions & 1 deletion packages/keepkey/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,23 @@ console.log(connectedWallets)
```

Initialization options:

```typescript
type keepkeyInitOptions = {
containerElement?: string
filter?: Platform
/**
* A number that defines the amount of consecutive empty addresses displayed
* within the Account Select modal. Default is 5
*/
consecutiveEmptyAccountThreshold?: number
}
```

The following is a list of the platforms that can be filtered:

```typescript
type Platform = DeviceOSName | DeviceBrowserName | DeviceType | 'all';
type Platform = DeviceOSName | DeviceBrowserName | DeviceType | 'all'

type Platform =
| 'Windows Phone'
Expand Down
4 changes: 2 additions & 2 deletions packages/keepkey/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/keepkey",
"version": "2.3.6",
"version": "2.3.7-alpha.1",
"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.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -64,7 +64,7 @@
"@shapeshiftoss/hdwallet-core": "^1.15.2",
"@shapeshiftoss/hdwallet-keepkey-webusb": "^1.15.2",
"@web3-onboard/common": "^2.3.2",
"@web3-onboard/hw-common": "^2.2.2",
"@web3-onboard/hw-common": "^2.3.0-alpha.1",
"ethereumjs-util": "^7.1.3"
}
}
16 changes: 13 additions & 3 deletions packages/keepkey/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ type ErrorCode = 'busy' | 'pairing'

function keepkey({
filter,
containerElement
}: { filter?: Platform[]; containerElement?: string } = {}): WalletInit {
containerElement,
consecutiveEmptyAccountThreshold
}: {
filter?: Platform[]
containerElement?: string
/**
* A number that defines the amount of consecutive empty addresses displayed
* within the Account Select modal. Default is 5
*/
consecutiveEmptyAccountThreshold?: number
} = {}): WalletInit {
const getIcon = async () => (await import('./icon.js')).default

return ({ device }) => {
Expand Down Expand Up @@ -88,6 +97,7 @@ function keepkey({
const keyring = new Keyring()
const keepKeyAdapter = WebUSBKeepKeyAdapter.useKeyring(keyring)
const eventEmitter = new EventEmitter()
const consecutiveEmptyAccounts = consecutiveEmptyAccountThreshold || 5

let keepKeyWallet: KeepKeyHDWallet
let currentChain: Chain = chains[0]
Expand Down Expand Up @@ -184,7 +194,7 @@ function keepkey({

// Iterates until a 0 balance account is found
// Then adds 4 more 0 balance accounts to the array
while (zeroBalanceAccounts < 5) {
while (zeroBalanceAccounts < consecutiveEmptyAccounts) {
const acc = await getAccount({
accountIdx: index,
provider,
Expand Down
5 changes: 5 additions & 0 deletions packages/keystone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ type KeystoneOptions = {
customNetwork?: CustomNetwork
filter?: Platform[]
containerElement?: string
/**
* A number that defines the amount of consecutive empty addresses displayed
* within the Account Select modal. Default is 5
*/
consecutiveEmptyAccountThreshold?: number
}

interface CustomNetwork {
Expand Down
4 changes: 2 additions & 2 deletions packages/keystone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/keystone",
"version": "2.3.6",
"version": "2.3.7-alpha.1",
"description": "Keystone 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.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -59,6 +59,6 @@
"@ethersproject/providers": "^5.5.0",
"@keystonehq/eth-keyring": "^0.14.00.3",
"@web3-onboard/common": "^2.3.2",
"@web3-onboard/hw-common": "^2.2.0"
"@web3-onboard/hw-common": "^2.3.0-alpha.1"
}
}
20 changes: 16 additions & 4 deletions packages/keystone/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ const getAccount = async (

const generateAccounts = async (
keyring: any,
provider: StaticJsonRpcProvider
provider: StaticJsonRpcProvider,
consecutiveEmptyAccounts: number
): Promise<Account[]> => {
const accounts = []
let zeroBalanceAccounts = 0,
index = 0

while (zeroBalanceAccounts < 5) {
while (zeroBalanceAccounts < consecutiveEmptyAccounts) {
const account = await getAccount(keyring, provider, index)
if (account.balance.value.isZero()) {
zeroBalanceAccounts++
Expand All @@ -66,11 +67,17 @@ const generateAccounts = async (
function keystone({
customNetwork,
filter,
containerElement
containerElement,
consecutiveEmptyAccountThreshold
}: {
customNetwork?: CustomNetwork
filter?: Platform[]
containerElement?: string
/**
* A number that defines the amount of consecutive empty addresses displayed
* within the Account Select modal. Default is 5
*/
consecutiveEmptyAccountThreshold?: number
} = {}): WalletInit {
const getIcon = async () => (await import('./icon.js')).default

Expand Down Expand Up @@ -121,6 +128,7 @@ function keystone({
getHardwareWalletProvider
} = await import('@web3-onboard/hw-common')

const consecutiveEmptyAccounts = consecutiveEmptyAccountThreshold || 5
const keyring = AirGappedKeyring.getEmptyKeyring()
await keyring.readKeyring()

Expand All @@ -136,7 +144,11 @@ function keystone({
chains.find(({ id }: Chain) => id === chainId) || currentChain

ethersProvider = new StaticJsonRpcProvider(currentChain.rpcUrl)
return generateAccounts(keyring, ethersProvider)
return generateAccounts(
keyring,
ethersProvider,
consecutiveEmptyAccounts
)
}

const getAccounts = async () => {
Expand Down
7 changes: 6 additions & 1 deletion packages/trezor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ type TrezorOptions = {
customNetwork?: CustomNetwork
filter?: Platform[]
containerElement?: string
/**
* A number that defines the amount of consecutive empty addresses displayed
* within the Account Select modal. Default is 5
*/
consecutiveEmptyAccountThreshold?: number
}

interface CustomNetwork {
Expand Down Expand Up @@ -49,7 +54,7 @@ interface BootstrapNode {
comment: string
}

type Platform = DeviceOSName | DeviceBrowserName | DeviceType | 'all';
type Platform = DeviceOSName | DeviceBrowserName | DeviceType | 'all'
```

### Usage
Expand Down
4 changes: 2 additions & 2 deletions packages/trezor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/trezor",
"version": "2.4.1",
"version": "2.4.2-alpha.2",
"description": "Trezor 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.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -61,7 +61,7 @@
"@ethereumjs/tx": "^3.4.0",
"@ethersproject/providers": "^5.5.0",
"@web3-onboard/common": "^2.3.2",
"@web3-onboard/hw-common": "^2.2.2",
"@web3-onboard/hw-common": "^2.3.0-alpha.1",
"buffer": "^6.0.3",
"eth-crypto": "^2.1.0",
"ethereumjs-util": "^7.1.3",
Expand Down
27 changes: 21 additions & 6 deletions packages/trezor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ interface TrezorOptions {
customNetwork?: CustomNetwork
filter?: Platform[]
containerElement?: string
/**
* A number that defines the amount of consecutive empty addresses displayed
* within the Account Select modal. Default is 5
*/
consecutiveEmptyAccountThreshold?: number
}

const TREZOR_DEFAULT_PATH = "m/44'/60'/0'/0"
Expand Down Expand Up @@ -85,15 +90,17 @@ const getAccount = async (
const getAddresses = async (
account: AccountData,
asset: Asset,
provider: StaticJsonRpcProvider
provider: StaticJsonRpcProvider,
consecutiveEmptyAccounts: number
): Promise<Account[]> => {
const accounts = []
let index = 0
let zeroBalanceAccounts = 0

// Iterates until a 0 balance account is found
// Then adds 4 more 0 balance accounts to the array
while (zeroBalanceAccounts < 5) {
// Then adds 4 (whatever consecutiveEmptyAccountThreshold is set to) more
// 0 balance accounts to the array
while (zeroBalanceAccounts < consecutiveEmptyAccounts) {
const acc = await getAccount(account, asset, index, provider)
if (
acc &&
Expand All @@ -118,14 +125,21 @@ function trezor(options: TrezorOptions): WalletInit {
const getIcon = async () => (await import('./icon.js')).default

return ({ device }) => {
const { email, appUrl, customNetwork, filter, containerElement } =
options || {}
const {
email,
appUrl,
customNetwork,
filter,
containerElement,
consecutiveEmptyAccountThreshold
} = options || {}

if (!email || !appUrl) {
throw new Error(
'Email and AppUrl required in Trezor options for Trezor Wallet Connection'
)
}
const consecutiveEmptyAccounts = consecutiveEmptyAccountThreshold || 5

const filtered =
Array.isArray(filter) &&
Expand Down Expand Up @@ -212,7 +226,8 @@ function trezor(options: TrezorOptions): WalletInit {
path: derivationPath
},
asset,
ethersProvider
ethersProvider,
consecutiveEmptyAccounts
)
}

Expand Down