]> git.codecow.com Git - libnemo.git/commitdiff
Update wallet type definitions.
authorChris Duncan <chris@zoso.dev>
Wed, 6 Aug 2025 19:37:45 +0000 (12:37 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 6 Aug 2025 19:37:45 +0000 (12:37 -0700)
src/types.d.ts

index 6d166281b59ca8fcba6cdbad624eacadd2c51bac..4041d41f39d8c6ec8c7e87c8905fe0ae58259512 100644 (file)
@@ -668,7 +668,7 @@ export declare class Wallet {
        /**
        * Retrieves an existing wallet from the database using its UUID.
        *
-       * @param {string} id - Entered by user when the wallet was initially created
+       * @param {string} id - Generated when the wallet was created or imported
        * @returns {Wallet} Restored locked Wallet
        */
        static restore (id: string): Promise<Wallet>
@@ -678,7 +678,7 @@ export declare class Wallet {
        get mnemonic (): string | undefined
        /** Set when calling `create()` and self-destructs after the first read. */
        get seed (): string | undefined
-       constructor (type: WalletType)
+       constructor (type: WalletType, id?: string)
        /**
        * Retrieves an account from a wallet using its child key derivation function.
        * Defaults to the first account at index 0.
@@ -751,7 +751,17 @@ export declare class Wallet {
        * @param {(Block)} block - Block data to be hashed and signed
        * @returns {Promise<string>} Hexadecimal-formatted 64-byte signature
        */
-       sign (index: number, block: Block): Promise<string>
+       sign (index: number, block: Block): Promise<Uint8Array<ArrayBuffer>>
+       /**
+       * Signs a block using the private key of the account 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
+       * @returns {Promise<string>} Hexadecimal-formatted 64-byte signature
+       */
+       sign (index: number, block: Block, format: 'hex'): Promise<string>
        /**
        * Unlocks the wallet using the same password as used prior to lock it.
        *
@@ -840,6 +850,37 @@ export declare class Ledger extends Wallet {
        get status (): DeviceStatus
        private constructor ()
        /**
+       * Gets the public key for an account from the Ledger device.
+       *
+       * @param {number[]} indexes - Indexes of the accounts
+       * @returns {Promise<Account>}
+       */
+       account (index: number): Promise<Account>
+       /**
+       * Retrieves accounts 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.accounts(5))
+       * // outputs sixth account of the wallet
+       * // {
+       * //   5: {
+       * //     privateKey: <...>,
+       * //     index: 5
+       * //   }
+       * // }
+       * ```
+       *
+       * @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
+       */
+       accounts (from?: number, to?: number): Promise<AccountList>
+       /**
        * Check if the Nano app is currently open and set device status accordingly.
        *
        * @returns Device status as follows:
@@ -873,10 +914,18 @@ export declare class Ledger extends Wallet {
        * Sign a block with the Ledger device.
        *
        * @param {number} index - Account number
-       * @param {Block} block - Block data to sign
+       * @param {object} block - Block data to sign
        * @returns {Promise<string>} Signature
        */
-       sign (index: number, block: Block, frontier?: Block): Promise<string>
+       sign (index: number, block: Block): Promise<Uint8Array<ArrayBuffer>>
+       /**
+       * Sign a block with the Ledger device.
+       *
+       * @param {number} index - Account number
+       * @param {object} block - Block data to sign
+       * @returns {Promise<string>} Signature
+       */
+       sign (index: number, block: Block, format?: 'hex', frontier?: Block): Promise<string>
        /**
        * Attempts to connect to the Ledger device.
        *
@@ -890,7 +939,7 @@ export declare class Ledger extends Wallet {
        * Update cache from raw block data. Suitable for offline use.
        *
        * @param {number} index - Account number
-       * @param {Block} block - JSON-formatted block data
+       * @param {object} block - JSON-formatted block data
        */
        updateCache (index: number, block: Block): Promise<LedgerResponse>
        /**
@@ -928,13 +977,6 @@ export declare class Ledger extends Wallet {
        * @returns Status, process name, and version
        */
        version (): Promise<LedgerVersionResponse>
-       /**
-       * Gets the public key for an account from the Ledger device.
-       *
-       * @param {number[]} indexes - Indexes of the accounts
-       * @returns {Promise<Account>}
-       */
-       ckd (indexes: number[]): Promise<KeyPair[]>
 }
 
 /**