@human-protocol/sdk 2.1.3 → 3.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 (54) hide show
  1. package/dist/constants.d.ts +1 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +56 -24
  4. package/dist/enums.d.ts +3 -2
  5. package/dist/enums.d.ts.map +1 -1
  6. package/dist/enums.js +2 -1
  7. package/dist/error.d.ts +9 -0
  8. package/dist/error.d.ts.map +1 -1
  9. package/dist/error.js +11 -2
  10. package/dist/escrow.d.ts +1 -2
  11. package/dist/escrow.d.ts.map +1 -1
  12. package/dist/escrow.js +3 -4
  13. package/dist/graphql/queries/kvstore.d.ts +2 -0
  14. package/dist/graphql/queries/kvstore.d.ts.map +1 -0
  15. package/dist/graphql/queries/kvstore.js +28 -0
  16. package/dist/graphql/queries/transaction.d.ts +4 -0
  17. package/dist/graphql/queries/transaction.d.ts.map +1 -0
  18. package/dist/graphql/queries/transaction.js +59 -0
  19. package/dist/graphql/types.d.ts +8 -0
  20. package/dist/graphql/types.d.ts.map +1 -1
  21. package/dist/interfaces.d.ts +23 -1
  22. package/dist/interfaces.d.ts.map +1 -1
  23. package/dist/kvstore.d.ts +84 -0
  24. package/dist/kvstore.d.ts.map +1 -1
  25. package/dist/kvstore.js +103 -1
  26. package/dist/operator.d.ts +5 -2
  27. package/dist/operator.d.ts.map +1 -1
  28. package/dist/operator.js +50 -22
  29. package/dist/statistics.d.ts +1 -0
  30. package/dist/statistics.d.ts.map +1 -1
  31. package/dist/statistics.js +8 -7
  32. package/dist/transaction.d.ts +69 -0
  33. package/dist/transaction.d.ts.map +1 -0
  34. package/dist/transaction.js +121 -0
  35. package/dist/types.d.ts +4 -0
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/utils.d.ts +9 -0
  38. package/dist/utils.d.ts.map +1 -1
  39. package/dist/utils.js +21 -1
  40. package/package.json +4 -4
  41. package/src/constants.ts +73 -23
  42. package/src/enums.ts +2 -1
  43. package/src/error.ts +15 -0
  44. package/src/escrow.ts +4 -5
  45. package/src/graphql/queries/kvstore.ts +23 -0
  46. package/src/graphql/queries/transaction.ts +59 -0
  47. package/src/graphql/types.ts +9 -0
  48. package/src/interfaces.ts +26 -1
  49. package/src/kvstore.ts +114 -1
  50. package/src/operator.ts +62 -29
  51. package/src/statistics.ts +10 -8
  52. package/src/transaction.ts +142 -0
  53. package/src/types.ts +4 -0
  54. package/src/utils.ts +25 -0
package/dist/kvstore.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { ContractRunner, Overrides } from 'ethers';
2
2
  import { BaseEthersClient } from './base';
3
+ import { ChainId } from './enums';
3
4
  import { NetworkData } from './types';
5
+ import { IKVStore } from './interfaces';
4
6
  /**
5
7
  * ## Introduction
6
8
  *
@@ -249,4 +251,86 @@ export declare class KVStoreClient extends BaseEthersClient {
249
251
  */
250
252
  getPublicKey(address: string): Promise<string>;
251
253
  }
254
+ /**
255
+ * ## Introduction
256
+ *
257
+ * Utility class for KVStore-related operations.
258
+ *
259
+ * ## Installation
260
+ *
261
+ * ### npm
262
+ * ```bash
263
+ * npm install @human-protocol/sdk
264
+ * ```
265
+ *
266
+ * ### yarn
267
+ * ```bash
268
+ * yarn install @human-protocol/sdk
269
+ * ```
270
+ *
271
+ * ## Code example
272
+ *
273
+ * ### Signer
274
+ *
275
+ * **Using private key (backend)**
276
+ *
277
+ * ```ts
278
+ * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
279
+ *
280
+ * const KVStoreAddresses = new KVStoreUtils.getData({
281
+ * networks: [ChainId.POLYGON_AMOY]
282
+ * });
283
+ * ```
284
+ */
285
+ export declare class KVStoreUtils {
286
+ /**
287
+ * This function returns the KVStore data for a given address.
288
+ *
289
+ * > This uses Subgraph
290
+ *
291
+ * **Input parameters**
292
+ *
293
+ * ```ts
294
+ * enum ChainId {
295
+ * ALL = -1,
296
+ * MAINNET = 1,
297
+ * RINKEBY = 4,
298
+ * GOERLI = 5,
299
+ * BSC_MAINNET = 56,
300
+ * BSC_TESTNET = 97,
301
+ * POLYGON = 137,
302
+ * POLYGON_MUMBAI = 80001,
303
+ * POLYGON_AMOY = 80002,
304
+ * MOONBEAM = 1284,
305
+ * MOONBASE_ALPHA = 1287,
306
+ * AVALANCHE = 43114,
307
+ * AVALANCHE_TESTNET = 43113,
308
+ * CELO = 42220,
309
+ * CELO_ALFAJORES = 44787,
310
+ * LOCALHOST = 1338,
311
+ * }
312
+ * ```
313
+ *
314
+ * ```ts
315
+ * interface IKVStore {
316
+ * key: string;
317
+ * value: string;
318
+ * }
319
+ * ```
320
+ *
321
+ * @param {ChainId} chainId Network in which the KVStore is deployed
322
+ * @param {string} address Address of the KVStore
323
+ * @returns {Promise<IKVStore[]>} KVStore data
324
+ *
325
+ * **Code example**
326
+ *
327
+ * ```ts
328
+ * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
329
+ *
330
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(ChainId.POLYGON_AMOY, "0x1234567890123456789012345678901234567890");
331
+ * console.log(kvStoreData);
332
+ * ```
333
+ */
334
+ static getKVStoreData(chainId: ChainId, address: string): Promise<IKVStore[]>;
335
+ }
252
336
  //# sourceMappingURL=kvstore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAa1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;;OAKG;gBACS,MAAM,EAAE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Aa,YAAY;IACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,QAAQ,EAAE,CAAC;CAwBvB"}
package/dist/kvstore.js CHANGED
@@ -8,15 +8,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.KVStoreClient = void 0;
15
+ exports.KVStoreUtils = exports.KVStoreClient = void 0;
13
16
  const typechain_types_1 = require("@human-protocol/core/typechain-types");
14
17
  const ethers_1 = require("ethers");
15
18
  const base_1 = require("./base");
16
19
  const constants_1 = require("./constants");
17
20
  const decorators_1 = require("./decorators");
18
21
  const error_1 = require("./error");
22
+ const graphql_request_1 = __importDefault(require("graphql-request"));
19
23
  const utils_1 = require("./utils");
24
+ const kvstore_1 = require("./graphql/queries/kvstore");
20
25
  /**
21
26
  * ## Introduction
22
27
  *
@@ -383,3 +388,100 @@ __decorate([
383
388
  __metadata("design:returntype", Promise)
384
389
  ], KVStoreClient.prototype, "setFileUrlAndHash", null);
385
390
  exports.KVStoreClient = KVStoreClient;
391
+ /**
392
+ * ## Introduction
393
+ *
394
+ * Utility class for KVStore-related operations.
395
+ *
396
+ * ## Installation
397
+ *
398
+ * ### npm
399
+ * ```bash
400
+ * npm install @human-protocol/sdk
401
+ * ```
402
+ *
403
+ * ### yarn
404
+ * ```bash
405
+ * yarn install @human-protocol/sdk
406
+ * ```
407
+ *
408
+ * ## Code example
409
+ *
410
+ * ### Signer
411
+ *
412
+ * **Using private key (backend)**
413
+ *
414
+ * ```ts
415
+ * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
416
+ *
417
+ * const KVStoreAddresses = new KVStoreUtils.getData({
418
+ * networks: [ChainId.POLYGON_AMOY]
419
+ * });
420
+ * ```
421
+ */
422
+ class KVStoreUtils {
423
+ /**
424
+ * This function returns the KVStore data for a given address.
425
+ *
426
+ * > This uses Subgraph
427
+ *
428
+ * **Input parameters**
429
+ *
430
+ * ```ts
431
+ * enum ChainId {
432
+ * ALL = -1,
433
+ * MAINNET = 1,
434
+ * RINKEBY = 4,
435
+ * GOERLI = 5,
436
+ * BSC_MAINNET = 56,
437
+ * BSC_TESTNET = 97,
438
+ * POLYGON = 137,
439
+ * POLYGON_MUMBAI = 80001,
440
+ * POLYGON_AMOY = 80002,
441
+ * MOONBEAM = 1284,
442
+ * MOONBASE_ALPHA = 1287,
443
+ * AVALANCHE = 43114,
444
+ * AVALANCHE_TESTNET = 43113,
445
+ * CELO = 42220,
446
+ * CELO_ALFAJORES = 44787,
447
+ * LOCALHOST = 1338,
448
+ * }
449
+ * ```
450
+ *
451
+ * ```ts
452
+ * interface IKVStore {
453
+ * key: string;
454
+ * value: string;
455
+ * }
456
+ * ```
457
+ *
458
+ * @param {ChainId} chainId Network in which the KVStore is deployed
459
+ * @param {string} address Address of the KVStore
460
+ * @returns {Promise<IKVStore[]>} KVStore data
461
+ *
462
+ * **Code example**
463
+ *
464
+ * ```ts
465
+ * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
466
+ *
467
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(ChainId.POLYGON_AMOY, "0x1234567890123456789012345678901234567890");
468
+ * console.log(kvStoreData);
469
+ * ```
470
+ */
471
+ static async getKVStoreData(chainId, address) {
472
+ const networkData = constants_1.NETWORKS[chainId];
473
+ if (!networkData) {
474
+ throw error_1.ErrorUnsupportedChainID;
475
+ }
476
+ if (address && !ethers_1.ethers.isAddress(address)) {
477
+ throw error_1.ErrorInvalidAddress;
478
+ }
479
+ const { kvstores } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, kvstore_1.GET_KVSTORE_BY_ADDRESS_QUERY)(), { address: address.toLowerCase() });
480
+ const kvStoreData = kvstores.map((item) => ({
481
+ key: item.key,
482
+ value: item.value,
483
+ }));
484
+ return kvStoreData || [];
485
+ }
486
+ }
487
+ exports.KVStoreUtils = KVStoreUtils;
@@ -29,10 +29,13 @@ export declare class OperatorUtils {
29
29
  * ```ts
30
30
  * import { OperatorUtils } from '@human-protocol/sdk';
31
31
  *
32
- * const leaders = await OperatorUtils.getLeaders();
32
+ * const filter: ILeadersFilter = {
33
+ * chainId: ChainId.POLYGON
34
+ * };
35
+ * const leaders = await OperatorUtils.getLeaders(filter);
33
36
  * ```
34
37
  */
35
- static getLeaders(filter?: ILeadersFilter): Promise<ILeader[]>;
38
+ static getLeaders(filter: ILeadersFilter): Promise<ILeader[]>;
36
39
  /**
37
40
  * Retrieves the reputation network operators of the specified address.
38
41
  *
@@ -1 +1 @@
1
- {"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAEP,cAAc,EACd,SAAS,EAET,OAAO,EACR,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;OAcG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;IA0BnB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,MAAM,GAAE,cAAqD,GAC5D,OAAO,CAAC,OAAO,EAAE,CAAC;IA4BrB;;;;;;;;;;;;;OAaG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,EAAE,CAAC;IAuBvB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,EAAE,CAAC;CA2BtB"}
1
+ {"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAEP,cAAc,EACd,SAAS,EAET,OAAO,EACR,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;OAcG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;IAkCnB;;;;;;;;;;;;;;;;;OAiBG;WACiB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA0C1E;;;;;;;;;;;;;OAaG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,EAAE,CAAC;IAiCvB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,EAAE,CAAC;CA2BtB"}
package/dist/operator.js CHANGED
@@ -11,7 +11,6 @@ const operator_1 = require("./graphql/queries/operator");
11
11
  const ethers_1 = require("ethers");
12
12
  const error_1 = require("./error");
13
13
  const utils_1 = require("./utils");
14
- const enums_1 = require("./enums");
15
14
  const constants_1 = require("./constants");
16
15
  class OperatorUtils {
17
16
  /**
@@ -38,12 +37,19 @@ class OperatorUtils {
38
37
  throw error_1.ErrorUnsupportedChainID;
39
38
  }
40
39
  try {
41
- const { leader } = await (0, graphql_request_1.default)(networkData.subgraphUrl, operator_1.GET_LEADER_QUERY, {
40
+ const { leader } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), operator_1.GET_LEADER_QUERY, {
42
41
  address: address.toLowerCase(),
43
42
  });
43
+ let jobTypes = [];
44
+ if (typeof leader.jobTypes === 'string') {
45
+ jobTypes = leader.jobTypes.split(',');
46
+ }
47
+ else if (Array.isArray(leader.jobTypes)) {
48
+ jobTypes = leader.jobTypes;
49
+ }
44
50
  return {
45
51
  ...leader,
46
- jobTypes: leader.jobTypes?.split(','),
52
+ jobTypes,
47
53
  };
48
54
  }
49
55
  catch (e) {
@@ -62,25 +68,38 @@ class OperatorUtils {
62
68
  * ```ts
63
69
  * import { OperatorUtils } from '@human-protocol/sdk';
64
70
  *
65
- * const leaders = await OperatorUtils.getLeaders();
71
+ * const filter: ILeadersFilter = {
72
+ * chainId: ChainId.POLYGON
73
+ * };
74
+ * const leaders = await OperatorUtils.getLeaders(filter);
66
75
  * ```
67
76
  */
68
- static async getLeaders(filter = { networks: [enums_1.ChainId.POLYGON_AMOY] }) {
77
+ static async getLeaders(filter) {
69
78
  try {
70
79
  let leaders_data = [];
71
- for (const chainId of filter.networks) {
72
- const networkData = constants_1.NETWORKS[chainId];
73
- if (!networkData) {
74
- throw error_1.ErrorUnsupportedChainID;
80
+ const networkData = constants_1.NETWORKS[filter.chainId];
81
+ if (!networkData) {
82
+ throw error_1.ErrorUnsupportedChainID;
83
+ }
84
+ const { leaders } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_LEADERS_QUERY)(filter), {
85
+ role: filter?.role,
86
+ });
87
+ if (!leaders) {
88
+ return [];
89
+ }
90
+ leaders_data = leaders_data.concat(leaders.map((leader) => {
91
+ let jobTypes = [];
92
+ if (typeof leader.jobTypes === 'string') {
93
+ jobTypes = leader.jobTypes.split(',');
94
+ }
95
+ else if (Array.isArray(leader.jobTypes)) {
96
+ jobTypes = leader.jobTypes;
75
97
  }
76
- const { leaders } = await (0, graphql_request_1.default)(networkData.subgraphUrl, (0, operator_1.GET_LEADERS_QUERY)(filter), {
77
- role: filter.role,
78
- });
79
- leaders_data = leaders_data.concat(leaders.map((leader) => ({
98
+ return {
80
99
  ...leader,
81
- jobTypes: leader.jobTypes?.split(','),
82
- })));
83
- }
100
+ jobTypes,
101
+ };
102
+ }));
84
103
  return leaders_data;
85
104
  }
86
105
  catch (e) {
@@ -107,14 +126,23 @@ class OperatorUtils {
107
126
  throw error_1.ErrorUnsupportedChainID;
108
127
  }
109
128
  try {
110
- const { reputationNetwork } = await (0, graphql_request_1.default)(networkData.subgraphUrl, (0, operator_1.GET_REPUTATION_NETWORK_QUERY)(role), {
129
+ const { reputationNetwork } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_REPUTATION_NETWORK_QUERY)(role), {
111
130
  address: address.toLowerCase(),
112
131
  role: role,
113
132
  });
114
- return reputationNetwork.operators.map((operator) => ({
115
- ...operator,
116
- jobTypes: operator.jobTypes?.split(','),
117
- }));
133
+ return reputationNetwork.operators.map((operator) => {
134
+ let jobTypes = [];
135
+ if (typeof operator.jobTypes === 'string') {
136
+ jobTypes = operator.jobTypes.split(',');
137
+ }
138
+ else if (Array.isArray(operator.jobTypes)) {
139
+ jobTypes = operator.jobTypes;
140
+ }
141
+ return {
142
+ ...operator,
143
+ jobTypes,
144
+ };
145
+ });
118
146
  }
119
147
  catch (e) {
120
148
  return (0, utils_1.throwError)(e);
@@ -144,7 +172,7 @@ class OperatorUtils {
144
172
  throw error_1.ErrorUnsupportedChainID;
145
173
  }
146
174
  try {
147
- const { rewardAddedEvents } = await (0, graphql_request_1.default)(networkData.subgraphUrl, reward_1.GET_REWARD_ADDED_EVENTS_QUERY, {
175
+ const { rewardAddedEvents } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), reward_1.GET_REWARD_ADDED_EVENTS_QUERY, {
148
176
  slasherAddress: slasherAddress.toLowerCase(),
149
177
  });
150
178
  return rewardAddedEvents.map((reward) => {
@@ -40,6 +40,7 @@ import { NetworkData } from './types';
40
40
  */
41
41
  export declare class StatisticsClient {
42
42
  networkData: NetworkData;
43
+ subgraphUrl: string;
43
44
  /**
44
45
  * **StatisticsClient constructor**
45
46
  *
@@ -1 +1 @@
1
- {"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,gBAAgB,EAGhB,aAAa,EAEb,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,gBAAgB;IACpB,WAAW,EAAE,WAAW,CAAC;IAEhC;;;;OAIG;gBACS,WAAW,EAAE,WAAW;IAIpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA6B5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAoB5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkEG;IACG,oBAAoB,CACxB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IA0B7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgFG;IACG,gBAAgB,CACpB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,aAAa,CAAC;CAuC1B"}
1
+ {"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,gBAAgB,EAGhB,aAAa,EAEb,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,gBAAgB;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;gBACS,WAAW,EAAE,WAAW;IAKpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA6B5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAoB5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkEG;IACG,oBAAoB,CACxB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IA0B7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgFG;IACG,gBAAgB,CACpB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,aAAa,CAAC;CAuC1B"}
@@ -54,6 +54,7 @@ class StatisticsClient {
54
54
  */
55
55
  constructor(networkData) {
56
56
  this.networkData = networkData;
57
+ this.subgraphUrl = (0, utils_1.getSubgraphUrl)(networkData);
57
58
  }
58
59
  /**
59
60
  * This function returns the statistical data of escrows.
@@ -106,8 +107,8 @@ class StatisticsClient {
106
107
  */
107
108
  async getEscrowStatistics(params = {}) {
108
109
  try {
109
- const { escrowStatistics } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, graphql_1.GET_ESCROW_STATISTICS_QUERY);
110
- const { eventDayDatas } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
110
+ const { escrowStatistics } = await (0, graphql_request_1.default)(this.subgraphUrl, graphql_1.GET_ESCROW_STATISTICS_QUERY);
111
+ const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
111
112
  from: params.from ? params.from.getTime() / 1000 : undefined,
112
113
  to: params.to ? params.to.getTime() / 1000 : undefined,
113
114
  });
@@ -173,7 +174,7 @@ class StatisticsClient {
173
174
  */
174
175
  async getWorkerStatistics(params = {}) {
175
176
  try {
176
- const { eventDayDatas } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
177
+ const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
177
178
  from: params.from ? params.from.getTime() / 1000 : undefined,
178
179
  to: params.to ? params.to.getTime() / 1000 : undefined,
179
180
  });
@@ -257,7 +258,7 @@ class StatisticsClient {
257
258
  */
258
259
  async getPaymentStatistics(params = {}) {
259
260
  try {
260
- const { eventDayDatas } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
261
+ const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
261
262
  from: params.from ? params.from.getTime() / 1000 : undefined,
262
263
  to: params.to ? params.to.getTime() / 1000 : undefined,
263
264
  });
@@ -360,9 +361,9 @@ class StatisticsClient {
360
361
  */
361
362
  async getHMTStatistics(params = {}) {
362
363
  try {
363
- const { hmtokenStatistics } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, graphql_1.GET_HMTOKEN_STATISTICS_QUERY);
364
- const { holders } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, graphql_1.GET_HOLDERS_QUERY);
365
- const { eventDayDatas } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
364
+ const { hmtokenStatistics } = await (0, graphql_request_1.default)(this.subgraphUrl, graphql_1.GET_HMTOKEN_STATISTICS_QUERY);
365
+ const { holders } = await (0, graphql_request_1.default)(this.subgraphUrl, graphql_1.GET_HOLDERS_QUERY);
366
+ const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
366
367
  from: params.from ? params.from.getTime() / 1000 : undefined,
367
368
  to: params.to ? params.to.getTime() / 1000 : undefined,
368
369
  });
@@ -0,0 +1,69 @@
1
+ import { ChainId } from './enums';
2
+ import { ITransaction, ITransactionsFilter } from './interfaces';
3
+ export declare class TransactionUtils {
4
+ /**
5
+ * This function returns the transaction data for the given hash.
6
+ *
7
+ * @param {ChainId} chainId The chain ID.
8
+ * @param {string} hash The transaction hash.
9
+ * @returns {Promise<ITransaction>} Returns the transaction details.
10
+ *
11
+ * **Code example**
12
+ *
13
+ * ```ts
14
+ * import { TransactionUtils, ChainId } from '@human-protocol/sdk';
15
+ *
16
+ * const transaction = await TransactionUtils.getTransaction(ChainId.POLYGON, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
17
+ * ```
18
+ */
19
+ static getTransaction(chainId: ChainId, hash: string): Promise<ITransaction>;
20
+ /**
21
+ * This function returns all transaction details based on the provided filter.
22
+ *
23
+ * > This uses Subgraph
24
+ *
25
+ * **Input parameters**
26
+ *
27
+ * ```ts
28
+ * interface ITransactionsFilter {
29
+ * networks: ChainId[]; // List of chain IDs to query.
30
+ * fromAddress?: string; // (Optional) The address from which transactions are sent.
31
+ * toAddress?: string; // (Optional) The address to which transactions are sent.
32
+ * startDate?: Date; // (Optional) The start date to filter transactions (inclusive).
33
+ * endDate?: Date; // (Optional) The end date to filter transactions (inclusive).
34
+ * startBlock?: number; // (Optional) The start block number to filter transactions (inclusive).
35
+ * endBlock?: number; // (Optional) The end block number to filter transactions (inclusive).
36
+ * }
37
+ * ```
38
+ *
39
+ * ```ts
40
+ * type ITransaction = {
41
+ * block: number;
42
+ * txHash: string;
43
+ * from: string;
44
+ * to: string;
45
+ * timestamp: number;
46
+ * value: string;
47
+ * method: string;
48
+ * };
49
+ * ```
50
+ *
51
+ * @param {ITransactionsFilter} filter Filter for the transactions.
52
+ * @returns {Promise<ITransaction[]>} Returns an array with all the transaction details.
53
+ *
54
+ * **Code example**
55
+ *
56
+ * ```ts
57
+ * import { TransactionUtils, ChainId } from '@human-protocol/sdk';
58
+ *
59
+ * const filter: ITransactionsFilter = {
60
+ * networks: [ChainId.POLYGON],
61
+ * startDate: new Date('2022-01-01'),
62
+ * endDate: new Date('2022-12-31')
63
+ * };
64
+ * const transactions = await TransactionUtils.getTransactions(filter);
65
+ * ```
66
+ */
67
+ static getTransactions(filter: ITransactionsFilter): Promise<ITransaction[]>;
68
+ }
69
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAUlC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGjE,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;OAcG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC;IAmBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8CG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CAqC3B"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TransactionUtils = void 0;
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ const ethers_1 = require("ethers");
9
+ const graphql_request_1 = __importDefault(require("graphql-request"));
10
+ const constants_1 = require("./constants");
11
+ const error_1 = require("./error");
12
+ const transaction_1 = require("./graphql/queries/transaction");
13
+ const utils_1 = require("./utils");
14
+ class TransactionUtils {
15
+ /**
16
+ * This function returns the transaction data for the given hash.
17
+ *
18
+ * @param {ChainId} chainId The chain ID.
19
+ * @param {string} hash The transaction hash.
20
+ * @returns {Promise<ITransaction>} Returns the transaction details.
21
+ *
22
+ * **Code example**
23
+ *
24
+ * ```ts
25
+ * import { TransactionUtils, ChainId } from '@human-protocol/sdk';
26
+ *
27
+ * const transaction = await TransactionUtils.getTransaction(ChainId.POLYGON, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
28
+ * ```
29
+ */
30
+ static async getTransaction(chainId, hash) {
31
+ if (!ethers_1.ethers.isHexString(hash)) {
32
+ throw error_1.ErrorInvalidHahsProvided;
33
+ }
34
+ const networkData = constants_1.NETWORKS[chainId];
35
+ if (!networkData) {
36
+ throw error_1.ErrorUnsupportedChainID;
37
+ }
38
+ const { transaction } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), transaction_1.GET_TRANSACTION_QUERY, {
39
+ hash: hash.toLowerCase(),
40
+ });
41
+ return transaction;
42
+ }
43
+ /**
44
+ * This function returns all transaction details based on the provided filter.
45
+ *
46
+ * > This uses Subgraph
47
+ *
48
+ * **Input parameters**
49
+ *
50
+ * ```ts
51
+ * interface ITransactionsFilter {
52
+ * networks: ChainId[]; // List of chain IDs to query.
53
+ * fromAddress?: string; // (Optional) The address from which transactions are sent.
54
+ * toAddress?: string; // (Optional) The address to which transactions are sent.
55
+ * startDate?: Date; // (Optional) The start date to filter transactions (inclusive).
56
+ * endDate?: Date; // (Optional) The end date to filter transactions (inclusive).
57
+ * startBlock?: number; // (Optional) The start block number to filter transactions (inclusive).
58
+ * endBlock?: number; // (Optional) The end block number to filter transactions (inclusive).
59
+ * }
60
+ * ```
61
+ *
62
+ * ```ts
63
+ * type ITransaction = {
64
+ * block: number;
65
+ * txHash: string;
66
+ * from: string;
67
+ * to: string;
68
+ * timestamp: number;
69
+ * value: string;
70
+ * method: string;
71
+ * };
72
+ * ```
73
+ *
74
+ * @param {ITransactionsFilter} filter Filter for the transactions.
75
+ * @returns {Promise<ITransaction[]>} Returns an array with all the transaction details.
76
+ *
77
+ * **Code example**
78
+ *
79
+ * ```ts
80
+ * import { TransactionUtils, ChainId } from '@human-protocol/sdk';
81
+ *
82
+ * const filter: ITransactionsFilter = {
83
+ * networks: [ChainId.POLYGON],
84
+ * startDate: new Date('2022-01-01'),
85
+ * endDate: new Date('2022-12-31')
86
+ * };
87
+ * const transactions = await TransactionUtils.getTransactions(filter);
88
+ * ```
89
+ */
90
+ static async getTransactions(filter) {
91
+ if ((!!filter.startDate || !!filter.endDate) &&
92
+ (!!filter.startBlock || !!filter.endBlock)) {
93
+ throw error_1.ErrorCannotUseDateAndBlockSimultaneously;
94
+ }
95
+ const transactions_data = [];
96
+ for (const chainId of filter.networks) {
97
+ const networkData = constants_1.NETWORKS[chainId];
98
+ if (!networkData) {
99
+ throw error_1.ErrorUnsupportedChainID;
100
+ }
101
+ const { transactions } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, transaction_1.GET_TRANSACTIONS_QUERY)(filter), {
102
+ fromAddress: filter?.fromAddress,
103
+ toAddress: filter?.toAddress,
104
+ startDate: filter?.startDate
105
+ ? Math.floor(filter?.startDate.getTime() / 1000)
106
+ : undefined,
107
+ endDate: filter.endDate
108
+ ? Math.floor(filter.endDate.getTime() / 1000)
109
+ : undefined,
110
+ startBlock: filter.startBlock ? filter.startBlock : undefined,
111
+ endBlock: filter.endBlock ? filter.endBlock : undefined,
112
+ });
113
+ if (!transactions) {
114
+ continue;
115
+ }
116
+ transactions_data.push(...transactions);
117
+ }
118
+ return transactions_data;
119
+ }
120
+ }
121
+ exports.TransactionUtils = TransactionUtils;
package/dist/types.d.ts CHANGED
@@ -123,6 +123,10 @@ export type NetworkData = {
123
123
  * Subgraph URL
124
124
  */
125
125
  subgraphUrl: string;
126
+ /**
127
+ * Subgraph URL
128
+ */
129
+ subgraphUrlApiKey: string;
126
130
  /**
127
131
  * Old subgraph URL
128
132
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,YAAY;IACtB;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,IAAI,IAAA;IACJ;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,SAAS,IAAA;CACV;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM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C;IACjB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC"}
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { NetworkData } from './types';
1
2
  /**
2
3
  * **Handle and throw the error.*
3
4
  *
@@ -12,4 +13,12 @@ export declare const throwError: (e: any) => never;
12
13
  * @returns
13
14
  */
14
15
  export declare const isValidUrl: (url: string) => boolean;
16
+ /**
17
+ * **Get the subgraph URL.*
18
+ *
19
+ * @param {NetworkData} networkData
20
+ * @param {string} apiKey
21
+ * @returns
22
+ */
23
+ export declare const getSubgraphUrl: (networkData: NetworkData) => string;
15
24
  //# sourceMappingURL=utils.d.ts.map