@human-protocol/sdk 2.1.3 → 3.0.1

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 (70) hide show
  1. package/README.md +23 -80
  2. package/dist/constants.d.ts +1 -0
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +56 -24
  5. package/dist/enums.d.ts +7 -2
  6. package/dist/enums.d.ts.map +1 -1
  7. package/dist/enums.js +8 -2
  8. package/dist/error.d.ts +16 -0
  9. package/dist/error.d.ts.map +1 -1
  10. package/dist/error.js +18 -2
  11. package/dist/escrow.d.ts +91 -7
  12. package/dist/escrow.d.ts.map +1 -1
  13. package/dist/escrow.js +154 -39
  14. package/dist/graphql/queries/escrow.d.ts +1 -0
  15. package/dist/graphql/queries/escrow.d.ts.map +1 -1
  16. package/dist/graphql/queries/escrow.js +50 -9
  17. package/dist/graphql/queries/hmtoken.d.ts +1 -1
  18. package/dist/graphql/queries/hmtoken.d.ts.map +1 -1
  19. package/dist/graphql/queries/hmtoken.js +23 -7
  20. package/dist/graphql/queries/kvstore.d.ts +2 -0
  21. package/dist/graphql/queries/kvstore.d.ts.map +1 -0
  22. package/dist/graphql/queries/kvstore.js +28 -0
  23. package/dist/graphql/queries/statistics.d.ts.map +1 -1
  24. package/dist/graphql/queries/statistics.js +2 -0
  25. package/dist/graphql/queries/transaction.d.ts +4 -0
  26. package/dist/graphql/queries/transaction.d.ts.map +1 -0
  27. package/dist/graphql/queries/transaction.js +64 -0
  28. package/dist/graphql/types.d.ts +19 -0
  29. package/dist/graphql/types.d.ts.map +1 -1
  30. package/dist/index.d.ts +2 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +3 -1
  33. package/dist/interfaces.d.ts +35 -4
  34. package/dist/interfaces.d.ts.map +1 -1
  35. package/dist/kvstore.d.ts +84 -0
  36. package/dist/kvstore.d.ts.map +1 -1
  37. package/dist/kvstore.js +103 -1
  38. package/dist/operator.d.ts +5 -2
  39. package/dist/operator.d.ts.map +1 -1
  40. package/dist/operator.js +68 -57
  41. package/dist/statistics.d.ts +29 -2
  42. package/dist/statistics.d.ts.map +1 -1
  43. package/dist/statistics.js +53 -7
  44. package/dist/transaction.d.ts +75 -0
  45. package/dist/transaction.d.ts.map +1 -0
  46. package/dist/transaction.js +130 -0
  47. package/dist/types.d.ts +4 -0
  48. package/dist/types.d.ts.map +1 -1
  49. package/dist/utils.d.ts +9 -0
  50. package/dist/utils.d.ts.map +1 -1
  51. package/dist/utils.js +21 -1
  52. package/package.json +7 -6
  53. package/src/constants.ts +73 -23
  54. package/src/enums.ts +7 -1
  55. package/src/error.ts +23 -0
  56. package/src/escrow.ts +199 -51
  57. package/src/graphql/queries/escrow.ts +53 -8
  58. package/src/graphql/queries/hmtoken.ts +23 -7
  59. package/src/graphql/queries/kvstore.ts +23 -0
  60. package/src/graphql/queries/statistics.ts +2 -0
  61. package/src/graphql/queries/transaction.ts +64 -0
  62. package/src/graphql/types.ts +22 -0
  63. package/src/index.ts +2 -0
  64. package/src/interfaces.ts +40 -4
  65. package/src/kvstore.ts +114 -1
  66. package/src/operator.ts +90 -69
  67. package/src/statistics.ts +63 -9
  68. package/src/transaction.ts +152 -0
  69. package/src/types.ts +4 -0
  70. package/src/utils.ts +25 -0
@@ -0,0 +1,75 @@
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
+ * chainId: 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
+ * first?: number; // (Optional) Number of transactions per page. Default is 10.
37
+ * skip?: number; // (Optional) Number of transactions to skip. Default is 0.
38
+ * orderDirection?: OrderDirection; // (Optional) Order of the results. Default is DESC.
39
+ * }
40
+ * ```
41
+ *
42
+ * ```ts
43
+ * type ITransaction = {
44
+ * block: number;
45
+ * txHash: string;
46
+ * from: string;
47
+ * to: string;
48
+ * timestamp: number;
49
+ * value: string;
50
+ * method: string;
51
+ * };
52
+ * ```
53
+ *
54
+ * @param {ITransactionsFilter} filter Filter for the transactions.
55
+ * @returns {Promise<ITransaction[]>} Returns an array with all the transaction details.
56
+ *
57
+ * **Code example**
58
+ *
59
+ * ```ts
60
+ * import { TransactionUtils, ChainId, OrderDirection } from '@human-protocol/sdk';
61
+ *
62
+ * const filter: ITransactionsFilter = {
63
+ * chainId: ChainId.POLYGON,
64
+ * startDate: new Date('2022-01-01'),
65
+ * endDate: new Date('2022-12-31'),
66
+ * first: 10,
67
+ * skip: 0,
68
+ * orderDirection: OrderDirection.DESC,
69
+ * };
70
+ * const transactions = await TransactionUtils.getTransactions(filter);
71
+ * ```
72
+ */
73
+ static getTransactions(filter: ITransactionsFilter): Promise<ITransaction[]>;
74
+ }
75
+ //# 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,EAAkB,MAAM,SAAS,CAAC;AAUlD,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CAyC3B"}
@@ -0,0 +1,130 @@
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 enums_1 = require("./enums");
12
+ const error_1 = require("./error");
13
+ const transaction_1 = require("./graphql/queries/transaction");
14
+ const utils_1 = require("./utils");
15
+ class TransactionUtils {
16
+ /**
17
+ * This function returns the transaction data for the given hash.
18
+ *
19
+ * @param {ChainId} chainId The chain ID.
20
+ * @param {string} hash The transaction hash.
21
+ * @returns {Promise<ITransaction>} Returns the transaction details.
22
+ *
23
+ * **Code example**
24
+ *
25
+ * ```ts
26
+ * import { TransactionUtils, ChainId } from '@human-protocol/sdk';
27
+ *
28
+ * const transaction = await TransactionUtils.getTransaction(ChainId.POLYGON, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
29
+ * ```
30
+ */
31
+ static async getTransaction(chainId, hash) {
32
+ if (!ethers_1.ethers.isHexString(hash)) {
33
+ throw error_1.ErrorInvalidHahsProvided;
34
+ }
35
+ const networkData = constants_1.NETWORKS[chainId];
36
+ if (!networkData) {
37
+ throw error_1.ErrorUnsupportedChainID;
38
+ }
39
+ const { transaction } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), transaction_1.GET_TRANSACTION_QUERY, {
40
+ hash: hash.toLowerCase(),
41
+ });
42
+ return transaction;
43
+ }
44
+ /**
45
+ * This function returns all transaction details based on the provided filter.
46
+ *
47
+ * > This uses Subgraph
48
+ *
49
+ * **Input parameters**
50
+ *
51
+ * ```ts
52
+ * interface ITransactionsFilter {
53
+ * chainId: ChainId; // List of chain IDs to query.
54
+ * fromAddress?: string; // (Optional) The address from which transactions are sent.
55
+ * toAddress?: string; // (Optional) The address to which transactions are sent.
56
+ * startDate?: Date; // (Optional) The start date to filter transactions (inclusive).
57
+ * endDate?: Date; // (Optional) The end date to filter transactions (inclusive).
58
+ * startBlock?: number; // (Optional) The start block number to filter transactions (inclusive).
59
+ * endBlock?: number; // (Optional) The end block number to filter transactions (inclusive).
60
+ * first?: number; // (Optional) Number of transactions per page. Default is 10.
61
+ * skip?: number; // (Optional) Number of transactions to skip. Default is 0.
62
+ * orderDirection?: OrderDirection; // (Optional) Order of the results. Default is DESC.
63
+ * }
64
+ * ```
65
+ *
66
+ * ```ts
67
+ * type ITransaction = {
68
+ * block: number;
69
+ * txHash: string;
70
+ * from: string;
71
+ * to: string;
72
+ * timestamp: number;
73
+ * value: string;
74
+ * method: string;
75
+ * };
76
+ * ```
77
+ *
78
+ * @param {ITransactionsFilter} filter Filter for the transactions.
79
+ * @returns {Promise<ITransaction[]>} Returns an array with all the transaction details.
80
+ *
81
+ * **Code example**
82
+ *
83
+ * ```ts
84
+ * import { TransactionUtils, ChainId, OrderDirection } from '@human-protocol/sdk';
85
+ *
86
+ * const filter: ITransactionsFilter = {
87
+ * chainId: ChainId.POLYGON,
88
+ * startDate: new Date('2022-01-01'),
89
+ * endDate: new Date('2022-12-31'),
90
+ * first: 10,
91
+ * skip: 0,
92
+ * orderDirection: OrderDirection.DESC,
93
+ * };
94
+ * const transactions = await TransactionUtils.getTransactions(filter);
95
+ * ```
96
+ */
97
+ static async getTransactions(filter) {
98
+ if ((!!filter.startDate || !!filter.endDate) &&
99
+ (!!filter.startBlock || !!filter.endBlock)) {
100
+ throw error_1.ErrorCannotUseDateAndBlockSimultaneously;
101
+ }
102
+ const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
103
+ const skip = filter.skip || 0;
104
+ const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
105
+ const networkData = constants_1.NETWORKS[filter.chainId];
106
+ if (!networkData) {
107
+ throw error_1.ErrorUnsupportedChainID;
108
+ }
109
+ const { transactions } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, transaction_1.GET_TRANSACTIONS_QUERY)(filter), {
110
+ fromAddress: filter?.fromAddress,
111
+ toAddress: filter?.toAddress,
112
+ startDate: filter?.startDate
113
+ ? Math.floor(filter?.startDate.getTime() / 1000)
114
+ : undefined,
115
+ endDate: filter.endDate
116
+ ? Math.floor(filter.endDate.getTime() / 1000)
117
+ : undefined,
118
+ startBlock: filter.startBlock ? filter.startBlock : undefined,
119
+ endBlock: filter.endBlock ? filter.endBlock : undefined,
120
+ orderDirection: orderDirection,
121
+ first: first,
122
+ skip: skip,
123
+ });
124
+ if (!transactions) {
125
+ return [];
126
+ }
127
+ return transactions;
128
+ }
129
+ }
130
+ 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;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AM,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
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,eAAO,MAAM,UAAU,MAAO,GAAG,UAgBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,YAOrC,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,MAAO,GAAG,UAgBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,YAOrC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,gBAAiB,WAAW,WAatD,CAAC"}
package/dist/utils.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidUrl = exports.throwError = void 0;
3
+ exports.getSubgraphUrl = exports.isValidUrl = exports.throwError = void 0;
4
4
  /* eslint-disable @typescript-eslint/no-explicit-any */
5
5
  const ethers_1 = require("ethers");
6
6
  const error_1 = require("./error");
7
+ const constants_1 = require("./constants");
7
8
  /**
8
9
  * **Handle and throw the error.*
9
10
  *
@@ -50,3 +51,22 @@ const isValidUrl = (url) => {
50
51
  }
51
52
  };
52
53
  exports.isValidUrl = isValidUrl;
54
+ /**
55
+ * **Get the subgraph URL.*
56
+ *
57
+ * @param {NetworkData} networkData
58
+ * @param {string} apiKey
59
+ * @returns
60
+ */
61
+ const getSubgraphUrl = (networkData) => {
62
+ let subgraphUrl = networkData.subgraphUrl;
63
+ if (process.env.SUBGRAPH_API_KEY) {
64
+ subgraphUrl = networkData.subgraphUrlApiKey.replace(constants_1.SUBGRAPH_API_KEY_PLACEHOLDER, process.env.SUBGRAPH_API_KEY);
65
+ }
66
+ else {
67
+ // eslint-disable-next-line no-console
68
+ console.warn(error_1.WarnSubgraphApiKeyNotProvided);
69
+ }
70
+ return subgraphUrl;
71
+ };
72
+ exports.getSubgraphUrl = getSubgraphUrl;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@human-protocol/sdk",
3
3
  "description": "Human Protocol SDK",
4
- "version": "2.1.3",
4
+ "version": "3.0.1",
5
5
  "files": [
6
6
  "src",
7
7
  "dist"
@@ -45,15 +45,15 @@
45
45
  "graphql": "^16.8.1",
46
46
  "graphql-request": "^6.1.0",
47
47
  "graphql-tag": "^2.12.6",
48
- "minio": "^7.0.32",
48
+ "minio": "7.1.3",
49
49
  "openpgp": "^5.11.1",
50
50
  "secp256k1": "^4.0.3",
51
- "vitest": "^0.30.1",
51
+ "vitest": "^1.6.0",
52
52
  "winston": "^3.13.0"
53
53
  },
54
54
  "devDependencies": {
55
- "typedoc": "^0.25.1",
56
- "typedoc-plugin-markdown": "^3.16.0"
55
+ "typedoc": "^0.26.5",
56
+ "typedoc-plugin-markdown": "^4.2.3"
57
57
  },
58
58
  "typedocOptions": {
59
59
  "entryPoints": [
@@ -64,7 +64,8 @@
64
64
  "./src/operator.ts",
65
65
  "./src/staking.ts",
66
66
  "./src/storage.ts",
67
- "./src/statistics.ts"
67
+ "./src/statistics.ts",
68
+ "./src/transaction.ts"
68
69
  ]
69
70
  }
70
71
  }
package/src/constants.ts CHANGED
@@ -61,7 +61,9 @@ export const NETWORKS: {
61
61
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
62
62
  kvstoreAddress: '0xB6d36B1CDaD50302BCB3DB43bAb0D349458e1b8D',
63
63
  subgraphUrl:
64
- 'https://api.thegraph.com/subgraphs/name/humanprotocol/mainnet-v2',
64
+ 'https://api.studio.thegraph.com/query/74256/ethereum/version/latest',
65
+ subgraphUrlApiKey:
66
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/BtC96WCK6ZpZ35v94MK6rZNiBzDEZYHFzDmhMYyZ369D',
65
67
  oldSubgraphUrl: '',
66
68
  oldFactoryAddress: '',
67
69
  },
@@ -75,6 +77,7 @@ export const NETWORKS: {
75
77
  rewardPoolAddress: '',
76
78
  kvstoreAddress: '',
77
79
  subgraphUrl: '',
80
+ subgraphUrlApiKey: '',
78
81
  oldSubgraphUrl: '',
79
82
  oldFactoryAddress: '',
80
83
  },
@@ -89,6 +92,7 @@ export const NETWORKS: {
89
92
  kvstoreAddress: '0x19Fc3e859C1813ac9427a7a78BeB9ae102CE96d3',
90
93
  subgraphUrl:
91
94
  'https://api.thegraph.com/subgraphs/name/humanprotocol/goerli-v2',
95
+ subgraphUrlApiKey: '',
92
96
  oldSubgraphUrl:
93
97
  'https://api.thegraph.com/subgraphs/name/humanprotocol/goerli',
94
98
  oldFactoryAddress: '0xaAe6a2646C1F88763E62e0cD08aD050Ea66AC46F',
@@ -103,7 +107,9 @@ export const NETWORKS: {
103
107
  rewardPoolAddress: '0xAFf5a986A530ff839d49325A5dF69F96627E8D29',
104
108
  kvstoreAddress: '0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60',
105
109
  subgraphUrl:
106
- 'https://subgraph.satsuma-prod.com/8d51f9873a51/team--2543/humanprotocol-sepolia/api',
110
+ 'https://api.studio.thegraph.com/query/74256/sepolia/version/latest',
111
+ subgraphUrlApiKey:
112
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/UMLaZHtLE9LxzDyvBLBgfWj4erzYzYMeGUbQtxtyMaE',
107
113
  oldSubgraphUrl: '',
108
114
  oldFactoryAddress: '',
109
115
  },
@@ -116,7 +122,10 @@ export const NETWORKS: {
116
122
  stakingAddress: '0xdFbB79dC35a3A53741be54a2C9b587d6BafAbd1C',
117
123
  rewardPoolAddress: '0xf376443BCc6d4d4D63eeC086bc4A9E4a83878e0e',
118
124
  kvstoreAddress: '0x21A0C4CED7aE447fCf87D9FE3A29FA9B3AB20Ff1',
119
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc-v2',
125
+ subgraphUrl:
126
+ 'https://api.studio.thegraph.com/query/74256/bsc/version/latest',
127
+ subgraphUrlApiKey:
128
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/JBJPC3YmRSNjyjRTTpazhhSX5CCZ4CeBx6ptRsM8PCBb',
120
129
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
121
130
  oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
122
131
  },
@@ -130,7 +139,9 @@ export const NETWORKS: {
130
139
  rewardPoolAddress: '0xB0A0500103eCEc431b73F6BAd923F0a2774E6e29',
131
140
  kvstoreAddress: '0x32e27177BA6Ea91cf28dfd91a0Da9822A4b74EcF',
132
141
  subgraphUrl:
133
- 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest-v2',
142
+ 'https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest',
143
+ subgraphUrlApiKey:
144
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/BnaC4CDqgdbGvcgM7KoZ6d7Yeebsm7NvLFrr61Lxg6Ao',
134
145
  oldSubgraphUrl:
135
146
  'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
136
147
  oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
@@ -145,7 +156,9 @@ export const NETWORKS: {
145
156
  rewardPoolAddress: '0xa8e32d777a3839440cc7c24D591A64B9481753B3',
146
157
  kvstoreAddress: '0xbcB28672F826a50B03EE91B28145EAbddA73B2eD',
147
158
  subgraphUrl:
148
- 'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon-v2',
159
+ 'https://api.studio.thegraph.com/query/74256/polygon/version/latest',
160
+ subgraphUrlApiKey:
161
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/HHYwCHBvDrjckpNB4jbB8k63pSot6rGtBYLBygGji3vD',
149
162
  oldSubgraphUrl:
150
163
  'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
151
164
  oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
@@ -161,6 +174,7 @@ export const NETWORKS: {
161
174
  kvstoreAddress: '0xD96158c7267Ea658a4688F4aEf1c85659851625d',
162
175
  subgraphUrl:
163
176
  'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai-v2',
177
+ subgraphUrlApiKey: '',
164
178
  oldSubgraphUrl:
165
179
  'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai',
166
180
  oldFactoryAddress: '0x558cd800f9F0B02f3B149667bDe003284c867E94',
@@ -175,7 +189,9 @@ export const NETWORKS: {
175
189
  rewardPoolAddress: '0xd866bCEFf6D0F77E1c3EAE28230AE6C79b03fDa7',
176
190
  kvstoreAddress: '0x724AeFC243EdacCA27EAB86D3ec5a76Af4436Fc7',
177
191
  subgraphUrl:
178
- 'https://subgraph.satsuma-prod.com/8d51f9873a51/team--2543/humanprotocol-amoy/api',
192
+ 'https://api.studio.thegraph.com/query/74256/amoy/version/latest',
193
+ subgraphUrlApiKey:
194
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/FmdCVzHV3bB4abPVYtBALtBHr7ZRZmZ67m5c432S7GZH',
179
195
  oldSubgraphUrl: '',
180
196
  oldFactoryAddress: '',
181
197
  },
@@ -189,7 +205,9 @@ export const NETWORKS: {
189
205
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
190
206
  kvstoreAddress: '0x2B95bEcb6EBC4589f64CB000dFCF716b4aeF8aA6',
191
207
  subgraphUrl:
192
- 'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbeam-v2',
208
+ 'https://api.studio.thegraph.com/query/74256/moonbeam/version/latest',
209
+ subgraphUrlApiKey:
210
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/BH5Sm6exn76o5frV5VeCufChB43DCfMXCQsdtWt4AuQP',
193
211
  oldSubgraphUrl:
194
212
  'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbeam',
195
213
  oldFactoryAddress: '0x98108c28B7767a52BE38B4860832dd4e11A7ecad',
@@ -204,7 +222,9 @@ export const NETWORKS: {
204
222
  rewardPoolAddress: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
205
223
  kvstoreAddress: '0xcC561f4482f4Ff051D2Dcc65c2cE1A0f291bbA46',
206
224
  subgraphUrl:
207
- 'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbase-alpha-v2',
225
+ 'https://api.studio.thegraph.com/query/74256/moonbase-alpha/version/latest',
226
+ subgraphUrlApiKey:
227
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/AmmRkJszUbjfUwHubcRkU6CfG1Q9psRWRbbHADVmsLjE',
208
228
  oldSubgraphUrl: '',
209
229
  oldFactoryAddress: '',
210
230
  },
@@ -218,7 +238,9 @@ export const NETWORKS: {
218
238
  rewardPoolAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
219
239
  kvstoreAddress: '0x3aD4B091E054f192a822D1406f4535eAd38580e4',
220
240
  subgraphUrl:
221
- 'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji-v2',
241
+ 'https://api.studio.thegraph.com/query/74256/fuji/version/latest',
242
+ subgraphUrlApiKey:
243
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/CnZCDsWziQF3jNoqgQMkmJbF9frof5osM3hN5eUgyL5u',
222
244
  oldSubgraphUrl:
223
245
  'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji',
224
246
  oldFactoryAddress: '0xfb4469201951C3B9a7F1996c477cb7BDBEcE0A88',
@@ -233,7 +255,9 @@ export const NETWORKS: {
233
255
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
234
256
  kvstoreAddress: '0x9Bc7bff35B2Be2413708d48c3B0aEF5c43646728',
235
257
  subgraphUrl:
236
- 'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche-v2',
258
+ 'https://api.studio.thegraph.com/query/74256/avalanche/version/latest',
259
+ subgraphUrlApiKey:
260
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/FweDaDWZ6ZDcsA63wsjnWgdgw4aCbkiVQYMYvtcP5p2u',
237
261
  oldSubgraphUrl:
238
262
  'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche',
239
263
  oldFactoryAddress: '0x9767a578ba7a5FA1563c8229943cB01cd8446BB4',
@@ -248,7 +272,9 @@ export const NETWORKS: {
248
272
  rewardPoolAddress: '0xA9545C2530BD5bdb464d5E274F59ACceAa73eD86',
249
273
  kvstoreAddress: '0x938335006ea6F9Eb0e8020969cFF94404425e298',
250
274
  subgraphUrl:
251
- 'https://api.thegraph.com/subgraphs/name/humanprotocol/celo-alfajores',
275
+ 'https://api.studio.thegraph.com/query/74256/celo-alfajores/version/latest',
276
+ subgraphUrlApiKey:
277
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/EGWCWuzBNkbypW8ipRKuyGwq8azoCy6LKKosGgSPMGRD',
252
278
  oldSubgraphUrl: '',
253
279
  oldFactoryAddress: '',
254
280
  },
@@ -261,23 +287,44 @@ export const NETWORKS: {
261
287
  stakingAddress: '0x34cD3Bd6B16c559f321799b516dE61E12017fFd1',
262
288
  rewardPoolAddress: '0xb9344bAD98E3d26a4d83900922baf395a2Ec154c',
263
289
  kvstoreAddress: '0x86Af9f6Cd34B69Db1B202223C6d6D109f2491569',
264
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/celo',
290
+ subgraphUrl:
291
+ 'https://api.studio.thegraph.com/query/74256/celo/version/latest',
292
+ subgraphUrlApiKey:
293
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/HTgMnYWGsdsw41o8dyph1bwhotuXh6va3L8r8DGgLjsA',
265
294
  oldSubgraphUrl: '',
266
295
  oldFactoryAddress: '',
267
296
  },
268
- [ChainId.SKALE]: {
269
- chainId: ChainId.SKALE,
270
- title: 'SKALE Human Protocol Chain',
271
- scanUrl: 'https://wan-red-ain.explorer.mainnet.skalenodes.com/',
272
- factoryAddress: '0x319070b49C8d1cC015915D1E7Eb5fd8e22833885',
273
- hmtAddress: '0x6E5FF61Ea88270F6142E0E0eC8cbe9d67476CbCd',
274
- stakingAddress: '0x79F37FB9C210910733c16228AC4D14a8e32C11BD',
275
- rewardPoolAddress: '0x881218246c25C6898aE96145259584340153aDA2',
276
- kvstoreAddress: '0xE1055607327b1be2080D31211dCDC4D9338CaF4A',
297
+ [ChainId.XLAYER]: {
298
+ chainId: ChainId.XLAYER,
299
+ title: 'XLayer',
300
+ scanUrl: 'https://www.oklink.com/xlayer',
301
+ factoryAddress: '0x4949C9DFFD83F0D5Ab0AB24C57C4D403D5c20C15',
302
+ hmtAddress: '0x10acbe3b9e6a2ff7f341e5cbf4b6617741ff44aa',
303
+ stakingAddress: '0x01D115E9E8bF0C58318793624CC662a030D07F1D',
304
+ rewardPoolAddress: '0x7ABa5F75b2b530cB0c8927C86591c21dF44f06b6',
305
+ kvstoreAddress: '0x6512d894cc3d3FE93Da9d0420430136fA889FaB9',
277
306
  subgraphUrl:
278
- 'https://graph-skale.humanprotocol.org/subgraphs/name/skale-human',
307
+ 'https://api.studio.thegraph.com/query/74256/xlayer/version/latest',
308
+ subgraphUrlApiKey:
309
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/CrratkbjCraj1BZLgJmck1GGxbMb2Y2iPZiW4Lh5DdcX',
279
310
  oldSubgraphUrl: '',
280
- oldFactoryAddress: '0x27B423cE73d1dBdB48d2dd351398b5Ce8223117c',
311
+ oldFactoryAddress: '',
312
+ },
313
+ [ChainId.XLAYER_TESTNET]: {
314
+ chainId: ChainId.XLAYER_TESTNET,
315
+ title: 'XLayer Testnet',
316
+ scanUrl: 'https://www.okx.com/explorer/xlayer-test',
317
+ factoryAddress: '0x6Cd3ecAD36ee88E9ef3665CF381D9dAE0FE0a32e',
318
+ hmtAddress: '0x792abbcC99c01dbDec49c9fa9A828a186Da45C33',
319
+ stakingAddress: '0x819069fEd50581587fAB9E583b5488fc2D33B7ea',
320
+ rewardPoolAddress: '0x6daccd1f3a68945f8a7ac6d20260953f7a97fae4',
321
+ kvstoreAddress: '0xdE8BE9E3C12E9F546309A429cd88d026a25EaF8C',
322
+ subgraphUrl:
323
+ 'https://api.studio.thegraph.com/query/74256/xlayer-testnet/version/latest',
324
+ subgraphUrlApiKey:
325
+ 'https://gateway-testnet-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/subgraphs/id/9zd1LcywWjuSUtde4ofC8oyyzpawPwGUiPsvqTq247xk',
326
+ oldSubgraphUrl: '',
327
+ oldFactoryAddress: '',
281
328
  },
282
329
  [ChainId.LOCALHOST]: {
283
330
  chainId: ChainId.LOCALHOST,
@@ -289,6 +336,7 @@ export const NETWORKS: {
289
336
  rewardPoolAddress: '0xa513E6E4b8f2a923D98304ec87F64353C4D5C853',
290
337
  kvstoreAddress: '0x5FC8d32690cc91D4c39d9d3abcBD16989F875707',
291
338
  subgraphUrl: 'http://localhost:8000/subgraphs/name/humanprotocol/localhost',
339
+ subgraphUrlApiKey: '',
292
340
  oldSubgraphUrl: '',
293
341
  oldFactoryAddress: '',
294
342
  },
@@ -309,3 +357,5 @@ export const Role = {
309
357
  ReputationOracle: 'Reputation Oracle',
310
358
  RecordingOracle: 'Recording Oracle',
311
359
  };
360
+
361
+ export const SUBGRAPH_API_KEY_PLACEHOLDER = '[SUBGRAPH_API_KEY]';
package/src/enums.ts CHANGED
@@ -13,8 +13,14 @@ export enum ChainId {
13
13
  MOONBASE_ALPHA = 1287,
14
14
  AVALANCHE_TESTNET = 43113,
15
15
  AVALANCHE = 43114,
16
- SKALE = 1273227453,
17
16
  CELO = 42220,
18
17
  CELO_ALFAJORES = 44787,
18
+ XLAYER_TESTNET = 195,
19
19
  LOCALHOST = 1338,
20
+ XLAYER = 196,
21
+ }
22
+
23
+ export enum OrderDirection {
24
+ ASC = 'asc',
25
+ DESC = 'desc',
20
26
  }
package/src/error.ts CHANGED
@@ -117,6 +117,18 @@ export const ErrorInvalidStakerAddressProvided = new Error(
117
117
  'Invalid staker address provided'
118
118
  );
119
119
 
120
+ /**
121
+ * @constant {Error} - Invalid hash provided.
122
+ */
123
+ export const ErrorInvalidHahsProvided = new Error('Invalid hash provided');
124
+
125
+ /**
126
+ * @constant {Error} - Cannot use both date and block filters simultaneously.
127
+ */
128
+ export const ErrorCannotUseDateAndBlockSimultaneously = new Error(
129
+ 'Cannot use both date and block filters simultaneously'
130
+ );
131
+
120
132
  /**
121
133
  * @constant {Error} - Invalid escrow address provided.
122
134
  */
@@ -322,3 +334,14 @@ export class InvalidEthereumAddressError extends Error {
322
334
  * @constant {Error} - The Hash does not match
323
335
  */
324
336
  export const ErrorInvalidHash = new Error('Invalid hash');
337
+
338
+ /**
339
+ * @constant {Error} - The Status is not supported
340
+ */
341
+ export const ErrorUnsupportedStatus = new Error('Unsupported status for query');
342
+
343
+ /**
344
+ * @constant {Error} - The SUBGRAPH_API_KEY is not being provided
345
+ */
346
+ export const WarnSubgraphApiKeyNotProvided =
347
+ '"SUBGRAPH_API_KEY" is not being provided. It might cause issues with the subgraph.';