From 8d6df96136ba63a63499ec832dd00ff41153a4ae Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 21 Sep 2025 22:10:49 -0700 Subject: [PATCH] Import bare specifier in test. --- src/lib/account/index.ts | 17 +++++++++++------ src/lib/rpc.ts | 4 ++++ src/lib/wallet/verify.ts | 1 - test/test.ledger.mjs | 6 +----- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/lib/account/index.ts b/src/lib/account/index.ts index 850307b..5019cac 100644 --- a/src/lib/account/index.ts +++ b/src/lib/account/index.ts @@ -236,15 +236,20 @@ export class Account { * @returns {Promise} Promise for array of new Account objects */ static async load (keypairs: KeyPair[], type: 'private'): Promise + /** + * Instantiates Account objects from their private keys which are used to + * derive public keys and then discarded. + * + * @param {string | Uint8Array | KeyPair | (string | Uint8Array | KeyPair)[]} input - Indexes and keys of the accounts + * @param {'private'} [type] - Indicates private keys + * @returns {Account | Account[] | Promise} Promise for array of new Account objects + */ static load (input: string | Uint8Array | KeyPair | (string | Uint8Array | KeyPair)[], type?: 'private'): Account | Account[] | Promise { const isInputArray = Array.isArray(input) const inputs = isInputArray ? input : [input] if (this.#isKeyPairs(inputs) && type === 'private') { - return new Promise((resolve, reject): void => { - this.#fromPrivate(inputs) - .then(r => resolve(isInputArray ? r : r[0])) - .catch(e => reject(e)) - }) + return this.#fromPrivate(inputs) + .then(r => isInputArray ? r : r[0]) } else { return isInputArray ? this.#fromPublic(inputs) : this.#fromPublic(inputs)[0] } @@ -278,7 +283,7 @@ export class Account { * the corresponding public key and then discarded. * * @param {KeyPair} keypairs - Indexes and keys of the accounts - * @returns {Account} A new Account object + * @returns {Promise} Promise for new Account objects */ static async #fromPrivate (keypairs: KeyPair[]): Promise { try { diff --git a/src/lib/rpc.ts b/src/lib/rpc.ts index 885f42f..9b361e2 100644 --- a/src/lib/rpc.ts +++ b/src/lib/rpc.ts @@ -12,6 +12,10 @@ export class Rpc { #u: URL #n?: string + /** + * @param {(string|URL)} url + * @param {string} [apiKeyName] + */ constructor (url: string | URL, apiKeyName?: string) { this.#u = new URL(url) this.#u.protocol = 'https:' diff --git a/src/lib/wallet/verify.ts b/src/lib/wallet/verify.ts index 86bf4b8..f364e7a 100644 --- a/src/lib/wallet/verify.ts +++ b/src/lib/wallet/verify.ts @@ -13,7 +13,6 @@ export async function _verify (type: WalletType, vault: Vault, secret: unknown): throw new TypeError('Wallet secret must be a string', { cause: typeof secret }) } if (type === 'Ledger') { - const { Ledger } = await import('../ledger') return await Ledger.verify(secret) } else { const data: { [key: string]: string | ArrayBuffer } = { diff --git a/test/test.ledger.mjs b/test/test.ledger.mjs index 30128a1..aae1bf0 100644 --- a/test/test.ledger.mjs +++ b/test/test.ledger.mjs @@ -27,11 +27,7 @@ let Rpc */ let Wallet -if (isNode) { - ({ Account, Block, Ledger, Rpc, Wallet } = await import('../dist/nodejs.min.js')) -} else { - ({ Account, Block, Ledger, Rpc, Wallet } = await import('../dist/browser.min.js')) -} +{ ({ Account, Block, Ledger, Rpc, Wallet } = await import('libnemo')) } const rpc = new Rpc(env.NODE_URL ?? '', env.API_KEY_NAME) -- 2.47.3