@human-protocol/sdk 3.0.7 → 3.0.8

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 (43) hide show
  1. package/dist/constants.d.ts +1 -24
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +23 -64
  4. package/dist/encryption.d.ts +1 -1
  5. package/dist/encryption.js +18 -8
  6. package/dist/escrow.d.ts +20 -57
  7. package/dist/escrow.d.ts.map +1 -1
  8. package/dist/escrow.js +74 -88
  9. package/dist/graphql/queries/operator.js +2 -2
  10. package/dist/graphql/queries/statistics.d.ts.map +1 -1
  11. package/dist/graphql/queries/statistics.js +0 -2
  12. package/dist/graphql/queries/transaction.d.ts.map +1 -1
  13. package/dist/graphql/queries/transaction.js +23 -10
  14. package/dist/graphql/types.d.ts +0 -2
  15. package/dist/graphql/types.d.ts.map +1 -1
  16. package/dist/interfaces.d.ts +19 -10
  17. package/dist/interfaces.d.ts.map +1 -1
  18. package/dist/kvstore.d.ts +1 -1
  19. package/dist/kvstore.js +1 -1
  20. package/dist/operator.d.ts.map +1 -1
  21. package/dist/operator.js +13 -0
  22. package/dist/staking.d.ts +3 -112
  23. package/dist/staking.d.ts.map +1 -1
  24. package/dist/staking.js +2 -170
  25. package/dist/statistics.d.ts.map +1 -1
  26. package/dist/statistics.js +3 -1
  27. package/dist/storage.js +17 -7
  28. package/dist/types.d.ts +17 -4
  29. package/dist/types.d.ts.map +1 -1
  30. package/package.json +8 -4
  31. package/src/constants.ts +23 -64
  32. package/src/encryption.ts +1 -1
  33. package/src/escrow.ts +119 -103
  34. package/src/graphql/queries/operator.ts +2 -2
  35. package/src/graphql/queries/statistics.ts +0 -2
  36. package/src/graphql/queries/transaction.ts +23 -13
  37. package/src/graphql/types.ts +0 -2
  38. package/src/interfaces.ts +19 -11
  39. package/src/kvstore.ts +1 -1
  40. package/src/operator.ts +21 -0
  41. package/src/staking.ts +2 -185
  42. package/src/statistics.ts +3 -1
  43. package/src/types.ts +18 -4
package/src/constants.ts CHANGED
@@ -1,39 +1,18 @@
1
1
  import { ChainId } from './enums';
2
2
  import { NetworkData } from './types';
3
3
 
4
- /**
5
- * @constant Default public bucket name
6
- */
7
4
  export const DEFAULT_PUBLIC_BUCKET = 'escrow-public-results';
8
5
 
9
- /**
10
- * @constant Default storage endpoint
11
- */
12
6
  export const DEFAULT_ENDPOINT = 'localhost';
13
7
 
14
- /**
15
- * @constant Default storage region
16
- */
17
8
  export const DEFAULT_REGION = 'eu';
18
9
 
19
- /**
20
- * @constant Default storage port
21
- */
22
10
  export const DEFAULT_PORT = 9000;
23
11
 
24
- /**
25
- * @constant Default storage port
26
- */
27
12
  export const DEFAULT_USE_SSL = false;
28
13
 
29
- /**
30
- * @constant Default tx Id
31
- */
32
14
  export const DEFAULT_TX_ID = 1;
33
15
 
34
- /**
35
- * @constant Default Enum for escrow statuses.
36
- */
37
16
  export enum HttpStatus {
38
17
  OK = 200,
39
18
  CREATED = 201,
@@ -45,9 +24,6 @@ export enum HttpStatus {
45
24
  INTERNAL_SERVER_ERROR = 500,
46
25
  }
47
26
 
48
- /**
49
- * @constant Default network parameters
50
- */
51
27
  export const NETWORKS: {
52
28
  [chainId in ChainId]?: NetworkData;
53
29
  } = {
@@ -57,13 +33,12 @@ export const NETWORKS: {
57
33
  scanUrl: 'https://etherscan.io',
58
34
  factoryAddress: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
59
35
  hmtAddress: '0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867',
60
- stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
61
- rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
36
+ stakingAddress: '0xEf6Da3aB52c33925Be3F84038193a7e1331F51E6',
62
37
  kvstoreAddress: '0xB6d36B1CDaD50302BCB3DB43bAb0D349458e1b8D',
63
38
  subgraphUrl:
64
39
  'https://api.studio.thegraph.com/query/74256/ethereum/version/latest',
65
40
  subgraphUrlApiKey:
66
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmaTcYR8NCzZuxwY7tBkMJAo1Q64BMqNNSzqjxd7FH9s2p',
41
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmNTdYHpQLW4sbrCxihXNdQwhxa2zdyu1yPkCUuTbqESba',
67
42
  oldSubgraphUrl: '',
68
43
  oldFactoryAddress: '',
69
44
  },
@@ -74,7 +49,6 @@ export const NETWORKS: {
74
49
  factoryAddress: '0x925B24444511c86F4d4E63141D8Be0A025E2dca4',
75
50
  hmtAddress: '0x4dCf5ac4509888714dd43A5cCc46d7ab389D9c23',
76
51
  stakingAddress: '',
77
- rewardPoolAddress: '',
78
52
  kvstoreAddress: '',
79
53
  subgraphUrl: '',
80
54
  subgraphUrlApiKey: '',
@@ -88,7 +62,6 @@ export const NETWORKS: {
88
62
  factoryAddress: '0x87469B4f2Fcf37cBd34E54244c0BD4Fa0603664c',
89
63
  hmtAddress: '0xd3A31D57FDD790725d0F6B78095F62E8CD4ab317',
90
64
  stakingAddress: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
91
- rewardPoolAddress: '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4',
92
65
  kvstoreAddress: '0x19Fc3e859C1813ac9427a7a78BeB9ae102CE96d3',
93
66
  subgraphUrl:
94
67
  'https://api.thegraph.com/subgraphs/name/humanprotocol/goerli-v2',
@@ -101,15 +74,14 @@ export const NETWORKS: {
101
74
  chainId: ChainId.SEPOLIA,
102
75
  title: 'Ethereum Sepolia',
103
76
  scanUrl: 'https://sepolia.etherscan.io/',
104
- factoryAddress: '0xD6D347ba6987519B4e42EcED43dF98eFf5465a23',
77
+ factoryAddress: '0x5987A5558d961ee674efe4A8c8eB7B1b5495D3bf',
105
78
  hmtAddress: '0x792abbcC99c01dbDec49c9fa9A828a186Da45C33',
106
- stakingAddress: '0x2B9C5EC6220BA8Ad08CB51A60FFdbC6a6235B203',
107
- rewardPoolAddress: '0xAFf5a986A530ff839d49325A5dF69F96627E8D29',
79
+ stakingAddress: '0x2163e3A40032Af1C359ac731deaB48258b317890',
108
80
  kvstoreAddress: '0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60',
109
81
  subgraphUrl:
110
82
  'https://api.studio.thegraph.com/query/74256/sepolia/version/latest',
111
83
  subgraphUrlApiKey:
112
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmadNQBBzcfJHTmzLezZGbwvLux7HmnmfByBHubS2cmLUr',
84
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmXVFVCLm2XxupxdKgnLRzvmkPJnpRbcoe4RNXoTqSRHsg',
113
85
  oldSubgraphUrl: '',
114
86
  oldFactoryAddress: '',
115
87
  },
@@ -119,13 +91,12 @@ export const NETWORKS: {
119
91
  scanUrl: 'https://bscscan.com',
120
92
  factoryAddress: '0x92FD968AcBd521c232f5fB8c33b342923cC72714',
121
93
  hmtAddress: '0x711Fd6ab6d65A98904522d4e3586F492B989c527',
122
- stakingAddress: '0xdFbB79dC35a3A53741be54a2C9b587d6BafAbd1C',
123
- rewardPoolAddress: '0xf376443BCc6d4d4D63eeC086bc4A9E4a83878e0e',
94
+ stakingAddress: '0xE24e5C08E28331D24758b69A5E9f383D2bDD1c98',
124
95
  kvstoreAddress: '0x21A0C4CED7aE447fCf87D9FE3A29FA9B3AB20Ff1',
125
96
  subgraphUrl:
126
97
  'https://api.studio.thegraph.com/query/74256/bsc/version/latest',
127
98
  subgraphUrlApiKey:
128
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmXZ4QJMi8kyfXDEJwtdizyKf5JdJui89iYCLCE79N8Xf5',
99
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmPMS6G5evLm5ZpbnmpCfUy8bHJPwzPkZTv9DgfNdFfrCM',
129
100
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
130
101
  oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
131
102
  },
@@ -135,13 +106,12 @@ export const NETWORKS: {
135
106
  scanUrl: 'https://testnet.bscscan.com',
136
107
  factoryAddress: '0x2bfA592DBDaF434DDcbb893B1916120d181DAD18',
137
108
  hmtAddress: '0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d',
138
- stakingAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
139
- rewardPoolAddress: '0xB0A0500103eCEc431b73F6BAd923F0a2774E6e29',
109
+ stakingAddress: '0xD6D347ba6987519B4e42EcED43dF98eFf5465a23',
140
110
  kvstoreAddress: '0x32e27177BA6Ea91cf28dfd91a0Da9822A4b74EcF',
141
111
  subgraphUrl:
142
112
  'https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest',
143
113
  subgraphUrlApiKey:
144
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/Qmdq449rn4WKDf7NLvRZgt7CedZRrvpDzPqcvSmhvuu16D',
114
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmW6JqXvhDnhRVHU6ixKVSD65U1GKWUf3xwJo8E6mTBsAu',
145
115
  oldSubgraphUrl:
146
116
  'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
147
117
  oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
@@ -152,13 +122,12 @@ export const NETWORKS: {
152
122
  scanUrl: 'https://polygonscan.com',
153
123
  factoryAddress: '0xBDBfD2cC708199C5640C6ECdf3B0F4A4C67AdfcB',
154
124
  hmtAddress: '0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571BF',
155
- stakingAddress: '0xcbAd56bE3f504E98bd70875823d3CC0242B7bB29',
156
- rewardPoolAddress: '0xa8e32d777a3839440cc7c24D591A64B9481753B3',
125
+ stakingAddress: '0x01D115E9E8bF0C58318793624CC662a030D07F1D',
157
126
  kvstoreAddress: '0xbcB28672F826a50B03EE91B28145EAbddA73B2eD',
158
127
  subgraphUrl:
159
128
  'https://api.studio.thegraph.com/query/74256/polygon/version/latest',
160
129
  subgraphUrlApiKey:
161
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmNdsofT4Cj2KRwr8vgyKgCWpZNmrMN41zUdygRz7eSGC9',
130
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmTyCQMQd5QtogeTEuiqxnGQZa2PtgpUBsWLYwPCCFPbUe',
162
131
  oldSubgraphUrl:
163
132
  'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
164
133
  oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
@@ -170,7 +139,6 @@ export const NETWORKS: {
170
139
  factoryAddress: '0xA8D927C4DA17A6b71675d2D49dFda4E9eBE58f2d',
171
140
  hmtAddress: '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4',
172
141
  stakingAddress: '0x7Fd3dF914E7b6Bd96B4c744Df32183b51368Bfac',
173
- rewardPoolAddress: '0xf0145eD99AC3c4f877aDa7dA4D1E059ec9116BAE',
174
142
  kvstoreAddress: '0xD96158c7267Ea658a4688F4aEf1c85659851625d',
175
143
  subgraphUrl:
176
144
  'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai-v2',
@@ -185,13 +153,12 @@ export const NETWORKS: {
185
153
  scanUrl: 'https://amoy.polygonscan.com/',
186
154
  factoryAddress: '0xAFf5a986A530ff839d49325A5dF69F96627E8D29',
187
155
  hmtAddress: '0x792abbcC99c01dbDec49c9fa9A828a186Da45C33',
188
- stakingAddress: '0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60',
189
- rewardPoolAddress: '0xd866bCEFf6D0F77E1c3EAE28230AE6C79b03fDa7',
156
+ stakingAddress: '0xffE496683F842a923110415b7278ded3F265f2C5',
190
157
  kvstoreAddress: '0x724AeFC243EdacCA27EAB86D3ec5a76Af4436Fc7',
191
158
  subgraphUrl:
192
159
  'https://api.studio.thegraph.com/query/74256/amoy/version/latest',
193
160
  subgraphUrlApiKey:
194
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/Qmbwio5UnvDn5GQRJ5kLJfK27fqHK9nkEh4YXXYKWCc9rH',
161
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmawobiPUYsGNK9chtb5PvicUtaa8Jsjpwvv8dNyMVXQ9r',
195
162
  oldSubgraphUrl: '',
196
163
  oldFactoryAddress: '',
197
164
  },
@@ -202,7 +169,6 @@ export const NETWORKS: {
202
169
  factoryAddress: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
203
170
  hmtAddress: '0x3b25BC1dC591D24d60560d0135D6750A561D4764',
204
171
  stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
205
- rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
206
172
  kvstoreAddress: '0x2B95bEcb6EBC4589f64CB000dFCF716b4aeF8aA6',
207
173
  subgraphUrl:
208
174
  'https://api.studio.thegraph.com/query/74256/moonbeam/version/latest',
@@ -218,13 +184,12 @@ export const NETWORKS: {
218
184
  scanUrl: 'https://moonbase.moonscan.io/',
219
185
  factoryAddress: '0x5e622FF522D81aa426f082bDD95210BC25fCA7Ed',
220
186
  hmtAddress: '0x2dd72db2bBA65cE663e476bA8b84A1aAF802A8e3',
221
- stakingAddress: '0xBFC7009F3371F93F3B54DdC8caCd02914a37495c',
222
- rewardPoolAddress: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
187
+ stakingAddress: '0xbA537fEF2442cD48f60686FE1Bbbe40F964a7940',
223
188
  kvstoreAddress: '0xcC561f4482f4Ff051D2Dcc65c2cE1A0f291bbA46',
224
189
  subgraphUrl:
225
190
  'https://api.studio.thegraph.com/query/74256/moonbase-alpha/version/latest',
226
191
  subgraphUrlApiKey:
227
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmeC4JrotcrXWJtJU519RX3KkxE5879wveRJJ58EheH3j1',
192
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmSDPbm5xxMvYVSJzHFVsRiMekvJVYSJ7UfZw17DhPMdaH',
228
193
  oldSubgraphUrl: '',
229
194
  oldFactoryAddress: '',
230
195
  },
@@ -234,13 +199,12 @@ export const NETWORKS: {
234
199
  scanUrl: 'https://testnet.snowtrace.io',
235
200
  factoryAddress: '0x56C2ba540726ED4f46E7a134b6b9Ee9C867FcF92',
236
201
  hmtAddress: '0x9406d5c635AD22b0d76c75E52De57A2177919ca3',
237
- stakingAddress: '0x9890473B0b93E24d6D1a8Dfb739D577C6f25FFd3',
238
- rewardPoolAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
202
+ stakingAddress: '0xbA537fEF2442cD48f60686FE1Bbbe40F964a7940',
239
203
  kvstoreAddress: '0x3aD4B091E054f192a822D1406f4535eAd38580e4',
240
204
  subgraphUrl:
241
205
  'https://api.studio.thegraph.com/query/74256/fuji/version/latest',
242
206
  subgraphUrlApiKey:
243
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmcFhecY6w3AhKGSg8XeidXwwuXCV9DAQ5SYGE1sTzydgR',
207
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmYXwNPwC5DcitK1SLVUR6gPANmEn3UsVvGeTbjCv1tTb2',
244
208
  oldSubgraphUrl:
245
209
  'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji',
246
210
  oldFactoryAddress: '0xfb4469201951C3B9a7F1996c477cb7BDBEcE0A88',
@@ -252,7 +216,6 @@ export const NETWORKS: {
252
216
  factoryAddress: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
253
217
  hmtAddress: '0x12365293cb6477d4fc2686e46BB97E3Fb64f1550',
254
218
  stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
255
- rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
256
219
  kvstoreAddress: '0x9Bc7bff35B2Be2413708d48c3B0aEF5c43646728',
257
220
  subgraphUrl:
258
221
  'https://api.studio.thegraph.com/query/74256/avalanche/version/latest',
@@ -269,7 +232,6 @@ export const NETWORKS: {
269
232
  factoryAddress: '0x86Af9f6Cd34B69Db1B202223C6d6D109f2491569',
270
233
  hmtAddress: '0x2736B33455A872dC478E1E004106D04c35472468',
271
234
  stakingAddress: '0x003548Df34be8836cF0F9673403a1E40ba449a0F',
272
- rewardPoolAddress: '0xA9545C2530BD5bdb464d5E274F59ACceAa73eD86',
273
235
  kvstoreAddress: '0x938335006ea6F9Eb0e8020969cFF94404425e298',
274
236
  subgraphUrl:
275
237
  'https://api.studio.thegraph.com/query/74256/celo-alfajores/version/latest',
@@ -285,7 +247,6 @@ export const NETWORKS: {
285
247
  factoryAddress: '0xc90B43a5d576D9d8026c48904dfbaED50C15Fa08',
286
248
  hmtAddress: '0x19Ead835951493A763c96910255d5eeF147E914F',
287
249
  stakingAddress: '0x34cD3Bd6B16c559f321799b516dE61E12017fFd1',
288
- rewardPoolAddress: '0xb9344bAD98E3d26a4d83900922baf395a2Ec154c',
289
250
  kvstoreAddress: '0x86Af9f6Cd34B69Db1B202223C6d6D109f2491569',
290
251
  subgraphUrl:
291
252
  'https://api.studio.thegraph.com/query/74256/celo/version/latest',
@@ -301,7 +262,6 @@ export const NETWORKS: {
301
262
  factoryAddress: '0x4949C9DFFD83F0D5Ab0AB24C57C4D403D5c20C15',
302
263
  hmtAddress: '0x10acbe3b9e6a2ff7f341e5cbf4b6617741ff44aa',
303
264
  stakingAddress: '0x01D115E9E8bF0C58318793624CC662a030D07F1D',
304
- rewardPoolAddress: '0x7ABa5F75b2b530cB0c8927C86591c21dF44f06b6',
305
265
  kvstoreAddress: '0x6512d894cc3d3FE93Da9d0420430136fA889FaB9',
306
266
  subgraphUrl:
307
267
  'https://api.studio.thegraph.com/query/74256/xlayer/version/latest',
@@ -316,13 +276,12 @@ export const NETWORKS: {
316
276
  scanUrl: 'https://www.okx.com/explorer/xlayer-test',
317
277
  factoryAddress: '0x6Cd3ecAD36ee88E9ef3665CF381D9dAE0FE0a32e',
318
278
  hmtAddress: '0x792abbcC99c01dbDec49c9fa9A828a186Da45C33',
319
- stakingAddress: '0x819069fEd50581587fAB9E583b5488fc2D33B7ea',
320
- rewardPoolAddress: '0x6daccd1f3a68945f8a7ac6d20260953f7a97fae4',
279
+ stakingAddress: '0xeF9849a904dF0d494D69ac0B0a6860a3A7936114',
321
280
  kvstoreAddress: '0xdE8BE9E3C12E9F546309A429cd88d026a25EaF8C',
322
281
  subgraphUrl:
323
282
  'https://api.studio.thegraph.com/query/74256/xlayer-testnet/version/latest',
324
283
  subgraphUrlApiKey:
325
- 'https://gateway-testnet-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmQrTmq89ZCdVABsFpLHtQUWuyyVzbcARoan9eztHd21oP',
284
+ 'https://gateway-testnet-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmNoRyqZtJTRrkbKAmWMZQUHuah7YSs8U9R3nzPu8WEhtY',
326
285
  oldSubgraphUrl: '',
327
286
  oldFactoryAddress: '',
328
287
  },
@@ -330,11 +289,10 @@ export const NETWORKS: {
330
289
  chainId: ChainId.LOCALHOST,
331
290
  title: 'Localhost',
332
291
  scanUrl: '',
333
- factoryAddress: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',
292
+ factoryAddress: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9',
334
293
  hmtAddress: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
335
- stakingAddress: '0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0',
336
- rewardPoolAddress: '0xa513E6E4b8f2a923D98304ec87F64353C4D5C853',
337
- kvstoreAddress: '0x5FC8d32690cc91D4c39d9d3abcBD16989F875707',
294
+ stakingAddress: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
295
+ kvstoreAddress: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',
338
296
  subgraphUrl: 'http://localhost:8000/subgraphs/name/humanprotocol/localhost',
339
297
  subgraphUrlApiKey: '',
340
298
  oldSubgraphUrl: '',
@@ -347,6 +305,7 @@ export const KVStoreKeys = {
347
305
  fee: 'fee',
348
306
  publicKey: 'public_key',
349
307
  webhookUrl: 'webhook_url',
308
+ website: 'website',
350
309
  url: 'url',
351
310
  jobTypes: 'job_types',
352
311
  registrationNeeded: 'registration_needed',
package/src/encryption.ts CHANGED
@@ -413,7 +413,7 @@ export class EncryptionUtils {
413
413
  * This function encrypts a message using the specified public keys.
414
414
  *
415
415
  * @param {string} message Message to encrypt.
416
- * @param {string} publicKey Array of public keys to use for encryption.
416
+ * @param {string} publicKeys Array of public keys to use for encryption.
417
417
  * @returns {Promise<string>} Message encrypted.
418
418
  *
419
419
  * **Code example**
package/src/escrow.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import {
3
+ ERC20,
4
+ ERC20__factory,
3
5
  Escrow,
4
6
  EscrowFactory,
5
7
  EscrowFactory__factory,
@@ -45,7 +47,12 @@ import {
45
47
  StatusEvent,
46
48
  } from './graphql';
47
49
  import { IEscrowConfig, IEscrowsFilter } from './interfaces';
48
- import { EscrowCancel, EscrowStatus, NetworkData } from './types';
50
+ import {
51
+ EscrowCancel,
52
+ EscrowStatus,
53
+ EscrowWithdraw,
54
+ NetworkData,
55
+ } from './types';
49
56
  import { getSubgraphUrl, isValidUrl, throwError } from './utils';
50
57
 
51
58
  /**
@@ -124,7 +131,7 @@ export class EscrowClient extends BaseEthersClient {
124
131
  * **EscrowClient constructor**
125
132
  *
126
133
  * @param {ContractRunner} runner The Runner object to interact with the Ethereum network
127
- * @param {NetworkData} network The network information required to connect to the Escrow contract
134
+ * @param {NetworkData} networkData The network information required to connect to the Escrow contract
128
135
  */
129
136
  constructor(runner: ContractRunner, networkData: NetworkData) {
130
137
  super(runner, networkData);
@@ -370,69 +377,6 @@ export class EscrowClient extends BaseEthersClient {
370
377
  }
371
378
  }
372
379
 
373
- /**
374
- * This function creates and sets up an escrow.
375
- *
376
- * @param {string} tokenAddress Token address to use for pay outs.
377
- * @param {string[]} trustedHandlers Array of addresses that can perform actions on the contract.
378
- * @param {string} jobRequesterId Job Requester Id
379
- * @param {IEscrowConfig} escrowConfig Configuration object with escrow settings.
380
- * @returns {Promise<string>} Returns the address of the escrow created.
381
- *
382
- *
383
- * **Code example**
384
- *
385
- * ```ts
386
- * import { ethers, Wallet, providers } from 'ethers';
387
- * import { EscrowClient } from '@human-protocol/sdk';
388
- *
389
- * const rpcUrl = 'YOUR_RPC_URL';
390
- * const privateKey = 'YOUR_PRIVATE_KEY'
391
- *
392
- * const provider = new providers.JsonRpcProvider(rpcUrl);
393
- * const signer = new Wallet(privateKey, provider);
394
- * const escrowClient = await EscrowClient.build(signer);
395
- *
396
- * const tokenAddress = '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4';
397
- * const trustedHandlers = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'];
398
- * const jobRequesterId = "job-requester-id";
399
- *
400
- * const escrowConfig = {
401
- * recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
402
- * reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
403
- * exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
404
- * recordingOracleFee: bigint.from('10'),
405
- * reputationOracleFee: bigint.from('10'),
406
- * exchangeOracleFee: bigint.from('10'),
407
- * manifestUrl: 'htttp://localhost/manifest.json',
408
- * manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079',
409
- * };
410
- *
411
- * const escrowAddress = await escrowClient.createAndSetupEscrow(tokenAddress, trustedHandlers, jobRequesterId, escrowConfig);
412
- * ```
413
- */
414
- @requiresSigner
415
- async createAndSetupEscrow(
416
- tokenAddress: string,
417
- trustedHandlers: string[],
418
- jobRequesterId: string,
419
- escrowConfig: IEscrowConfig
420
- ): Promise<string> {
421
- try {
422
- const escrowAddress = await this.createEscrow(
423
- tokenAddress,
424
- trustedHandlers,
425
- jobRequesterId
426
- );
427
-
428
- await this.setup(escrowAddress, escrowConfig);
429
-
430
- return escrowAddress;
431
- } catch (e) {
432
- return throwError(e);
433
- }
434
- }
435
-
436
380
  /**
437
381
  * This function adds funds of the chosen token to the escrow.
438
382
  *
@@ -619,6 +563,7 @@ export class EscrowClient extends BaseEthersClient {
619
563
  * @param {bigint[]} amounts Array of amounts the recipients will receive.
620
564
  * @param {string} finalResultsUrl Final results file url.
621
565
  * @param {string} finalResultsHash Final results file hash.
566
+ * @param {string} forceComplete Indicates if remaining balance should be transferred to the escrow creator (optional, defaults to false).
622
567
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
623
568
  * @returns Returns void if successful. Throws error if any.
624
569
  *
@@ -653,6 +598,7 @@ export class EscrowClient extends BaseEthersClient {
653
598
  amounts: bigint[],
654
599
  finalResultsUrl: string,
655
600
  finalResultsHash: string,
601
+ forceComplete = false,
656
602
  txOptions: Overrides = {}
657
603
  ): Promise<void> {
658
604
  if (!ethers.isAddress(escrowAddress)) {
@@ -706,17 +652,34 @@ export class EscrowClient extends BaseEthersClient {
706
652
 
707
653
  try {
708
654
  const escrowContract = this.getEscrowContract(escrowAddress);
709
-
710
- await (
711
- await escrowContract.bulkPayOut(
712
- recipients,
713
- amounts,
714
- finalResultsUrl,
715
- finalResultsHash,
716
- DEFAULT_TX_ID,
717
- txOptions
718
- )
719
- ).wait();
655
+ if (forceComplete) {
656
+ await (
657
+ await escrowContract[
658
+ 'bulkPayOut(address[],uint256[],string,string,uint256,bool)'
659
+ ](
660
+ recipients,
661
+ amounts,
662
+ finalResultsUrl,
663
+ finalResultsHash,
664
+ DEFAULT_TX_ID,
665
+ forceComplete,
666
+ txOptions
667
+ )
668
+ ).wait();
669
+ } else {
670
+ await (
671
+ await escrowContract[
672
+ 'bulkPayOut(address[],uint256[],string,string,uint256)'
673
+ ](
674
+ recipients,
675
+ amounts,
676
+ finalResultsUrl,
677
+ finalResultsHash,
678
+ DEFAULT_TX_ID,
679
+ txOptions
680
+ )
681
+ ).wait();
682
+ }
720
683
  return;
721
684
  } catch (e) {
722
685
  return throwError(e);
@@ -808,9 +771,10 @@ export class EscrowClient extends BaseEthersClient {
808
771
  }
809
772
 
810
773
  /**
811
- * This function cancels the specified escrow, sends the balance to the canceler and selfdestructs the escrow contract.
774
+ * This function adds an array of addresses to the trusted handlers list.
812
775
  *
813
776
  * @param {string} escrowAddress Address of the escrow.
777
+ * @param {string[]} trustedHandlers Array of addresses of trusted handlers to add.
814
778
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
815
779
  * @returns Returns void if successful. Throws error if any.
816
780
  *
@@ -830,15 +794,30 @@ export class EscrowClient extends BaseEthersClient {
830
794
  * const signer = new Wallet(privateKey, provider);
831
795
  * const escrowClient = await EscrowClient.build(signer);
832
796
  *
833
- * await escrowClient.abort('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
797
+ * const trustedHandlers = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266']
798
+ * await escrowClient.addTrustedHandlers('0x62dD51230A30401C455c8398d06F85e4EaB6309f', trustedHandlers);
834
799
  * ```
835
800
  */
836
801
  @requiresSigner
837
- async abort(escrowAddress: string, txOptions: Overrides = {}): Promise<void> {
802
+ async addTrustedHandlers(
803
+ escrowAddress: string,
804
+ trustedHandlers: string[],
805
+ txOptions: Overrides = {}
806
+ ): Promise<void> {
838
807
  if (!ethers.isAddress(escrowAddress)) {
839
808
  throw ErrorInvalidEscrowAddressProvided;
840
809
  }
841
810
 
811
+ if (trustedHandlers.length === 0) {
812
+ throw ErrorListOfHandlersCannotBeEmpty;
813
+ }
814
+
815
+ trustedHandlers.forEach((trustedHandler) => {
816
+ if (!ethers.isAddress(trustedHandler)) {
817
+ throw new InvalidEthereumAddressError(trustedHandler);
818
+ }
819
+ });
820
+
842
821
  if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
843
822
  throw ErrorEscrowAddressIsNotProvidedByFactory;
844
823
  }
@@ -846,7 +825,9 @@ export class EscrowClient extends BaseEthersClient {
846
825
  try {
847
826
  const escrowContract = this.getEscrowContract(escrowAddress);
848
827
 
849
- await (await escrowContract.abort(txOptions)).wait();
828
+ await (
829
+ await escrowContract.addTrustedHandlers(trustedHandlers, txOptions)
830
+ ).wait();
850
831
  return;
851
832
  } catch (e) {
852
833
  return throwError(e);
@@ -854,20 +835,20 @@ export class EscrowClient extends BaseEthersClient {
854
835
  }
855
836
 
856
837
  /**
857
- * This function sets the status of an escrow to completed.
838
+ * This function withdraws additional tokens in the escrow to the canceler.
858
839
  *
859
- * @param {string} escrowAddress Address of the escrow.
860
- * @param {string[]} trustedHandlers Array of addresses of trusted handlers to add.
840
+ * @param {string} escrowAddress Address of the escrow to withdraw.
841
+ * @param {string} tokenAddress Address of the token to withdraw.
861
842
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
862
- * @returns Returns void if successful. Throws error if any.
843
+ * @returns {EscrowWithdraw} Returns the escrow withdrawal data including transaction hash and withdrawal amount. Throws error if any.
863
844
  *
864
845
  *
865
846
  * **Code example**
866
847
  *
867
- * > Only Job Launcher or trusted handler can call it.
848
+ * > Only Job Launcher or a trusted handler can call it.
868
849
  *
869
850
  * ```ts
870
- * import { Wallet, providers } from 'ethers';
851
+ * import { ethers, Wallet, providers } from 'ethers';
871
852
  * import { EscrowClient } from '@human-protocol/sdk';
872
853
  *
873
854
  * const rpcUrl = 'YOUR_RPC_URL';
@@ -877,30 +858,26 @@ export class EscrowClient extends BaseEthersClient {
877
858
  * const signer = new Wallet(privateKey, provider);
878
859
  * const escrowClient = await EscrowClient.build(signer);
879
860
  *
880
- * const trustedHandlers = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266']
881
- * await escrowClient.addTrustedHandlers('0x62dD51230A30401C455c8398d06F85e4EaB6309f', trustedHandlers);
861
+ * await escrowClient.withdraw(
862
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
863
+ * '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4'
864
+ * );
882
865
  * ```
883
866
  */
884
867
  @requiresSigner
885
- async addTrustedHandlers(
868
+ async withdraw(
886
869
  escrowAddress: string,
887
- trustedHandlers: string[],
870
+ tokenAddress: string,
888
871
  txOptions: Overrides = {}
889
- ): Promise<void> {
872
+ ): Promise<EscrowWithdraw> {
890
873
  if (!ethers.isAddress(escrowAddress)) {
891
874
  throw ErrorInvalidEscrowAddressProvided;
892
875
  }
893
876
 
894
- if (trustedHandlers.length === 0) {
895
- throw ErrorListOfHandlersCannotBeEmpty;
877
+ if (!ethers.isAddress(tokenAddress)) {
878
+ throw ErrorInvalidTokenAddress;
896
879
  }
897
880
 
898
- trustedHandlers.forEach((trustedHandler) => {
899
- if (!ethers.isAddress(trustedHandler)) {
900
- throw new InvalidEthereumAddressError(trustedHandler);
901
- }
902
- });
903
-
904
881
  if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
905
882
  throw ErrorEscrowAddressIsNotProvidedByFactory;
906
883
  }
@@ -908,10 +885,43 @@ export class EscrowClient extends BaseEthersClient {
908
885
  try {
909
886
  const escrowContract = this.getEscrowContract(escrowAddress);
910
887
 
911
- await (
912
- await escrowContract.addTrustedHandlers(trustedHandlers, txOptions)
888
+ const transactionReceipt = await (
889
+ await escrowContract.withdraw(tokenAddress, txOptions)
913
890
  ).wait();
914
- return;
891
+
892
+ let amountTransferred: bigint | undefined = undefined;
893
+
894
+ const tokenContract: ERC20 = ERC20__factory.connect(
895
+ tokenAddress,
896
+ this.runner
897
+ );
898
+ if (transactionReceipt)
899
+ for (const log of transactionReceipt.logs) {
900
+ if (log.address === tokenAddress) {
901
+ const parsedLog = tokenContract.interface.parseLog({
902
+ topics: log.topics as string[],
903
+ data: log.data,
904
+ });
905
+
906
+ const from = parsedLog?.args[0];
907
+ if (parsedLog?.name === 'Transfer' && from === escrowAddress) {
908
+ amountTransferred = parsedLog?.args[2];
909
+ break;
910
+ }
911
+ }
912
+ }
913
+
914
+ if (amountTransferred === undefined) {
915
+ throw ErrorTransferEventNotFoundInTransactionLogs;
916
+ }
917
+
918
+ const escrowWithdrawData: EscrowWithdraw = {
919
+ txHash: transactionReceipt?.hash || '',
920
+ tokenAddress,
921
+ amountWithdrawn: amountTransferred,
922
+ };
923
+
924
+ return escrowWithdrawData;
915
925
  } catch (e) {
916
926
  return throwError(e);
917
927
  }
@@ -949,7 +959,13 @@ export class EscrowClient extends BaseEthersClient {
949
959
  try {
950
960
  const escrowContract = this.getEscrowContract(escrowAddress);
951
961
 
952
- return escrowContract.getBalance();
962
+ try {
963
+ return await escrowContract.remainingFunds();
964
+ } catch {
965
+ // Use getBalance() method below if remainingFunds() is not available
966
+ }
967
+
968
+ return await escrowContract.getBalance();
953
969
  } catch (e) {
954
970
  return throwError(e);
955
971
  }
@@ -6,22 +6,22 @@ const LEADER_FRAGMENT = gql`
6
6
  id
7
7
  address
8
8
  amountStaked
9
- amountAllocated
10
9
  amountLocked
11
10
  lockedUntilTimestamp
12
11
  amountWithdrawn
13
12
  amountSlashed
14
- reputation
15
13
  reward
16
14
  amountJobsProcessed
17
15
  role
18
16
  fee
19
17
  publicKey
20
18
  webhookUrl
19
+ website
21
20
  url
22
21
  jobTypes
23
22
  registrationNeeded
24
23
  registrationInstructions
24
+ reputationNetworks
25
25
  }
26
26
  `;
27
27
 
@@ -15,7 +15,6 @@ const HMTOKEN_STATISTICS_FRAGMENT = gql`
15
15
  const ESCROW_STATISTICS_FRAGMENT = gql`
16
16
  fragment EscrowStatisticsFields on EscrowStatistics {
17
17
  fundEventCount
18
- setupEventCount
19
18
  storeResultsEventCount
20
19
  bulkPayoutEventCount
21
20
  pendingStatusEventCount
@@ -32,7 +31,6 @@ const EVENT_DAY_DATA_FRAGMENT = gql`
32
31
  fragment EventDayDataFields on EventDayData {
33
32
  timestamp
34
33
  dailyFundEventCount
35
- dailySetupEventCount
36
34
  dailyStoreResultsEventCount
37
35
  dailyBulkPayoutEventCount
38
36
  dailyPendingStatusEventCount