From: Chris Duncan Date: Sun, 1 Dec 2024 21:41:11 +0000 (-0800) Subject: Update Bip44Ckd exports and imports. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=aac74d64fb528a61e1f8851590a230f2bde3a55d;p=libnemo.git Update Bip44Ckd exports and imports. --- diff --git a/src/lib/wallet.ts b/src/lib/wallet.ts index 49d74e6..5b97b21 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet.ts @@ -9,7 +9,7 @@ import { Entropy } from './entropy.js' import { Pool } from './pool.js' import { Rpc } from './rpc.js' import { Safe } from './safe.js' -import { ckdBip44, NanoNaCl } from './workers.js' +import { Bip44Ckd, NanoNaCl } from './workers.js' import type { Ledger } from './ledger.js' type KeyPair = { @@ -276,7 +276,7 @@ export class Bip44Wallet extends Wallet { throw new Error(`Bip44Wallet cannot be instantiated directly. Use 'await Bip44Wallet.create()' instead.`) } super(seed, mnemonic, id) - this.#pool = new Pool(ckdBip44) + this.#pool = new Pool(Bip44Ckd) Bip44Wallet.#isInternal = false } diff --git a/src/lib/workers.ts b/src/lib/workers.ts index 4367980..6861f7c 100644 --- a/src/lib/workers.ts +++ b/src/lib/workers.ts @@ -1,8 +1,8 @@ -import ckdBip44 from './workers/ckdBip44.js' +import { worker as Bip44Ckd } from './workers/ckdBip44.js' import { worker as NanoNaCl } from './nano-nacl.js' // import './workers/passkey.js' import pow from './workers/pow.js' -export { ckdBip44, NanoNaCl } +export { Bip44Ckd, NanoNaCl } diff --git a/src/lib/workers/ckdBip44.ts b/src/lib/workers/ckdBip44.ts index c1f1294..772f78e 100644 --- a/src/lib/workers/ckdBip44.ts +++ b/src/lib/workers/ckdBip44.ts @@ -6,7 +6,7 @@ type ExtendedKey = { chainCode: DataView } -const Bip44Ckd = () => { +const b = () => { const BIP44_COIN_NANO = 165 const BIP44_PURPOSE = 44 const HARDENED_OFFSET = 0x80000000 @@ -107,6 +107,12 @@ const Bip44Ckd = () => { const signature = await subtle.sign('HMAC', pk, data) return new Uint8Array(signature) } + + return { nanoCKD } } -export default Bip44Ckd.toString().substring(Bip44Ckd.toString().indexOf('{') + 1, Bip44Ckd.toString().lastIndexOf('}')) +export const Bip44Ckd = b() + +const start = b.toString().indexOf('{') + 1 +const end = b.toString().lastIndexOf('return') +export const worker = b.toString().substring(start, end)