Skip to content

Commit cf533d6

Browse files
committed
wallet: update client types.
1 parent 3f83d57 commit cf533d6

File tree

5 files changed

+59
-45
lines changed

5 files changed

+59
-45
lines changed

lib/node/spvnode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class SPVNode extends Node {
372372
/**
373373
* Get current name state.
374374
* @param {Buffer} nameHash
375-
* @returns {NameState}
375+
* @returns {Promise<NameState>}
376376
*/
377377

378378
async getNameStatus(nameHash) {

lib/wallet/client.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ class WalletClient extends NodeClient {
114114
return NameState.fromJSON(json);
115115
}
116116

117+
/**
118+
* @param {Hash} hash
119+
* @param {Number} index
120+
* @returns {Promise<Coin>}
121+
*/
122+
117123
async getCoin(hash, index) {
118124
const json = super.getCoin(hash, index);
119125
return Coin.fromJSON(json);

lib/wallet/migrations.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const {
3535
const layouts = require('./layout');
3636
const wlayout = layouts.wdb;
3737

38-
/** @typedef {import('../migrations/migrator').MigrationType} MigrationType */
38+
/** @typedef {import('../migrations/migrator').types} MigrationType */
3939
/** @typedef {ReturnType<bdb.DB['batch']>} Batch */
4040
/** @typedef {ReturnType<bdb.DB['bucket']>} Bucket */
4141
/** @typedef {import('./walletdb')} WalletDB */
@@ -166,7 +166,7 @@ class MigrateChangeAddress extends AbstractMigration {
166166
/**
167167
* Actual migration
168168
* @param {Batch} b
169-
* @param {WalletMigrationResult} pending
169+
* @param {WalletMigrationResult} [pending]
170170
* @returns {Promise}
171171
*/
172172

@@ -520,7 +520,7 @@ class MigrateTXDBBalances extends AbstractMigration {
520520
/**
521521
* Actual migration
522522
* @param {Batch} b
523-
* @param {WalletMigrationResult} pending
523+
* @param {WalletMigrationResult} [pending]
524524
* @returns {Promise}
525525
*/
526526

@@ -1458,7 +1458,7 @@ class WalletMigratorOptions {
14581458

14591459
function fromU32(num) {
14601460
const data = Buffer.allocUnsafe(4);
1461-
data.writeUInt32LE(num, 0, true);
1461+
data.writeUInt32LE(num, 0);
14621462
return data;
14631463
}
14641464

lib/wallet/nodeclient.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ const assert = require('bsert');
1010
const blacklist = require('bsock/lib/blacklist');
1111
const AsyncEmitter = require('bevent');
1212

13-
/** @typedef {import('../node/node')} Node */
13+
/** @typedef {import('@handshake-org/bfilter').BloomFilter} BloomFilter */
14+
/** @typedef {import('../types').Hash} Hash */
15+
/** @typedef {import('../primitives/tx')} TX */
16+
/** @typedef {import('../primitives/claim')} Claim */
17+
/** @typedef {import('../covenants/namestate')} NameState */
18+
/** @typedef {import('../blockchain/chainentry')} ChainEntry */
19+
/** @typedef {import('../node/fullnode')} FullNode */
20+
/** @typedef {import('../node/spvnode')} SPVNode */
21+
/** @typedef {FullNode|SPVNode} Node */
1422

1523
/**
1624
* Node Client
@@ -73,7 +81,7 @@ class NodeClient extends AsyncEmitter {
7381

7482
/**
7583
* Open the client.
76-
* @returns {Promise}
84+
* @returns {Promise<void>}
7785
*/
7886

7987
async open() {
@@ -84,7 +92,7 @@ class NodeClient extends AsyncEmitter {
8492

8593
/**
8694
* Close the client.
87-
* @returns {Promise}
95+
* @returns {Promise<void>}
8896
*/
8997

9098
async close() {
@@ -148,7 +156,7 @@ class NodeClient extends AsyncEmitter {
148156

149157
/**
150158
* Get chain tip.
151-
* @returns {Promise}
159+
* @returns {Promise<ChainEntry>}
152160
*/
153161

154162
async getTip() {
@@ -158,7 +166,7 @@ class NodeClient extends AsyncEmitter {
158166
/**
159167
* Get chain entry.
160168
* @param {Hash} hash
161-
* @returns {Promise}
169+
* @returns {Promise<ChainEntry?>}
162170
*/
163171

164172
async getEntry(hash) {
@@ -176,7 +184,7 @@ class NodeClient extends AsyncEmitter {
176184
/**
177185
* Send a transaction. Do not wait for promise.
178186
* @param {TX} tx
179-
* @returns {Promise}
187+
* @returns {Promise<void>}
180188
*/
181189

182190
async send(tx) {
@@ -186,7 +194,7 @@ class NodeClient extends AsyncEmitter {
186194
/**
187195
* Send a claim. Do not wait for promise.
188196
* @param {Claim} claim
189-
* @returns {Promise}
197+
* @returns {Promise<void>}
190198
*/
191199

192200
async sendClaim(claim) {
@@ -195,8 +203,8 @@ class NodeClient extends AsyncEmitter {
195203

196204
/**
197205
* Set bloom filter.
198-
* @param {Bloom} filter
199-
* @returns {Promise}
206+
* @param {BloomFilter} filter
207+
* @returns {Promise<void>}
200208
*/
201209

202210
async setFilter(filter) {
@@ -207,7 +215,7 @@ class NodeClient extends AsyncEmitter {
207215
/**
208216
* Add data to filter.
209217
* @param {Buffer} data
210-
* @returns {Promise}
218+
* @returns {Promise<void>}
211219
*/
212220

213221
async addFilter(data) {
@@ -220,7 +228,7 @@ class NodeClient extends AsyncEmitter {
220228

221229
/**
222230
* Reset filter.
223-
* @returns {Promise}
231+
* @returns {Promise<void>}
224232
*/
225233

226234
async resetFilter() {
@@ -230,7 +238,7 @@ class NodeClient extends AsyncEmitter {
230238
/**
231239
* Esimate smart fee.
232240
* @param {Number?} blocks
233-
* @returns {Promise}
241+
* @returns {Promise<Number>}
234242
*/
235243

236244
async estimateFee(blocks) {
@@ -244,7 +252,7 @@ class NodeClient extends AsyncEmitter {
244252
* Get hash range.
245253
* @param {Number} start
246254
* @param {Number} end
247-
* @returns {Promise}
255+
* @returns {Promise<Hash[]>}
248256
*/
249257

250258
async getHashes(start = -1, end = -1) {
@@ -265,7 +273,7 @@ class NodeClient extends AsyncEmitter {
265273
/**
266274
* Rescan for any missed transactions.
267275
* @param {Number|Hash} start - Start block.
268-
* @returns {Promise}
276+
* @returns {Promise<void>}
269277
*/
270278

271279
async rescan(start) {
@@ -281,7 +289,7 @@ class NodeClient extends AsyncEmitter {
281289
* Rescan interactive for any missed transactions.
282290
* @param {Number|Hash} start - Start block.
283291
* @param {Boolean} [fullLock=false]
284-
* @returns {Promise}
292+
* @returns {Promise<void>}
285293
*/
286294

287295
async rescanInteractive(start, fullLock = true) {
@@ -308,7 +316,7 @@ class NodeClient extends AsyncEmitter {
308316
/**
309317
* Get name state.
310318
* @param {Buffer} nameHash
311-
* @returns {Object}
319+
* @returns {Promise<NameState>}
312320
*/
313321

314322
async getNameStatus(nameHash) {

0 commit comments

Comments
 (0)