@human-protocol/sdk 3.0.8 → 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 (55) hide show
  1. package/dist/constants.d.ts +1 -1
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +2 -2
  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 +17 -29
  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 +102 -59
  12. package/dist/escrow.d.ts.map +1 -1
  13. package/dist/escrow.js +186 -98
  14. package/dist/graphql/queries/operator.d.ts.map +1 -1
  15. package/dist/graphql/queries/operator.js +13 -5
  16. package/dist/interfaces.d.ts +10 -2
  17. package/dist/interfaces.d.ts.map +1 -1
  18. package/dist/kvstore.d.ts +15 -15
  19. package/dist/kvstore.d.ts.map +1 -1
  20. package/dist/kvstore.js +15 -15
  21. package/dist/operator.d.ts +11 -10
  22. package/dist/operator.d.ts.map +1 -1
  23. package/dist/operator.js +23 -11
  24. package/dist/staking.d.ts +38 -21
  25. package/dist/staking.d.ts.map +1 -1
  26. package/dist/staking.js +62 -21
  27. package/dist/statistics.d.ts +10 -29
  28. package/dist/statistics.d.ts.map +1 -1
  29. package/dist/statistics.js +10 -29
  30. package/dist/storage.d.ts +13 -18
  31. package/dist/storage.d.ts.map +1 -1
  32. package/dist/storage.js +13 -18
  33. package/dist/transaction.js +1 -1
  34. package/dist/types.d.ts +6 -2
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js +1 -1
  37. package/dist/utils.d.ts +0 -1
  38. package/dist/utils.d.ts.map +1 -1
  39. package/dist/utils.js +0 -1
  40. package/package.json +1 -1
  41. package/src/constants.ts +2 -2
  42. package/src/decorators.ts +1 -1
  43. package/src/encryption.ts +21 -29
  44. package/src/error.ts +39 -37
  45. package/src/escrow.ts +245 -117
  46. package/src/graphql/queries/operator.ts +13 -5
  47. package/src/interfaces.ts +11 -2
  48. package/src/kvstore.ts +16 -16
  49. package/src/operator.ts +26 -12
  50. package/src/staking.ts +71 -22
  51. package/src/statistics.ts +10 -29
  52. package/src/storage.ts +13 -18
  53. package/src/transaction.ts +2 -2
  54. package/src/types.ts +6 -2
  55. package/src/utils.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAc1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAC1C,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,aAAa,CAAC;IAE5C;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAmB5D;;;;;;;;OAQG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc;IAiBhD;;;;OAIG;YACW,gBAAgB;IAU9B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IAEU,YAAY,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAuBhB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IAEU,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB5E;;;;;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;;;;;;;;;;OAuBG;IAEU,YAAY,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAuBhB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB5E;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IAEU,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,QAAQ,CAAC,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/D;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAoChB;;;;;;;;;;;;;;;;;;;OAmBG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAgCvE"}
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';
@@ -140,7 +140,6 @@ class StakingClient extends base_1.BaseEthersClient {
140
140
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
141
141
  * @returns Returns void if successful. Throws error if any.
142
142
  *
143
- *
144
143
  * **Code example**
145
144
  *
146
145
  * ```ts
@@ -148,7 +147,7 @@ class StakingClient extends base_1.BaseEthersClient {
148
147
  * import { StakingClient } from '@human-protocol/sdk';
149
148
  *
150
149
  * const rpcUrl = 'YOUR_RPC_URL';
151
- * const privateKey = 'YOUR_PRIVATE_KEY'
150
+ * const privateKey = 'YOUR_PRIVATE_KEY';
152
151
  *
153
152
  * const provider = new providers.JsonRpcProvider(rpcUrl);
154
153
  * const signer = new Wallet(privateKey, provider);
@@ -182,7 +181,6 @@ class StakingClient extends base_1.BaseEthersClient {
182
181
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
183
182
  * @returns Returns void if successful. Throws error if any.
184
183
  *
185
- *
186
184
  * **Code example**
187
185
  *
188
186
  * ```ts
@@ -190,7 +188,7 @@ class StakingClient extends base_1.BaseEthersClient {
190
188
  * import { StakingClient } from '@human-protocol/sdk';
191
189
  *
192
190
  * const rpcUrl = 'YOUR_RPC_URL';
193
- * const privateKey = 'YOUR_PRIVATE_KEY'
191
+ * const privateKey = 'YOUR_PRIVATE_KEY';
194
192
  *
195
193
  * const provider = new providers.JsonRpcProvider(rpcUrl);
196
194
  * const signer = new Wallet(privateKey, provider);
@@ -198,7 +196,7 @@ class StakingClient extends base_1.BaseEthersClient {
198
196
  *
199
197
  * const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
200
198
  * await stakingClient.approveStake(amount); // if it was already approved before, this is not necessary
201
- * await stakingClient.approveStake(amount);
199
+ * await stakingClient.stake(amount);
202
200
  * ```
203
201
  */
204
202
  async stake(amount, txOptions = {}) {
@@ -225,7 +223,6 @@ class StakingClient extends base_1.BaseEthersClient {
225
223
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
226
224
  * @returns Returns void if successful. Throws error if any.
227
225
  *
228
- *
229
226
  * **Code example**
230
227
  *
231
228
  * ```ts
@@ -233,7 +230,7 @@ class StakingClient extends base_1.BaseEthersClient {
233
230
  * import { StakingClient } from '@human-protocol/sdk';
234
231
  *
235
232
  * const rpcUrl = 'YOUR_RPC_URL';
236
- * const privateKey = 'YOUR_PRIVATE_KEY'
233
+ * const privateKey = 'YOUR_PRIVATE_KEY';
237
234
  *
238
235
  * const provider = new providers.JsonRpcProvider(rpcUrl);
239
236
  * const signer = new Wallet(privateKey, provider);
@@ -259,14 +256,13 @@ class StakingClient extends base_1.BaseEthersClient {
259
256
  }
260
257
  }
261
258
  /**
262
- * 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.
263
260
  *
264
261
  * > Must have tokens available to withdraw
265
262
  *
266
263
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
267
264
  * @returns Returns void if successful. Throws error if any.
268
265
  *
269
- *
270
266
  * **Code example**
271
267
  *
272
268
  * ```ts
@@ -274,7 +270,7 @@ class StakingClient extends base_1.BaseEthersClient {
274
270
  * import { StakingClient } from '@human-protocol/sdk';
275
271
  *
276
272
  * const rpcUrl = 'YOUR_RPC_URL';
277
- * const privateKey = 'YOUR_PRIVATE_KEY'
273
+ * const privateKey = 'YOUR_PRIVATE_KEY';
278
274
  *
279
275
  * const provider = new providers.JsonRpcProvider(rpcUrl);
280
276
  * const signer = new Wallet(privateKey, provider);
@@ -293,16 +289,15 @@ class StakingClient extends base_1.BaseEthersClient {
293
289
  }
294
290
  }
295
291
  /**
296
- * 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.
297
293
  *
298
294
  * @param {string} slasher Wallet address from who requested the slash
299
295
  * @param {string} staker Wallet address from who is going to be slashed
300
296
  * @param {string} escrowAddress Address of the escrow that the slash is made
297
+ * @param {bigint} amount Amount in WEI of tokens to slash.
301
298
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
302
- * @param {bigint} amount Amount in WEI of tokens to unstake.
303
299
  * @returns Returns void if successful. Throws error if any.
304
300
  *
305
- *
306
301
  * **Code example**
307
302
  *
308
303
  * ```ts
@@ -310,7 +305,7 @@ class StakingClient extends base_1.BaseEthersClient {
310
305
  * import { StakingClient } from '@human-protocol/sdk';
311
306
  *
312
307
  * const rpcUrl = 'YOUR_RPC_URL';
313
- * const privateKey = 'YOUR_PRIVATE_KEY'
308
+ * const privateKey = 'YOUR_PRIVATE_KEY';
314
309
  *
315
310
  * const provider = new providers.JsonRpcProvider(rpcUrl);
316
311
  * const signer = new Wallet(privateKey, provider);
@@ -342,6 +337,52 @@ class StakingClient extends base_1.BaseEthersClient {
342
337
  return (0, utils_1.throwError)(e);
343
338
  }
344
339
  }
340
+ /**
341
+ * Retrieves comprehensive staking information for a staker.
342
+ *
343
+ * @param {string} stakerAddress - The address of the staker.
344
+ * @returns {Promise<StakerInfo>}
345
+ *
346
+ * **Code example**
347
+ *
348
+ * ```ts
349
+ * import { StakingClient } from '@human-protocol/sdk';
350
+ *
351
+ * const rpcUrl = 'YOUR_RPC_URL';
352
+ *
353
+ * const provider = new providers.JsonRpcProvider(rpcUrl);
354
+ * const stakingClient = await StakingClient.build(provider);
355
+ *
356
+ * const stakingInfo = await stakingClient.getStakerInfo('0xYourStakerAddress');
357
+ * console.log(stakingInfo.tokensStaked);
358
+ * ```
359
+ */
360
+ async getStakerInfo(stakerAddress) {
361
+ if (!ethers_1.ethers.isAddress(stakerAddress)) {
362
+ throw error_1.ErrorInvalidStakerAddressProvided;
363
+ }
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);
384
+ }
385
+ }
345
386
  }
346
387
  exports.StakingClient = StakingClient;
347
388
  __decorate([
@@ -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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GAAE,iBAAsB,GAC7B,OAAO,CAAC,YAAY,EAAE,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
  *
@@ -142,7 +134,6 @@ class StatisticsClient {
142
134
  /**
143
135
  * This function returns the statistical data of workers.
144
136
  *
145
- *
146
137
  * **Input parameters**
147
138
  *
148
139
  * ```ts
@@ -166,10 +157,8 @@ class StatisticsClient {
166
157
  * };
167
158
  * ```
168
159
  *
169
- *
170
160
  * @param {IStatisticsFilter} filter Statistics params with duration data
171
- * @returns {WorkerStatistics} Worker statistics data.
172
- *
161
+ * @returns {Promise<WorkerStatistics>} Worker statistics data.
173
162
  *
174
163
  * **Code example**
175
164
  *
@@ -211,7 +200,6 @@ class StatisticsClient {
211
200
  /**
212
201
  * This function returns the statistical data of payments.
213
202
  *
214
- *
215
203
  * **Input parameters**
216
204
  *
217
205
  * ```ts
@@ -237,10 +225,8 @@ class StatisticsClient {
237
225
  * };
238
226
  * ```
239
227
  *
240
- *
241
228
  * @param {IStatisticsFilter} filter Statistics params with duration data
242
- * @returns {PaymentStatistics} Payment statistics data.
243
- *
229
+ * @returns {Promise<PaymentStatistics>} Payment statistics data.
244
230
  *
245
231
  * **Code example**
246
232
  *
@@ -308,7 +294,7 @@ class StatisticsClient {
308
294
  /**
309
295
  * This function returns the statistical data of HMToken.
310
296
  *
311
- *
297
+ * ```ts
312
298
  * type HMTStatistics = {
313
299
  * totalTransferAmount: BigNumber;
314
300
  * totalTransferCount: BigNumber;
@@ -316,9 +302,7 @@ class StatisticsClient {
316
302
  * };
317
303
  * ```
318
304
  *
319
- *
320
- * @returns {HMTStatistics} HMToken statistics data.
321
- *
305
+ * @returns {Promise<HMTStatistics>} HMToken statistics data.
322
306
  *
323
307
  * **Code example**
324
308
  *
@@ -354,7 +338,7 @@ class StatisticsClient {
354
338
  * **Input parameters**
355
339
  *
356
340
  * @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
357
- * @returns {HMTHolder[]} List of HMToken holders.
341
+ * @returns {Promise<HMTHolder[]>} List of HMToken holders.
358
342
  *
359
343
  * **Code example**
360
344
  *
@@ -394,7 +378,6 @@ class StatisticsClient {
394
378
  /**
395
379
  * This function returns the statistical data of HMToken day by day.
396
380
  *
397
- *
398
381
  * **Input parameters**
399
382
  *
400
383
  * ```ts
@@ -417,10 +400,8 @@ class StatisticsClient {
417
400
  * }
418
401
  * ```
419
402
  *
420
- *
421
403
  * @param {IStatisticsFilter} filter Statistics params with duration data
422
- * @returns {DailyHMTData[]} Daily HMToken statistics data.
423
- *
404
+ * @returns {Promise<DailyHMTData[]>} Daily HMToken statistics data.
424
405
  *
425
406
  * **Code example**
426
407
  *
package/dist/storage.d.ts CHANGED
@@ -5,7 +5,7 @@ import { UploadFile, StorageCredentials, StorageParams } from './types';
5
5
  *
6
6
  * ## Introduction
7
7
  *
8
- * This client enables to interact with S3 cloud storage services like Amazon S3 Bucket, Google Cloud Storage and others.
8
+ * This client enables interacting with S3 cloud storage services like Amazon S3 Bucket, Google Cloud Storage, and others.
9
9
  *
10
10
  * The instance creation of `StorageClient` should be made using its constructor:
11
11
  *
@@ -13,7 +13,7 @@ import { UploadFile, StorageCredentials, StorageParams } from './types';
13
13
  * constructor(params: StorageParams, credentials?: StorageCredentials)
14
14
  * ```
15
15
  *
16
- * > If credentials is not provided, it uses an anonymous access to the bucket for downloading files.
16
+ * > If credentials are not provided, it uses anonymous access to the bucket for downloading files.
17
17
  *
18
18
  * ## Installation
19
19
  *
@@ -53,7 +53,7 @@ export declare class StorageClient {
53
53
  * **Storage client constructor**
54
54
  *
55
55
  * @param {StorageParams} params - Cloud storage params
56
- * @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials is not provided - use an anonymous access to the bucket
56
+ * @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials are not provided - use anonymous access to the bucket
57
57
  */
58
58
  constructor(params: StorageParams, credentials?: StorageCredentials);
59
59
  /**
@@ -61,8 +61,7 @@ export declare class StorageClient {
61
61
  *
62
62
  * @param {string[]} keys Array of filenames to download.
63
63
  * @param {string} bucket Bucket name.
64
- * @returns {any[]} Returns an array of json files downloaded and parsed into objects.
65
- *
64
+ * @returns {Promise<any[]>} Returns an array of JSON files downloaded and parsed into objects.
66
65
  *
67
66
  * **Code example**
68
67
  *
@@ -84,28 +83,26 @@ export declare class StorageClient {
84
83
  */
85
84
  downloadFiles(keys: string[], bucket: string): Promise<any[]>;
86
85
  /**
87
- * This function downloads files from a Url.
88
- *
89
- * @param {string} url Url of the file to download.
90
- * @returns {any} Returns the JSON file downloaded and parsed into object.
86
+ * This function downloads files from a URL.
91
87
  *
88
+ * @param {string} url URL of the file to download.
89
+ * @returns {Promise<any>} Returns the JSON file downloaded and parsed into an object.
92
90
  *
93
91
  * **Code example**
94
92
  *
95
93
  * ```ts
96
94
  * import { StorageClient } from '@human-protocol/sdk';
97
95
  *
98
- * const file = await storageClient.downloadFileFromUrl('http://localhost/file.json');
96
+ * const file = await StorageClient.downloadFileFromUrl('http://localhost/file.json');
99
97
  * ```
100
98
  */
101
99
  static downloadFileFromUrl(url: string): Promise<any>;
102
100
  /**
103
101
  * This function uploads files to a bucket.
104
102
  *
105
- * @param {any[]} files Array of objects to upload serialized into json.
103
+ * @param {any[]} files Array of objects to upload serialized into JSON.
106
104
  * @param {string} bucket Bucket name.
107
- * @returns {UploadFile[]} Returns an array of json files downloaded and parsed into objects.
108
- *
105
+ * @returns {Promise<UploadFile[]>} Returns an array of uploaded file metadata.
109
106
  *
110
107
  * **Code example**
111
108
  *
@@ -135,8 +132,7 @@ export declare class StorageClient {
135
132
  * This function checks if a bucket exists.
136
133
  *
137
134
  * @param {string} bucket Bucket name.
138
- * @returns {boolean} Returns `true` if exists, `false` if it doesn't.
139
- *
135
+ * @returns {Promise<boolean>} Returns `true` if exists, `false` if it doesn't.
140
136
  *
141
137
  * **Code example**
142
138
  *
@@ -160,11 +156,10 @@ export declare class StorageClient {
160
156
  */
161
157
  bucketExists(bucket: string): Promise<boolean>;
162
158
  /**
163
- * This function list all file names contained in the bucket.
159
+ * This function lists all file names contained in the bucket.
164
160
  *
165
161
  * @param {string} bucket Bucket name.
166
- * @returns {boolean} Returns the list of file names contained in the bucket.
167
- *
162
+ * @returns {Promise<string[]>} Returns the list of file names contained in the bucket.
168
163
  *
169
164
  * **Code example**
170
165
  *
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAoB1E;;;;;;;;;;;;;OAaG;WACiB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACU,WAAW,CACtB,KAAK,EAAE,GAAG,EAAE,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,EAAE,CAAC;IAmCxB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAqB5D"}
package/dist/storage.js CHANGED
@@ -50,7 +50,7 @@ const constants_1 = require("./constants");
50
50
  *
51
51
  * ## Introduction
52
52
  *
53
- * This client enables to interact with S3 cloud storage services like Amazon S3 Bucket, Google Cloud Storage and others.
53
+ * This client enables interacting with S3 cloud storage services like Amazon S3 Bucket, Google Cloud Storage, and others.
54
54
  *
55
55
  * The instance creation of `StorageClient` should be made using its constructor:
56
56
  *
@@ -58,7 +58,7 @@ const constants_1 = require("./constants");
58
58
  * constructor(params: StorageParams, credentials?: StorageCredentials)
59
59
  * ```
60
60
  *
61
- * > If credentials is not provided, it uses an anonymous access to the bucket for downloading files.
61
+ * > If credentials are not provided, it uses anonymous access to the bucket for downloading files.
62
62
  *
63
63
  * ## Installation
64
64
  *
@@ -96,7 +96,7 @@ class StorageClient {
96
96
  * **Storage client constructor**
97
97
  *
98
98
  * @param {StorageParams} params - Cloud storage params
99
- * @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials is not provided - use an anonymous access to the bucket
99
+ * @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials are not provided - use anonymous access to the bucket
100
100
  */
101
101
  constructor(params, credentials) {
102
102
  try {
@@ -116,8 +116,7 @@ class StorageClient {
116
116
  *
117
117
  * @param {string[]} keys Array of filenames to download.
118
118
  * @param {string} bucket Bucket name.
119
- * @returns {any[]} Returns an array of json files downloaded and parsed into objects.
120
- *
119
+ * @returns {Promise<any[]>} Returns an array of JSON files downloaded and parsed into objects.
121
120
  *
122
121
  * **Code example**
123
122
  *
@@ -154,18 +153,17 @@ class StorageClient {
154
153
  }));
155
154
  }
156
155
  /**
157
- * This function downloads files from a Url.
158
- *
159
- * @param {string} url Url of the file to download.
160
- * @returns {any} Returns the JSON file downloaded and parsed into object.
156
+ * This function downloads files from a URL.
161
157
  *
158
+ * @param {string} url URL of the file to download.
159
+ * @returns {Promise<any>} Returns the JSON file downloaded and parsed into an object.
162
160
  *
163
161
  * **Code example**
164
162
  *
165
163
  * ```ts
166
164
  * import { StorageClient } from '@human-protocol/sdk';
167
165
  *
168
- * const file = await storageClient.downloadFileFromUrl('http://localhost/file.json');
166
+ * const file = await StorageClient.downloadFileFromUrl('http://localhost/file.json');
169
167
  * ```
170
168
  */
171
169
  static async downloadFileFromUrl(url) {
@@ -190,10 +188,9 @@ class StorageClient {
190
188
  /**
191
189
  * This function uploads files to a bucket.
192
190
  *
193
- * @param {any[]} files Array of objects to upload serialized into json.
191
+ * @param {any[]} files Array of objects to upload serialized into JSON.
194
192
  * @param {string} bucket Bucket name.
195
- * @returns {UploadFile[]} Returns an array of json files downloaded and parsed into objects.
196
- *
193
+ * @returns {Promise<UploadFile[]>} Returns an array of uploaded file metadata.
197
194
  *
198
195
  * **Code example**
199
196
  *
@@ -247,8 +244,7 @@ class StorageClient {
247
244
  * This function checks if a bucket exists.
248
245
  *
249
246
  * @param {string} bucket Bucket name.
250
- * @returns {boolean} Returns `true` if exists, `false` if it doesn't.
251
- *
247
+ * @returns {Promise<boolean>} Returns `true` if exists, `false` if it doesn't.
252
248
  *
253
249
  * **Code example**
254
250
  *
@@ -274,11 +270,10 @@ class StorageClient {
274
270
  return this.client.bucketExists(bucket);
275
271
  }
276
272
  /**
277
- * This function list all file names contained in the bucket.
273
+ * This function lists all file names contained in the bucket.
278
274
  *
279
275
  * @param {string} bucket Bucket name.
280
- * @returns {boolean} Returns the list of file names contained in the bucket.
281
- *
276
+ * @returns {Promise<string[]>} Returns the list of file names contained in the bucket.
282
277
  *
283
278
  * **Code example**
284
279
  *