@human-protocol/sdk 5.0.0 → 5.2.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 (56) hide show
  1. package/dist/base.d.ts +1 -10
  2. package/dist/base.d.ts.map +1 -1
  3. package/dist/base.js +0 -21
  4. package/dist/constants.d.ts +0 -1
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +7 -22
  7. package/dist/encryption.js +1 -1
  8. package/dist/enums.d.ts +0 -1
  9. package/dist/enums.d.ts.map +1 -1
  10. package/dist/enums.js +0 -1
  11. package/dist/error.d.ts +8 -0
  12. package/dist/error.d.ts.map +1 -1
  13. package/dist/error.js +9 -1
  14. package/dist/escrow.d.ts +14 -17
  15. package/dist/escrow.d.ts.map +1 -1
  16. package/dist/escrow.js +34 -33
  17. package/dist/interfaces.d.ts +14 -0
  18. package/dist/interfaces.d.ts.map +1 -1
  19. package/dist/kvstore.d.ts +9 -5
  20. package/dist/kvstore.d.ts.map +1 -1
  21. package/dist/kvstore.js +15 -15
  22. package/dist/operator.d.ts +9 -5
  23. package/dist/operator.d.ts.map +1 -1
  24. package/dist/operator.js +16 -16
  25. package/dist/staking.d.ts +6 -3
  26. package/dist/staking.d.ts.map +1 -1
  27. package/dist/staking.js +13 -15
  28. package/dist/statistics.d.ts +13 -7
  29. package/dist/statistics.d.ts.map +1 -1
  30. package/dist/statistics.js +24 -22
  31. package/dist/storage.js +4 -4
  32. package/dist/transaction.d.ts +5 -3
  33. package/dist/transaction.d.ts.map +1 -1
  34. package/dist/transaction.js +8 -11
  35. package/dist/utils.d.ts +7 -0
  36. package/dist/utils.d.ts.map +1 -1
  37. package/dist/utils.js +66 -1
  38. package/dist/worker.d.ts +5 -3
  39. package/dist/worker.d.ts.map +1 -1
  40. package/dist/worker.js +8 -10
  41. package/package.json +8 -5
  42. package/src/base.ts +1 -23
  43. package/src/constants.ts +6 -24
  44. package/src/encryption.ts +1 -1
  45. package/src/enums.ts +0 -1
  46. package/src/error.ts +14 -0
  47. package/src/escrow.ts +70 -64
  48. package/src/interfaces.ts +15 -0
  49. package/src/kvstore.ts +26 -24
  50. package/src/operator.ts +54 -26
  51. package/src/staking.ts +28 -27
  52. package/src/statistics.ts +87 -47
  53. package/src/storage.ts +4 -4
  54. package/src/transaction.ts +39 -26
  55. package/src/utils.ts +81 -0
  56. package/src/worker.ts +32 -17
package/src/operator.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import gqlFetch from 'graphql-request';
3
- import { IOperator, IOperatorsFilter, IReward } from './interfaces';
2
+ import {
3
+ IOperator,
4
+ IOperatorsFilter,
5
+ IReward,
6
+ SubgraphOptions,
7
+ } from './interfaces';
4
8
  import { GET_REWARD_ADDED_EVENTS_QUERY } from './graphql/queries/reward';
5
9
  import {
6
10
  IOperatorSubgraph,
@@ -18,7 +22,7 @@ import {
18
22
  ErrorInvalidStakerAddressProvided,
19
23
  ErrorUnsupportedChainID,
20
24
  } from './error';
21
- import { getSubgraphUrl } from './utils';
25
+ import { getSubgraphUrl, customGqlFetch } from './utils';
22
26
  import { ChainId, OrderDirection } from './enums';
23
27
  import { NETWORKS } from './constants';
24
28
 
@@ -28,6 +32,7 @@ export class OperatorUtils {
28
32
  *
29
33
  * @param {ChainId} chainId Network in which the operator is deployed
30
34
  * @param {string} address Operator address.
35
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
31
36
  * @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
32
37
  *
33
38
  * **Code example**
@@ -40,7 +45,8 @@ export class OperatorUtils {
40
45
  */
41
46
  public static async getOperator(
42
47
  chainId: ChainId,
43
- address: string
48
+ address: string,
49
+ options?: SubgraphOptions
44
50
  ): Promise<IOperator | null> {
45
51
  if (!ethers.isAddress(address)) {
46
52
  throw ErrorInvalidStakerAddressProvided;
@@ -51,10 +57,11 @@ export class OperatorUtils {
51
57
  throw ErrorUnsupportedChainID;
52
58
  }
53
59
 
54
- const { operator } = await gqlFetch<{
60
+ const { operator } = await customGqlFetch<{
55
61
  operator: IOperatorSubgraph;
56
62
  }>(getSubgraphUrl(networkData), GET_LEADER_QUERY, {
57
63
  address: address.toLowerCase(),
64
+ options,
58
65
  });
59
66
 
60
67
  if (!operator) {
@@ -68,6 +75,7 @@ export class OperatorUtils {
68
75
  * This function returns all the operator details of the protocol.
69
76
  *
70
77
  * @param {IOperatorsFilter} filter Filter for the operators.
78
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
71
79
  * @returns {Promise<IOperator[]>} Returns an array with all the operator details.
72
80
  *
73
81
  * **Code example**
@@ -82,7 +90,8 @@ export class OperatorUtils {
82
90
  * ```
83
91
  */
84
92
  public static async getOperators(
85
- filter: IOperatorsFilter
93
+ filter: IOperatorsFilter,
94
+ options?: SubgraphOptions
86
95
  ): Promise<IOperator[]> {
87
96
  const first =
88
97
  filter.first !== undefined && filter.first > 0
@@ -107,16 +116,21 @@ export class OperatorUtils {
107
116
  throw ErrorUnsupportedChainID;
108
117
  }
109
118
 
110
- const { operators } = await gqlFetch<{
119
+ const { operators } = await customGqlFetch<{
111
120
  operators: IOperatorSubgraph[];
112
- }>(getSubgraphUrl(networkData), GET_LEADERS_QUERY(filter), {
113
- minStakedAmount: filter?.minStakedAmount,
114
- roles: filter?.roles,
115
- orderBy: orderBy,
116
- orderDirection: orderDirection,
117
- first: first,
118
- skip: skip,
119
- });
121
+ }>(
122
+ getSubgraphUrl(networkData),
123
+ GET_LEADERS_QUERY(filter),
124
+ {
125
+ minStakedAmount: filter?.minStakedAmount,
126
+ roles: filter?.roles,
127
+ orderBy: orderBy,
128
+ orderDirection: orderDirection,
129
+ first: first,
130
+ skip: skip,
131
+ },
132
+ options
133
+ );
120
134
 
121
135
  if (!operators) {
122
136
  return [];
@@ -131,6 +145,7 @@ export class OperatorUtils {
131
145
  * @param {ChainId} chainId Network in which the reputation network is deployed
132
146
  * @param {string} address Address of the reputation oracle.
133
147
  * @param {string} [role] - (Optional) Role of the operator.
148
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
134
149
  * @returns {Promise<IOperator[]>} - Returns an array of operator details.
135
150
  *
136
151
  * **Code example**
@@ -144,19 +159,25 @@ export class OperatorUtils {
144
159
  public static async getReputationNetworkOperators(
145
160
  chainId: ChainId,
146
161
  address: string,
147
- role?: string
162
+ role?: string,
163
+ options?: SubgraphOptions
148
164
  ): Promise<IOperator[]> {
149
165
  const networkData = NETWORKS[chainId];
150
166
 
151
167
  if (!networkData) {
152
168
  throw ErrorUnsupportedChainID;
153
169
  }
154
- const { reputationNetwork } = await gqlFetch<{
170
+ const { reputationNetwork } = await customGqlFetch<{
155
171
  reputationNetwork: IReputationNetworkSubgraph;
156
- }>(getSubgraphUrl(networkData), GET_REPUTATION_NETWORK_QUERY(role), {
157
- address: address.toLowerCase(),
158
- role: role,
159
- });
172
+ }>(
173
+ getSubgraphUrl(networkData),
174
+ GET_REPUTATION_NETWORK_QUERY(role),
175
+ {
176
+ address: address.toLowerCase(),
177
+ role: role,
178
+ },
179
+ options
180
+ );
160
181
 
161
182
  if (!reputationNetwork) return [];
162
183
 
@@ -170,6 +191,7 @@ export class OperatorUtils {
170
191
  *
171
192
  * @param {ChainId} chainId Network in which the rewards are deployed
172
193
  * @param {string} slasherAddress Slasher address.
194
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
173
195
  * @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
174
196
  *
175
197
  * **Code example**
@@ -182,7 +204,8 @@ export class OperatorUtils {
182
204
  */
183
205
  public static async getRewards(
184
206
  chainId: ChainId,
185
- slasherAddress: string
207
+ slasherAddress: string,
208
+ options?: SubgraphOptions
186
209
  ): Promise<IReward[]> {
187
210
  if (!ethers.isAddress(slasherAddress)) {
188
211
  throw ErrorInvalidSlasherAddressProvided;
@@ -193,11 +216,16 @@ export class OperatorUtils {
193
216
  throw ErrorUnsupportedChainID;
194
217
  }
195
218
 
196
- const { rewardAddedEvents } = await gqlFetch<{
219
+ const { rewardAddedEvents } = await customGqlFetch<{
197
220
  rewardAddedEvents: RewardAddedEventData[];
198
- }>(getSubgraphUrl(networkData), GET_REWARD_ADDED_EVENTS_QUERY, {
199
- slasherAddress: slasherAddress.toLowerCase(),
200
- });
221
+ }>(
222
+ getSubgraphUrl(networkData),
223
+ GET_REWARD_ADDED_EVENTS_QUERY,
224
+ {
225
+ slasherAddress: slasherAddress.toLowerCase(),
226
+ },
227
+ options
228
+ );
201
229
 
202
230
  if (!rewardAddedEvents) return [];
203
231
 
package/src/staking.ts CHANGED
@@ -7,7 +7,6 @@ import {
7
7
  Staking__factory,
8
8
  } from '@human-protocol/core/typechain-types';
9
9
  import { ContractRunner, Overrides, ethers } from 'ethers';
10
- import gqlFetch from 'graphql-request';
11
10
  import { BaseEthersClient } from './base';
12
11
  import { NETWORKS } from './constants';
13
12
  import { requiresSigner } from './decorators';
@@ -23,10 +22,15 @@ import {
23
22
  ErrorStakerNotFound,
24
23
  ErrorUnsupportedChainID,
25
24
  } from './error';
26
- import { IStaker, IStakersFilter, StakerInfo } from './interfaces';
25
+ import {
26
+ IStaker,
27
+ IStakersFilter,
28
+ StakerInfo,
29
+ SubgraphOptions,
30
+ } from './interfaces';
27
31
  import { StakerData } from './graphql';
28
32
  import { NetworkData } from './types';
29
- import { getSubgraphUrl, throwError } from './utils';
33
+ import { getSubgraphUrl, customGqlFetch, throwError } from './utils';
30
34
  import {
31
35
  GET_STAKER_BY_ADDRESS_QUERY,
32
36
  GET_STAKERS_QUERY,
@@ -214,7 +218,7 @@ export class StakingClient extends BaseEthersClient {
214
218
  await this.tokenContract.approve(
215
219
  await this.stakingContract.getAddress(),
216
220
  amount,
217
- this.applyTxDefaults(txOptions)
221
+ txOptions
218
222
  )
219
223
  ).wait();
220
224
  return;
@@ -261,12 +265,7 @@ export class StakingClient extends BaseEthersClient {
261
265
  }
262
266
 
263
267
  try {
264
- await (
265
- await this.stakingContract.stake(
266
- amount,
267
- this.applyTxDefaults(txOptions)
268
- )
269
- ).wait();
268
+ await (await this.stakingContract.stake(amount, txOptions)).wait();
270
269
  return;
271
270
  } catch (e) {
272
271
  return throwError(e);
@@ -313,12 +312,7 @@ export class StakingClient extends BaseEthersClient {
313
312
  }
314
313
 
315
314
  try {
316
- await (
317
- await this.stakingContract.unstake(
318
- amount,
319
- this.applyTxDefaults(txOptions)
320
- )
321
- ).wait();
315
+ await (await this.stakingContract.unstake(amount, txOptions)).wait();
322
316
  return;
323
317
  } catch (e) {
324
318
  return throwError(e);
@@ -352,9 +346,7 @@ export class StakingClient extends BaseEthersClient {
352
346
  @requiresSigner
353
347
  public async withdraw(txOptions: Overrides = {}): Promise<void> {
354
348
  try {
355
- await (
356
- await this.stakingContract.withdraw(this.applyTxDefaults(txOptions))
357
- ).wait();
349
+ await (await this.stakingContract.withdraw(txOptions)).wait();
358
350
  return;
359
351
  } catch (e) {
360
352
  return throwError(e);
@@ -421,7 +413,7 @@ export class StakingClient extends BaseEthersClient {
421
413
  staker,
422
414
  escrowAddress,
423
415
  amount,
424
- this.applyTxDefaults(txOptions)
416
+ txOptions
425
417
  )
426
418
  ).wait();
427
419
 
@@ -458,7 +450,7 @@ export class StakingClient extends BaseEthersClient {
458
450
 
459
451
  try {
460
452
  const stakerInfo = await this.stakingContract.stakes(stakerAddress);
461
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
453
+
462
454
  const currentBlock = await this.runner.provider!.getBlockNumber();
463
455
 
464
456
  const tokensWithdrawable =
@@ -495,11 +487,13 @@ export class StakingUtils {
495
487
  *
496
488
  * @param {ChainId} chainId Network in which the staking contract is deployed
497
489
  * @param {string} stakerAddress Address of the staker
490
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
498
491
  * @returns {Promise<IStaker>} Staker info from subgraph
499
492
  */
500
493
  public static async getStaker(
501
494
  chainId: ChainId,
502
- stakerAddress: string
495
+ stakerAddress: string,
496
+ options?: SubgraphOptions
503
497
  ): Promise<IStaker> {
504
498
  if (!ethers.isAddress(stakerAddress)) {
505
499
  throw ErrorInvalidStakerAddressProvided;
@@ -510,10 +504,11 @@ export class StakingUtils {
510
504
  throw ErrorUnsupportedChainID;
511
505
  }
512
506
 
513
- const { staker } = await gqlFetch<{ staker: StakerData }>(
507
+ const { staker } = await customGqlFetch<{ staker: StakerData }>(
514
508
  getSubgraphUrl(networkData),
515
509
  GET_STAKER_BY_ADDRESS_QUERY,
516
- { id: stakerAddress.toLowerCase() }
510
+ { id: stakerAddress.toLowerCase() },
511
+ options
517
512
  );
518
513
 
519
514
  if (!staker) {
@@ -526,9 +521,14 @@ export class StakingUtils {
526
521
  /**
527
522
  * Gets all stakers from the subgraph with filters, pagination and ordering.
528
523
  *
524
+ * @param {IStakersFilter} filter Stakers filter with pagination and ordering
525
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
529
526
  * @returns {Promise<IStaker[]>} Array of stakers
530
527
  */
531
- public static async getStakers(filter: IStakersFilter): Promise<IStaker[]> {
528
+ public static async getStakers(
529
+ filter: IStakersFilter,
530
+ options?: SubgraphOptions
531
+ ): Promise<IStaker[]> {
532
532
  const first =
533
533
  filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
534
534
  const skip = filter.skip || 0;
@@ -540,7 +540,7 @@ export class StakingUtils {
540
540
  throw ErrorUnsupportedChainID;
541
541
  }
542
542
 
543
- const { stakers } = await gqlFetch<{ stakers: StakerData[] }>(
543
+ const { stakers } = await customGqlFetch<{ stakers: StakerData[] }>(
544
544
  getSubgraphUrl(networkData),
545
545
  GET_STAKERS_QUERY(filter),
546
546
  {
@@ -572,7 +572,8 @@ export class StakingUtils {
572
572
  orderDirection: orderDirection,
573
573
  first: first,
574
574
  skip: skip,
575
- }
575
+ },
576
+ options
576
577
  );
577
578
  if (!stakers) {
578
579
  return [];
package/src/statistics.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import gqlFetch from 'graphql-request';
3
-
4
2
  import { OrderDirection } from './enums';
5
3
  import {
6
4
  EscrowStatisticsData,
@@ -21,9 +19,15 @@ import {
21
19
  IPaymentStatistics,
22
20
  IStatisticsFilter,
23
21
  IWorkerStatistics,
22
+ SubgraphOptions,
24
23
  } from './interfaces';
25
24
  import { NetworkData } from './types';
26
- import { getSubgraphUrl, getUnixTimestamp, throwError } from './utils';
25
+ import {
26
+ getSubgraphUrl,
27
+ getUnixTimestamp,
28
+ customGqlFetch,
29
+ throwError,
30
+ } from './utils';
27
31
 
28
32
  /**
29
33
  * ## Introduction
@@ -103,6 +107,7 @@ export class StatisticsClient {
103
107
  * ```
104
108
  *
105
109
  * @param {IStatisticsFilter} filter Statistics params with duration data
110
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
106
111
  * @returns {Promise<IEscrowStatistics>} Escrow statistics data.
107
112
  *
108
113
  * **Code example**
@@ -120,7 +125,8 @@ export class StatisticsClient {
120
125
  * ```
121
126
  */
122
127
  async getEscrowStatistics(
123
- filter: IStatisticsFilter = {}
128
+ filter: IStatisticsFilter = {},
129
+ options?: SubgraphOptions
124
130
  ): Promise<IEscrowStatistics> {
125
131
  try {
126
132
  const first =
@@ -128,19 +134,24 @@ export class StatisticsClient {
128
134
  const skip = filter.skip || 0;
129
135
  const orderDirection = filter.orderDirection || OrderDirection.ASC;
130
136
 
131
- const { escrowStatistics } = await gqlFetch<{
137
+ const { escrowStatistics } = await customGqlFetch<{
132
138
  escrowStatistics: EscrowStatisticsData;
133
- }>(this.subgraphUrl, GET_ESCROW_STATISTICS_QUERY);
139
+ }>(this.subgraphUrl, GET_ESCROW_STATISTICS_QUERY, options);
134
140
 
135
- const { eventDayDatas } = await gqlFetch<{
141
+ const { eventDayDatas } = await customGqlFetch<{
136
142
  eventDayDatas: EventDayData[];
137
- }>(this.subgraphUrl, GET_EVENT_DAY_DATA_QUERY(filter), {
138
- from: filter.from ? getUnixTimestamp(filter.from) : undefined,
139
- to: filter.to ? getUnixTimestamp(filter.to) : undefined,
140
- orderDirection: orderDirection,
141
- first: first,
142
- skip: skip,
143
- });
143
+ }>(
144
+ this.subgraphUrl,
145
+ GET_EVENT_DAY_DATA_QUERY(filter),
146
+ {
147
+ from: filter.from ? getUnixTimestamp(filter.from) : undefined,
148
+ to: filter.to ? getUnixTimestamp(filter.to) : undefined,
149
+ orderDirection: orderDirection,
150
+ first: first,
151
+ skip: skip,
152
+ },
153
+ options
154
+ );
144
155
 
145
156
  return {
146
157
  totalEscrows: escrowStatistics?.totalEscrowCount
@@ -187,6 +198,7 @@ export class StatisticsClient {
187
198
  * ```
188
199
  *
189
200
  * @param {IStatisticsFilter} filter Statistics params with duration data
201
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
190
202
  * @returns {Promise<IWorkerStatistics>} Worker statistics data.
191
203
  *
192
204
  * **Code example**
@@ -204,7 +216,8 @@ export class StatisticsClient {
204
216
  * ```
205
217
  */
206
218
  async getWorkerStatistics(
207
- filter: IStatisticsFilter = {}
219
+ filter: IStatisticsFilter = {},
220
+ options?: SubgraphOptions
208
221
  ): Promise<IWorkerStatistics> {
209
222
  try {
210
223
  const first =
@@ -212,15 +225,20 @@ export class StatisticsClient {
212
225
  const skip = filter.skip || 0;
213
226
  const orderDirection = filter.orderDirection || OrderDirection.ASC;
214
227
 
215
- const { eventDayDatas } = await gqlFetch<{
228
+ const { eventDayDatas } = await customGqlFetch<{
216
229
  eventDayDatas: EventDayData[];
217
- }>(this.subgraphUrl, GET_EVENT_DAY_DATA_QUERY(filter), {
218
- from: filter.from ? getUnixTimestamp(filter.from) : undefined,
219
- to: filter.to ? getUnixTimestamp(filter.to) : undefined,
220
- orderDirection: orderDirection,
221
- first: first,
222
- skip: skip,
223
- });
230
+ }>(
231
+ this.subgraphUrl,
232
+ GET_EVENT_DAY_DATA_QUERY(filter),
233
+ {
234
+ from: filter.from ? getUnixTimestamp(filter.from) : undefined,
235
+ to: filter.to ? getUnixTimestamp(filter.to) : undefined,
236
+ orderDirection: orderDirection,
237
+ first: first,
238
+ skip: skip,
239
+ },
240
+ options
241
+ );
224
242
 
225
243
  return {
226
244
  dailyWorkersData: eventDayDatas.map((eventDayData) => ({
@@ -262,6 +280,7 @@ export class StatisticsClient {
262
280
  * ```
263
281
  *
264
282
  * @param {IStatisticsFilter} filter Statistics params with duration data
283
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
265
284
  * @returns {Promise<IPaymentStatistics>} Payment statistics data.
266
285
  *
267
286
  * **Code example**
@@ -300,7 +319,8 @@ export class StatisticsClient {
300
319
  * ```
301
320
  */
302
321
  async getPaymentStatistics(
303
- filter: IStatisticsFilter = {}
322
+ filter: IStatisticsFilter = {},
323
+ options?: SubgraphOptions
304
324
  ): Promise<IPaymentStatistics> {
305
325
  try {
306
326
  const first =
@@ -308,15 +328,20 @@ export class StatisticsClient {
308
328
  const skip = filter.skip || 0;
309
329
  const orderDirection = filter.orderDirection || OrderDirection.ASC;
310
330
 
311
- const { eventDayDatas } = await gqlFetch<{
331
+ const { eventDayDatas } = await customGqlFetch<{
312
332
  eventDayDatas: EventDayData[];
313
- }>(this.subgraphUrl, GET_EVENT_DAY_DATA_QUERY(filter), {
314
- from: filter.from ? getUnixTimestamp(filter.from) : undefined,
315
- to: filter.to ? getUnixTimestamp(filter.to) : undefined,
316
- orderDirection: orderDirection,
317
- first: first,
318
- skip: skip,
319
- });
333
+ }>(
334
+ this.subgraphUrl,
335
+ GET_EVENT_DAY_DATA_QUERY(filter),
336
+ {
337
+ from: filter.from ? getUnixTimestamp(filter.from) : undefined,
338
+ to: filter.to ? getUnixTimestamp(filter.to) : undefined,
339
+ orderDirection: orderDirection,
340
+ first: first,
341
+ skip: skip,
342
+ },
343
+ options
344
+ );
320
345
 
321
346
  return {
322
347
  dailyPaymentsData: eventDayDatas.map((eventDayData) => ({
@@ -346,6 +371,7 @@ export class StatisticsClient {
346
371
  * };
347
372
  * ```
348
373
  *
374
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
349
375
  * @returns {Promise<IHMTStatistics>} HMToken statistics data.
350
376
  *
351
377
  * **Code example**
@@ -363,11 +389,11 @@ export class StatisticsClient {
363
389
  * });
364
390
  * ```
365
391
  */
366
- async getHMTStatistics(): Promise<IHMTStatistics> {
392
+ async getHMTStatistics(options?: SubgraphOptions): Promise<IHMTStatistics> {
367
393
  try {
368
- const { hmtokenStatistics } = await gqlFetch<{
394
+ const { hmtokenStatistics } = await customGqlFetch<{
369
395
  hmtokenStatistics: HMTStatisticsData;
370
- }>(this.subgraphUrl, GET_HMTOKEN_STATISTICS_QUERY);
396
+ }>(this.subgraphUrl, GET_HMTOKEN_STATISTICS_QUERY, options);
371
397
 
372
398
  return {
373
399
  totalTransferAmount: BigInt(hmtokenStatistics.totalValueTransfered),
@@ -385,6 +411,7 @@ export class StatisticsClient {
385
411
  * **Input parameters**
386
412
  *
387
413
  * @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
414
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
388
415
  * @returns {Promise<IHMTHolder[]>} List of HMToken holders.
389
416
  *
390
417
  * **Code example**
@@ -404,19 +431,23 @@ export class StatisticsClient {
404
431
  * })));
405
432
  * ```
406
433
  */
407
- async getHMTHolders(params: IHMTHoldersParams = {}): Promise<IHMTHolder[]> {
434
+ async getHMTHolders(
435
+ params: IHMTHoldersParams = {},
436
+ options?: SubgraphOptions
437
+ ): Promise<IHMTHolder[]> {
408
438
  try {
409
439
  const { address, orderDirection } = params;
410
440
  const query = GET_HOLDERS_QUERY(address);
411
441
 
412
- const { holders } = await gqlFetch<{ holders: HMTHolderData[] }>(
442
+ const { holders } = await customGqlFetch<{ holders: HMTHolderData[] }>(
413
443
  this.subgraphUrl,
414
444
  query,
415
445
  {
416
446
  address,
417
447
  orderBy: 'balance',
418
448
  orderDirection,
419
- }
449
+ },
450
+ options
420
451
  );
421
452
 
422
453
  return holders.map((holder) => ({
@@ -454,6 +485,7 @@ export class StatisticsClient {
454
485
  * ```
455
486
  *
456
487
  * @param {IStatisticsFilter} filter Statistics params with duration data
488
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
457
489
  * @returns {Promise<IDailyHMT[]>} Daily HMToken statistics data.
458
490
  *
459
491
  * **Code example**
@@ -475,22 +507,30 @@ export class StatisticsClient {
475
507
  * console.log('HMT statistics from 5/8 - 6/8:', hmtStatisticsRange);
476
508
  * ```
477
509
  */
478
- async getHMTDailyData(filter: IStatisticsFilter = {}): Promise<IDailyHMT[]> {
510
+ async getHMTDailyData(
511
+ filter: IStatisticsFilter = {},
512
+ options?: SubgraphOptions
513
+ ): Promise<IDailyHMT[]> {
479
514
  try {
480
515
  const first =
481
516
  filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
482
517
  const skip = filter.skip || 0;
483
518
  const orderDirection = filter.orderDirection || OrderDirection.ASC;
484
519
 
485
- const { eventDayDatas } = await gqlFetch<{
520
+ const { eventDayDatas } = await customGqlFetch<{
486
521
  eventDayDatas: EventDayData[];
487
- }>(this.subgraphUrl, GET_EVENT_DAY_DATA_QUERY(filter), {
488
- from: filter.from ? getUnixTimestamp(filter.from) : undefined,
489
- to: filter.to ? getUnixTimestamp(filter.to) : undefined,
490
- orderDirection: orderDirection,
491
- first: first,
492
- skip: skip,
493
- });
522
+ }>(
523
+ this.subgraphUrl,
524
+ GET_EVENT_DAY_DATA_QUERY(filter),
525
+ {
526
+ from: filter.from ? getUnixTimestamp(filter.from) : undefined,
527
+ to: filter.to ? getUnixTimestamp(filter.to) : undefined,
528
+ orderDirection: orderDirection,
529
+ first: first,
530
+ skip: skip,
531
+ },
532
+ options
533
+ );
494
534
 
495
535
  return eventDayDatas.map((eventDayData) => ({
496
536
  timestamp: +eventDayData.timestamp * 1000,
package/src/storage.ts CHANGED
@@ -79,7 +79,7 @@ export class StorageClient {
79
79
  accessKey: credentials?.accessKey ?? '',
80
80
  secretKey: credentials?.secretKey ?? '',
81
81
  });
82
- } catch (e) {
82
+ } catch {
83
83
  throw ErrorStorageClientNotInitialized;
84
84
  }
85
85
  }
@@ -122,7 +122,7 @@ export class StorageClient {
122
122
  const content = response?.read();
123
123
 
124
124
  return { key, content: JSON.parse(content?.toString('utf-8') || '') };
125
- } catch (e) {
125
+ } catch {
126
126
  throw ErrorStorageFileNotFound;
127
127
  }
128
128
  })
@@ -160,7 +160,7 @@ export class StorageClient {
160
160
  }
161
161
 
162
162
  return data;
163
- } catch (e) {
163
+ } catch {
164
164
  throw ErrorStorageFileNotFound;
165
165
  }
166
166
  }
@@ -226,7 +226,7 @@ export class StorageClient {
226
226
  }/${bucket}/${key}`,
227
227
  hash,
228
228
  };
229
- } catch (e) {
229
+ } catch {
230
230
  throw ErrorStorageFileNotUploaded;
231
231
  }
232
232
  })