From: Chris Duncan Date: Thu, 10 Jul 2025 15:29:55 +0000 (-0700) Subject: Put window scrolling back in test page. Log to console when waiting for Ledger to... X-Git-Tag: v0.10.5~67 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=9d9dc4588725a958ee6fd549d3ed58df29d0cc24;p=libnemo.git Put window scrolling back in test page. Log to console when waiting for Ledger to sign. Use Ledger derivation path defined once. --- diff --git a/index.html b/index.html index b1a75c6..f193df5 100644 --- a/index.html +++ b/index.html @@ -41,6 +41,7 @@ SPDX-License-Identifier: GPL-3.0-or-later a = a.replace('%c', '') output.innerHTML += `
${a}
` consoleGroup(...args) + window?.scrollTo(0, document.body.scrollHeight) } const consoleError = console.error console.error = (...args) => { @@ -48,6 +49,7 @@ SPDX-License-Identifier: GPL-3.0-or-later a = a.replace('%cFAIL ,color:red,', 'FAIL ') output.innerHTML += `
${a}
` consoleError(...args) + window?.scrollTo(0, document.body.scrollHeight) } const consoleLog = console.log console.log = (...args) => { @@ -58,6 +60,7 @@ SPDX-License-Identifier: GPL-3.0-or-later a = a.replace('%cTESTING COMPLETE,color:orange;font-weight:bold', 'TESTING COMPLETE') output.innerHTML += `
${a}
` consoleLog(...args) + window?.scrollTo(0, document.body.scrollHeight) } })() diff --git a/src/lib/wallets/ledger-wallet.ts b/src/lib/wallets/ledger-wallet.ts index d62402c..ec25851 100644 --- a/src/lib/wallets/ledger-wallet.ts +++ b/src/lib/wallets/ledger-wallet.ts @@ -233,6 +233,7 @@ export class LedgerWallet extends Wallet { if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) { throw new TypeError('Invalid account index') } + console.log('Waiting for signature confirmation on Ledger device...') if (input instanceof Uint8Array) { // input is a nonce return await this.#signNonce(index, input) @@ -400,10 +401,8 @@ export class LedgerWallet extends Wallet { if (typeof index !== 'number' || index < 0 || index >= HARDENED_OFFSET) { throw new TypeError('Invalid account index') } - const purpose = dec.toBytes(BIP44_PURPOSE + HARDENED_OFFSET, 4) - const coin = dec.toBytes(BIP44_COIN_NANO + HARDENED_OFFSET, 4) const account = dec.toBytes(index + HARDENED_OFFSET, 4) - const data = new Uint8Array([LEDGER_ADPU_CODES.bip32DerivationLevel, ...purpose, ...coin, ...account]) + const data = new Uint8Array([...LedgerWallet.#derivationPath, ...account]) const transport = await this.DynamicTransport.create(this.openTimeout, this.listenTimeout) const response = await transport diff --git a/test/GLOBALS.mjs b/test/GLOBALS.mjs index d41178b..88a4490 100644 --- a/test/GLOBALS.mjs +++ b/test/GLOBALS.mjs @@ -195,7 +195,6 @@ export function test (name, opts, fn) { } else { fail(`${name}: test cannot execute on ${typeof fn} ${fn}`) } - window?.scrollTo(0, document.body.scrollHeight) } export const assert = { diff --git a/test/test.main.mjs b/test/test.main.mjs index a2f78f9..90f7644 100644 --- a/test/test.main.mjs +++ b/test/test.main.mjs @@ -1,16 +1,16 @@ // SPDX-FileCopyrightText: 2025 Chris Duncan // SPDX-License-Identifier: GPL-3.0-or-later -// import './test.blake2b.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.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.sign-blocks.mjs' -// import './test.tools.mjs' +import './test.lock-unlock.mjs' +import './test.manage-rolodex.mjs' +import './test.refresh-accounts.mjs' +import './test.sign-blocks.mjs' +import './test.tools.mjs' console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold')