@human-protocol/sdk 5.0.0-beta.3 → 5.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.
package/dist/constants.js CHANGED
@@ -30,7 +30,7 @@ exports.NETWORKS = {
30
30
  stakingAddress: '0xEf6Da3aB52c33925Be3F84038193a7e1331F51E6',
31
31
  kvstoreAddress: '0xB6d36B1CDaD50302BCB3DB43bAb0D349458e1b8D',
32
32
  subgraphUrl: 'https://api.studio.thegraph.com/query/74256/ethereum/version/latest',
33
- subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmQwp4Rr2J4UbPFykb9eXg2t7GPcGRS6WT7QzExZtv32jK',
33
+ subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmXGmcjEtwwEgB83KE2ECjjYY38kLMqzaq4ip8GWY7A6zz',
34
34
  oldSubgraphUrl: '',
35
35
  oldFactoryAddress: '',
36
36
  },
@@ -43,7 +43,7 @@ exports.NETWORKS = {
43
43
  stakingAddress: '0x2163e3A40032Af1C359ac731deaB48258b317890',
44
44
  kvstoreAddress: '0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60',
45
45
  subgraphUrl: 'https://api.studio.thegraph.com/query/74256/sepolia/version/latest',
46
- subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmaDx3yapopC5xbXqqpkuZ5yLNPjs35wui9kyLS2oX55uE',
46
+ subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmT4xNvZh8ymarrk1zdytjLhCW59iuTavsd4JgHS4LbCVB',
47
47
  oldSubgraphUrl: '',
48
48
  oldFactoryAddress: '',
49
49
  },
@@ -56,7 +56,7 @@ exports.NETWORKS = {
56
56
  stakingAddress: '0xE24e5C08E28331D24758b69A5E9f383D2bDD1c98',
57
57
  kvstoreAddress: '0x21A0C4CED7aE447fCf87D9FE3A29FA9B3AB20Ff1',
58
58
  subgraphUrl: 'https://api.studio.thegraph.com/query/74256/bsc/version/latest',
59
- subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmT2VoBLjAfc4pQzDmeCGra6weoLuk2jPRgnRz5iSMUw1t',
59
+ subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmdVdpm9NnFz5B8QyzhW1bW1nNfRWemTiFn2MrhYZGTSQD',
60
60
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
61
61
  oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
62
62
  },
@@ -69,7 +69,7 @@ exports.NETWORKS = {
69
69
  stakingAddress: '0xD6D347ba6987519B4e42EcED43dF98eFf5465a23',
70
70
  kvstoreAddress: '0x32e27177BA6Ea91cf28dfd91a0Da9822A4b74EcF',
71
71
  subgraphUrl: 'https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest',
72
- subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/Qmezp2vvVWXasTeyBmLHUaMA8WyX253r7RXcs1M4Zw2hN8',
72
+ subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmZjYMktZe8RAz7W7qL33VZBV6AC57xsLyE1cEfv6NABdZ',
73
73
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
74
74
  oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
75
75
  },
@@ -82,7 +82,7 @@ exports.NETWORKS = {
82
82
  stakingAddress: '0x01D115E9E8bF0C58318793624CC662a030D07F1D',
83
83
  kvstoreAddress: '0xbcB28672F826a50B03EE91B28145EAbddA73B2eD',
84
84
  subgraphUrl: 'https://api.studio.thegraph.com/query/74256/polygon/version/latest',
85
- subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmT72ecfx6Zaje21kLNi17kDJTpPKFYvzQETDyLpQgDrPu',
85
+ subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmUt9mmfNjtC5ZnQNiWHRbFG3k5zfngMuoTyky9jhXYqG2',
86
86
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
87
87
  oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
88
88
  },
@@ -95,7 +95,7 @@ exports.NETWORKS = {
95
95
  stakingAddress: '0xffE496683F842a923110415b7278ded3F265f2C5',
96
96
  kvstoreAddress: '0x724AeFC243EdacCA27EAB86D3ec5a76Af4436Fc7',
97
97
  subgraphUrl: 'https://api.studio.thegraph.com/query/74256/amoy/version/latest',
98
- subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmZq6nAyJZgTqCEChm95xqntPpHJ7mnMBi9iDPDAQSyxZa',
98
+ subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmWRUFWpWoRRUh7Ec1HUJEwxc84DkP4iFTfLLsoVngJAPa',
99
99
  oldSubgraphUrl: '',
100
100
  oldFactoryAddress: '',
101
101
  },
package/dist/escrow.d.ts CHANGED
@@ -100,8 +100,8 @@ export declare class EscrowClient extends BaseEthersClient {
100
100
  /**
101
101
  * This function creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
102
102
  *
103
- * @param {string} tokenAddress Token address to use for payouts.
104
- * @param {string} jobRequesterId Job Requester Id
103
+ * @param {string} tokenAddress - The address of the token to use for escrow funding.
104
+ * @param {string} jobRequesterId - Identifier for the job requester.
105
105
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
106
106
  * @returns {Promise<string>} Returns the address of the escrow created.
107
107
  *
@@ -127,6 +127,65 @@ export declare class EscrowClient extends BaseEthersClient {
127
127
  * ```
128
128
  */
129
129
  createEscrow(tokenAddress: string, jobRequesterId: string, txOptions?: Overrides): Promise<string>;
130
+ private verifySetupParameters;
131
+ /**
132
+ * Creates, funds, and sets up a new escrow contract in a single transaction.
133
+ *
134
+ * @param {string} tokenAddress - The ERC-20 token address used to fund the escrow.
135
+ * @param {bigint} amount - The token amount to fund the escrow with.
136
+ * @param {string} jobRequesterId - An off-chain identifier for the job requester.
137
+ * @param {IEscrowConfig} escrowConfig - Configuration parameters for escrow setup:
138
+ * - `recordingOracle`: Address of the recording oracle.
139
+ * - `reputationOracle`: Address of the reputation oracle.
140
+ * - `exchangeOracle`: Address of the exchange oracle.
141
+ * - `recordingOracleFee`: Fee (in basis points or percentage * 100) for the recording oracle.
142
+ * - `reputationOracleFee`: Fee for the reputation oracle.
143
+ * - `exchangeOracleFee`: Fee for the exchange oracle.
144
+ * - `manifest`: URL to the manifest file.
145
+ * - `manifestHash`: Hash of the manifest content.
146
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
147
+ *
148
+ * @returns {Promise<string>} Returns the address of the escrow created.
149
+ *
150
+ * @example
151
+ * import { Wallet, ethers } from 'ethers';
152
+ * import { EscrowClient, IERC20__factory } from '@human-protocol/sdk';
153
+ *
154
+ * const rpcUrl = 'YOUR_RPC_URL';
155
+ * const privateKey = 'YOUR_PRIVATE_KEY';
156
+ * const provider = new ethers.JsonRpcProvider(rpcUrl);
157
+ * const signer = new Wallet(privateKey, provider);
158
+ *
159
+ * const escrowClient = await EscrowClient.build(signer);
160
+ *
161
+ * const tokenAddress = '0xTokenAddress';
162
+ * const amount = ethers.parseUnits('1000', 18);
163
+ * const jobRequesterId = 'requester-123';
164
+ *
165
+ * const token = IERC20__factory.connect(tokenAddress, signer);
166
+ * await token.approve(escrowClient.escrowFactoryContract.target, amount);
167
+ *
168
+ * const escrowConfig = {
169
+ * recordingOracle: '0xRecordingOracle',
170
+ * reputationOracle: '0xReputationOracle',
171
+ * exchangeOracle: '0xExchangeOracle',
172
+ * recordingOracleFee: 5n,
173
+ * reputationOracleFee: 5n,
174
+ * exchangeOracleFee: 5n,
175
+ * manifest: 'https://example.com/manifest.json',
176
+ * manifestHash: 'manifestHash-123',
177
+ * } satisfies IEscrowConfig;
178
+ *
179
+ * const escrowAddress = await escrowClient.createFundAndSetupEscrow(
180
+ * tokenAddress,
181
+ * amount,
182
+ * jobRequesterId,
183
+ * escrowConfig
184
+ * );
185
+ *
186
+ * console.log('Escrow created at:', escrowAddress);
187
+ */
188
+ createFundAndSetupEscrow(tokenAddress: string, amount: bigint, jobRequesterId: string, escrowConfig: IEscrowConfig, txOptions?: Overrides): Promise<string>;
130
189
  /**
131
190
  * This function sets up the parameters of the escrow.
132
191
  *
@@ -1 +1 @@
1
- {"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAY,SAAS,EAAkB,MAAM,QAAQ,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAwClD,OAAO,EACL,OAAO,EACP,aAAa,EACb,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAS9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,OA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E,aAAa,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA2CzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;WACiB,sBAAsB,CAAC,MAAM,EAAE;QACjD,OAAO,EAAE,OAAO,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,IAAI,CAAC;QACZ,EAAE,CAAC,EAAE,IAAI,CAAC;QACV,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,cAAc,CAAC;KACjC,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IA0ClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;WACiB,qBAAqB,CACvC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;CA8BvC"}
package/dist/escrow.js CHANGED
@@ -142,8 +142,8 @@ class EscrowClient extends base_1.BaseEthersClient {
142
142
  /**
143
143
  * This function creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
144
144
  *
145
- * @param {string} tokenAddress Token address to use for payouts.
146
- * @param {string} jobRequesterId Job Requester Id
145
+ * @param {string} tokenAddress - The address of the token to use for escrow funding.
146
+ * @param {string} jobRequesterId - Identifier for the job requester.
147
147
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
148
148
  * @returns {Promise<string>} Returns the address of the escrow created.
149
149
  *
@@ -184,6 +184,108 @@ class EscrowClient extends base_1.BaseEthersClient {
184
184
  return (0, utils_1.throwError)(e);
185
185
  }
186
186
  }
187
+ verifySetupParameters(escrowConfig) {
188
+ const { recordingOracle, reputationOracle, exchangeOracle, recordingOracleFee, reputationOracleFee, exchangeOracleFee, manifest, manifestHash, } = escrowConfig;
189
+ if (!ethers_1.ethers.isAddress(recordingOracle)) {
190
+ throw error_1.ErrorInvalidRecordingOracleAddressProvided;
191
+ }
192
+ if (!ethers_1.ethers.isAddress(reputationOracle)) {
193
+ throw error_1.ErrorInvalidReputationOracleAddressProvided;
194
+ }
195
+ if (!ethers_1.ethers.isAddress(exchangeOracle)) {
196
+ throw error_1.ErrorInvalidExchangeOracleAddressProvided;
197
+ }
198
+ if (recordingOracleFee <= 0 ||
199
+ reputationOracleFee <= 0 ||
200
+ exchangeOracleFee <= 0) {
201
+ throw error_1.ErrorAmountMustBeGreaterThanZero;
202
+ }
203
+ if (recordingOracleFee + reputationOracleFee + exchangeOracleFee > 100) {
204
+ throw error_1.ErrorTotalFeeMustBeLessThanHundred;
205
+ }
206
+ const isManifestValid = (0, utils_1.isValidUrl)(manifest) || (0, utils_1.isValidJson)(manifest);
207
+ if (!isManifestValid) {
208
+ throw error_1.ErrorInvalidManifest;
209
+ }
210
+ if (!manifestHash) {
211
+ throw error_1.ErrorHashIsEmptyString;
212
+ }
213
+ }
214
+ /**
215
+ * Creates, funds, and sets up a new escrow contract in a single transaction.
216
+ *
217
+ * @param {string} tokenAddress - The ERC-20 token address used to fund the escrow.
218
+ * @param {bigint} amount - The token amount to fund the escrow with.
219
+ * @param {string} jobRequesterId - An off-chain identifier for the job requester.
220
+ * @param {IEscrowConfig} escrowConfig - Configuration parameters for escrow setup:
221
+ * - `recordingOracle`: Address of the recording oracle.
222
+ * - `reputationOracle`: Address of the reputation oracle.
223
+ * - `exchangeOracle`: Address of the exchange oracle.
224
+ * - `recordingOracleFee`: Fee (in basis points or percentage * 100) for the recording oracle.
225
+ * - `reputationOracleFee`: Fee for the reputation oracle.
226
+ * - `exchangeOracleFee`: Fee for the exchange oracle.
227
+ * - `manifest`: URL to the manifest file.
228
+ * - `manifestHash`: Hash of the manifest content.
229
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
230
+ *
231
+ * @returns {Promise<string>} Returns the address of the escrow created.
232
+ *
233
+ * @example
234
+ * import { Wallet, ethers } from 'ethers';
235
+ * import { EscrowClient, IERC20__factory } from '@human-protocol/sdk';
236
+ *
237
+ * const rpcUrl = 'YOUR_RPC_URL';
238
+ * const privateKey = 'YOUR_PRIVATE_KEY';
239
+ * const provider = new ethers.JsonRpcProvider(rpcUrl);
240
+ * const signer = new Wallet(privateKey, provider);
241
+ *
242
+ * const escrowClient = await EscrowClient.build(signer);
243
+ *
244
+ * const tokenAddress = '0xTokenAddress';
245
+ * const amount = ethers.parseUnits('1000', 18);
246
+ * const jobRequesterId = 'requester-123';
247
+ *
248
+ * const token = IERC20__factory.connect(tokenAddress, signer);
249
+ * await token.approve(escrowClient.escrowFactoryContract.target, amount);
250
+ *
251
+ * const escrowConfig = {
252
+ * recordingOracle: '0xRecordingOracle',
253
+ * reputationOracle: '0xReputationOracle',
254
+ * exchangeOracle: '0xExchangeOracle',
255
+ * recordingOracleFee: 5n,
256
+ * reputationOracleFee: 5n,
257
+ * exchangeOracleFee: 5n,
258
+ * manifest: 'https://example.com/manifest.json',
259
+ * manifestHash: 'manifestHash-123',
260
+ * } satisfies IEscrowConfig;
261
+ *
262
+ * const escrowAddress = await escrowClient.createFundAndSetupEscrow(
263
+ * tokenAddress,
264
+ * amount,
265
+ * jobRequesterId,
266
+ * escrowConfig
267
+ * );
268
+ *
269
+ * console.log('Escrow created at:', escrowAddress);
270
+ */
271
+ async createFundAndSetupEscrow(tokenAddress, amount, jobRequesterId, escrowConfig, txOptions = {}) {
272
+ if (!ethers_1.ethers.isAddress(tokenAddress)) {
273
+ throw error_1.ErrorInvalidTokenAddress;
274
+ }
275
+ this.verifySetupParameters(escrowConfig);
276
+ const { recordingOracle, reputationOracle, exchangeOracle, recordingOracleFee, reputationOracleFee, exchangeOracleFee, manifest, manifestHash, } = escrowConfig;
277
+ try {
278
+ const result = await (await this.escrowFactoryContract.createFundAndSetupEscrow(tokenAddress, amount, jobRequesterId, reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash, this.applyTxDefaults(txOptions))).wait();
279
+ const event = result?.logs?.find(({ topics }) => topics.includes(ethers_1.ethers.id('LaunchedV2(address,address,string)')))?.args;
280
+ if (!event) {
281
+ throw error_1.ErrorLaunchedEventIsNotEmitted;
282
+ }
283
+ return event.escrow;
284
+ }
285
+ catch (e) {
286
+ return (0, utils_1.throwError)(e);
287
+ }
288
+ }
187
289
  /**
188
290
  * This function sets up the parameters of the escrow.
189
291
  *
@@ -224,33 +326,10 @@ class EscrowClient extends base_1.BaseEthersClient {
224
326
  */
225
327
  async setup(escrowAddress, escrowConfig, txOptions = {}) {
226
328
  const { recordingOracle, reputationOracle, exchangeOracle, recordingOracleFee, reputationOracleFee, exchangeOracleFee, manifest, manifestHash, } = escrowConfig;
227
- if (!ethers_1.ethers.isAddress(recordingOracle)) {
228
- throw error_1.ErrorInvalidRecordingOracleAddressProvided;
229
- }
230
- if (!ethers_1.ethers.isAddress(reputationOracle)) {
231
- throw error_1.ErrorInvalidReputationOracleAddressProvided;
232
- }
233
- if (!ethers_1.ethers.isAddress(exchangeOracle)) {
234
- throw error_1.ErrorInvalidExchangeOracleAddressProvided;
235
- }
329
+ this.verifySetupParameters(escrowConfig);
236
330
  if (!ethers_1.ethers.isAddress(escrowAddress)) {
237
331
  throw error_1.ErrorInvalidEscrowAddressProvided;
238
332
  }
239
- if (recordingOracleFee <= 0 ||
240
- reputationOracleFee <= 0 ||
241
- exchangeOracleFee <= 0) {
242
- throw error_1.ErrorAmountMustBeGreaterThanZero;
243
- }
244
- if (recordingOracleFee + reputationOracleFee + exchangeOracleFee > 100) {
245
- throw error_1.ErrorTotalFeeMustBeLessThanHundred;
246
- }
247
- const isManifestValid = (0, utils_1.isValidUrl)(manifest) || (0, utils_1.isValidJson)(manifest);
248
- if (!isManifestValid) {
249
- throw error_1.ErrorInvalidManifest;
250
- }
251
- if (!manifestHash) {
252
- throw error_1.ErrorHashIsEmptyString;
253
- }
254
333
  if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
255
334
  throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
256
335
  }
@@ -1184,6 +1263,12 @@ __decorate([
1184
1263
  __metadata("design:paramtypes", [String, String, Object]),
1185
1264
  __metadata("design:returntype", Promise)
1186
1265
  ], EscrowClient.prototype, "createEscrow", null);
1266
+ __decorate([
1267
+ decorators_1.requiresSigner,
1268
+ __metadata("design:type", Function),
1269
+ __metadata("design:paramtypes", [String, BigInt, String, Object, Object]),
1270
+ __metadata("design:returntype", Promise)
1271
+ ], EscrowClient.prototype, "createFundAndSetupEscrow", null);
1187
1272
  __decorate([
1188
1273
  decorators_1.requiresSigner,
1189
1274
  __metadata("design:type", Function),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@human-protocol/sdk",
3
3
  "description": "Human Protocol SDK",
4
- "version": "5.0.0-beta.3",
4
+ "version": "5.0.0",
5
5
  "files": [
6
6
  "src",
7
7
  "dist"
@@ -38,7 +38,7 @@
38
38
  ]
39
39
  },
40
40
  "dependencies": {
41
- "@human-protocol/core": "5.0.0-beta.2",
41
+ "@human-protocol/core": "5.0.0",
42
42
  "axios": "^1.4.0",
43
43
  "ethers": "~6.15.0",
44
44
  "graphql": "^16.8.1",
package/src/constants.ts CHANGED
@@ -39,7 +39,7 @@ export const NETWORKS: {
39
39
  subgraphUrl:
40
40
  'https://api.studio.thegraph.com/query/74256/ethereum/version/latest',
41
41
  subgraphUrlApiKey:
42
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmQwp4Rr2J4UbPFykb9eXg2t7GPcGRS6WT7QzExZtv32jK',
42
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmXGmcjEtwwEgB83KE2ECjjYY38kLMqzaq4ip8GWY7A6zz',
43
43
  oldSubgraphUrl: '',
44
44
  oldFactoryAddress: '',
45
45
  },
@@ -54,7 +54,7 @@ export const NETWORKS: {
54
54
  subgraphUrl:
55
55
  'https://api.studio.thegraph.com/query/74256/sepolia/version/latest',
56
56
  subgraphUrlApiKey:
57
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmaDx3yapopC5xbXqqpkuZ5yLNPjs35wui9kyLS2oX55uE',
57
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmT4xNvZh8ymarrk1zdytjLhCW59iuTavsd4JgHS4LbCVB',
58
58
  oldSubgraphUrl: '',
59
59
  oldFactoryAddress: '',
60
60
  },
@@ -69,7 +69,7 @@ export const NETWORKS: {
69
69
  subgraphUrl:
70
70
  'https://api.studio.thegraph.com/query/74256/bsc/version/latest',
71
71
  subgraphUrlApiKey:
72
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmT2VoBLjAfc4pQzDmeCGra6weoLuk2jPRgnRz5iSMUw1t',
72
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmdVdpm9NnFz5B8QyzhW1bW1nNfRWemTiFn2MrhYZGTSQD',
73
73
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
74
74
  oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
75
75
  },
@@ -84,7 +84,7 @@ export const NETWORKS: {
84
84
  subgraphUrl:
85
85
  'https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest',
86
86
  subgraphUrlApiKey:
87
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/Qmezp2vvVWXasTeyBmLHUaMA8WyX253r7RXcs1M4Zw2hN8',
87
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmZjYMktZe8RAz7W7qL33VZBV6AC57xsLyE1cEfv6NABdZ',
88
88
  oldSubgraphUrl:
89
89
  'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
90
90
  oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
@@ -100,7 +100,7 @@ export const NETWORKS: {
100
100
  subgraphUrl:
101
101
  'https://api.studio.thegraph.com/query/74256/polygon/version/latest',
102
102
  subgraphUrlApiKey:
103
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmT72ecfx6Zaje21kLNi17kDJTpPKFYvzQETDyLpQgDrPu',
103
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmUt9mmfNjtC5ZnQNiWHRbFG3k5zfngMuoTyky9jhXYqG2',
104
104
  oldSubgraphUrl:
105
105
  'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
106
106
  oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
@@ -116,7 +116,7 @@ export const NETWORKS: {
116
116
  subgraphUrl:
117
117
  'https://api.studio.thegraph.com/query/74256/amoy/version/latest',
118
118
  subgraphUrlApiKey:
119
- 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmZq6nAyJZgTqCEChm95xqntPpHJ7mnMBi9iDPDAQSyxZa',
119
+ 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmWRUFWpWoRRUh7Ec1HUJEwxc84DkP4iFTfLLsoVngJAPa',
120
120
  oldSubgraphUrl: '',
121
121
  oldFactoryAddress: '',
122
122
  },
package/src/escrow.ts CHANGED
@@ -203,8 +203,8 @@ export class EscrowClient extends BaseEthersClient {
203
203
  /**
204
204
  * This function creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
205
205
  *
206
- * @param {string} tokenAddress Token address to use for payouts.
207
- * @param {string} jobRequesterId Job Requester Id
206
+ * @param {string} tokenAddress - The address of the token to use for escrow funding.
207
+ * @param {string} jobRequesterId - Identifier for the job requester.
208
208
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
209
209
  * @returns {Promise<string>} Returns the address of the escrow created.
210
210
  *
@@ -263,6 +263,167 @@ export class EscrowClient extends BaseEthersClient {
263
263
  return throwError(e);
264
264
  }
265
265
  }
266
+ private verifySetupParameters(escrowConfig: IEscrowConfig) {
267
+ const {
268
+ recordingOracle,
269
+ reputationOracle,
270
+ exchangeOracle,
271
+ recordingOracleFee,
272
+ reputationOracleFee,
273
+ exchangeOracleFee,
274
+ manifest,
275
+ manifestHash,
276
+ } = escrowConfig;
277
+
278
+ if (!ethers.isAddress(recordingOracle)) {
279
+ throw ErrorInvalidRecordingOracleAddressProvided;
280
+ }
281
+
282
+ if (!ethers.isAddress(reputationOracle)) {
283
+ throw ErrorInvalidReputationOracleAddressProvided;
284
+ }
285
+
286
+ if (!ethers.isAddress(exchangeOracle)) {
287
+ throw ErrorInvalidExchangeOracleAddressProvided;
288
+ }
289
+
290
+ if (
291
+ recordingOracleFee <= 0 ||
292
+ reputationOracleFee <= 0 ||
293
+ exchangeOracleFee <= 0
294
+ ) {
295
+ throw ErrorAmountMustBeGreaterThanZero;
296
+ }
297
+
298
+ if (recordingOracleFee + reputationOracleFee + exchangeOracleFee > 100) {
299
+ throw ErrorTotalFeeMustBeLessThanHundred;
300
+ }
301
+
302
+ const isManifestValid = isValidUrl(manifest) || isValidJson(manifest);
303
+ if (!isManifestValid) {
304
+ throw ErrorInvalidManifest;
305
+ }
306
+
307
+ if (!manifestHash) {
308
+ throw ErrorHashIsEmptyString;
309
+ }
310
+ }
311
+
312
+ /**
313
+ * Creates, funds, and sets up a new escrow contract in a single transaction.
314
+ *
315
+ * @param {string} tokenAddress - The ERC-20 token address used to fund the escrow.
316
+ * @param {bigint} amount - The token amount to fund the escrow with.
317
+ * @param {string} jobRequesterId - An off-chain identifier for the job requester.
318
+ * @param {IEscrowConfig} escrowConfig - Configuration parameters for escrow setup:
319
+ * - `recordingOracle`: Address of the recording oracle.
320
+ * - `reputationOracle`: Address of the reputation oracle.
321
+ * - `exchangeOracle`: Address of the exchange oracle.
322
+ * - `recordingOracleFee`: Fee (in basis points or percentage * 100) for the recording oracle.
323
+ * - `reputationOracleFee`: Fee for the reputation oracle.
324
+ * - `exchangeOracleFee`: Fee for the exchange oracle.
325
+ * - `manifest`: URL to the manifest file.
326
+ * - `manifestHash`: Hash of the manifest content.
327
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
328
+ *
329
+ * @returns {Promise<string>} Returns the address of the escrow created.
330
+ *
331
+ * @example
332
+ * import { Wallet, ethers } from 'ethers';
333
+ * import { EscrowClient, IERC20__factory } from '@human-protocol/sdk';
334
+ *
335
+ * const rpcUrl = 'YOUR_RPC_URL';
336
+ * const privateKey = 'YOUR_PRIVATE_KEY';
337
+ * const provider = new ethers.JsonRpcProvider(rpcUrl);
338
+ * const signer = new Wallet(privateKey, provider);
339
+ *
340
+ * const escrowClient = await EscrowClient.build(signer);
341
+ *
342
+ * const tokenAddress = '0xTokenAddress';
343
+ * const amount = ethers.parseUnits('1000', 18);
344
+ * const jobRequesterId = 'requester-123';
345
+ *
346
+ * const token = IERC20__factory.connect(tokenAddress, signer);
347
+ * await token.approve(escrowClient.escrowFactoryContract.target, amount);
348
+ *
349
+ * const escrowConfig = {
350
+ * recordingOracle: '0xRecordingOracle',
351
+ * reputationOracle: '0xReputationOracle',
352
+ * exchangeOracle: '0xExchangeOracle',
353
+ * recordingOracleFee: 5n,
354
+ * reputationOracleFee: 5n,
355
+ * exchangeOracleFee: 5n,
356
+ * manifest: 'https://example.com/manifest.json',
357
+ * manifestHash: 'manifestHash-123',
358
+ * } satisfies IEscrowConfig;
359
+ *
360
+ * const escrowAddress = await escrowClient.createFundAndSetupEscrow(
361
+ * tokenAddress,
362
+ * amount,
363
+ * jobRequesterId,
364
+ * escrowConfig
365
+ * );
366
+ *
367
+ * console.log('Escrow created at:', escrowAddress);
368
+ */
369
+ @requiresSigner
370
+ public async createFundAndSetupEscrow(
371
+ tokenAddress: string,
372
+ amount: bigint,
373
+ jobRequesterId: string,
374
+ escrowConfig: IEscrowConfig,
375
+ txOptions: Overrides = {}
376
+ ): Promise<string> {
377
+ if (!ethers.isAddress(tokenAddress)) {
378
+ throw ErrorInvalidTokenAddress;
379
+ }
380
+
381
+ this.verifySetupParameters(escrowConfig);
382
+
383
+ const {
384
+ recordingOracle,
385
+ reputationOracle,
386
+ exchangeOracle,
387
+ recordingOracleFee,
388
+ reputationOracleFee,
389
+ exchangeOracleFee,
390
+ manifest,
391
+ manifestHash,
392
+ } = escrowConfig;
393
+
394
+ try {
395
+ const result = await (
396
+ await this.escrowFactoryContract.createFundAndSetupEscrow(
397
+ tokenAddress,
398
+ amount,
399
+ jobRequesterId,
400
+ reputationOracle,
401
+ recordingOracle,
402
+ exchangeOracle,
403
+ reputationOracleFee,
404
+ recordingOracleFee,
405
+ exchangeOracleFee,
406
+ manifest,
407
+ manifestHash,
408
+ this.applyTxDefaults(txOptions)
409
+ )
410
+ ).wait();
411
+
412
+ const event = (
413
+ result?.logs?.find(({ topics }) =>
414
+ topics.includes(ethers.id('LaunchedV2(address,address,string)'))
415
+ ) as EventLog
416
+ )?.args;
417
+
418
+ if (!event) {
419
+ throw ErrorLaunchedEventIsNotEmitted;
420
+ }
421
+
422
+ return event.escrow;
423
+ } catch (e: any) {
424
+ return throwError(e);
425
+ }
426
+ }
266
427
 
267
428
  /**
268
429
  * This function sets up the parameters of the escrow.
@@ -319,43 +480,12 @@ export class EscrowClient extends BaseEthersClient {
319
480
  manifestHash,
320
481
  } = escrowConfig;
321
482
 
322
- if (!ethers.isAddress(recordingOracle)) {
323
- throw ErrorInvalidRecordingOracleAddressProvided;
324
- }
325
-
326
- if (!ethers.isAddress(reputationOracle)) {
327
- throw ErrorInvalidReputationOracleAddressProvided;
328
- }
329
-
330
- if (!ethers.isAddress(exchangeOracle)) {
331
- throw ErrorInvalidExchangeOracleAddressProvided;
332
- }
483
+ this.verifySetupParameters(escrowConfig);
333
484
 
334
485
  if (!ethers.isAddress(escrowAddress)) {
335
486
  throw ErrorInvalidEscrowAddressProvided;
336
487
  }
337
488
 
338
- if (
339
- recordingOracleFee <= 0 ||
340
- reputationOracleFee <= 0 ||
341
- exchangeOracleFee <= 0
342
- ) {
343
- throw ErrorAmountMustBeGreaterThanZero;
344
- }
345
-
346
- if (recordingOracleFee + reputationOracleFee + exchangeOracleFee > 100) {
347
- throw ErrorTotalFeeMustBeLessThanHundred;
348
- }
349
-
350
- const isManifestValid = isValidUrl(manifest) || isValidJson(manifest);
351
- if (!isManifestValid) {
352
- throw ErrorInvalidManifest;
353
- }
354
-
355
- if (!manifestHash) {
356
- throw ErrorHashIsEmptyString;
357
- }
358
-
359
489
  if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
360
490
  throw ErrorEscrowAddressIsNotProvidedByFactory;
361
491
  }