* @returns Promise for the Account at the specified index\r
*/\r
async account (index: number = 0): Promise<Account> {\r
- return await _accounts(this.type, this.#accounts, this.#vault, index)\r
+ return _accounts(this.type, this.#accounts, this.#vault, index)\r
}\r
\r
/**\r
* @returns {Promise<Map<number, Account>>} Promise for a list of Accounts at the specified indexes\r
*/\r
async accounts (from: number = 0, to: number = from): Promise<Map<number, Account>> {\r
- return await _accounts(this.type, this.#accounts, this.#vault, from, to)\r
+ return _accounts(this.type, this.#accounts, this.#vault, from, to)\r
}\r
\r
/**\r
*/\r
async config (settings: { timeout: number }): Promise<void>\r
async config (settings: { connection: 'hid' | 'ble' | 'usb' } | { timeout: number }): Promise<void> {\r
- return await _config(this.type, this.#vault, settings)\r
+ return _config(this.type, this.#vault, settings)\r
}\r
\r
/**\r
* allow garbage collection, and terminates vault worker.\r
*/\r
async destroy (): Promise<void> {\r
- return await _destroy(this, this.#vault)\r
+ return _destroy(this, this.#vault)\r
}\r
\r
/**\r
* @returns {Promise<Map<number, Account>>} Promise for accounts with updated balances, frontiers, and representatives\r
*/\r
async refresh (rpc: Rpc | string | URL, from: number = 0, to: number = from): Promise<Map<number, Account>> {\r
- return await _refresh(this, rpc, from, to)\r
+ return _refresh(this, rpc, from, to)\r
}\r
\r
/**\r
*\r
* @param {number} index - Account to use for signing\r
* @param {(string|string[])} data - Arbitrary data to be signed\r
+ * @returns {Promise<string>} 128-character hexadecimal detached signature\r
*/\r
async sign (index: number, data: string | string[]): Promise<string>\r
/**\r
* Signs a block using the private key of the account at the wallet index\r
- * specified. The signature is appended to the signature field of the block\r
- * before being returned. The wallet must be unlocked prior to signing.\r
+ * specified. The signature is appended to the signature field of the block,\r
+ * and the block is returned to allow chaining with other Block functions. The\r
+ * wallet must be unlocked prior to signing.\r
*\r
* @param {number} index - Account to use for signing\r
* @param {Block} block - Block data to be hashed and signed\r
+ * @returns {Promise<Block>} Block with signature\r
*/\r
- async sign (index: number, block: Block): Promise<void>\r
+ async sign (index: number, block: Block): Promise<Block>\r
/**\r
* Signs a block using a Ledger hardware wallet at the wallet index specified.\r
- * The signature is appended to the signature field of the block before being\r
- * returned. The wallet must be unlocked prior to signing.\r
+ * The signature is appended to the signature field of the block, and the block\r
+ * is returned to allow chaining with other Block functions. The wallet must be\r
+ * unlocked prior to signing.\r
*\r
* @param {number} index - Account to use for signing\r
* @param {Block} block - Block data to be hashed and signed\r
* @param {Block} [frontier] - Previous block data to be cached by Ledger wallet\r
+ * @returns {Promise<Block>} Block with signature\r
*/\r
- async sign (index: number, block: Block, frontier?: Block): Promise<void>\r
- async sign (index: number, data: string | string[] | Block, frontier?: Block): Promise<void | string> {\r
+ async sign (index: number, block: Block, frontier?: Block): Promise<Block>\r
+ async sign (index: number, data: string | string[] | Block, frontier?: Block): Promise<Block | string> {\r
const { address } = await this.account(index)\r
return data instanceof Block\r
- ? await _signBlock(this, this.#vault, index, address, data, frontier)\r
- : await _signData(this, this.#vault, index, address, data)\r
+ ? _signBlock(this, this.#vault, index, address, data, frontier)\r
+ : _signData(this, this.#vault, index, address, data)\r
}\r
\r
/**\r
* @returns {Promise<Account>} The lowest-indexed unopened account belonging to the wallet\r
*/\r
async unopened (rpc: Rpc, batchSize: number = ADDRESS_GAP, from: number = 0): Promise<Account> {\r
- return await _unopened(this, rpc, batchSize, from)\r
+ return _unopened(this, rpc, batchSize, from)\r
}\r
\r
/**\r
*\r
* @param {string} password Used to re-encrypt the wallet\r
*/\r
- async update (password: string): Promise<void> {\r
+ async update (password: string): Promise<void>\r
+ async update (password?: string): Promise<void> {\r
const pending = _update(this, this.#vault, password)\r
- password = undefined!\r
+ password = undefined\r
await pending\r
}\r
\r
*/\r
async verify (mnemonic: string): Promise<boolean>\r
async verify (secret: string): Promise<boolean> {\r
- return await _verify(this.type, this.#vault, secret)\r
+ return _verify(this.type, this.#vault, secret)\r
}\r
}\r