@human-protocol/sdk 3.0.6 → 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.
- package/dist/constants.d.ts +1 -24
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +23 -64
- package/dist/encryption.d.ts +6 -4
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +52 -16
- package/dist/escrow.d.ts +20 -57
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +74 -88
- package/dist/graphql/queries/operator.js +2 -2
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +0 -2
- package/dist/graphql/queries/transaction.d.ts.map +1 -1
- package/dist/graphql/queries/transaction.js +23 -10
- package/dist/graphql/types.d.ts +0 -2
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/interfaces.d.ts +19 -10
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +1 -1
- package/dist/kvstore.js +1 -1
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +13 -0
- package/dist/staking.d.ts +3 -112
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +2 -170
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +3 -1
- package/dist/storage.js +17 -7
- package/dist/types.d.ts +17 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/constants.ts +23 -64
- package/src/encryption.ts +47 -15
- package/src/escrow.ts +119 -103
- package/src/graphql/queries/operator.ts +2 -2
- package/src/graphql/queries/statistics.ts +0 -2
- package/src/graphql/queries/transaction.ts +23 -13
- package/src/graphql/types.ts +0 -2
- package/src/interfaces.ts +19 -11
- package/src/kvstore.ts +1 -1
- package/src/operator.ts +21 -0
- package/src/staking.ts +2 -185
- package/src/statistics.ts +3 -1
- 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: '
|
|
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/
|
|
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: '
|
|
77
|
+
factoryAddress: '0x5987A5558d961ee674efe4A8c8eB7B1b5495D3bf',
|
|
105
78
|
hmtAddress: '0x792abbcC99c01dbDec49c9fa9A828a186Da45C33',
|
|
106
|
-
stakingAddress: '
|
|
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/
|
|
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: '
|
|
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/
|
|
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: '
|
|
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/
|
|
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: '
|
|
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/
|
|
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: '
|
|
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/
|
|
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: '
|
|
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/
|
|
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: '
|
|
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/
|
|
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: '
|
|
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/
|
|
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: '
|
|
292
|
+
factoryAddress: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9',
|
|
334
293
|
hmtAddress: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
|
|
335
|
-
stakingAddress: '
|
|
336
|
-
|
|
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
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import * as openpgp from 'openpgp';
|
|
2
2
|
import { IKeyPair } from './interfaces';
|
|
3
3
|
|
|
4
|
+
type MessageDataType = string | Uint8Array;
|
|
5
|
+
|
|
6
|
+
function makeMessageDataBinary(message: MessageDataType): Uint8Array {
|
|
7
|
+
if (typeof message === 'string') {
|
|
8
|
+
return Buffer.from(message);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return message;
|
|
12
|
+
}
|
|
13
|
+
|
|
4
14
|
/**
|
|
5
15
|
* ## Introduction
|
|
6
16
|
*
|
|
@@ -126,20 +136,21 @@ export class Encryption {
|
|
|
126
136
|
* ```
|
|
127
137
|
*/
|
|
128
138
|
public async signAndEncrypt(
|
|
129
|
-
message:
|
|
139
|
+
message: MessageDataType,
|
|
130
140
|
publicKeys: string[]
|
|
131
141
|
): Promise<string> {
|
|
132
|
-
const plaintext = message;
|
|
133
|
-
|
|
134
142
|
const pgpPublicKeys = await Promise.all(
|
|
135
143
|
publicKeys.map((armoredKey) => openpgp.readKey({ armoredKey }))
|
|
136
144
|
);
|
|
137
145
|
|
|
138
|
-
const pgpMessage = await openpgp.createMessage({
|
|
146
|
+
const pgpMessage = await openpgp.createMessage({
|
|
147
|
+
binary: makeMessageDataBinary(message),
|
|
148
|
+
});
|
|
139
149
|
const encrypted = await openpgp.encrypt({
|
|
140
150
|
message: pgpMessage,
|
|
141
151
|
encryptionKeys: pgpPublicKeys,
|
|
142
152
|
signingKeys: this.privateKey,
|
|
153
|
+
format: 'armored',
|
|
143
154
|
});
|
|
144
155
|
|
|
145
156
|
return encrypted as string;
|
|
@@ -176,23 +187,43 @@ export class Encryption {
|
|
|
176
187
|
* const resultMessage = await encription.decrypt('message');
|
|
177
188
|
* ```
|
|
178
189
|
*/
|
|
179
|
-
public async decrypt(
|
|
180
|
-
|
|
190
|
+
public async decrypt(
|
|
191
|
+
message: string,
|
|
192
|
+
publicKey?: string
|
|
193
|
+
): Promise<Uint8Array> {
|
|
194
|
+
const pgpMessage = await openpgp.readMessage({
|
|
195
|
+
armoredMessage: message,
|
|
196
|
+
});
|
|
181
197
|
|
|
182
198
|
const decryptionOptions: openpgp.DecryptOptions = {
|
|
183
199
|
message: pgpMessage,
|
|
184
200
|
decryptionKeys: this.privateKey,
|
|
185
|
-
|
|
201
|
+
format: 'binary',
|
|
186
202
|
};
|
|
187
203
|
|
|
188
|
-
|
|
204
|
+
const shouldVerifySignature = !!publicKey;
|
|
205
|
+
if (shouldVerifySignature) {
|
|
189
206
|
const pgpPublicKey = await openpgp.readKey({ armoredKey: publicKey });
|
|
190
207
|
decryptionOptions.verificationKeys = pgpPublicKey;
|
|
191
208
|
}
|
|
192
209
|
|
|
193
|
-
const { data: decrypted } =
|
|
210
|
+
const { data: decrypted, signatures } =
|
|
211
|
+
await openpgp.decrypt(decryptionOptions);
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* There is an option to automatically verify signatures - `expectSigned`,
|
|
215
|
+
* but atm it has a bug - https://github.com/openpgpjs/openpgpjs/issues/1803,
|
|
216
|
+
* so we have to verify it manually till it's fixed.
|
|
217
|
+
*/
|
|
218
|
+
try {
|
|
219
|
+
if (shouldVerifySignature) {
|
|
220
|
+
await signatures[0].verified;
|
|
221
|
+
}
|
|
222
|
+
} catch {
|
|
223
|
+
throw new Error('Signature could not be verified');
|
|
224
|
+
}
|
|
194
225
|
|
|
195
|
-
return decrypted as
|
|
226
|
+
return decrypted as Uint8Array;
|
|
196
227
|
}
|
|
197
228
|
|
|
198
229
|
/**
|
|
@@ -382,7 +413,7 @@ export class EncryptionUtils {
|
|
|
382
413
|
* This function encrypts a message using the specified public keys.
|
|
383
414
|
*
|
|
384
415
|
* @param {string} message Message to encrypt.
|
|
385
|
-
* @param {string}
|
|
416
|
+
* @param {string} publicKeys Array of public keys to use for encryption.
|
|
386
417
|
* @returns {Promise<string>} Message encrypted.
|
|
387
418
|
*
|
|
388
419
|
* **Code example**
|
|
@@ -419,19 +450,20 @@ export class EncryptionUtils {
|
|
|
419
450
|
* ```
|
|
420
451
|
*/
|
|
421
452
|
public static async encrypt(
|
|
422
|
-
message:
|
|
453
|
+
message: MessageDataType,
|
|
423
454
|
publicKeys: string[]
|
|
424
455
|
): Promise<string> {
|
|
425
|
-
const plaintext = message;
|
|
426
|
-
|
|
427
456
|
const pgpPublicKeys = await Promise.all(
|
|
428
457
|
publicKeys.map((armoredKey) => openpgp.readKey({ armoredKey }))
|
|
429
458
|
);
|
|
430
459
|
|
|
431
|
-
const pgpMessage = await openpgp.createMessage({
|
|
460
|
+
const pgpMessage = await openpgp.createMessage({
|
|
461
|
+
binary: makeMessageDataBinary(message),
|
|
462
|
+
});
|
|
432
463
|
const encrypted = await openpgp.encrypt({
|
|
433
464
|
message: pgpMessage,
|
|
434
465
|
encryptionKeys: pgpPublicKeys,
|
|
466
|
+
format: 'armored',
|
|
435
467
|
});
|
|
436
468
|
|
|
437
469
|
return encrypted as string;
|