]> git.codecow.com Git - libnemo.git/commitdiff
bkp
authorChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 22:20:29 +0000 (15:20 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 22:20:29 +0000 (15:20 -0700)
src/lib/account.ts
src/lib/wallets/wallet.ts
test/main.test.mjs
test/test.ledger.mjs

index 8fb93eae3c0f566ef75d4e11120b1bab0cd54ee0..6e2dce40ac4b17d3f18a9ed0eef468863676a877 100644 (file)
@@ -452,10 +452,10 @@ export class Account {
                        if ('index' in obj && typeof obj.index === 'number') {\r
                                return true\r
                        }\r
-                       if ('privateKey' in obj && this.#isKey(obj.privateKey)) {\r
+                       if ('publicKey' in obj && this.#isKey(obj.publicKey)) {\r
                                return true\r
                        }\r
-                       if ('publicKey' in obj && this.#isKey(obj.privateKey)) {\r
+                       if ('privateKey' in obj && this.#isKey(obj.privateKey)) {\r
                                return true\r
                        }\r
                }\r
index 1cce9c4cdaafb4394e34846233b3966c340c8846..7a8153f92ad440ea175ebd2ef2916468448f7ad1 100644 (file)
@@ -93,9 +93,6 @@ export abstract class Wallet {
        * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts\r
        */\r
        async accounts (from: number = 0, to: number = from): Promise<AccountList> {\r
-               if (this.#locked || this.#s == null) {\r
-                       throw new Error('wallet must be unlocked to derive accounts')\r
-               }\r
                if (from > to) {\r
                        const swap = from\r
                        from = to\r
@@ -125,8 +122,12 @@ export abstract class Wallet {
                                        publicKeys.push(keypair)\r
                                }\r
                        }\r
-                       const privateAccounts = await Account.import(privateKeys, this.seed)\r
-                       const publicAccounts = Account.import(publicKeys)\r
+                       const privateAccounts = privateKeys.length > 0\r
+                               ? await Account.import(privateKeys, this.seed)\r
+                               : []\r
+                       const publicAccounts = publicKeys.length > 0\r
+                               ? Account.import(publicKeys)\r
+                               : []\r
                        const accounts = [...privateAccounts, ...publicAccounts]\r
                        for (const a of accounts) {\r
                                if (a.index == null) {\r
index ada0c28a6a82c56c51ec92ec5f2b578718caf2c9..381f3e9d1c5ab34f6f36815cdc9be19e83ef5e83 100644 (file)
@@ -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)
index c4ae355fbfce9537cc85b56284d6c108c6bcf540..b01c1d574ba687e84fa9cf41b28fceccdcb78eb1 100644 (file)
@@ -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 */
 ])