]> git.codecow.com Git - libnemo.git/commitdiff
Update wallet account JSdoc.
authorChris Duncan <chris@zoso.dev>
Mon, 11 Aug 2025 13:12:31 +0000 (06:12 -0700)
committerChris Duncan <chris@zoso.dev>
Mon, 11 Aug 2025 13:12:31 +0000 (06:12 -0700)
src/lib/wallet/index.ts
src/lib/wallet/ledger.ts

index 1762f75637c0d0e1a2c2898a64cee6bd8317c4ea..60d406e5bc7dc0d3d82a600030c07f3270a9cf2a 100644 (file)
@@ -176,17 +176,19 @@ export class Wallet {
        * Retrieves an account from a wallet using its child key derivation function.\r
        * Defaults to the first account at index 0.\r
        *\r
+       * The returned object will have keys corresponding with the requested range\r
+       * of account indexes. The value of each key will be the Account derived for\r
+       * that index in the wallet.\r
+       *\r
        * ```\r
-       * console.log(await wallet.account(5))\r
-       * // outputs sixth account of the wallet\r
-       * // {\r
-       * //   privateKey: <...>,\r
-       * //   index: 5\r
-       * // }\r
+       * const account = await wallet.account(1)\r
+       * // outputs the second account of the wallet\r
+       * console.log(account)\r
+       * // { address:  <...>, publicKey: <...>, index: 1, <etc...> }\r
        * ```\r
        *\r
-       * @param {number} index - Wallet index of secret key. Default: 0\r
-       * @returns {Account} Account derived at the specified wallet index\r
+       * @param {number} index - Wallet index of account. Default: 0\r
+       * @returns Promise for the Account at the specified index\r
        */\r
        async account (index: number = 0): Promise<Account> {\r
                return (await this.accounts(index))[index]\r
@@ -201,19 +203,32 @@ export class Wallet {
        * that index in the wallet.\r
        *\r
        * ```\r
-       * console.log(await wallet.accounts(5))\r
-       * // outputs sixth account of the wallet\r
+       * const accounts = await wallet.accounts(0, 1))\r
+       * // outputs the first and second account of the wallet\r
+       * console.log(accounts)\r
        * // {\r
-       * //   5: {\r
-       * //     privateKey: <...>,\r
-       * //     index: 5\r
-       * //   }\r
+       * //    0: {\r
+       * //            address: <...>,\r
+       * //            publicKey: <...>,\r
+       * //            index: 0,\r
+       * //            <etc...>\r
+       * //    },\r
+       * //    1: {\r
+       * //            address: <...>,\r
+       * //            publicKey: <...>,\r
+       * //            index: 1,\r
+       * //            <etc...>\r
+       * //    }\r
        * // }\r
+       * // individual accounts can be referenced using array index notation\r
+       * console.log(accounts[1])\r
+       * // { address: <...>, publicKey: <...>, index: 1, <etc...> }\r
        * ```\r
        *\r
-       * @param {number} from - Start index of secret keys. Default: 0\r
-       * @param {number} to - End index of secret keys. Default: `from`\r
-       * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts\r
+       * If `from` is greater than `to`, their values will be swapped.\r
+       * @param {number} from - Start index of accounts. Default: 0\r
+       * @param {number} to - End index of accounts. Default: `from`\r
+       * @returns {AccountList} Promise for a list of Accounts at the specified indexes\r
        */\r
        async accounts (from: number = 0, to: number = from): Promise<AccountList> {\r
                if (from > to) [from, to] = [to, from]\r
index 5a608580ee3503a26eae14d2c02421193d7d491b..bfbd9e89b940af2a31ea70e588f51f7a18dd7e88 100644 (file)
@@ -117,10 +117,10 @@ export class Ledger extends Wallet {
        get status (): DeviceStatus { return this.#status }\r
 \r
        /**\r
-       * Gets the public key for an account from the Ledger device.\r
+       * Gets the index and public key for an account from the Ledger device.\r
        *\r
-       * @param {number[]} indexes - Indexes of the accounts\r
-       * @returns {Promise<Account>}\r
+       * @param {number} index - Wallet index of the account\r
+       * @returns Promise for the Account at the index specified\r
        */\r
        async account (index: number): Promise<Account> {\r
                const { status, publicKey } = await Ledger.#account(index)\r
@@ -131,7 +131,7 @@ export class Ledger extends Wallet {
        }\r
 \r
        /**\r
-       * Retrieves accounts from a wallet using its child key derivation function.\r
+       * Retrieves accounts from a Ledger wallet using its internal secure software.\r
        * Defaults to the first account at index 0.\r
        *\r
        * The returned object will have keys corresponding with the requested range\r
@@ -140,20 +140,31 @@ export class Ledger extends Wallet {
        *\r
        * ```\r
        * const accounts = await wallet.accounts(0, 1))\r
-       *\r
        * // outputs the first and second account of the wallet\r
        * console.log(accounts)\r
-       * // { 0: { privateKey: <...>, index: 0 }, 1: { privateKey: <...>, index: 1 } }\r
-       *\r
+       * // {\r
+       * //    0: {\r
+       * //            address: <...>,\r
+       * //            publicKey: <...>,\r
+       * //            index: 0,\r
+       * //            <etc...>\r
+       * //    },\r
+       * //    1: {\r
+       * //            address: <...>,\r
+       * //            publicKey: <...>,\r
+       * //            index: 1,\r
+       * //            <etc...>\r
+       * //    }\r
+       * // }\r
        * // individual accounts can be referenced using array index notation\r
        * console.log(accounts[1])\r
-       * // { privateKey: <...>, index: 1 }\r
+       * // { address: <...>, publicKey: <...>, index: 1, <etc...> }\r
        * ```\r
        *\r
        * If `from` is greater than `to`, their values will be swapped.\r
-       * @param {number} from - Start index of secret keys. Default: 0\r
-       * @param {number} to - End index of secret keys. Default: `from`\r
-       * @returns {AccountList} Object with keys of account indexes and values of the corresponding Accounts\r
+       * @param {number} from - Start index of accounts. Default: 0\r
+       * @param {number} to - End index of accounts. Default: `from`\r
+       * @returns {AccountList} Promise for a list of Accounts at the specified indexes\r
        */\r
        async accounts (from: number = 0, to: number = from): Promise<AccountList> {\r
                if (from > to) [from, to] = [to, from]\r