From e99761a3f3f3c59009c6442d5e1ba9cd83365193 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 11 Aug 2025 06:02:32 -0700 Subject: [PATCH] Simplify account range swap. --- src/lib/wallet/ledger.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/lib/wallet/ledger.ts b/src/lib/wallet/ledger.ts index 5bfd3c6..5a60858 100644 --- a/src/lib/wallet/ledger.ts +++ b/src/lib/wallet/ledger.ts @@ -150,16 +150,13 @@ export class Ledger extends Wallet { * // { privateKey: <...>, index: 1 } * ``` * + * If `from` is greater than `to`, their values will be swapped. * @param {number} from - Start index of secret keys. Default: 0 * @param {number} to - End index of secret keys. Default: `from` * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts */ async accounts (from: number = 0, to: number = from): Promise { - if (from > to) { - const swap = from - from = to - to = swap - } + if (from > to) [from, to] = [to, from] const output = new AccountList() const indexes: number[] = [] for (let i = from; i <= to; i++) { -- 2.47.3