From: Chris Duncan Date: Mon, 11 Aug 2025 13:12:31 +0000 (-0700) Subject: Update wallet account JSdoc. X-Git-Tag: v0.10.5~41^2~121 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=1898b68b013fc1c82cf777348059247726c56da7;p=libnemo.git Update wallet account JSdoc. --- diff --git a/src/lib/wallet/index.ts b/src/lib/wallet/index.ts index 1762f75..60d406e 100644 --- a/src/lib/wallet/index.ts +++ b/src/lib/wallet/index.ts @@ -176,17 +176,19 @@ export class Wallet { * Retrieves an account from a wallet using its child key derivation function. * Defaults to the first account at index 0. * + * The returned object will have keys corresponding with the requested range + * of account indexes. The value of each key will be the Account derived for + * that index in the wallet. + * * ``` - * console.log(await wallet.account(5)) - * // outputs sixth account of the wallet - * // { - * // privateKey: <...>, - * // index: 5 - * // } + * const account = await wallet.account(1) + * // outputs the second account of the wallet + * console.log(account) + * // { address: <...>, publicKey: <...>, index: 1, } * ``` * - * @param {number} index - Wallet index of secret key. Default: 0 - * @returns {Account} Account derived at the specified wallet index + * @param {number} index - Wallet index of account. Default: 0 + * @returns Promise for the Account at the specified index */ async account (index: number = 0): Promise { return (await this.accounts(index))[index] @@ -201,19 +203,32 @@ export class Wallet { * that index in the wallet. * * ``` - * console.log(await wallet.accounts(5)) - * // outputs sixth account of the wallet + * const accounts = await wallet.accounts(0, 1)) + * // outputs the first and second account of the wallet + * console.log(accounts) * // { - * // 5: { - * // privateKey: <...>, - * // index: 5 - * // } + * // 0: { + * // address: <...>, + * // publicKey: <...>, + * // index: 0, + * // + * // }, + * // 1: { + * // address: <...>, + * // publicKey: <...>, + * // index: 1, + * // + * // } * // } + * // individual accounts can be referenced using array index notation + * console.log(accounts[1]) + * // { address: <...>, publicKey: <...>, index: 1, } * ``` * - * @param {number} from - Start index of secret keys. Default: 0 - * @param {number} to - End index of secret keys. Default: `from` - * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts + * 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` + * @returns {AccountList} Promise for a list of Accounts at the specified indexes */ async accounts (from: number = 0, to: number = from): Promise { if (from > to) [from, to] = [to, from] diff --git a/src/lib/wallet/ledger.ts b/src/lib/wallet/ledger.ts index 5a60858..bfbd9e8 100644 --- a/src/lib/wallet/ledger.ts +++ b/src/lib/wallet/ledger.ts @@ -117,10 +117,10 @@ export class Ledger extends Wallet { get status (): DeviceStatus { return this.#status } /** - * Gets the public key for an account from the Ledger device. + * Gets the index and public key for an account from the Ledger device. * - * @param {number[]} indexes - Indexes of the accounts - * @returns {Promise} + * @param {number} index - Wallet index of the account + * @returns Promise for the Account at the index specified */ async account (index: number): Promise { const { status, publicKey } = await Ledger.#account(index) @@ -131,7 +131,7 @@ export class Ledger extends Wallet { } /** - * Retrieves accounts from a wallet using its child key derivation function. + * Retrieves accounts from a Ledger wallet using its internal secure software. * Defaults to the first account at index 0. * * The returned object will have keys corresponding with the requested range @@ -140,20 +140,31 @@ export class Ledger extends Wallet { * * ``` * const accounts = await wallet.accounts(0, 1)) - * * // outputs the first and second account of the wallet * console.log(accounts) - * // { 0: { privateKey: <...>, index: 0 }, 1: { privateKey: <...>, index: 1 } } - * + * // { + * // 0: { + * // address: <...>, + * // publicKey: <...>, + * // index: 0, + * // + * // }, + * // 1: { + * // address: <...>, + * // publicKey: <...>, + * // index: 1, + * // + * // } + * // } * // individual accounts can be referenced using array index notation * console.log(accounts[1]) - * // { privateKey: <...>, index: 1 } + * // { address: <...>, publicKey: <...>, index: 1, } * ``` * * If `from` is greater than `to`, their values will be swapped. - * @param {number} from - Start index of secret keys. Default: 0 - * @param {number} to - End index of secret keys. Default: `from` - * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts + * @param {number} from - Start index of accounts. Default: 0 + * @param {number} to - End index of accounts. Default: `from` + * @returns {AccountList} Promise for a list of Accounts at the specified indexes */ async accounts (from: number = 0, to: number = from): Promise { if (from > to) [from, to] = [to, from]