From: Chris Duncan Date: Tue, 9 Sep 2025 04:50:37 +0000 (-0700) Subject: Update type definitions. X-Git-Tag: v0.10.5~24^2 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=433c25ba67b50dee0b168c064d603c5daa6e80ed;p=libnemo.git Update type definitions. --- diff --git a/src/types.d.ts b/src/types.d.ts index ae0c0ab..d4f776d 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -53,6 +53,28 @@ export declare class Account { * Releases variable references to allow garbage collection. */ destroy (): Promise + /** + * Stringifies public properties into a JSON object so it can be further + * stringified by JSON.stringify() + */ + toJSON (): { + address: string + index: number | undefined + publicKey: string + confirmed_balance: string | undefined + confirmed_height: string | undefined + confirmed_frontier: string | undefined + confirmed_receivable: string | undefined + confirmed_representative: string | undefined + balance: string | undefined + block_count: number | undefined + frontier: string | undefined + open_block: string | undefined + receivable: string | undefined + representative: string | undefined + representative_block: string | undefined + weight: string | undefined + } /** * Instantiates an Account object from its Nano address. * @@ -141,10 +163,15 @@ export declare class Account { */ export declare class Bip39 { #private + encoder: TextEncoder /** - * https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt - */ - static wordlist: readonly string[] + * SHA-256 hash of entropy that is appended to the entropy and subsequently + * used to generate the mnemonic phrase. + * + * @param {Uint8Array} entropy - Cryptographically strong pseudorandom data of length N bits + * @returns {Promise} First N/32 bits of the hash as a bigint + */ + static checksum (entropy: Uint8Array): Promise /** * Derives a mnemonic phrase from source of entropy or seed. * @@ -153,7 +180,7 @@ export declare class Bip39 { * maximum entropy allowed. * * @param {(ArrayBuffer|Uint8Array)} entropy - Cryptographically secure random value - * @returns {string} Mnemonic phrase created using the BIP-39 wordlist + * @returns {Promise} Mnemonic phrase created using the BIP-39 wordlist */ static fromEntropy (entropy: ArrayBuffer | Uint8Array): Promise /** @@ -163,19 +190,23 @@ export declare class Bip39 { * wallets use the maximum of 24 words. * * @param {string} phrase - String of 12, 15, 18, 21, or 24 words - * @returns {string} Mnemonic phrase validated using the BIP-39 wordlist + * @returns {Promise} Mnemonic phrase validated using the BIP-39 wordlist */ static fromPhrase (phrase: string): Promise /** * Validates a mnemonic phrase meets the BIP-39 specification. * * @param {string} mnemonic - Mnemonic phrase to validate - * @returns {boolean} True if the mnemonic phrase is valid + * @returns {Promise} True if the mnemonic phrase is valid */ static validate (mnemonic: string): Promise - get phrase (): string | undefined private constructor () /** + * BIP-39 mnemonic phrase, normlized using Normalization Form Compatibility + * Decomposition (NFKD). + */ + get phrase (): string | undefined + /** * Erases seed bytes and releases variable references. */ destroy (): void @@ -202,16 +233,20 @@ export declare class Bip39 { /** * Converts the mnemonic phrase to a BLAKE2b seed. * - * @returns {Promise>} Promise for seed as bytes + * @returns {Uint8Array} Seed as bytes */ - toBlake2bSeed (): Promise> + toBlake2bSeed (): Uint8Array /** * Converts the mnemonic phrase to a BLAKE2b seed. * * @param {string} format - * @returns {Promise} Promise for seed as hexadecimal string + * @returns {string} Seed as hexadecimal string */ - toBlake2bSeed (format: 'hex'): Promise + toBlake2bSeed (format: 'hex'): string + /** + * https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt + */ + static wordlist: readonly string[] } /** @@ -698,7 +733,7 @@ export declare class Wallet { * If `from` is greater than `to`, their values will be swapped. * @param {number} [from=0] - Start index of accounts. Default: 0 * @param {number} [to=from] - End index of accounts. Default: `from` - * @returns {Promise} Promise for a list of Accounts at the specified indexes + * @returns {Promise>} Promise for a list of Accounts at the specified indexes */ accounts (from?: number, to?: number): Promise> /** @@ -722,7 +757,7 @@ export declare class Wallet { * A successful response will set these properties on each account. * * @param {(Rpc|string|URL)} rpc - RPC node information required to refresh accounts, calculate PoW, and process blocks - * @returns {Promise} Promise for accounts with updated balances, frontiers, and representatives + * @returns {Promise>} Promise for accounts with updated balances, frontiers, and representatives */ refresh (rpc: Rpc | string | URL, from?: number, to?: number): Promise> /**