@human-protocol/sdk 2.1.2 → 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 +68 -23
  4. package/dist/enums.d.ts +4 -2
  5. package/dist/enums.d.ts.map +1 -1
  6. package/dist/enums.js +3 -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 +4 -5
  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 +33 -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 +54 -17
  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 +86 -22
  42. package/src/enums.ts +3 -1
  43. package/src/error.ts +15 -0
  44. package/src/escrow.ts +5 -6
  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 +40 -1
  49. package/src/kvstore.ts +114 -1
  50. package/src/operator.ts +69 -24
  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/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.2",
4
+ "version": "3.0.0",
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
55
  "typedoc": "^0.25.1",
56
- "typedoc-plugin-markdown": "^3.16.0"
56
+ "typedoc-plugin-markdown": "^4.0.3"
57
57
  },
58
58
  "typedocOptions": {
59
59
  "entryPoints": [
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,10 +92,27 @@ 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',
95
99
  },
100
+ [ChainId.SEPOLIA]: {
101
+ chainId: ChainId.SEPOLIA,
102
+ title: 'Ethereum Sepolia',
103
+ scanUrl: 'https://sepolia.etherscan.io/',
104
+ factoryAddress: '0xD6D347ba6987519B4e42EcED43dF98eFf5465a23',
105
+ hmtAddress: '0x792abbcC99c01dbDec49c9fa9A828a186Da45C33',
106
+ stakingAddress: '0x2B9C5EC6220BA8Ad08CB51A60FFdbC6a6235B203',
107
+ rewardPoolAddress: '0xAFf5a986A530ff839d49325A5dF69F96627E8D29',
108
+ kvstoreAddress: '0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60',
109
+ subgraphUrl:
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',
113
+ oldSubgraphUrl: '',
114
+ oldFactoryAddress: '',
115
+ },
96
116
  [ChainId.BSC_MAINNET]: {
97
117
  chainId: ChainId.BSC_MAINNET,
98
118
  title: 'Binance Smart Chain',
@@ -102,7 +122,10 @@ export const NETWORKS: {
102
122
  stakingAddress: '0xdFbB79dC35a3A53741be54a2C9b587d6BafAbd1C',
103
123
  rewardPoolAddress: '0xf376443BCc6d4d4D63eeC086bc4A9E4a83878e0e',
104
124
  kvstoreAddress: '0x21A0C4CED7aE447fCf87D9FE3A29FA9B3AB20Ff1',
105
- 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',
106
129
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
107
130
  oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
108
131
  },
@@ -116,7 +139,9 @@ export const NETWORKS: {
116
139
  rewardPoolAddress: '0xB0A0500103eCEc431b73F6BAd923F0a2774E6e29',
117
140
  kvstoreAddress: '0x32e27177BA6Ea91cf28dfd91a0Da9822A4b74EcF',
118
141
  subgraphUrl:
119
- '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',
120
145
  oldSubgraphUrl:
121
146
  'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
122
147
  oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
@@ -131,7 +156,9 @@ export const NETWORKS: {
131
156
  rewardPoolAddress: '0xa8e32d777a3839440cc7c24D591A64B9481753B3',
132
157
  kvstoreAddress: '0xbcB28672F826a50B03EE91B28145EAbddA73B2eD',
133
158
  subgraphUrl:
134
- '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',
135
162
  oldSubgraphUrl:
136
163
  'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
137
164
  oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
@@ -147,6 +174,7 @@ export const NETWORKS: {
147
174
  kvstoreAddress: '0xD96158c7267Ea658a4688F4aEf1c85659851625d',
148
175
  subgraphUrl:
149
176
  'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai-v2',
177
+ subgraphUrlApiKey: '',
150
178
  oldSubgraphUrl:
151
179
  'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai',
152
180
  oldFactoryAddress: '0x558cd800f9F0B02f3B149667bDe003284c867E94',
@@ -161,7 +189,9 @@ export const NETWORKS: {
161
189
  rewardPoolAddress: '0xd866bCEFf6D0F77E1c3EAE28230AE6C79b03fDa7',
162
190
  kvstoreAddress: '0x724AeFC243EdacCA27EAB86D3ec5a76Af4436Fc7',
163
191
  subgraphUrl:
164
- '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',
165
195
  oldSubgraphUrl: '',
166
196
  oldFactoryAddress: '',
167
197
  },
@@ -175,7 +205,9 @@ export const NETWORKS: {
175
205
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
176
206
  kvstoreAddress: '0x2B95bEcb6EBC4589f64CB000dFCF716b4aeF8aA6',
177
207
  subgraphUrl:
178
- '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',
179
211
  oldSubgraphUrl:
180
212
  'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbeam',
181
213
  oldFactoryAddress: '0x98108c28B7767a52BE38B4860832dd4e11A7ecad',
@@ -190,7 +222,9 @@ export const NETWORKS: {
190
222
  rewardPoolAddress: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
191
223
  kvstoreAddress: '0xcC561f4482f4Ff051D2Dcc65c2cE1A0f291bbA46',
192
224
  subgraphUrl:
193
- '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',
194
228
  oldSubgraphUrl: '',
195
229
  oldFactoryAddress: '',
196
230
  },
@@ -204,7 +238,9 @@ export const NETWORKS: {
204
238
  rewardPoolAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
205
239
  kvstoreAddress: '0x3aD4B091E054f192a822D1406f4535eAd38580e4',
206
240
  subgraphUrl:
207
- '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',
208
244
  oldSubgraphUrl:
209
245
  'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji',
210
246
  oldFactoryAddress: '0xfb4469201951C3B9a7F1996c477cb7BDBEcE0A88',
@@ -219,7 +255,9 @@ export const NETWORKS: {
219
255
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
220
256
  kvstoreAddress: '0x9Bc7bff35B2Be2413708d48c3B0aEF5c43646728',
221
257
  subgraphUrl:
222
- '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',
223
261
  oldSubgraphUrl:
224
262
  'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche',
225
263
  oldFactoryAddress: '0x9767a578ba7a5FA1563c8229943cB01cd8446BB4',
@@ -234,7 +272,9 @@ export const NETWORKS: {
234
272
  rewardPoolAddress: '0xA9545C2530BD5bdb464d5E274F59ACceAa73eD86',
235
273
  kvstoreAddress: '0x938335006ea6F9Eb0e8020969cFF94404425e298',
236
274
  subgraphUrl:
237
- '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',
238
278
  oldSubgraphUrl: '',
239
279
  oldFactoryAddress: '',
240
280
  },
@@ -247,23 +287,44 @@ export const NETWORKS: {
247
287
  stakingAddress: '0x34cD3Bd6B16c559f321799b516dE61E12017fFd1',
248
288
  rewardPoolAddress: '0xb9344bAD98E3d26a4d83900922baf395a2Ec154c',
249
289
  kvstoreAddress: '0x86Af9f6Cd34B69Db1B202223C6d6D109f2491569',
250
- 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',
251
294
  oldSubgraphUrl: '',
252
295
  oldFactoryAddress: '',
253
296
  },
254
- [ChainId.SKALE]: {
255
- chainId: ChainId.SKALE,
256
- title: 'SKALE Human Protocol Chain',
257
- scanUrl: 'https://wan-red-ain.explorer.mainnet.skalenodes.com/',
258
- factoryAddress: '0x319070b49C8d1cC015915D1E7Eb5fd8e22833885',
259
- hmtAddress: '0x6E5FF61Ea88270F6142E0E0eC8cbe9d67476CbCd',
260
- stakingAddress: '0x79F37FB9C210910733c16228AC4D14a8e32C11BD',
261
- rewardPoolAddress: '0x881218246c25C6898aE96145259584340153aDA2',
262
- 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',
263
306
  subgraphUrl:
264
- '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',
265
310
  oldSubgraphUrl: '',
266
- 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: '',
267
328
  },
268
329
  [ChainId.LOCALHOST]: {
269
330
  chainId: ChainId.LOCALHOST,
@@ -275,6 +336,7 @@ export const NETWORKS: {
275
336
  rewardPoolAddress: '0xa513E6E4b8f2a923D98304ec87F64353C4D5C853',
276
337
  kvstoreAddress: '0x5FC8d32690cc91D4c39d9d3abcBD16989F875707',
277
338
  subgraphUrl: 'http://localhost:8000/subgraphs/name/humanprotocol/localhost',
339
+ subgraphUrlApiKey: '',
278
340
  oldSubgraphUrl: '',
279
341
  oldFactoryAddress: '',
280
342
  },
@@ -295,3 +357,5 @@ export const Role = {
295
357
  ReputationOracle: 'Reputation Oracle',
296
358
  RecordingOracle: 'Recording Oracle',
297
359
  };
360
+
361
+ export const SUBGRAPH_API_KEY_PLACEHOLDER = '[SUBGRAPH_API_KEY]';
package/src/enums.ts CHANGED
@@ -3,6 +3,7 @@ export enum ChainId {
3
3
  MAINNET = 1,
4
4
  RINKEBY = 4,
5
5
  GOERLI = 5,
6
+ SEPOLIA = 11155111,
6
7
  BSC_MAINNET = 56,
7
8
  BSC_TESTNET = 97,
8
9
  POLYGON = 137,
@@ -12,8 +13,9 @@ export enum ChainId {
12
13
  MOONBASE_ALPHA = 1287,
13
14
  AVALANCHE_TESTNET = 43113,
14
15
  AVALANCHE = 43114,
15
- SKALE = 1273227453,
16
16
  CELO = 42220,
17
17
  CELO_ALFAJORES = 44787,
18
+ XLAYER_TESTNET = 195,
18
19
  LOCALHOST = 1338,
20
+ XLAYER = 196,
19
21
  }
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,6 @@ 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
+ export const WarnSubgraphApiKeyNotProvided =
339
+ '"SUBGRAPH_API_KEY" is not being provided. It might cause issues with the subgraph.';
package/src/escrow.ts CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  } from './graphql';
45
45
  import { IEscrowConfig, IEscrowsFilter } from './interfaces';
46
46
  import { EscrowCancel, EscrowStatus, NetworkData } from './types';
47
- import { isValidUrl, throwError } from './utils';
47
+ import { getSubgraphUrl, isValidUrl, throwError } from './utils';
48
48
 
49
49
  /**
50
50
  * ## Introduction
@@ -486,7 +486,7 @@ export class EscrowClient extends BaseEthersClient {
486
486
  );
487
487
  await (
488
488
  await tokenContract.transfer(escrowAddress, amount, txOptions)
489
- ).wait;
489
+ ).wait();
490
490
 
491
491
  return;
492
492
  } catch (e) {
@@ -1441,7 +1441,7 @@ export class EscrowUtils {
1441
1441
  * AVALANCHE_TESTNET = 43113,
1442
1442
  * CELO = 42220,
1443
1443
  * CELO_ALFAJORES = 44787,
1444
- * SKALE = 1273227453,
1444
+ * = 1273227453,
1445
1445
  * LOCALHOST = 1338,
1446
1446
  * }
1447
1447
  * ```
@@ -1534,7 +1534,7 @@ export class EscrowUtils {
1534
1534
  }
1535
1535
 
1536
1536
  const { escrows } = await gqlFetch<{ escrows: EscrowData[] }>(
1537
- networkData.subgraphUrl,
1537
+ getSubgraphUrl(networkData),
1538
1538
  GET_ESCROWS_QUERY(filter),
1539
1539
  {
1540
1540
  ...filter,
@@ -1586,7 +1586,6 @@ export class EscrowUtils {
1586
1586
  * AVALANCHE_TESTNET = 43113,
1587
1587
  * CELO = 42220,
1588
1588
  * CELO_ALFAJORES = 44787,
1589
- * SKALE = 1273227453,
1590
1589
  * LOCALHOST = 1338,
1591
1590
  * }
1592
1591
  * ```
@@ -1647,7 +1646,7 @@ export class EscrowUtils {
1647
1646
 
1648
1647
  try {
1649
1648
  const { escrow } = await gqlFetch<{ escrow: EscrowData }>(
1650
- networkData.subgraphUrl,
1649
+ getSubgraphUrl(networkData),
1651
1650
  GET_ESCROW_BY_ADDRESS_QUERY(),
1652
1651
  { escrowAddress: escrowAddress.toLowerCase() }
1653
1652
  );
@@ -0,0 +1,23 @@
1
+ import gql from 'graphql-tag';
2
+
3
+ const KVSTORE_FRAGMENT = gql`
4
+ fragment KVStoreFields on KVStore {
5
+ id
6
+ block
7
+ timestamp
8
+ address
9
+ key
10
+ value
11
+ }
12
+ `;
13
+
14
+ export const GET_KVSTORE_BY_ADDRESS_QUERY = () => {
15
+ return gql`
16
+ query getKVStoreData($address: String!) {
17
+ kvstores(where: { address: $address }) {
18
+ ...KVStoreFields
19
+ }
20
+ }
21
+ ${KVSTORE_FRAGMENT}
22
+ `;
23
+ };
@@ -0,0 +1,59 @@
1
+ import gql from 'graphql-tag';
2
+ import { ITransactionsFilter } from '../../../src/interfaces';
3
+
4
+ const TRANSACTION_FRAGMENT = gql`
5
+ fragment TransactionFields on Transaction {
6
+ block
7
+ txHash
8
+ from
9
+ to
10
+ timestamp
11
+ value
12
+ method
13
+ }
14
+ `;
15
+
16
+ export const GET_TRANSACTIONS_QUERY = (filter: ITransactionsFilter) => {
17
+ const { startDate, endDate, startBlock, endBlock, fromAddress, toAddress } =
18
+ filter;
19
+
20
+ const WHERE_CLAUSE = `
21
+ where: {
22
+ ${fromAddress ? `from: $fromAddress` : ''}
23
+ ${toAddress ? `to: $toAddress` : ''}
24
+ ${startDate ? `timestamp_gte: $startDate` : ''}
25
+ ${endDate ? `timestamp_lte: $endDate` : ''}
26
+ ${startBlock ? `block_gte: $startBlock` : ''}
27
+ ${endBlock ? `block_lte: $endBlock` : ''}
28
+ }
29
+ `;
30
+
31
+ return gql`
32
+ query getTransactions(
33
+ $fromAddress: String
34
+ $toAddress: String
35
+ $startDate: Int
36
+ $endDate: Int
37
+ $startBlock: Int
38
+ $endBlock: Int
39
+ ) {
40
+ transactions(
41
+ ${WHERE_CLAUSE}
42
+ orderBy: timestamp,
43
+ orderDirection: asc,
44
+ ) {
45
+ ...TransactionFields
46
+ }
47
+ }
48
+ ${TRANSACTION_FRAGMENT}
49
+ `;
50
+ };
51
+
52
+ export const GET_TRANSACTION_QUERY = gql`
53
+ query getTransaction($hash: String!) {
54
+ transaction(id: $hash) {
55
+ ...TransactionFields
56
+ }
57
+ }
58
+ ${TRANSACTION_FRAGMENT}
59
+ `;
@@ -155,3 +155,12 @@ export type DailyTaskData = {
155
155
  export type TaskStatistics = {
156
156
  dailyTasksData: DailyTaskData[];
157
157
  };
158
+
159
+ export type KVStoreData = {
160
+ id: string;
161
+ address: string;
162
+ key: string;
163
+ value: string;
164
+ timestamp: Date;
165
+ block: number;
166
+ };
package/src/interfaces.ts CHANGED
@@ -32,10 +32,15 @@ export interface ILeader {
32
32
  publicKey?: string;
33
33
  webhookUrl?: string;
34
34
  url?: string;
35
+ jobTypes?: string[];
36
+ }
37
+
38
+ export interface ILeaderSubgraph extends Omit<ILeader, 'jobTypes'> {
39
+ jobTypes?: string;
35
40
  }
36
41
 
37
42
  export interface ILeadersFilter {
38
- networks: ChainId[];
43
+ chainId: ChainId;
39
44
  role?: string;
40
45
  }
41
46
 
@@ -45,6 +50,11 @@ export interface IReputationNetwork {
45
50
  operators: IOperator[];
46
51
  }
47
52
 
53
+ export interface IReputationNetworkSubgraph
54
+ extends Omit<IReputationNetwork, 'operators'> {
55
+ operators: IOperatorSubgraph[];
56
+ }
57
+
48
58
  export interface IOperator {
49
59
  address: string;
50
60
  role?: string;
@@ -52,6 +62,10 @@ export interface IOperator {
52
62
  jobTypes?: string[];
53
63
  }
54
64
 
65
+ export interface IOperatorSubgraph extends Omit<IOperator, 'jobTypes'> {
66
+ jobTypes?: string;
67
+ }
68
+
55
69
  export interface IEscrowsFilter {
56
70
  launcher?: string;
57
71
  reputationOracle?: string;
@@ -94,3 +108,28 @@ export interface IPayoutFilter {
94
108
  from?: Date;
95
109
  to?: Date;
96
110
  }
111
+
112
+ export interface IKVStore {
113
+ key: string;
114
+ value: string;
115
+ }
116
+
117
+ export interface ITransaction {
118
+ block: bigint;
119
+ hash: string;
120
+ from: string;
121
+ to: string;
122
+ timestamp: bigint;
123
+ value: string;
124
+ method: string;
125
+ }
126
+
127
+ export interface ITransactionsFilter {
128
+ networks: ChainId[];
129
+ startBlock?: number;
130
+ endBlock?: number;
131
+ startDate?: Date;
132
+ endDate?: Date;
133
+ fromAddress?: string;
134
+ toAddress?: string;
135
+ }