From: Chris Duncan Date: Wed, 20 Aug 2025 21:03:38 +0000 (-0700) Subject: Update type definitions. X-Git-Tag: v0.10.5~41^2~25 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=bdf475affc05c5b32c50ce79a1d7f708c8353577;p=libnemo.git Update type definitions. --- diff --git a/src/types.d.ts b/src/types.d.ts index 0124879..cb070a2 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -18,12 +18,14 @@ export declare class Account { get publicKey (): string get confirmed_balance (): bigint | undefined get confirmed_block_height (): number | undefined - get confirmed_frontier_block (): string | undefined + get confirmed_frontier (): string | undefined + get confirmed_frontier_block (): Block | undefined get confirmed_receivable (): bigint | undefined get confirmed_representative (): Account | undefined get balance (): bigint | undefined get block_height (): number | undefined - get frontier_block (): string | undefined + get frontier (): string | undefined + get frontier_block (): Block | undefined get open_block (): string | undefined get receivable (): bigint | undefined get representative (): Account | undefined @@ -31,12 +33,14 @@ export declare class Account { get weight (): bigint | undefined set confirmed_balance (v: bigint | number | string) set confirmed_block_height (v: number | undefined) - set confirmed_frontier_block (v: string | undefined) + set confirmed_frontier (v: string | undefined) + set confirmed_frontier_block (v: Block | undefined) set confirmed_receivable (v: bigint | number | string) set confirmed_representative (v: unknown) set balance (v: bigint | number | string) set block_height (v: number | undefined) - set frontier_block (v: string | undefined) + set frontier (v: string | undefined) + set frontier_block (v: Block | undefined) set open_block (v: string | undefined) set receivable (v: bigint | number | string) set representative (v: unknown) @@ -122,7 +126,7 @@ export declare class Account { */ refresh (rpc: Rpc | string | URL): Promise /** - * Validates a Nano address with 'nano' and 'xrb' prefixes + * Validates a Nano address with 'nano' and 'xrb' prefixes. * Derived from https://github.com/alecrios/nano-address-validator * * @param {string} address - Nano address to validate @@ -249,6 +253,7 @@ export declare class Blake2b { */ export declare class Block { #private + [key: string]: bigint | string | Account | Function | Uint8Array | 'send' | 'receive' | 'change' | undefined subtype?: 'send' | 'receive' | 'change' account: Account balance: bigint @@ -344,17 +349,6 @@ export declare class Block { */ sign (key: string): Promise /** - * Signs the block using a Ledger hardware wallet. If that fails, an error is - * thrown with the status code from the device. If successful, the result is - * stored in the `signature` property of the block. The wallet must be unlocked - * prior to signing. - * - * @param {number} index - Account index between 0x0 and 0x7fffffff - * @param {object} [frontier] - JSON of frontier block for offline signing - * @returns Block with `signature` value set - */ - sign (index: number, frontier?: Block): Promise - /** * Signs the block using a Wallet. If successful, the result is stored in * the `signature` property of the block. The wallet must be unlocked prior to * signing. @@ -365,6 +359,17 @@ export declare class Block { */ sign (wallet: Wallet, index: number): Promise /** + * Signs the block using a Ledger hardware wallet. If that fails, an error is + * thrown with the status code from the device. If successful, the result is + * stored in the `signature` property of the block. The wallet must be unlocked + * prior to signing. + * + * @param {number} index - Account index between 0x0 and 0x7fffffff + * @param {object} [frontier] - JSON of frontier block for offline signing + * @returns Block with `signature` value set + */ + sign (wallet: Wallet, index: number, frontier?: Block): Promise + /** * Verifies the signature of the block. If a key is not provided, the public * key of the block's account will be used if it exists. * @@ -405,7 +410,7 @@ export type KeyPair = { * saved under one nickname. */ export declare class Rolodex { - static #private + #private /** * Adds an address to the rolodex under a specific nickname. * @@ -514,13 +519,13 @@ export declare function sign (key: Key, ...input: string[]): Promise * 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 {(Wallet|Ledger)} wallet - Wallet from which to sweep funds +* @param {(Wallet)} 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 +* @param {number} [from=0] - Starting account index to sweep +* @param {number} [to=from] - Ending account index to sweep * @returns An array of results including both successes and failures */ -export declare function sweep (rpc: Rpc | string | URL, wallet: Wallet | Ledger, recipient: string, from?: number, to?: number): Promise +export declare function sweep (rpc: Rpc | string | URL, wallet: Wallet, recipient: string, from?: number, to?: number): Promise /** * Verifies the signature of arbitrary strings using a public key. * @@ -555,6 +560,13 @@ export declare class Wallet { */ static backup (): Promise /** + * Creates a new Ledger wallet manager. + * + * @param {string} type - Encrypts the wallet to lock and unlock it + * @returns {Wallet} A newly instantiated Wallet + */ + static create (type: 'Ledger'): Promise + /** * Creates a new HD wallet by using an entropy value generated using a * cryptographically strong pseudorandom number generator. * @@ -562,7 +574,7 @@ export declare class Wallet { * @param {string} [salt=''] - Used when generating the final seed * @returns {Wallet} A newly instantiated Wallet */ - static create (type: 'BIP-44' | 'BLAKE2b', password: string, mnemonicSalt?: string): Promise + static create (type: 'BIP-44' | 'BLAKE2b', password?: string, mnemonicSalt?: string): Promise /** * Imports an existing HD wallet by using an entropy value generated using a * cryptographically strong pseudorandom number generator.NamedD @@ -604,7 +616,7 @@ export declare class Wallet { */ get id (): string /** - * Method used to create wallet and derive accounts. + * Algorithm or device used to create wallet and derive accounts. */ get type (): WalletType /** @@ -668,8 +680,8 @@ export declare class Wallet { * ``` * * If `from` is greater than `to`, their values will be swapped. - * @param {number} from - Start index of accounts. Default: 0 - * @param {number} to - End index of accounts. Default: `from` + * @param {number} [from=0] - Start index of accounts. Default: 0 + * @param {number} [to=from] - End index of accounts. Default: `from` * @returns {AccountList} Promise for a list of Accounts at the specified indexes */ accounts (from?: number, to?: number): Promise @@ -679,7 +691,12 @@ export declare class Wallet { */ destroy (): Promise /** - * Clears the seed and mnemonic from the vault. + * For BIP-44 and BLAKE2b wallets, clears the seed and mnemonic from the vault. + * + * For Ledger hardware wallets, revokes permission granted by the user to + * access the Ledger device. The 'quit app' ADPU command is uncooperative, so + * this is currently the only way to ensure the connection is severed. + * `setTimeout` is used to expire any lingering transient user activation. */ lock (): void /** @@ -688,8 +705,8 @@ 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} Accounts with updated balances, frontiers, and representatives + * @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 */ refresh (rpc: Rpc | string | URL, from?: number, to?: number): Promise /** @@ -698,10 +715,24 @@ export declare class Wallet { * before being returned. The wallet must be unlocked prior to signing. * * @param {number} index - Account to use for signing - * @param {(Block)} block - Block data to be hashed and signed + * @param {Block} block - Block data to be hashed and signed */ sign (index: number, block: Block): Promise /** + * Signs a block using a Ledger hardware wallet at the wallet index specified. + * The signature is appended to the signature field of the block before being + * returned. The wallet must be unlocked prior to signing. + * + * @param {number} index - Account to use for signing + * @param {Block} block - Block data to be hashed and signed + * @param {Block} [frontier] - Previous block data to be cached by Ledger wallet + */ + sign (index: number, block: Block, frontier?: Block): Promise + /** + * Attempts to connect to the Ledger device. + */ + unlock (): Promise + /** * Unlocks the wallet using the same password as used prior to lock it. * * @param {string} password Used previously to lock the wallet