From 501f529504c79f240be7fe96acf87bb0ccc56d52 Mon Sep 17 00:00:00 2001 From: Nodari Chkuaselidze Date: Mon, 18 Dec 2023 21:25:49 +0400 Subject: [PATCH] wallet-client: add options to the getNames. --- CHANGELOG.md | 4 +++- lib/client/wallet.js | 27 +++++++++++++++++++++++---- test/util/node-context.js | 9 +++++++++ test/wallet-http-test.js | 4 +--- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea54c913c..96a52e3b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,11 +61,13 @@ process and allows parallel rescans. - `open()` no longer calls scan, instead only rollbacks and waits for sync to do the rescan. - emits events for: `open`, `close`, `connect`, `disconnect`, `sync done`. -- HTTP Changes: + +### Wallet HTTP Client - All transaction creating endpoints now accept `hardFee` for specifying the exact fee. - All transaction sending endpoints now fundlock/queue tx creation. (no more conflicting transactions) + - Add options to `getNames` for passing `own`. ## v6.0.0 diff --git a/lib/client/wallet.js b/lib/client/wallet.js index 3ae11d8e4..1a027ce45 100644 --- a/lib/client/wallet.js +++ b/lib/client/wallet.js @@ -118,6 +118,9 @@ class WalletClient extends Client { /** * Create a wallet object. + * @param {String} id + * @param {String} [token] + * @returns {Wallet} */ wallet(id, token) { @@ -339,11 +342,13 @@ class WalletClient extends Client { * that the wallet is managing. * {@see hsd.NameState} * @param {String} id + * @param {Object} options + * @param {Boolean} [optoins.own=false] * @returns {Promise} */ - getNames(id) { - return this.get(`/wallet/${id}/name`); + getNames(id, options) { + return this.get(`/wallet/${id}/name`, options); } /** @@ -893,6 +898,18 @@ class WalletClient extends Client { */ class Wallet extends EventEmitter { + /** @type {WalletClient} */ + client; + + /** @type {WalletClient} */ + parent; + + /** @type {String} */ + id; + + /** @type {String} */ + token; + /** * Create a wallet client. * @param {Object?} options @@ -1051,11 +1068,13 @@ class Wallet extends EventEmitter { * Get name state for all names * that the wallet is managing. * {@see hsd.NameState} + * @param {Object} options + * @param {Boolean} [optoins.own=false] * @returns {Promise} */ - getNames() { - return this.client.getNames(this.id); + getNames(options) { + return this.client.getNames(this.id, options); } /** diff --git a/test/util/node-context.js b/test/util/node-context.js index fce35076c..c0a49db1c 100644 --- a/test/util/node-context.js +++ b/test/util/node-context.js @@ -11,6 +11,15 @@ const {NodeClient, WalletClient} = require('../../lib/client'); const Logger = require('blgr'); class NodeContext { + /** @type {FullNode|SPVNode} */ + node; + + /** @type {WalletClient} */ + wclient; + + /** @type {NodeClient} */ + nclient; + constructor(options = {}) { this.name = 'node-test'; this.options = {}; diff --git a/test/wallet-http-test.js b/test/wallet-http-test.js index 6f1dd4d92..ea0a3d266 100644 --- a/test/wallet-http-test.js +++ b/test/wallet-http-test.js @@ -1787,9 +1787,7 @@ describe('Wallet HTTP', function() { }); it('should only get wallet-owned names', async () => { - // TODO: convert to using hs-client method - // when wallet.getNames() allows `options` - const names = await wallet.client.get(`/wallet/${wallet.id}/name`, {own: true}); + const names = await wallet.getNames({ own: true }); assert.equal(names.length, ownedNames.length);