From: Chris Duncan Date: Wed, 23 Jul 2025 22:20:29 +0000 (-0700) Subject: bkp X-Git-Tag: v0.10.5~55^2~1 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=d68c27cd0a11a107ae076cc5399be0bc3f38ed45;p=libnemo.git bkp --- diff --git a/src/lib/account.ts b/src/lib/account.ts index 8fb93ea..6e2dce4 100644 --- a/src/lib/account.ts +++ b/src/lib/account.ts @@ -452,10 +452,10 @@ export class Account { if ('index' in obj && typeof obj.index === 'number') { return true } - if ('privateKey' in obj && this.#isKey(obj.privateKey)) { + if ('publicKey' in obj && this.#isKey(obj.publicKey)) { return true } - if ('publicKey' in obj && this.#isKey(obj.privateKey)) { + if ('privateKey' in obj && this.#isKey(obj.privateKey)) { return true } } diff --git a/src/lib/wallets/wallet.ts b/src/lib/wallets/wallet.ts index 1cce9c4..7a8153f 100644 --- a/src/lib/wallets/wallet.ts +++ b/src/lib/wallets/wallet.ts @@ -93,9 +93,6 @@ export abstract class Wallet { * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts */ async accounts (from: number = 0, to: number = from): Promise { - if (this.#locked || this.#s == null) { - throw new Error('wallet must be unlocked to derive accounts') - } if (from > to) { const swap = from from = to @@ -125,8 +122,12 @@ export abstract class Wallet { publicKeys.push(keypair) } } - const privateAccounts = await Account.import(privateKeys, this.seed) - const publicAccounts = Account.import(publicKeys) + const privateAccounts = privateKeys.length > 0 + ? await Account.import(privateKeys, this.seed) + : [] + const publicAccounts = publicKeys.length > 0 + ? Account.import(publicKeys) + : [] const accounts = [...privateAccounts, ...publicAccounts] for (const a of accounts) { if (a.index == null) { diff --git a/test/main.test.mjs b/test/main.test.mjs index ada0c28..381f3e9 100644 --- a/test/main.test.mjs +++ b/test/main.test.mjs @@ -4,17 +4,17 @@ import { failures, passes } from './GLOBALS.mjs' import './test.runner-check.mjs' -import './test.blake2b.mjs' -import './test.blocks.mjs' -import './test.calculate-pow.mjs' -import './test.create-wallet.mjs' -import './test.derive-accounts.mjs' -import './test.import-wallet.mjs' +// import './test.blake2b.mjs' +// import './test.blocks.mjs' +// import './test.calculate-pow.mjs' +// import './test.create-wallet.mjs' +// import './test.derive-accounts.mjs' +// import './test.import-wallet.mjs' import './test.ledger.mjs' -import './test.lock-unlock.mjs' -import './test.manage-rolodex.mjs' -import './test.refresh-accounts.mjs' -import './test.tools.mjs' +// import './test.lock-unlock.mjs' +// import './test.manage-rolodex.mjs' +// import './test.refresh-accounts.mjs' +// import './test.tools.mjs' console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold') console.log('%cPASS: ', 'color:green;font-weight:bold', passes.length) diff --git a/test/test.ledger.mjs b/test/test.ledger.mjs index c4ae355..b01c1d5 100644 --- a/test/test.ledger.mjs +++ b/test/test.ledger.mjs @@ -40,7 +40,8 @@ const rpc = new Rpc(env.NODE_URL ?? '', env.API_KEY_NAME) * shared among tests like wallet and account are declared at the top-level. */ await Promise.all([ - suite('Ledger hardware wallet', { skip: true || isNode }, async () => { + /* node:coverage disable */ + suite('Ledger hardware wallet', { skip: false || isNode }, async () => { let wallet, account, openBlock, sendBlock, receiveBlock @@ -226,4 +227,5 @@ await Promise.all([ await assert.rejects(sendBlock.sign(0)) }) }) + /* node:coverage enable */ ])