@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/escrow.ts CHANGED
@@ -10,7 +10,6 @@ import {
10
10
  HMToken__factory,
11
11
  } from '@human-protocol/core/typechain-types';
12
12
  import { ContractRunner, EventLog, Overrides, Signer, ethers } from 'ethers';
13
- import gqlFetch from 'graphql-request';
14
13
  import { BaseEthersClient } from './base';
15
14
  import { ESCROW_BULK_PAYOUT_MAX_ITEMS, NETWORKS } from './constants';
16
15
  import { requiresSigner } from './decorators';
@@ -62,13 +61,16 @@ import {
62
61
  IStatusEventFilter,
63
62
  IStatusEvent,
64
63
  ICancellationRefund,
64
+ ICancellationRefundFilter,
65
65
  IPayout,
66
66
  IEscrowWithdraw,
67
+ SubgraphOptions,
67
68
  } from './interfaces';
68
69
  import { EscrowStatus, NetworkData, TransactionLikeWithNonce } from './types';
69
70
  import {
70
71
  getSubgraphUrl,
71
72
  getUnixTimestamp,
73
+ customGqlFetch,
72
74
  isValidJson,
73
75
  isValidUrl,
74
76
  throwError,
@@ -244,7 +246,7 @@ export class EscrowClient extends BaseEthersClient {
244
246
  await this.escrowFactoryContract.createEscrow(
245
247
  tokenAddress,
246
248
  jobRequesterId,
247
- this.applyTxDefaults(txOptions)
249
+ txOptions
248
250
  )
249
251
  ).wait();
250
252
 
@@ -263,6 +265,7 @@ export class EscrowClient extends BaseEthersClient {
263
265
  return throwError(e);
264
266
  }
265
267
  }
268
+
266
269
  private verifySetupParameters(escrowConfig: IEscrowConfig) {
267
270
  const {
268
271
  recordingOracle,
@@ -405,7 +408,7 @@ export class EscrowClient extends BaseEthersClient {
405
408
  exchangeOracleFee,
406
409
  manifest,
407
410
  manifestHash,
408
- this.applyTxDefaults(txOptions)
411
+ txOptions
409
412
  )
410
413
  ).wait();
411
414
 
@@ -503,7 +506,7 @@ export class EscrowClient extends BaseEthersClient {
503
506
  exchangeOracleFee,
504
507
  manifest,
505
508
  manifestHash,
506
- this.applyTxDefaults(txOptions)
509
+ txOptions
507
510
  )
508
511
  ).wait();
509
512
 
@@ -567,11 +570,7 @@ export class EscrowClient extends BaseEthersClient {
567
570
  this.runner
568
571
  );
569
572
  await (
570
- await tokenContract.transfer(
571
- escrowAddress,
572
- amount,
573
- this.applyTxDefaults(txOptions)
574
- )
573
+ await tokenContract.transfer(escrowAddress, amount, txOptions)
575
574
  ).wait();
576
575
 
577
576
  return;
@@ -692,7 +691,7 @@ export class EscrowClient extends BaseEthersClient {
692
691
  url,
693
692
  hash,
694
693
  fundsToReserve,
695
- this.applyTxDefaults(txOptions)
694
+ txOptions
696
695
  )
697
696
  ).wait();
698
697
  } else {
@@ -700,7 +699,7 @@ export class EscrowClient extends BaseEthersClient {
700
699
  await escrowContract['storeResults(string,string)'](
701
700
  url,
702
701
  hash,
703
- this.applyTxDefaults(txOptions)
702
+ txOptions
704
703
  )
705
704
  ).wait();
706
705
  }
@@ -756,9 +755,7 @@ export class EscrowClient extends BaseEthersClient {
756
755
  try {
757
756
  const escrowContract = this.getEscrowContract(escrowAddress);
758
757
 
759
- await (
760
- await escrowContract.complete(this.applyTxDefaults(txOptions))
761
- ).wait();
758
+ await (await escrowContract.complete(txOptions)).wait();
762
759
  return;
763
760
  } catch (e) {
764
761
  return throwError(e);
@@ -898,7 +895,7 @@ export class EscrowClient extends BaseEthersClient {
898
895
  finalResultsHash,
899
896
  id,
900
897
  forceComplete,
901
- this.applyTxDefaults(txOptions)
898
+ txOptions
902
899
  )
903
900
  ).wait();
904
901
  } else {
@@ -912,7 +909,7 @@ export class EscrowClient extends BaseEthersClient {
912
909
  finalResultsHash,
913
910
  id,
914
911
  forceComplete,
915
- this.applyTxDefaults(txOptions)
912
+ txOptions
916
913
  )
917
914
  ).wait();
918
915
  }
@@ -966,9 +963,7 @@ export class EscrowClient extends BaseEthersClient {
966
963
 
967
964
  try {
968
965
  const escrowContract = this.getEscrowContract(escrowAddress);
969
- await (
970
- await escrowContract.cancel(this.applyTxDefaults(txOptions))
971
- ).wait();
966
+ await (await escrowContract.cancel(txOptions)).wait();
972
967
  } catch (e) {
973
968
  return throwError(e);
974
969
  }
@@ -1014,11 +1009,7 @@ export class EscrowClient extends BaseEthersClient {
1014
1009
 
1015
1010
  try {
1016
1011
  const escrowContract = this.getEscrowContract(escrowAddress);
1017
- await (
1018
- await escrowContract.requestCancellation(
1019
- this.applyTxDefaults(txOptions)
1020
- )
1021
- ).wait();
1012
+ await (await escrowContract.requestCancellation(txOptions)).wait();
1022
1013
  } catch (e) {
1023
1014
  return throwError(e);
1024
1015
  }
@@ -1076,10 +1067,7 @@ export class EscrowClient extends BaseEthersClient {
1076
1067
  const escrowContract = this.getEscrowContract(escrowAddress);
1077
1068
 
1078
1069
  const transactionReceipt = await (
1079
- await escrowContract.withdraw(
1080
- tokenAddress,
1081
- this.applyTxDefaults(txOptions)
1082
- )
1070
+ await escrowContract.withdraw(tokenAddress, txOptions)
1083
1071
  ).wait();
1084
1072
 
1085
1073
  let amountTransferred: bigint | undefined = undefined;
@@ -1169,7 +1157,6 @@ export class EscrowClient extends BaseEthersClient {
1169
1157
  forceComplete = false,
1170
1158
  txOptions: Overrides = {}
1171
1159
  ): Promise<TransactionLikeWithNonce> {
1172
- txOptions = this.applyTxDefaults(txOptions);
1173
1160
  await this.ensureCorrectBulkPayoutInput(
1174
1161
  escrowAddress,
1175
1162
  recipients,
@@ -1940,6 +1927,7 @@ export class EscrowUtils {
1940
1927
  *
1941
1928
  *
1942
1929
  * @param {IEscrowsFilter} filter Filter parameters.
1930
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
1943
1931
  * @returns {IEscrow[]} List of escrows that match the filter.
1944
1932
  *
1945
1933
  * **Code example**
@@ -1956,7 +1944,10 @@ export class EscrowUtils {
1956
1944
  * const escrows = await EscrowUtils.getEscrows(filters);
1957
1945
  * ```
1958
1946
  */
1959
- public static async getEscrows(filter: IEscrowsFilter): Promise<IEscrow[]> {
1947
+ public static async getEscrows(
1948
+ filter: IEscrowsFilter,
1949
+ options?: SubgraphOptions
1950
+ ): Promise<IEscrow[]> {
1960
1951
  if (filter.launcher && !ethers.isAddress(filter.launcher)) {
1961
1952
  throw ErrorInvalidAddress;
1962
1953
  }
@@ -1989,7 +1980,7 @@ export class EscrowUtils {
1989
1980
  statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
1990
1981
  statuses = statuses.map((status) => EscrowStatus[status]);
1991
1982
  }
1992
- const { escrows } = await gqlFetch<{ escrows: EscrowData[] }>(
1983
+ const { escrows } = await customGqlFetch<{ escrows: EscrowData[] }>(
1993
1984
  getSubgraphUrl(networkData),
1994
1985
  GET_ESCROWS_QUERY(filter),
1995
1986
  {
@@ -2004,7 +1995,8 @@ export class EscrowUtils {
2004
1995
  orderDirection: orderDirection,
2005
1996
  first: first,
2006
1997
  skip: skip,
2007
- }
1998
+ },
1999
+ options
2008
2000
  );
2009
2001
  return (escrows || []).map((e) => mapEscrow(e, networkData.chainId));
2010
2002
  }
@@ -2062,6 +2054,7 @@ export class EscrowUtils {
2062
2054
  *
2063
2055
  * @param {ChainId} chainId Network in which the escrow has been deployed
2064
2056
  * @param {string} escrowAddress Address of the escrow
2057
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
2065
2058
  * @returns {Promise<IEscrow | null>} - Escrow data or null if not found.
2066
2059
  *
2067
2060
  * **Code example**
@@ -2074,7 +2067,8 @@ export class EscrowUtils {
2074
2067
  */
2075
2068
  public static async getEscrow(
2076
2069
  chainId: ChainId,
2077
- escrowAddress: string
2070
+ escrowAddress: string,
2071
+ options?: SubgraphOptions
2078
2072
  ): Promise<IEscrow | null> {
2079
2073
  const networkData = NETWORKS[chainId];
2080
2074
 
@@ -2086,10 +2080,11 @@ export class EscrowUtils {
2086
2080
  throw ErrorInvalidAddress;
2087
2081
  }
2088
2082
 
2089
- const { escrow } = await gqlFetch<{ escrow: EscrowData | null }>(
2083
+ const { escrow } = await customGqlFetch<{ escrow: EscrowData | null }>(
2090
2084
  getSubgraphUrl(networkData),
2091
2085
  GET_ESCROW_BY_ADDRESS_QUERY(),
2092
- { escrowAddress: escrowAddress.toLowerCase() }
2086
+ { escrowAddress: escrowAddress.toLowerCase() },
2087
+ options
2093
2088
  );
2094
2089
  if (!escrow) return null;
2095
2090
 
@@ -2132,6 +2127,7 @@ export class EscrowUtils {
2132
2127
  * ```
2133
2128
  *
2134
2129
  * @param {IStatusEventFilter} filter Filter parameters.
2130
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
2135
2131
  * @returns {Promise<StatusEvent[]>} - Array of status events with their corresponding statuses.
2136
2132
  *
2137
2133
  * **Code example**
@@ -2153,7 +2149,8 @@ export class EscrowUtils {
2153
2149
  * ```
2154
2150
  */
2155
2151
  public static async getStatusEvents(
2156
- filter: IStatusEventFilter
2152
+ filter: IStatusEventFilter,
2153
+ options?: SubgraphOptions
2157
2154
  ): Promise<IStatusEvent[]> {
2158
2155
  const {
2159
2156
  chainId,
@@ -2187,7 +2184,7 @@ export class EscrowUtils {
2187
2184
 
2188
2185
  const statusNames = effectiveStatuses.map((status) => EscrowStatus[status]);
2189
2186
 
2190
- const data = await gqlFetch<{
2187
+ const data = await customGqlFetch<{
2191
2188
  escrowStatusEvents: StatusEvent[];
2192
2189
  }>(
2193
2190
  getSubgraphUrl(networkData),
@@ -2200,7 +2197,8 @@ export class EscrowUtils {
2200
2197
  orderDirection,
2201
2198
  first: Math.min(first, 1000),
2202
2199
  skip,
2203
- }
2200
+ },
2201
+ options
2204
2202
  );
2205
2203
 
2206
2204
  if (!data || !data['escrowStatusEvents']) {
@@ -2224,6 +2222,7 @@ export class EscrowUtils {
2224
2222
  * Fetch payouts from the subgraph.
2225
2223
  *
2226
2224
  * @param {IPayoutFilter} filter Filter parameters.
2225
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
2227
2226
  * @returns {Promise<IPayout[]>} List of payouts matching the filters.
2228
2227
  *
2229
2228
  * **Code example**
@@ -2241,7 +2240,10 @@ export class EscrowUtils {
2241
2240
  * console.log(payouts);
2242
2241
  * ```
2243
2242
  */
2244
- public static async getPayouts(filter: IPayoutFilter): Promise<IPayout[]> {
2243
+ public static async getPayouts(
2244
+ filter: IPayoutFilter,
2245
+ options?: SubgraphOptions
2246
+ ): Promise<IPayout[]> {
2245
2247
  const networkData = NETWORKS[filter.chainId];
2246
2248
  if (!networkData) {
2247
2249
  throw ErrorUnsupportedChainID;
@@ -2258,7 +2260,7 @@ export class EscrowUtils {
2258
2260
  const skip = filter.skip || 0;
2259
2261
  const orderDirection = filter.orderDirection || OrderDirection.DESC;
2260
2262
 
2261
- const { payouts } = await gqlFetch<{ payouts: PayoutData[] }>(
2263
+ const { payouts } = await customGqlFetch<{ payouts: PayoutData[] }>(
2262
2264
  getSubgraphUrl(networkData),
2263
2265
  GET_PAYOUTS_QUERY(filter),
2264
2266
  {
@@ -2269,7 +2271,8 @@ export class EscrowUtils {
2269
2271
  first: Math.min(first, 1000),
2270
2272
  skip,
2271
2273
  orderDirection,
2272
- }
2274
+ },
2275
+ options
2273
2276
  );
2274
2277
  if (!payouts) {
2275
2278
  return [];
@@ -2318,6 +2321,7 @@ export class EscrowUtils {
2318
2321
  *
2319
2322
  *
2320
2323
  * @param {Object} filter Filter parameters.
2324
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
2321
2325
  * @returns {Promise<ICancellationRefund[]>} List of cancellation refunds matching the filters.
2322
2326
  *
2323
2327
  * **Code example**
@@ -2332,16 +2336,10 @@ export class EscrowUtils {
2332
2336
  * console.log(cancellationRefunds);
2333
2337
  * ```
2334
2338
  */
2335
- public static async getCancellationRefunds(filter: {
2336
- chainId: ChainId;
2337
- escrowAddress?: string;
2338
- receiver?: string;
2339
- from?: Date;
2340
- to?: Date;
2341
- first?: number;
2342
- skip?: number;
2343
- orderDirection?: OrderDirection;
2344
- }): Promise<ICancellationRefund[]> {
2339
+ public static async getCancellationRefunds(
2340
+ filter: ICancellationRefundFilter,
2341
+ options?: SubgraphOptions
2342
+ ): Promise<ICancellationRefund[]> {
2345
2343
  const networkData = NETWORKS[filter.chainId];
2346
2344
  if (!networkData) throw ErrorUnsupportedChainID;
2347
2345
  if (filter.escrowAddress && !ethers.isAddress(filter.escrowAddress)) {
@@ -2356,17 +2354,22 @@ export class EscrowUtils {
2356
2354
  const skip = filter.skip || 0;
2357
2355
  const orderDirection = filter.orderDirection || OrderDirection.DESC;
2358
2356
 
2359
- const { cancellationRefundEvents } = await gqlFetch<{
2357
+ const { cancellationRefundEvents } = await customGqlFetch<{
2360
2358
  cancellationRefundEvents: CancellationRefundData[];
2361
- }>(getSubgraphUrl(networkData), GET_CANCELLATION_REFUNDS_QUERY(filter), {
2362
- escrowAddress: filter.escrowAddress?.toLowerCase(),
2363
- receiver: filter.receiver?.toLowerCase(),
2364
- from: filter.from ? getUnixTimestamp(filter.from) : undefined,
2365
- to: filter.to ? getUnixTimestamp(filter.to) : undefined,
2366
- first,
2367
- skip,
2368
- orderDirection,
2369
- });
2359
+ }>(
2360
+ getSubgraphUrl(networkData),
2361
+ GET_CANCELLATION_REFUNDS_QUERY(filter),
2362
+ {
2363
+ escrowAddress: filter.escrowAddress?.toLowerCase(),
2364
+ receiver: filter.receiver?.toLowerCase(),
2365
+ from: filter.from ? getUnixTimestamp(filter.from) : undefined,
2366
+ to: filter.to ? getUnixTimestamp(filter.to) : undefined,
2367
+ first,
2368
+ skip,
2369
+ orderDirection,
2370
+ },
2371
+ options
2372
+ );
2370
2373
 
2371
2374
  if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
2372
2375
  return [];
@@ -2418,6 +2421,7 @@ export class EscrowUtils {
2418
2421
  *
2419
2422
  * @param {ChainId} chainId Network in which the escrow has been deployed
2420
2423
  * @param {string} escrowAddress Address of the escrow
2424
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
2421
2425
  * @returns {Promise<ICancellationRefund>} Cancellation refund data
2422
2426
  *
2423
2427
  * **Code example**
@@ -2430,7 +2434,8 @@ export class EscrowUtils {
2430
2434
  */
2431
2435
  public static async getCancellationRefund(
2432
2436
  chainId: ChainId,
2433
- escrowAddress: string
2437
+ escrowAddress: string,
2438
+ options?: SubgraphOptions
2434
2439
  ): Promise<ICancellationRefund | null> {
2435
2440
  const networkData = NETWORKS[chainId];
2436
2441
  if (!networkData) throw ErrorUnsupportedChainID;
@@ -2439,12 +2444,13 @@ export class EscrowUtils {
2439
2444
  throw ErrorInvalidEscrowAddressProvided;
2440
2445
  }
2441
2446
 
2442
- const { cancellationRefundEvents } = await gqlFetch<{
2447
+ const { cancellationRefundEvents } = await customGqlFetch<{
2443
2448
  cancellationRefundEvents: CancellationRefundData[];
2444
2449
  }>(
2445
2450
  getSubgraphUrl(networkData),
2446
2451
  GET_CANCELLATION_REFUND_BY_ADDRESS_QUERY(),
2447
- { escrowAddress: escrowAddress.toLowerCase() }
2452
+ { escrowAddress: escrowAddress.toLowerCase() },
2453
+ options
2448
2454
  );
2449
2455
 
2450
2456
  if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
package/src/interfaces.ts CHANGED
@@ -312,3 +312,18 @@ export interface IEscrowWithdraw {
312
312
  tokenAddress: string;
313
313
  withdrawnAmount: bigint;
314
314
  }
315
+
316
+ /**
317
+ * Configuration options for subgraph requests with retry logic.
318
+ */
319
+ export interface SubgraphOptions {
320
+ /** Maximum number of retry attempts */
321
+ maxRetries?: number;
322
+ /** Base delay between retries in milliseconds */
323
+ baseDelay?: number;
324
+ /**
325
+ * Optional indexer identifier. When provided, requests target
326
+ * `{gateway}/deployments/id/<DEPLOYMENT_ID>/indexers/id/<INDEXER_ID>`.
327
+ */
328
+ indexerId?: string;
329
+ }
package/src/kvstore.ts CHANGED
@@ -17,15 +17,14 @@ import {
17
17
  ErrorUnsupportedChainID,
18
18
  InvalidKeyError,
19
19
  } from './error';
20
- import gqlFetch from 'graphql-request';
21
20
  import { NetworkData } from './types';
22
- import { getSubgraphUrl, isValidUrl } from './utils';
21
+ import { getSubgraphUrl, customGqlFetch, isValidUrl } from './utils';
23
22
  import {
24
23
  GET_KVSTORE_BY_ADDRESS_AND_KEY_QUERY,
25
24
  GET_KVSTORE_BY_ADDRESS_QUERY,
26
25
  } from './graphql/queries/kvstore';
27
26
  import { KVStoreData } from './graphql';
28
- import { IKVStore } from './interfaces';
27
+ import { IKVStore, SubgraphOptions } from './interfaces';
29
28
  /**
30
29
  * ## Introduction
31
30
  *
@@ -175,9 +174,7 @@ export class KVStoreClient extends BaseEthersClient {
175
174
  ): Promise<void> {
176
175
  if (key === '') throw ErrorKVStoreEmptyKey;
177
176
  try {
178
- await (
179
- await this.contract.set(key, value, this.applyTxDefaults(txOptions))
180
- ).wait();
177
+ await (await this.contract.set(key, value, txOptions)).wait();
181
178
  } catch (e) {
182
179
  if (e instanceof Error) throw Error(`Failed to set value: ${e.message}`);
183
180
  }
@@ -222,13 +219,7 @@ export class KVStoreClient extends BaseEthersClient {
222
219
  if (keys.includes('')) throw ErrorKVStoreEmptyKey;
223
220
 
224
221
  try {
225
- await (
226
- await this.contract.setBulk(
227
- keys,
228
- values,
229
- this.applyTxDefaults(txOptions)
230
- )
231
- ).wait();
222
+ await (await this.contract.setBulk(keys, values, txOptions)).wait();
232
223
  } catch (e) {
233
224
  if (e instanceof Error)
234
225
  throw Error(`Failed to set bulk values: ${e.message}`);
@@ -281,7 +272,7 @@ export class KVStoreClient extends BaseEthersClient {
281
272
  await this.contract.setBulk(
282
273
  [urlKey, hashKey],
283
274
  [url, contentHash],
284
- this.applyTxDefaults(txOptions)
275
+ txOptions
285
276
  )
286
277
  ).wait();
287
278
  } catch (e) {
@@ -294,6 +285,7 @@ export class KVStoreClient extends BaseEthersClient {
294
285
  *
295
286
  * @param {string} address Address from which to get the key value.
296
287
  * @param {string} key Key to obtain the value.
288
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
297
289
  * @returns {string} Value of the key.
298
290
  *
299
291
  *
@@ -365,6 +357,7 @@ export class KVStoreUtils {
365
357
  *
366
358
  * @param {ChainId} chainId Network in which the KVStore is deployed
367
359
  * @param {string} address Address of the KVStore
360
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
368
361
  * @returns {Promise<IKVStore[]>} KVStore data
369
362
  * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
370
363
  * @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
@@ -380,7 +373,8 @@ export class KVStoreUtils {
380
373
  */
381
374
  public static async getKVStoreData(
382
375
  chainId: ChainId,
383
- address: string
376
+ address: string,
377
+ options?: SubgraphOptions
384
378
  ): Promise<IKVStore[]> {
385
379
  const networkData = NETWORKS[chainId];
386
380
 
@@ -392,10 +386,11 @@ export class KVStoreUtils {
392
386
  throw ErrorInvalidAddress;
393
387
  }
394
388
 
395
- const { kvstores } = await gqlFetch<{ kvstores: KVStoreData[] }>(
389
+ const { kvstores } = await customGqlFetch<{ kvstores: KVStoreData[] }>(
396
390
  getSubgraphUrl(networkData),
397
391
  GET_KVSTORE_BY_ADDRESS_QUERY(),
398
- { address: address.toLowerCase() }
392
+ { address: address.toLowerCase() },
393
+ options
399
394
  );
400
395
 
401
396
  const kvStoreData = kvstores.map((item) => ({
@@ -412,6 +407,7 @@ export class KVStoreUtils {
412
407
  * @param {ChainId} chainId Network in which the KVStore is deployed
413
408
  * @param {string} address Address from which to get the key value.
414
409
  * @param {string} key Key to obtain the value.
410
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
415
411
  * @returns {Promise<string>} Value of the key.
416
412
  * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
417
413
  * @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
@@ -433,7 +429,8 @@ export class KVStoreUtils {
433
429
  public static async get(
434
430
  chainId: ChainId,
435
431
  address: string,
436
- key: string
432
+ key: string,
433
+ options?: SubgraphOptions
437
434
  ): Promise<string> {
438
435
  if (key === '') throw ErrorKVStoreEmptyKey;
439
436
  if (!ethers.isAddress(address)) throw ErrorInvalidAddress;
@@ -444,10 +441,11 @@ export class KVStoreUtils {
444
441
  throw ErrorUnsupportedChainID;
445
442
  }
446
443
 
447
- const { kvstores } = await gqlFetch<{ kvstores: KVStoreData[] }>(
444
+ const { kvstores } = await customGqlFetch<{ kvstores: KVStoreData[] }>(
448
445
  getSubgraphUrl(networkData),
449
446
  GET_KVSTORE_BY_ADDRESS_AND_KEY_QUERY(),
450
- { address: address.toLowerCase(), key }
447
+ { address: address.toLowerCase(), key },
448
+ options
451
449
  );
452
450
 
453
451
  if (!kvstores || kvstores.length === 0) {
@@ -463,6 +461,7 @@ export class KVStoreUtils {
463
461
  * @param {ChainId} chainId Network in which the KVStore is deployed
464
462
  * @param {string} address Address from which to get the URL value.
465
463
  * @param {string} urlKey Configurable URL key. `url` by default.
464
+ * @param {SubgraphOptions} options Optional configuration for subgraph requests.
466
465
  * @returns {Promise<string>} URL value for the given address if it exists, and the content is valid
467
466
  *
468
467
  * **Code example**
@@ -480,7 +479,8 @@ export class KVStoreUtils {
480
479
  public static async getFileUrlAndVerifyHash(
481
480
  chainId: ChainId,
482
481
  address: string,
483
- urlKey = 'url'
482
+ urlKey = 'url',
483
+ options?: SubgraphOptions
484
484
  ): Promise<string> {
485
485
  if (!ethers.isAddress(address)) throw ErrorInvalidAddress;
486
486
  const hashKey = urlKey + '_hash';
@@ -489,7 +489,7 @@ export class KVStoreUtils {
489
489
  hash = '';
490
490
 
491
491
  try {
492
- url = await this.get(chainId, address, urlKey);
492
+ url = await this.get(chainId, address, urlKey, options);
493
493
  } catch (e) {
494
494
  if (e instanceof Error) throw Error(`Failed to get URL: ${e.message}`);
495
495
  }
@@ -539,12 +539,14 @@ export class KVStoreUtils {
539
539
  */
540
540
  public static async getPublicKey(
541
541
  chainId: ChainId,
542
- address: string
542
+ address: string,
543
+ options?: SubgraphOptions
543
544
  ): Promise<string> {
544
545
  const publicKeyUrl = await this.getFileUrlAndVerifyHash(
545
546
  chainId,
546
547
  address,
547
- KVStoreKeys.publicKey
548
+ KVStoreKeys.publicKey,
549
+ options
548
550
  );
549
551
 
550
552
  if (publicKeyUrl === '') {