]> git.codecow.com Git - libnemo.git/commitdiff
Fix types and imports.
authorChris Duncan <chris@zoso.dev>
Thu, 31 Jul 2025 22:56:00 +0000 (15:56 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 31 Jul 2025 22:56:00 +0000 (15:56 -0700)
src/lib/bip39-mnemonic.ts
src/lib/database.ts
src/lib/ledger.ts
src/lib/nano-nacl.ts
src/lib/safe.ts
src/lib/wallet.ts
src/lib/worker-queue.ts
src/types.d.ts
test/main.test.mjs
test/test.blocks.mjs

index 2acdccfd7ec633382866d2e50b17969e8debc999..e00d7c44f1abe145f8885c46b82630cde37e95ce 100644 (file)
@@ -15,8 +15,8 @@ export class Bip39Mnemonic {
         * SHA-256 hash of entropy that is appended to the entropy and subsequently\r
         * used to generate the mnemonic phrase.\r
         *\r
-        * @param {Entropy} entropy - Cryptographically strong pseudorandom data of length N bits\r
-        * @returns {Promise<string>} First N/32 bits of the hash as a hexadecimal string\r
+        * @param {Uint8Array<ArrayBuffer>} entropy - Cryptographically strong pseudorandom data of length N bits\r
+        * @returns {Promise<bigint>} First N/32 bits of the hash as a bigint\r
         */\r
        static async #checksum (entropy: Uint8Array<ArrayBuffer>): Promise<bigint> {\r
                const sha256sum = new Uint8Array(await crypto.subtle.digest('SHA-256', entropy))[0]\r
index f6b35780672840f8543af24332818e03217dab8a..959c16c6538e26ab11636530aac6e96004ae62a0 100644 (file)
@@ -150,7 +150,10 @@ export class Database {
                return new Promise((resolve, reject) => {
                        const request = indexedDB.open(database, 1)
                        request.onupgradeneeded = (event) => {
-                               const db = (event.target as IDBOpenDBRequest).result
+                               const db = (event.target as IDBOpenDBRequest)?.result
+                               if (db == null) {
+                                       throw new Error('Failed to open database')
+                               }
                                for (const DB_STORE of this.DB_STORES) {
                                        if (!db.objectStoreNames.contains(DB_STORE)) {
                                                db.createObjectStore(DB_STORE, { keyPath: 'id' })
index bf671a6ee07d489306c9a3f8ba2b1b7fa18adbe4..689d5e22f43d440d6de82225a294967434cc350d 100644 (file)
@@ -8,7 +8,6 @@ import { default as TransportHID } from '@ledgerhq/hw-transport-webhid'
 import { ChangeBlock, ReceiveBlock, SendBlock } from './block'\r
 import { BIP44_COIN_NANO, BIP44_PURPOSE, HARDENED_OFFSET, LEDGER_ADPU_CODES, LEDGER_STATUS_CODES } from './constants'\r
 import { bytes, dec, hex } from './convert'\r
-import { Entropy } from './entropy'\r
 import { Rpc } from './rpc'\r
 import { Wallet } from './wallet'\r
 import { DeviceStatus, KeyPair, LedgerAccountResponse, LedgerResponse, LedgerSignResponse, LedgerVersionResponse } from '#types'\r
@@ -61,7 +60,7 @@ export class LedgerWallet extends Wallet {
        static async create (): Promise<LedgerWallet> {\r
                try {\r
                        if (this.isUnsupported) throw new Error('Browser is unsupported')\r
-                       const id = await Entropy.create(16)\r
+                       const id = 'Ledger'\r
                        LedgerWallet.#isInternal = true\r
                        const wallet = new this(id)\r
                        return wallet\r
@@ -73,12 +72,12 @@ export class LedgerWallet extends Wallet {
        #status: DeviceStatus = 'DISCONNECTED'\r
        get status (): DeviceStatus { return this.#status }\r
 \r
-       private constructor (id: Entropy) {\r
+       private constructor (id: string) {\r
                if (!LedgerWallet.#isInternal) {\r
                        throw new Error(`LedgerWallet cannot be instantiated directly. Use 'await LedgerWallet.create()' instead.`)\r
                }\r
                LedgerWallet.#isInternal = false\r
-               super(id.hex, 'Ledger')\r
+               super(id, 'Ledger')\r
        }\r
 \r
        /**\r
@@ -181,7 +180,7 @@ export class LedgerWallet extends Wallet {
                try {\r
                        id = id.replace('Ledger_', '')\r
                        LedgerWallet.#isInternal = true\r
-                       return new this(await Entropy.import(id))\r
+                       return new this(id)\r
                } catch (err) {\r
                        console.error(err)\r
                        throw new Error('failed to restore wallet', { cause: err })\r
index 7bd20e7d61d88a4b44dba1d27c5eac55501168a4..3fdb793e2bb0f20c3fd7dbf50dcde200e8c30d46 100644 (file)
@@ -477,10 +477,10 @@ export class NanoNaCl {
        */\r
        static #checkArrayTypes (args: { [i: string]: unknown }): asserts args is { [i: string]: Uint8Array<ArrayBuffer> } {\r
                for (const arg of Object.keys(args)) {\r
-                       if (typeof arg !== 'object') {\r
+                       if (typeof args[arg] !== 'object') {\r
                                throw new TypeError(`Invalid input, expected Uint8Array, actual ${typeof arg}`)\r
                        }\r
-                       const obj = arg as { [key: string]: unknown }\r
+                       const obj = args[arg] as { [key: string]: unknown }\r
                        if (!(obj instanceof Uint8Array)) {\r
                                throw new TypeError(`Invalid input, expected Uint8Array, actual ${obj.constructor?.name ?? typeof arg}`)\r
                        }\r
index bf53b381b491feebd5bf8a3bb933ddfb98c7d4f4..fb085dd8eb54b933c121fa4b0904210a982e56e5 100644 (file)
@@ -6,6 +6,7 @@
 import { parentPort } from 'node:worker_threads'
 import { Bip39Words } from './bip39-wordlist'
 import { Bip44Ckd } from './bip44-ckd'
+import { Blake2b } from './blake2b'
 import { Blake2bCkd } from './blake2b-ckd'
 import { NanoNaCl } from './nano-nacl'
 import { Bip39Mnemonic } from './bip39-mnemonic.js'
@@ -28,6 +29,7 @@ export class Safe {
        static {
                NODE: this.#parentPort = parentPort
                const listener = async (message: MessageEvent<any>): Promise<void> => {
+                       debugger
                        const {
                                action,
                                type,
@@ -458,6 +460,11 @@ NODE: importWorkerThreads = `import { parentPort } from 'node:worker_threads'`
 export default `
        ${importWorkerThreads}
        ${Convert}
-       const Bip39Words = ${Bip39Words}
+       const Bip39Mnemonic = ${Bip39Mnemonic}
+       const Bip39Words = ["${Bip39Words.join('","')}"]
+       const Bip44Ckd = ${Bip44Ckd}
+       const Blake2b = ${Blake2b}
+       const Blake2bCkd = ${Blake2bCkd}
+       const NanoNaCl = ${NanoNaCl}
        const Safe = ${Safe}
 `
index cb907d9cb6cc215c2948b93b7734bb51de06494e..94b6a23af58d4de280daee383b2269018178219f 100644 (file)
@@ -3,22 +3,18 @@
 \r
 import { Account, AccountList } from '#src/lib/account.js'\r
 import { ChangeBlock, ReceiveBlock, SendBlock } from '#src/lib/block.js'\r
-import { Bip39Mnemonic } from '#src/lib/bip39-mnemonic.js'\r
 import { ADDRESS_GAP } from '#src/lib/constants.js'\r
 import { bytes, hex, utf8 } from '#src/lib/convert.js'\r
 import { Database } from '#src/lib/database.js'\r
-import { Entropy } from '#src/lib/entropy.js'\r
 import { Rpc } from '#src/lib/rpc.js'\r
 import { default as SafeWorker } from '#src/lib/safe.js'\r
 import { WorkerQueue } from '#src/lib/worker-queue.js'\r
-import { KeyPair, NamedData, WalletType } from '#types'\r
+import { KeyPair, WalletType } from '#types'\r
 \r
 /**\r
 * Represents a wallet containing numerous Nano accounts derived from a single\r
-* source, the form of which can vary based on the type of wallet. The Wallet\r
-* class itself is abstract and cannot be directly instantiated. Currently, three\r
-* types of wallets are supported, each as a derived class: Bip44Wallet,\r
-* Blake2bWallet, LedgerWallet.\r
+* source, the form of which can vary based on the type of wallet. Currently,\r
+* three types of wallets are supported: BIP-44, BLAKE2b, and Ledger.\r
 */\r
 export class Wallet {\r
        static #DB_NAME = 'Wallet'\r
@@ -47,7 +43,7 @@ export class Wallet {
        *\r
        * @param {string} password - Encrypts the wallet to lock and unlock it\r
        * @param {string} [salt=''] - Used when generating the final seed\r
-       * @returns {Bip44Wallet} A newly instantiated Wallet\r
+       * @returns {Wallet} A newly instantiated Wallet\r
        */\r
        static async create (name: string, type: 'BIP-44' | 'BLAKE2b', password: string, mnemonicSalt?: string): Promise<Wallet> {\r
                Wallet.#isInternal = true\r
@@ -68,7 +64,7 @@ export class Wallet {
                        await Database.put({ [name]: encoded }, Wallet.#DB_NAME)\r
                        return self\r
                } catch (err) {\r
-                       throw new Error('Error creating new Bip44Wallet', { cause: err })\r
+                       throw new Error('Error creating new Wallet', { cause: err })\r
                }\r
        }\r
 \r
index d69e56581bf2adba9e9bf5d2674accd59ff6b9d3..eb3630604612e1898f1bf47b5af57cb8081f02a2 100644 (file)
@@ -2,7 +2,6 @@
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
 import { Worker as NodeWorker } from 'node:worker_threads'
-import { default as safe } from './safe'
 import { Data, NamedData } from '#types'
 
 type Task = {
@@ -34,6 +33,8 @@ export class WorkerQueue {
        constructor (worker: string) {
                this.#isIdle = true
                this.#queue = []
+               console.log(worker)
+               debugger
                this.#url = URL.createObjectURL(new Blob([worker], { type: 'text/javascript' }))
                BROWSER: this.#worker = new Worker(this.#url, { type: 'module' })
                BROWSER: this.#worker.addEventListener('message', message => {
index 28e4ad64511438632c3ba9c815c180e15f9b792e..29507325b00ffe2b2b4a57cbfd922668669f0e49 100644 (file)
@@ -559,13 +559,13 @@ export declare function sign (key: Key, ...input: string[]): Promise<string>
 * them all to a single recipient address. Hardware wallets are unsupported.
 *
 * @param {Rpc|string|URL} rpc - RPC node information required to refresh accounts, calculate PoW, and process blocks
-* @param {Blake2bWallet|Bip44Wallet|LedgerWallet} wallet - Wallet from which to sweep funds
+* @param {Wallet|LedgerWallet} wallet - Wallet from which to sweep funds
 * @param {string} recipient - Destination address for all swept funds
 * @param {number} from - Starting account index to sweep
 * @param {number} to - Ending account index to sweep
 * @returns An array of results including both successes and failures
  */
-export declare function sweep (rpc: Rpc | string | URL, wallet: Blake2bWallet | Bip44Wallet | LedgerWallet, recipient: string, from?: number, to?: number): Promise<SweepResult[]>
+export declare function sweep (rpc: Rpc | string | URL, wallet: Wallet | LedgerWallet, recipient: string, from?: number, to?: number): Promise<SweepResult[]>
 /**
 * Verifies the signature of arbitrary strings using a public key.
 *
@@ -587,27 +587,30 @@ export type WalletType = 'BIP-44' | 'BLAKE2b' | 'Ledger'
 
 /**
 * Represents a wallet containing numerous Nano accounts derived from a single
-* source, the form of which can vary based on the type of wallet. The Wallet
-* class itself is abstract and cannot be directly instantiated. Currently, three
-* types of wallets are supported, each as a derived class: Bip44Wallet,
-* Blake2bWallet, LedgerWallet.
+* source, the form of which can vary based on the type of wallet. Currently,
+* three types of wallets are supported: BIP-44, BLAKE2b, and Ledger.
 */
-export declare abstract class Wallet {
+export declare class Wallet {
        #private
-       abstract ckd (index: number[]): Promise<KeyPair[]>
        /**
-       * Retrieves all wallet IDs from the Safe.
+       * Creates a new HD wallet by using an entropy value generated using a
+       * cryptographically strong pseudorandom number generator.
+       *
+       * @param {string} password - Encrypts the wallet to lock and unlock it
+       * @param {string} [salt=''] - Used when generating the final seed
+       * @returns {Wallet} A newly instantiated Wallet
+       */
+       static create (name: string, type: 'BIP-44' | 'BLAKE2b', password: string, mnemonicSalt?: string): Promise<Wallet>
+       /**
+       * Retrieves an existing wallet from the database using its name.
        *
-       * @returns Array of hexadecimal-formatted wallet IDs
+       * @param {string} name - Entered by user when the wallet was initially created
+       * @returns {Wallet} Restored locked Wallet
        */
-       static export (): Promise<string[]>
-       get id (): string
-       get isLocked (): boolean
-       get isUnlocked (): boolean
-       get mnemonic (): string
-       get seed (): string
+       static restore (name: string): Promise<Wallet>
+       get name (): string
        get type (): WalletType
-       constructor (id: Entropy, seed?: Uint8Array<ArrayBuffer>, mnemonic?: Bip39Mnemonic)
+       constructor (name: string, type: WalletType)
        /**
        * Retrieves an account from a wallet using its child key derivation function.
        * Defaults to the first account at index 0.
@@ -658,10 +661,9 @@ export declare abstract class Wallet {
        * Locks the wallet and all currently derived accounts with a password that
        * will be needed to unlock it later.
        *
-       * @param {Key} password Used to lock the wallet
        * @returns True if successfully locked
        */
-       lock (password: Key): Promise<boolean>
+       lock (): Promise<boolean>
        /**
        * Refreshes wallet account balances, frontiers, and representatives from the
        * current state on the network.
@@ -685,10 +687,10 @@ export declare abstract class Wallet {
        /**
        * Unlocks the wallet using the same password as used prior to lock it.
        *
-       * @param {Key} password Used previously to lock the wallet
+       * @param {string} password Used previously to lock the wallet
        * @returns True if successfully unlocked
        */
-       unlock (password: Key): Promise<boolean>
+       unlock (password: string): Promise<boolean>
        /**
        * Fetches the lowest-indexed unopened account from a wallet in sequential
        * order. An account is unopened if it has no frontier block.
@@ -701,208 +703,6 @@ export declare abstract class Wallet {
        unopened (rpc: Rpc, batchSize?: number, from?: number): Promise<Account>
 }
 
-/**
-* Hierarchical deterministic (HD) wallet created by using a source of entropy to
-* derive a mnemonic phrase. The mnemonic phrase, in combination with an optional
-* salt, is used to generate a seed. A value can be provided as a parameter for
-* entropy, mnemonic + salt, or seed; if no argument is passed, a new entropy
-* value will be generated using a cryptographically strong pseudorandom number
-* generator.
-*
-* Importantly, the salt is not stored in the instantiated Wallet object. If a
-* salt is used, then losing it means losing the ability to regenerate the seed
-* from the mnemonic.
-*
-* Accounts are derived from the seed. Private keys are derived using a BIP-44
-* derivation path. The public key is derived from the private key using the
-* Ed25519 key algorithm. Account addresses are derived as described in the nano
-* documentation (https://docs.nano.org)
-*
-* A password must be provided when creating or importing the wallet and is used
-* to lock and unlock the wallet. The wallet will be initialized as locked. When
-* the wallet is unlocked, a new password can be specified using the lock()
-* method.
-*/
-export declare class Bip44Wallet extends Wallet {
-       #private
-       private constructor ()
-       /**
-       * Creates a new HD wallet by using an entropy value generated using a
-       * cryptographically strong pseudorandom number generator.
-       *
-       * @param {string} password - Encrypts the wallet to lock and unlock it
-       * @param {string} [salt=''] - Used when generating the final seed
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
-       */
-       static create (password: string, salt?: string): Promise<Bip44Wallet>
-       /**
-       * Creates a new HD wallet by using an entropy value generated using a
-       * cryptographically strong pseudorandom number generator.
-       *
-       * @param {Uint8Array} key - Encrypts the wallet to lock and unlock it
-       * @param {string} [salt=''] - Used when generating the final seed
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
-       */
-       static create (key: Uint8Array, salt?: string): Promise<Bip44Wallet>
-       /**
-       * Creates a new HD wallet by using a pregenerated entropy value. The user
-       * must ensure that it is cryptographically strongly random.
-       *
-       * @param {string} password - Used to lock and unlock the wallet
-       * @param {string} entropy - Used when generating the initial mnemonic phrase
-       * @param {string} [salt=''] - Used when generating the final seed
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
-       */
-       static fromEntropy (password: string, entropy: string, salt?: string): Promise<Bip44Wallet>
-       /**
-       * Creates a new HD wallet by using a pregenerated entropy value. The user
-       * must ensure that it is cryptographically strongly random.
-       *
-       * @param {Uint8Array} key - Used to lock and unlock the wallet
-       * @param {string} entropy - Used when generating the initial mnemonic phrase
-       * @param {string} [salt=''] - Used when generating the final seed
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
-       */
-       static fromEntropy (key: Uint8Array<ArrayBuffer>, entropy: string, salt?: string): Promise<Bip44Wallet>
-       /**
-       * Creates a new HD wallet by using a pregenerated mnemonic phrase.
-       *
-       * @param {string} password - Used to lock and unlock the wallet
-       * @param {string} mnemonic - Used when generating the final seed
-       * @param {string} [salt=''] - Used when generating the final seed
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
-       */
-       static fromMnemonic (password: string, mnemonic: string, salt?: string): Promise<Bip44Wallet>
-       /**
-       * Creates a new HD wallet by using a pregenerated mnemonic phrase.
-       *
-       * @param {Uint8Array} key - Used to lock and unlock the wallet
-       * @param {string} mnemonic - Used when generating the final seed
-       * @param {string} [salt=''] - Used when generating the final seed
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
-       */
-       static fromMnemonic (key: Uint8Array<ArrayBuffer>, mnemonic: string, salt?: string): Promise<Bip44Wallet>
-       /**
-       * Creates a new HD wallet by using a pregenerated seed value. This seed cannot
-       * be used to regenerate any higher level randomness which includes entropy,
-       * mnemonic phrase, and salt.
-       *
-       * @param {string} password - Used to lock and unlock the wallet
-       * @param {string} seed - Hexadecimal 128-character string used to derive private-public key pairs
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
-       */
-       static fromSeed (password: string, seed: string): Promise<Bip44Wallet>
-       /**
-       * Creates a new HD wallet by using a pregenerated seed value. This seed cannot
-       * be used to regenerate any higher level randomness which includes entropy,
-       * mnemonic phrase, and salt.
-       *
-       * @param {Uint8Array} key - Used to lock and unlock the wallet
-       * @param {string} seed - Hexadecimal 128-character string used to derive private-public key pairs
-       * @returns {Bip44Wallet} A newly instantiated Bip44Wallet
-       */
-       static fromSeed (key: Uint8Array<ArrayBuffer>, seed: string): Promise<Bip44Wallet>
-       /**
-       * Retrieves an existing HD wallet from storage using its ID.
-       *
-       * @param {string} id - Generated when the wallet was initially created
-       * @returns {Bip44Wallet} Restored locked Bip44Wallet
-       */
-       static restore (id: string): Promise<Bip44Wallet>
-       /**
-       * Derives BIP-44 Nano account private keys.
-       *
-       * @param {number[]} indexes - Indexes of the accounts
-       * @returns {Promise<Account>}
-       */
-       ckd (indexes: number[]): Promise<KeyPair[]>
-}
-
-/**
-* BLAKE2b wallet created by deriving a mnemonic phrase from a seed or vice
-* versa. If no value is provided for either, a new BIP-39 seed and mnemonic will
-* be generated using a cryptographically strong pseudorandom number generator.
-*
-* Account private keys are derived on an ad hoc basis using the Blake2b hashing
-* function. Account public key are derived from the private key using the
-* Ed25519 key algorithm. Account addresses are derived from the public key as
-* described in the Nano documentation.
-* https://docs.nano.org/integration-guides/the-basics/
-*
-* A password must be provided when creating or importing the wallet and is used
-* to lock and unlock the wallet. The wallet will be initialized as locked. When
-* the wallet is unlocked, a new password can be specified using the lock()
-* method.
-*/
-export declare class Blake2bWallet extends Wallet {
-       #private
-       private constructor ()
-       /**
-       * Creates a new BLAKE2b wallet by using a seed generated using a
-       * cryptographically strong pseudorandom number generator.
-       *
-       * @param {string} password - Encrypts the wallet to lock and unlock it
-       * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
-       */
-       static create (password: string): Promise<Blake2bWallet>
-       /**
-       * Creates a new BLAKE2b wallet by using a seed generated using a
-       * cryptographically strong pseudorandom number generator.
-       *
-       * @param {Uint8Array} key - Encrypts the wallet to lock and unlock it
-       * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
-       */
-       static create (key: Uint8Array): Promise<Blake2bWallet>
-       /**
-       * Creates a new BLAKE2b wallet by using a pregenerated seed. The user must
-       * ensure that it is cryptographically strongly random.
-       *
-       * @param {string} password - Used to lock and unlock the wallet
-       * @param {string} seed - Hexadecimal 64-character string used to derive private-public key pairs
-       * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
-       */
-       static fromSeed (password: string, seed: string): Promise<Blake2bWallet>
-       /**
-       * Creates a new BLAKE2b wallet by using a pregenerated seed. The user must
-       * ensure that it is cryptographically strongly random.
-       *
-       * @param {Uint8Array} key - Used to lock and unlock the wallet
-       * @param {string} seed - Hexadecimal 64-character string used to derive private-public key pairs
-       * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
-       */
-       static fromSeed (key: Uint8Array<ArrayBuffer>, seed: string): Promise<Blake2bWallet>
-       /**
-       * Creates a new BLAKE2b wallet by using a pregenerated mnemonic phrase.
-       *
-       * @param {string} password - Used to lock and unlock the wallet
-       * @param {string} mnemonic - Used when generating the final seed
-       * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
-       */
-       static fromMnemonic (password: string, mnemonic: string): Promise<Blake2bWallet>
-       /**
-       * Creates a new BLAKE2b wallet by using a pregenerated mnemonic phrase.
-       *
-       * @param {Uint8Array} key - Used to lock and unlock the wallet
-       * @param {string} mnemonic - Used when generating the final seed
-       * @returns {Blake2bWallet} A newly instantiated Blake2bWallet
-       */
-       static fromMnemonic (key: Uint8Array<ArrayBuffer>, mnemonic: string): Promise<Blake2bWallet>
-       /**
-       * Retrieves an existing BLAKE2b wallet from storage using its ID.
-       *
-       * @param {string} id - Generated when the wallet was initially created
-       * @returns {Blake2bWallet} Restored locked Blake2bWallet
-       */
-       static restore (id: string): Promise<Blake2bWallet>
-       /**
-       * Derives BLAKE2b account private keys.
-       *
-       * @param {number[]} indexes - Indexes of the accounts
-       * @returns {Promise<Account>}
-       */
-       ckd (indexes: number[]): Promise<KeyPair[]>
-}
-
 type DeviceStatus = 'DISCONNECTED' | 'BUSY' | 'LOCKED' | 'CONNECTED'
 
 interface LedgerResponse {
index ada0c28a6a82c56c51ec92ec5f2b578718caf2c9..3ab48d6ad4c1eacdfa59c884afa7e240ce61e552 100644 (file)
@@ -4,17 +4,17 @@
 import { failures, passes } from './GLOBALS.mjs'
 import './test.runner-check.mjs'
 
-import './test.blake2b.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.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'
 
 console.log('%cTESTING COMPLETE', 'color:orange;font-weight:bold')
 console.log('%cPASS: ', 'color:green;font-weight:bold', passes.length)
index 6869879ac4ef19c86250f78385f5be428e7aebc1..5e7ee8c0368e074dedcced919ddecd2c976c9c88 100644 (file)
@@ -7,9 +7,9 @@ import { assert, isNode, suite, test } from './GLOBALS.mjs'
 import { NANO_TEST_VECTORS } from './VECTORS.mjs'\r
 \r
 /**\r
-* @type {typeof import('../dist/types.d.ts').Bip44Wallet}\r
+* @type {typeof import('../dist/types.d.ts').Wallet}\r
 */\r
-let Bip44Wallet\r
+let Wallet\r
 /**\r
 * @type {typeof import('../dist/types.d.ts').ChangeBlock}\r
 */\r
@@ -23,9 +23,9 @@ let ReceiveBlock
 */\r
 let SendBlock\r
 if (isNode) {\r
-       ({ Bip44Wallet, ChangeBlock, ReceiveBlock, SendBlock } = await import('../dist/nodejs.min.js'))\r
+       ({ Wallet, ChangeBlock, ReceiveBlock, SendBlock } = await import('../dist/nodejs.min.js'))\r
 } else {\r
-       ({ Bip44Wallet, ChangeBlock, ReceiveBlock, SendBlock } = await import('../dist/browser.min.js'))\r
+       ({ Wallet, ChangeBlock, ReceiveBlock, SendBlock } = await import('../dist/browser.min.js'))\r
 }\r
 \r
 await Promise.all([\r
@@ -85,7 +85,7 @@ await Promise.all([
        suite('Block signing using official test vectors', async () => {\r
 \r
                await test('sign open block with wallet', async () => {\r
-                       const wallet = await Bip44Wallet.fromSeed(NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
+                       const wallet = await Wallet.create('Test', 'BIP-44', NANO_TEST_VECTORS.PASSWORD, NANO_TEST_VECTORS.BIP39_SEED)\r
                        await assert.resolves(wallet.unlock(NANO_TEST_VECTORS.PASSWORD))\r
 \r
                        const block = new ReceiveBlock(\r