@human-protocol/sdk 3.0.7 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/constants.d.ts +2 -25
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +25 -66
  4. package/dist/decorators.js +1 -1
  5. package/dist/encryption.d.ts +21 -29
  6. package/dist/encryption.d.ts.map +1 -1
  7. package/dist/encryption.js +34 -36
  8. package/dist/error.d.ts +31 -28
  9. package/dist/error.d.ts.map +1 -1
  10. package/dist/error.js +36 -33
  11. package/dist/escrow.d.ts +118 -112
  12. package/dist/escrow.d.ts.map +1 -1
  13. package/dist/escrow.js +254 -180
  14. package/dist/graphql/queries/operator.d.ts.map +1 -1
  15. package/dist/graphql/queries/operator.js +15 -7
  16. package/dist/graphql/queries/statistics.d.ts.map +1 -1
  17. package/dist/graphql/queries/statistics.js +0 -2
  18. package/dist/graphql/queries/transaction.d.ts.map +1 -1
  19. package/dist/graphql/queries/transaction.js +23 -10
  20. package/dist/graphql/types.d.ts +0 -2
  21. package/dist/graphql/types.d.ts.map +1 -1
  22. package/dist/interfaces.d.ts +29 -12
  23. package/dist/interfaces.d.ts.map +1 -1
  24. package/dist/kvstore.d.ts +16 -16
  25. package/dist/kvstore.d.ts.map +1 -1
  26. package/dist/kvstore.js +16 -16
  27. package/dist/operator.d.ts +11 -10
  28. package/dist/operator.d.ts.map +1 -1
  29. package/dist/operator.js +36 -11
  30. package/dist/staking.d.ts +26 -118
  31. package/dist/staking.d.ts.map +1 -1
  32. package/dist/staking.js +46 -173
  33. package/dist/statistics.d.ts +10 -29
  34. package/dist/statistics.d.ts.map +1 -1
  35. package/dist/statistics.js +13 -30
  36. package/dist/storage.d.ts +13 -18
  37. package/dist/storage.d.ts.map +1 -1
  38. package/dist/storage.js +30 -25
  39. package/dist/transaction.js +1 -1
  40. package/dist/types.d.ts +23 -6
  41. package/dist/types.d.ts.map +1 -1
  42. package/dist/types.js +1 -1
  43. package/dist/utils.d.ts +0 -1
  44. package/dist/utils.d.ts.map +1 -1
  45. package/dist/utils.js +0 -1
  46. package/package.json +8 -4
  47. package/src/constants.ts +25 -66
  48. package/src/decorators.ts +1 -1
  49. package/src/encryption.ts +21 -29
  50. package/src/error.ts +39 -37
  51. package/src/escrow.ts +360 -216
  52. package/src/graphql/queries/operator.ts +15 -7
  53. package/src/graphql/queries/statistics.ts +0 -2
  54. package/src/graphql/queries/transaction.ts +23 -13
  55. package/src/graphql/types.ts +0 -2
  56. package/src/interfaces.ts +30 -13
  57. package/src/kvstore.ts +17 -17
  58. package/src/operator.ts +47 -12
  59. package/src/staking.ts +53 -187
  60. package/src/statistics.ts +13 -30
  61. package/src/storage.ts +13 -18
  62. package/src/transaction.ts +2 -2
  63. package/src/types.ts +24 -6
  64. package/src/utils.ts +0 -1
package/dist/staking.js CHANGED
@@ -20,19 +20,19 @@ const utils_1 = require("./utils");
20
20
  /**
21
21
  * ## Introduction
22
22
  *
23
- * This client enables to perform actions on staking contracts and obtain staking information from both the contracts and subgraph.
23
+ * This client enables performing actions on staking contracts and obtaining staking information from both the contracts and subgraph.
24
24
  *
25
25
  * Internally, the SDK will use one network or another according to the network ID of the `runner`.
26
26
  * To use this client, it is recommended to initialize it using the static `build` method.
27
27
  *
28
28
  * ```ts
29
- * static async build(runner: ContractRunner);
29
+ * static async build(runner: ContractRunner): Promise<StakingClient>;
30
30
  * ```
31
31
  *
32
32
  * A `Signer` or a `Provider` should be passed depending on the use case of this module:
33
33
  *
34
- * - **Signer**: when the user wants to use this model in order to send transactions caling the contract functions.
35
- * - **Provider**: when the user wants to use this model in order to get information from the contracts or subgraph.
34
+ * - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
35
+ * - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
36
36
  *
37
37
  * ## Installation
38
38
  *
@@ -50,21 +50,21 @@ const utils_1 = require("./utils");
50
50
  *
51
51
  * ### Signer
52
52
  *
53
- * **Using private key(backend)**
53
+ * **Using private key (backend)**
54
54
  *
55
55
  * ```ts
56
56
  * import { StakingClient } from '@human-protocol/sdk';
57
57
  * import { Wallet, providers } from 'ethers';
58
58
  *
59
59
  * const rpcUrl = 'YOUR_RPC_URL';
60
- * const privateKey = 'YOUR_PRIVATE_KEY'
60
+ * const privateKey = 'YOUR_PRIVATE_KEY';
61
61
  *
62
62
  * const provider = new providers.JsonRpcProvider(rpcUrl);
63
63
  * const signer = new Wallet(privateKey, provider);
64
64
  * const stakingClient = await StakingClient.build(signer);
65
65
  * ```
66
66
  *
67
- * **Using Wagmi(frontend)**
67
+ * **Using Wagmi (frontend)**
68
68
  *
69
69
  * ```ts
70
70
  * import { useSigner, useChainId } from 'wagmi';
@@ -91,20 +91,18 @@ class StakingClient extends base_1.BaseEthersClient {
91
91
  * **StakingClient constructor**
92
92
  *
93
93
  * @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
94
- * @param {NetworkData} network - The network information required to connect to the Staking contract
94
+ * @param {NetworkData} networkData - The network information required to connect to the Staking contract
95
95
  */
96
96
  constructor(runner, networkData) {
97
97
  super(runner, networkData);
98
98
  this.stakingContract = typechain_types_1.Staking__factory.connect(networkData.stakingAddress, runner);
99
99
  this.escrowFactoryContract = typechain_types_1.EscrowFactory__factory.connect(networkData.factoryAddress, runner);
100
100
  this.tokenContract = typechain_types_1.HMToken__factory.connect(networkData.hmtAddress, runner);
101
- this.rewardPoolContract = typechain_types_1.RewardPool__factory.connect(networkData.rewardPoolAddress, this.runner);
102
101
  }
103
102
  /**
104
103
  * Creates an instance of StakingClient from a Runner.
105
104
  *
106
105
  * @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
107
- * @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
108
106
  *
109
107
  * @returns {Promise<StakingClient>} - An instance of StakingClient
110
108
  * @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
@@ -142,7 +140,6 @@ class StakingClient extends base_1.BaseEthersClient {
142
140
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
143
141
  * @returns Returns void if successful. Throws error if any.
144
142
  *
145
- *
146
143
  * **Code example**
147
144
  *
148
145
  * ```ts
@@ -150,7 +147,7 @@ class StakingClient extends base_1.BaseEthersClient {
150
147
  * import { StakingClient } from '@human-protocol/sdk';
151
148
  *
152
149
  * const rpcUrl = 'YOUR_RPC_URL';
153
- * const privateKey = 'YOUR_PRIVATE_KEY'
150
+ * const privateKey = 'YOUR_PRIVATE_KEY';
154
151
  *
155
152
  * const provider = new providers.JsonRpcProvider(rpcUrl);
156
153
  * const signer = new Wallet(privateKey, provider);
@@ -184,7 +181,6 @@ class StakingClient extends base_1.BaseEthersClient {
184
181
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
185
182
  * @returns Returns void if successful. Throws error if any.
186
183
  *
187
- *
188
184
  * **Code example**
189
185
  *
190
186
  * ```ts
@@ -192,7 +188,7 @@ class StakingClient extends base_1.BaseEthersClient {
192
188
  * import { StakingClient } from '@human-protocol/sdk';
193
189
  *
194
190
  * const rpcUrl = 'YOUR_RPC_URL';
195
- * const privateKey = 'YOUR_PRIVATE_KEY'
191
+ * const privateKey = 'YOUR_PRIVATE_KEY';
196
192
  *
197
193
  * const provider = new providers.JsonRpcProvider(rpcUrl);
198
194
  * const signer = new Wallet(privateKey, provider);
@@ -200,7 +196,7 @@ class StakingClient extends base_1.BaseEthersClient {
200
196
  *
201
197
  * const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
202
198
  * await stakingClient.approveStake(amount); // if it was already approved before, this is not necessary
203
- * await stakingClient.approveStake(amount);
199
+ * await stakingClient.stake(amount);
204
200
  * ```
205
201
  */
206
202
  async stake(amount, txOptions = {}) {
@@ -227,7 +223,6 @@ class StakingClient extends base_1.BaseEthersClient {
227
223
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
228
224
  * @returns Returns void if successful. Throws error if any.
229
225
  *
230
- *
231
226
  * **Code example**
232
227
  *
233
228
  * ```ts
@@ -235,7 +230,7 @@ class StakingClient extends base_1.BaseEthersClient {
235
230
  * import { StakingClient } from '@human-protocol/sdk';
236
231
  *
237
232
  * const rpcUrl = 'YOUR_RPC_URL';
238
- * const privateKey = 'YOUR_PRIVATE_KEY'
233
+ * const privateKey = 'YOUR_PRIVATE_KEY';
239
234
  *
240
235
  * const provider = new providers.JsonRpcProvider(rpcUrl);
241
236
  * const signer = new Wallet(privateKey, provider);
@@ -261,14 +256,13 @@ class StakingClient extends base_1.BaseEthersClient {
261
256
  }
262
257
  }
263
258
  /**
264
- * This function withdraws unstaked and non locked tokens form staking contract to the user wallet.
259
+ * This function withdraws unstaked and non-locked tokens from staking contract to the user wallet.
265
260
  *
266
261
  * > Must have tokens available to withdraw
267
262
  *
268
263
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
269
264
  * @returns Returns void if successful. Throws error if any.
270
265
  *
271
- *
272
266
  * **Code example**
273
267
  *
274
268
  * ```ts
@@ -276,7 +270,7 @@ class StakingClient extends base_1.BaseEthersClient {
276
270
  * import { StakingClient } from '@human-protocol/sdk';
277
271
  *
278
272
  * const rpcUrl = 'YOUR_RPC_URL';
279
- * const privateKey = 'YOUR_PRIVATE_KEY'
273
+ * const privateKey = 'YOUR_PRIVATE_KEY';
280
274
  *
281
275
  * const provider = new providers.JsonRpcProvider(rpcUrl);
282
276
  * const signer = new Wallet(privateKey, provider);
@@ -295,16 +289,15 @@ class StakingClient extends base_1.BaseEthersClient {
295
289
  }
296
290
  }
297
291
  /**
298
- * This function reduces the allocated amount by an staker in an escrow and transfers those tokens to the reward pool. This allows the slasher to claim them later.
292
+ * This function reduces the allocated amount by a staker in an escrow and transfers those tokens to the reward pool. This allows the slasher to claim them later.
299
293
  *
300
294
  * @param {string} slasher Wallet address from who requested the slash
301
295
  * @param {string} staker Wallet address from who is going to be slashed
302
- * @param {string} escrowAddress Address of the escrow which allocation will be slashed
296
+ * @param {string} escrowAddress Address of the escrow that the slash is made
297
+ * @param {bigint} amount Amount in WEI of tokens to slash.
303
298
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
304
- * @param {bigint} amount Amount in WEI of tokens to unstake.
305
299
  * @returns Returns void if successful. Throws error if any.
306
300
  *
307
- *
308
301
  * **Code example**
309
302
  *
310
303
  * ```ts
@@ -312,7 +305,7 @@ class StakingClient extends base_1.BaseEthersClient {
312
305
  * import { StakingClient } from '@human-protocol/sdk';
313
306
  *
314
307
  * const rpcUrl = 'YOUR_RPC_URL';
315
- * const privateKey = 'YOUR_PRIVATE_KEY'
308
+ * const privateKey = 'YOUR_PRIVATE_KEY';
316
309
  *
317
310
  * const provider = new providers.JsonRpcProvider(rpcUrl);
318
311
  * const signer = new Wallet(privateKey, provider);
@@ -345,151 +338,49 @@ class StakingClient extends base_1.BaseEthersClient {
345
338
  }
346
339
  }
347
340
  /**
348
- * This function allocates a portion of the staked tokens to a specific escrow.
349
- *
350
- * > Must have tokens staked
351
- *
352
- * @param {string} escrowAddress Address of the escrow contract to allocate in.
353
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
354
- * @param {bigint} amount Amount in WEI of tokens to allocate.
355
- * @returns Returns void if successful. Throws error if any.
356
- *
357
- *
358
- * **Code example**
359
- *
360
- * ```ts
361
- * import { ethers, Wallet, providers } from 'ethers';
362
- * import { StakingClient } from '@human-protocol/sdk';
363
- *
364
- * const rpcUrl = 'YOUR_RPC_URL';
365
- * const privateKey = 'YOUR_PRIVATE_KEY'
366
- *
367
- * const provider = new providers.JsonRpcProvider(rpcUrl);
368
- * const signer = new Wallet(privateKey, provider);
369
- * const stakingClient = await StakingClient.build(signer);
370
- *
371
- * const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
372
- * await stakingClient.allocate('0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
373
- * ```
374
- */
375
- async allocate(escrowAddress, amount, txOptions = {}) {
376
- if (typeof amount !== 'bigint') {
377
- throw error_1.ErrorInvalidStakingValueType;
378
- }
379
- if (amount < 0n) {
380
- throw error_1.ErrorInvalidStakingValueSign;
381
- }
382
- await this.checkValidEscrow(escrowAddress);
383
- try {
384
- await (await this.stakingContract.allocate(escrowAddress, amount, txOptions)).wait();
385
- return;
386
- }
387
- catch (e) {
388
- return (0, utils_1.throwError)(e);
389
- }
390
- }
391
- /**
392
- * This function drops the allocation from a specific escrow.
393
- *
394
- * > The escrow must have allocation
395
- * > The escrow must be cancelled or completed.
396
- *
397
- * @param {string} escrowAddress Address of the escrow contract to close allocation from.
398
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
399
- * @returns Returns void if successful. Throws error if any.
400
- *
401
- *
402
- * **Code example**
403
- *
404
- * ```ts
405
- * import { Wallet, providers } from 'ethers';
406
- * import { StakingClient } from '@human-protocol/sdk';
407
- *
408
- * const rpcUrl = 'YOUR_RPC_URL';
409
- * const privateKey = 'YOUR_PRIVATE_KEY'
410
- *
411
- * const provider = new providers.JsonRpcProvider(rpcUrl);
412
- * const signer = new Wallet(privateKey, provider);
413
- * const stakingClient = await StakingClient.build(signer);
414
- *
415
- * await stakingClient.closeAllocation('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
416
- * ```
417
- */
418
- async closeAllocation(escrowAddress, txOptions = {}) {
419
- await this.checkValidEscrow(escrowAddress);
420
- try {
421
- await (await this.stakingContract.closeAllocation(escrowAddress, txOptions)).wait();
422
- return;
423
- }
424
- catch (e) {
425
- return (0, utils_1.throwError)(e);
426
- }
427
- }
428
- /**
429
- * This function drops the allocation from a specific escrow.
430
- *
431
- * > The escrow must have rewards added
432
- *
433
- * @param {string} escrowAddress Escrow address from which rewards are distributed.
434
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
435
- * @returns Returns void if successful. Throws error if any.
436
- *
437
- *
438
- * **Code example**
439
- *
440
- * ```ts
441
- * import { Wallet, providers } from 'ethers';
442
- * import { StakingClient } from '@human-protocol/sdk';
443
- *
444
- * const rpcUrl = 'YOUR_RPC_URL';
445
- * const privateKey = 'YOUR_PRIVATE_KEY'
446
- *
447
- * const provider = new providers.JsonRpcProvider(rpcUrl);
448
- * const signer = new Wallet(privateKey, provider);
449
- * const stakingClient = await StakingClient.build(signer);
450
- *
451
- * await stakingClient.distributeReward('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
452
- * ```
453
- */
454
- async distributeReward(escrowAddress, txOptions = {}) {
455
- await this.checkValidEscrow(escrowAddress);
456
- try {
457
- (await this.rewardPoolContract.distributeReward(escrowAddress, txOptions)).wait();
458
- return;
459
- }
460
- catch (e) {
461
- return (0, utils_1.throwError)(e);
462
- }
463
- }
464
- /**
465
- * This function returns information about the allocation of the specified escrow.
466
- *
467
- * @param {string} escrowAddress Escrow address from which we want to get allocation information.
468
- * @returns {IAllocation} Returns allocation info if exists.
341
+ * Retrieves comprehensive staking information for a staker.
469
342
  *
343
+ * @param {string} stakerAddress - The address of the staker.
344
+ * @returns {Promise<StakerInfo>}
470
345
  *
471
346
  * **Code example**
472
347
  *
473
348
  * ```ts
474
349
  * import { StakingClient } from '@human-protocol/sdk';
475
- * import { providers } from 'ethers';
476
350
  *
477
351
  * const rpcUrl = 'YOUR_RPC_URL';
478
352
  *
479
353
  * const provider = new providers.JsonRpcProvider(rpcUrl);
480
354
  * const stakingClient = await StakingClient.build(provider);
481
355
  *
482
- * const allocationInfo = await stakingClient.getAllocation('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
356
+ * const stakingInfo = await stakingClient.getStakerInfo('0xYourStakerAddress');
357
+ * console.log(stakingInfo.tokensStaked);
483
358
  * ```
484
359
  */
485
- async getAllocation(escrowAddress) {
486
- await this.checkValidEscrow(escrowAddress);
487
- try {
488
- const result = await this.stakingContract.getAllocation(escrowAddress);
489
- return result;
360
+ async getStakerInfo(stakerAddress) {
361
+ if (!ethers_1.ethers.isAddress(stakerAddress)) {
362
+ throw error_1.ErrorInvalidStakerAddressProvided;
490
363
  }
491
- catch (e) {
492
- return (0, utils_1.throwError)(e);
364
+ try {
365
+ const stakerInfo = await this.stakingContract.stakes(stakerAddress);
366
+ const currentBlock = await this.runner.provider.getBlockNumber();
367
+ const tokensWithdrawable = stakerInfo.tokensLockedUntil !== 0n &&
368
+ currentBlock >= stakerInfo.tokensLockedUntil
369
+ ? stakerInfo.tokensLocked
370
+ : 0n;
371
+ const adjustedLockedAmount = stakerInfo.tokensLockedUntil !== 0n &&
372
+ currentBlock >= stakerInfo.tokensLockedUntil
373
+ ? 0n
374
+ : stakerInfo.tokensLocked;
375
+ return {
376
+ stakedAmount: stakerInfo.tokensStaked,
377
+ lockedAmount: adjustedLockedAmount,
378
+ lockedUntil: adjustedLockedAmount === 0n ? 0n : stakerInfo.tokensLockedUntil,
379
+ withdrawableAmount: tokensWithdrawable,
380
+ };
381
+ }
382
+ catch (error) {
383
+ return (0, utils_1.throwError)(error);
493
384
  }
494
385
  }
495
386
  }
@@ -524,21 +415,3 @@ __decorate([
524
415
  __metadata("design:paramtypes", [String, String, String, BigInt, Object]),
525
416
  __metadata("design:returntype", Promise)
526
417
  ], StakingClient.prototype, "slash", null);
527
- __decorate([
528
- decorators_1.requiresSigner,
529
- __metadata("design:type", Function),
530
- __metadata("design:paramtypes", [String, BigInt, Object]),
531
- __metadata("design:returntype", Promise)
532
- ], StakingClient.prototype, "allocate", null);
533
- __decorate([
534
- decorators_1.requiresSigner,
535
- __metadata("design:type", Function),
536
- __metadata("design:paramtypes", [String, Object]),
537
- __metadata("design:returntype", Promise)
538
- ], StakingClient.prototype, "closeAllocation", null);
539
- __decorate([
540
- decorators_1.requiresSigner,
541
- __metadata("design:type", Function),
542
- __metadata("design:paramtypes", [String, Object]),
543
- __metadata("design:returntype", Promise)
544
- ], StakingClient.prototype, "distributeReward", null);
@@ -4,20 +4,15 @@ import { NetworkData } from './types';
4
4
  /**
5
5
  * ## Introduction
6
6
  *
7
- * This client enables to obtain statistical information from the subgraph.
7
+ * This client enables obtaining statistical information from the subgraph.
8
8
  *
9
- * Unlikely from the other SDK clients, `StatisticsClient` does not require `signer` or `provider` to be provided.
10
- * We just need to create client object using relevant network data.
9
+ * Unlike other SDK clients, `StatisticsClient` does not require `signer` or `provider` to be provided.
10
+ * We just need to create a client object using relevant network data.
11
11
  *
12
12
  * ```ts
13
13
  * constructor(network: NetworkData)
14
14
  * ```
15
15
  *
16
- * A `Signer` or a `Provider` should be passed depending on the use case of this module:
17
- *
18
- * - **Signer**: when the user wants to use this model in order to send transactions caling the contract functions.
19
- * - **Provider**: when the user wants to use this model in order to get information from the contracts or subgraph.
20
- *
21
16
  * ## Installation
22
17
  *
23
18
  * ### npm
@@ -50,7 +45,6 @@ export declare class StatisticsClient {
50
45
  /**
51
46
  * This function returns the statistical data of escrows.
52
47
  *
53
- *
54
48
  * **Input parameters**
55
49
  *
56
50
  * ```ts
@@ -79,10 +73,8 @@ export declare class StatisticsClient {
79
73
  * };
80
74
  * ```
81
75
  *
82
- *
83
76
  * @param {IStatisticsFilter} filter Statistics params with duration data
84
- * @returns {EscrowStatistics} Escrow statistics data.
85
- *
77
+ * @returns {Promise<EscrowStatistics>} Escrow statistics data.
86
78
  *
87
79
  * **Code example**
88
80
  *
@@ -102,7 +94,6 @@ export declare class StatisticsClient {
102
94
  /**
103
95
  * This function returns the statistical data of workers.
104
96
  *
105
- *
106
97
  * **Input parameters**
107
98
  *
108
99
  * ```ts
@@ -126,10 +117,8 @@ export declare class StatisticsClient {
126
117
  * };
127
118
  * ```
128
119
  *
129
- *
130
120
  * @param {IStatisticsFilter} filter Statistics params with duration data
131
- * @returns {WorkerStatistics} Worker statistics data.
132
- *
121
+ * @returns {Promise<WorkerStatistics>} Worker statistics data.
133
122
  *
134
123
  * **Code example**
135
124
  *
@@ -149,7 +138,6 @@ export declare class StatisticsClient {
149
138
  /**
150
139
  * This function returns the statistical data of payments.
151
140
  *
152
- *
153
141
  * **Input parameters**
154
142
  *
155
143
  * ```ts
@@ -175,10 +163,8 @@ export declare class StatisticsClient {
175
163
  * };
176
164
  * ```
177
165
  *
178
- *
179
166
  * @param {IStatisticsFilter} filter Statistics params with duration data
180
- * @returns {PaymentStatistics} Payment statistics data.
181
- *
167
+ * @returns {Promise<PaymentStatistics>} Payment statistics data.
182
168
  *
183
169
  * **Code example**
184
170
  *
@@ -219,7 +205,7 @@ export declare class StatisticsClient {
219
205
  /**
220
206
  * This function returns the statistical data of HMToken.
221
207
  *
222
- *
208
+ * ```ts
223
209
  * type HMTStatistics = {
224
210
  * totalTransferAmount: BigNumber;
225
211
  * totalTransferCount: BigNumber;
@@ -227,9 +213,7 @@ export declare class StatisticsClient {
227
213
  * };
228
214
  * ```
229
215
  *
230
- *
231
- * @returns {HMTStatistics} HMToken statistics data.
232
- *
216
+ * @returns {Promise<HMTStatistics>} HMToken statistics data.
233
217
  *
234
218
  * **Code example**
235
219
  *
@@ -253,7 +237,7 @@ export declare class StatisticsClient {
253
237
  * **Input parameters**
254
238
  *
255
239
  * @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
256
- * @returns {HMTHolder[]} List of HMToken holders.
240
+ * @returns {Promise<HMTHolder[]>} List of HMToken holders.
257
241
  *
258
242
  * **Code example**
259
243
  *
@@ -276,7 +260,6 @@ export declare class StatisticsClient {
276
260
  /**
277
261
  * This function returns the statistical data of HMToken day by day.
278
262
  *
279
- *
280
263
  * **Input parameters**
281
264
  *
282
265
  * ```ts
@@ -299,10 +282,8 @@ export declare class StatisticsClient {
299
282
  * }
300
283
  * ```
301
284
  *
302
- *
303
285
  * @param {IStatisticsFilter} filter Statistics params with duration data
304
- * @returns {DailyHMTData[]} Daily HMToken statistics data.
305
- *
286
+ * @returns {Promise<DailyHMTData[]>} Daily HMToken statistics data.
306
287
  *
307
288
  * **Code example**
308
289
  *
@@ -1 +1 @@
1
- {"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,gBAAgB,EAG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CAAC;CA8B3B"}
@@ -13,20 +13,15 @@ const enums_1 = require("./enums");
13
13
  /**
14
14
  * ## Introduction
15
15
  *
16
- * This client enables to obtain statistical information from the subgraph.
16
+ * This client enables obtaining statistical information from the subgraph.
17
17
  *
18
- * Unlikely from the other SDK clients, `StatisticsClient` does not require `signer` or `provider` to be provided.
19
- * We just need to create client object using relevant network data.
18
+ * Unlike other SDK clients, `StatisticsClient` does not require `signer` or `provider` to be provided.
19
+ * We just need to create a client object using relevant network data.
20
20
  *
21
21
  * ```ts
22
22
  * constructor(network: NetworkData)
23
23
  * ```
24
24
  *
25
- * A `Signer` or a `Provider` should be passed depending on the use case of this module:
26
- *
27
- * - **Signer**: when the user wants to use this model in order to send transactions caling the contract functions.
28
- * - **Provider**: when the user wants to use this model in order to get information from the contracts or subgraph.
29
- *
30
25
  * ## Installation
31
26
  *
32
27
  * ### npm
@@ -60,7 +55,6 @@ class StatisticsClient {
60
55
  /**
61
56
  * This function returns the statistical data of escrows.
62
57
  *
63
- *
64
58
  * **Input parameters**
65
59
  *
66
60
  * ```ts
@@ -89,10 +83,8 @@ class StatisticsClient {
89
83
  * };
90
84
  * ```
91
85
  *
92
- *
93
86
  * @param {IStatisticsFilter} filter Statistics params with duration data
94
- * @returns {EscrowStatistics} Escrow statistics data.
95
- *
87
+ * @returns {Promise<EscrowStatistics>} Escrow statistics data.
96
88
  *
97
89
  * **Code example**
98
90
  *
@@ -122,7 +114,9 @@ class StatisticsClient {
122
114
  skip: skip,
123
115
  });
124
116
  return {
125
- totalEscrows: +escrowStatistics.totalEscrowCount,
117
+ totalEscrows: escrowStatistics?.totalEscrowCount
118
+ ? +escrowStatistics.totalEscrowCount
119
+ : 0,
126
120
  dailyEscrowsData: eventDayDatas.map((eventDayData) => ({
127
121
  timestamp: new Date(+eventDayData.timestamp * 1000),
128
122
  escrowsTotal: +eventDayData.dailyEscrowCount,
@@ -140,7 +134,6 @@ class StatisticsClient {
140
134
  /**
141
135
  * This function returns the statistical data of workers.
142
136
  *
143
- *
144
137
  * **Input parameters**
145
138
  *
146
139
  * ```ts
@@ -164,10 +157,8 @@ class StatisticsClient {
164
157
  * };
165
158
  * ```
166
159
  *
167
- *
168
160
  * @param {IStatisticsFilter} filter Statistics params with duration data
169
- * @returns {WorkerStatistics} Worker statistics data.
170
- *
161
+ * @returns {Promise<WorkerStatistics>} Worker statistics data.
171
162
  *
172
163
  * **Code example**
173
164
  *
@@ -209,7 +200,6 @@ class StatisticsClient {
209
200
  /**
210
201
  * This function returns the statistical data of payments.
211
202
  *
212
- *
213
203
  * **Input parameters**
214
204
  *
215
205
  * ```ts
@@ -235,10 +225,8 @@ class StatisticsClient {
235
225
  * };
236
226
  * ```
237
227
  *
238
- *
239
228
  * @param {IStatisticsFilter} filter Statistics params with duration data
240
- * @returns {PaymentStatistics} Payment statistics data.
241
- *
229
+ * @returns {Promise<PaymentStatistics>} Payment statistics data.
242
230
  *
243
231
  * **Code example**
244
232
  *
@@ -306,7 +294,7 @@ class StatisticsClient {
306
294
  /**
307
295
  * This function returns the statistical data of HMToken.
308
296
  *
309
- *
297
+ * ```ts
310
298
  * type HMTStatistics = {
311
299
  * totalTransferAmount: BigNumber;
312
300
  * totalTransferCount: BigNumber;
@@ -314,9 +302,7 @@ class StatisticsClient {
314
302
  * };
315
303
  * ```
316
304
  *
317
- *
318
- * @returns {HMTStatistics} HMToken statistics data.
319
- *
305
+ * @returns {Promise<HMTStatistics>} HMToken statistics data.
320
306
  *
321
307
  * **Code example**
322
308
  *
@@ -352,7 +338,7 @@ class StatisticsClient {
352
338
  * **Input parameters**
353
339
  *
354
340
  * @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
355
- * @returns {HMTHolder[]} List of HMToken holders.
341
+ * @returns {Promise<HMTHolder[]>} List of HMToken holders.
356
342
  *
357
343
  * **Code example**
358
344
  *
@@ -392,7 +378,6 @@ class StatisticsClient {
392
378
  /**
393
379
  * This function returns the statistical data of HMToken day by day.
394
380
  *
395
- *
396
381
  * **Input parameters**
397
382
  *
398
383
  * ```ts
@@ -415,10 +400,8 @@ class StatisticsClient {
415
400
  * }
416
401
  * ```
417
402
  *
418
- *
419
403
  * @param {IStatisticsFilter} filter Statistics params with duration data
420
- * @returns {DailyHMTData[]} Daily HMToken statistics data.
421
- *
404
+ * @returns {Promise<DailyHMTData[]>} Daily HMToken statistics data.
422
405
  *
423
406
  * **Code example**
424
407
  *