]> git.codecow.com Git - libnemo.git/commitdiff
Update type definitions.
authorChris Duncan <chris@zoso.dev>
Tue, 9 Sep 2025 04:50:37 +0000 (21:50 -0700)
committerChris Duncan <chris@zoso.dev>
Tue, 9 Sep 2025 04:50:37 +0000 (21:50 -0700)
src/types.d.ts

index ae0c0ab7bc0f02392a663ff13bda8927d09c8c64..d4f776d3d9139de60fba71e62d19094ebfcc9037 100644 (file)
@@ -53,6 +53,28 @@ export declare class Account {
        * Releases variable references to allow garbage collection.
        */
        destroy (): Promise<void>
+       /**
+        * 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<ArrayBuffer>} entropy - Cryptographically strong pseudorandom data of length N bits
+        * @returns {Promise<bigint>} First N/32 bits of the hash as a bigint
+        */
+       static checksum (entropy: Uint8Array<ArrayBuffer>): Promise<bigint>
        /**
        * Derives a mnemonic phrase from source of entropy or seed.
        *
@@ -153,7 +180,7 @@ export declare class Bip39 {
        * maximum entropy allowed.
        *
        * @param {(ArrayBuffer|Uint8Array<ArrayBuffer>)} entropy - Cryptographically secure random value
-       * @returns {string} Mnemonic phrase created using the BIP-39 wordlist
+       * @returns {Promise<Bip39>} Mnemonic phrase created using the BIP-39 wordlist
        */
        static fromEntropy (entropy: ArrayBuffer | Uint8Array<ArrayBuffer>): Promise<Bip39>
        /**
@@ -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<Bip39>} Mnemonic phrase validated using the BIP-39 wordlist
        */
        static fromPhrase (phrase: string): Promise<Bip39>
        /**
        * 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<boolean>} True if the mnemonic phrase is valid
        */
        static validate (mnemonic: string): Promise<boolean>
-       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<Uint8Array<ArrayBuffer>>} Promise for seed as bytes
+       * @returns {Uint8Array<ArrayBuffer>} Seed as bytes
        */
-       toBlake2bSeed (): Promise<Uint8Array<ArrayBuffer>>
+       toBlake2bSeed (): Uint8Array<ArrayBuffer>
        /**
        * Converts the mnemonic phrase to a BLAKE2b seed.
        *
        * @param {string} format
-       * @returns {Promise<string>} Promise for seed as hexadecimal string
+       * @returns {string} Seed as hexadecimal string
        */
-       toBlake2bSeed (format: 'hex'): Promise<string>
+       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<AccountList>} Promise for a list of Accounts at the specified indexes
+       * @returns {Promise<Map<number, Account>>} Promise for a list of Accounts at the specified indexes
        */
        accounts (from?: number, to?: number): Promise<Map<number, Account>>
        /**
@@ -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<AccountList>} Promise for accounts with updated balances, frontiers, and representatives
+       * @returns {Promise<Map<number, Account>>} Promise for accounts with updated balances, frontiers, and representatives
        */
        refresh (rpc: Rpc | string | URL, from?: number, to?: number): Promise<Map<number, Account>>
        /**