export async function _accounts (type: WalletType, accounts: Map<number, Account>, vault: Vault, index: number): Promise<Account>
export async function _accounts (type: WalletType, accounts: Map<number, Account>, vault: Vault, from: number, to: number): Promise<Map<number, Account>>
-export async function _accounts (type: WalletType, accounts: Map<number, Account>, vault: Vault, from: unknown, to: unknown = from): Promise<Account | Map<number, Account>> {
+export async function _accounts (type: WalletType, accounts: Map<number, Account>, vault: Vault, from: unknown, to?: unknown): Promise<Account | Map<number, Account>> {
+ const isSingle = to === undefined
+ to ??= from
if (typeof from !== 'number' || typeof to !== 'number') {
throw new TypeError('Invalid account range', { cause: `${from}-${to}` })
}
accounts.set(a.index, a)
}
}
- if (from === to) {
+ if (isSingle) {
const account = output.get(from)
if (account === undefined) {
throw new Error(`Failed to get account at index ${from}`)