From a03bc623b3ee786463199264458158f943844a45 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 15 May 2026 14:58:20 -0700 Subject: [PATCH] Rename queueing function. --- src/lib/ledger/index.ts | 18 +++++++++--------- src/lib/ledger/queue.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/ledger/index.ts b/src/lib/ledger/index.ts index 6d2c858..25ad785 100644 --- a/src/lib/ledger/index.ts +++ b/src/lib/ledger/index.ts @@ -11,7 +11,7 @@ import { BIP44_COIN_NANO, BIP44_PURPOSE, HARDENED_OFFSET } from '../constants' import { bytes, dec, hex, utf8 } from '../convert' import { Rpc } from '../rpc' import { Wallet } from '../wallet' -import { enqueue } from './queue' +import { queue } from './queue' type LedgerStatus = 'UNSUPPORTED' | 'DISCONNECTED' | 'BUSY' | 'LOCKED' | 'CONNECTED' @@ -128,7 +128,7 @@ export class Ledger { * @returns Response object containing command status, public key, and address */ static async account (index: number = 0, show: boolean = false): Promise { - return enqueue(async () => { + return queue(async () => { try { if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) { throw new TypeError('Invalid account index') @@ -206,7 +206,7 @@ export class Ledger { * connection updates. */ static async disconnect (): Promise { - enqueue(async () => { + queue(async () => { try { this.#isPolling = false const hidDevices = await navigator?.hid?.getDevices?.() ?? [] @@ -368,7 +368,7 @@ export class Ledger { * @returns Status of command */ static async #cacheBlock (index: number = 0, block: Block): Promise { - return enqueue(async () => { + return queue(async () => { try { if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) { throw new TypeError('Invalid account index') @@ -425,7 +425,7 @@ export class Ledger { * @returns Status of command */ static async #close (): Promise { - return enqueue(async () => { + return queue(async () => { const transport = await this.#transport.create(this.#openTimeout, this.#listenTimeout) const response = await transport .send(0xb0, 0xa7, this.#ADPU_CODES.paramUnused, this.#ADPU_CODES.paramUnused) @@ -486,7 +486,7 @@ export class Ledger { * @returns Status of command */ static async #open (): Promise { - return enqueue(async () => { + return queue(async () => { const name = new TextEncoder().encode('Nano') const transport = await this.#transport.create(this.#openTimeout, this.#listenTimeout) const response = await transport @@ -551,7 +551,7 @@ export class Ledger { if (block.signature !== undefined) { throw new TypeError('Block signature already exists', { cause: block.signature }) } - return enqueue(async () => { + return queue(async () => { try { if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) { throw new TypeError('Invalid account index') @@ -604,7 +604,7 @@ export class Ledger { * @returns {Promise} Status and signature */ static async #signNonce (index: number, nonce: Uint8Array): Promise { - return enqueue(async () => { + return queue(async () => { if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) { throw new TypeError('Invalid account index') } @@ -645,7 +645,7 @@ export class Ledger { * @returns Status, process name, and version */ static async #version (): Promise { - return enqueue(async () => { + return queue(async () => { try { const transport = await this.#transport.create(this.#openTimeout, this.#listenTimeout) const response = await transport diff --git a/src/lib/ledger/queue.ts b/src/lib/ledger/queue.ts index 30560bf..460766e 100644 --- a/src/lib/ledger/queue.ts +++ b/src/lib/ledger/queue.ts @@ -6,7 +6,7 @@ let job: Promise = Promise.resolve() /** * Serially executes sync and async functions. */ -export function enqueue (task: () => T | Promise): Promise { +export function queue (task: () => T | Promise): Promise { if (typeof task !== 'function') throw new TypeError('task is not a function') const result = job.then(() => task(), () => task()) job = result.then(() => void 0, () => void 0) -- 2.47.3