@human-protocol/sdk 1.1.18 → 2.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/base.d.ts +4 -13
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +3 -18
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +18 -11
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +4 -2
- package/dist/encryption.d.ts +31 -0
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +37 -0
- package/dist/error.d.ts +0 -10
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +2 -18
- package/dist/escrow.d.ts +39 -33
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +121 -137
- package/dist/graphql/queries/{staking.d.ts → operator.d.ts} +2 -1
- package/dist/graphql/queries/operator.d.ts.map +1 -0
- package/dist/graphql/queries/{staking.js → operator.js} +24 -1
- package/dist/graphql/types.d.ts +5 -6
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/interfaces.d.ts +28 -18
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +14 -14
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +30 -48
- package/dist/operator.d.ts +68 -0
- package/dist/operator.d.ts.map +1 -0
- package/dist/operator.js +153 -0
- package/dist/staking.d.ts +35 -95
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +73 -201
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +7 -6
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +0 -15
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +9 -49
- package/package.json +4 -4
- package/src/base.ts +5 -30
- package/src/constants.ts +18 -10
- package/src/decorators.ts +3 -2
- package/src/encryption.ts +40 -0
- package/src/error.ts +0 -17
- package/src/escrow.ts +169 -178
- package/src/graphql/queries/{staking.ts → operator.ts} +24 -0
- package/src/graphql/types.ts +5 -7
- package/src/index.ts +2 -0
- package/src/interfaces.ts +30 -18
- package/src/kvstore.ts +47 -59
- package/src/operator.ts +192 -0
- package/src/staking.ts +101 -213
- package/src/statistics.ts +8 -9
- package/src/types.ts +1 -3
- package/src/utils.ts +8 -58
- package/dist/graphql/queries/staking.d.ts.map +0 -1
package/dist/escrow.js
CHANGED
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.EscrowUtils = exports.EscrowClient = void 0;
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
16
17
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
17
18
|
const ethers_1 = require("ethers");
|
|
18
19
|
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
@@ -20,19 +21,19 @@ const base_1 = require("./base");
|
|
|
20
21
|
const constants_1 = require("./constants");
|
|
21
22
|
const decorators_1 = require("./decorators");
|
|
22
23
|
const error_1 = require("./error");
|
|
24
|
+
const graphql_1 = require("./graphql");
|
|
23
25
|
const types_1 = require("./types");
|
|
24
26
|
const utils_1 = require("./utils");
|
|
25
|
-
const graphql_1 = require("./graphql");
|
|
26
27
|
/**
|
|
27
28
|
* ## Introduction
|
|
28
29
|
*
|
|
29
30
|
* This client enables to perform actions on Escrow contracts and obtain information from both the contracts and subgraph.
|
|
30
31
|
*
|
|
31
|
-
* Internally, the SDK will use one network or another according to the network ID of the `
|
|
32
|
+
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
32
33
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
33
34
|
*
|
|
34
35
|
* ```ts
|
|
35
|
-
* static async build(
|
|
36
|
+
* static async build(runner: ContractRunner);
|
|
36
37
|
* ```
|
|
37
38
|
*
|
|
38
39
|
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
@@ -96,41 +97,33 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
96
97
|
/**
|
|
97
98
|
* **EscrowClient constructor**
|
|
98
99
|
*
|
|
99
|
-
* @param {
|
|
100
|
+
* @param {ContractRunner} runner The Runner object to interact with the Ethereum network
|
|
100
101
|
* @param {NetworkData} network The network information required to connect to the Escrow contract
|
|
101
|
-
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
102
102
|
*/
|
|
103
|
-
constructor(
|
|
104
|
-
super(
|
|
105
|
-
this.escrowFactoryContract = typechain_types_1.EscrowFactory__factory.connect(networkData.factoryAddress,
|
|
103
|
+
constructor(runner, networkData) {
|
|
104
|
+
super(runner, networkData);
|
|
105
|
+
this.escrowFactoryContract = typechain_types_1.EscrowFactory__factory.connect(networkData.factoryAddress, runner);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
|
-
* Creates an instance of EscrowClient from a
|
|
108
|
+
* Creates an instance of EscrowClient from a Runner.
|
|
109
109
|
*
|
|
110
|
-
* @param {
|
|
111
|
-
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
110
|
+
* @param {ContractRunner} runner The Runner object to interact with the Ethereum network
|
|
112
111
|
*
|
|
113
112
|
* @returns {Promise<EscrowClient>} An instance of EscrowClient
|
|
114
113
|
* @throws {ErrorProviderDoesNotExist} Thrown if the provider does not exist for the provided Signer
|
|
115
114
|
* @throws {ErrorUnsupportedChainID} Thrown if the network's chainId is not supported
|
|
116
115
|
*/
|
|
117
|
-
static async build(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (!signerOrProvider.provider) {
|
|
121
|
-
throw error_1.ErrorProviderDoesNotExist;
|
|
122
|
-
}
|
|
123
|
-
network = await signerOrProvider.provider.getNetwork();
|
|
116
|
+
static async build(runner) {
|
|
117
|
+
if (!runner.provider) {
|
|
118
|
+
throw error_1.ErrorProviderDoesNotExist;
|
|
124
119
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
const chainId = network.chainId;
|
|
120
|
+
const network = await runner.provider?.getNetwork();
|
|
121
|
+
const chainId = Number(network?.chainId);
|
|
129
122
|
const networkData = constants_1.NETWORKS[chainId];
|
|
130
123
|
if (!networkData) {
|
|
131
124
|
throw error_1.ErrorUnsupportedChainID;
|
|
132
125
|
}
|
|
133
|
-
return new EscrowClient(
|
|
126
|
+
return new EscrowClient(runner, networkData);
|
|
134
127
|
}
|
|
135
128
|
/**
|
|
136
129
|
* Connects to the escrow contract
|
|
@@ -139,7 +132,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
139
132
|
*/
|
|
140
133
|
getEscrowContract(escrowAddress) {
|
|
141
134
|
try {
|
|
142
|
-
return typechain_types_1.Escrow__factory.connect(escrowAddress, this.
|
|
135
|
+
return typechain_types_1.Escrow__factory.connect(escrowAddress, this.runner);
|
|
143
136
|
}
|
|
144
137
|
catch (e) {
|
|
145
138
|
return (0, utils_1.throwError)(e);
|
|
@@ -151,6 +144,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
151
144
|
* @param {string} tokenAddress Token address to use for pay outs.
|
|
152
145
|
* @param {string[]} trustedHandlers Array of addresses that can perform actions on the contract.
|
|
153
146
|
* @param {string} jobRequesterId Job Requester Id
|
|
147
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
154
148
|
* @returns {Promise<string>} Return the address of the escrow created.
|
|
155
149
|
*
|
|
156
150
|
*
|
|
@@ -175,20 +169,18 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
175
169
|
* const escrowAddress = await escrowClient.createEscrow(tokenAddress, trustedHandlers, jobRequesterId);
|
|
176
170
|
* ```
|
|
177
171
|
*/
|
|
178
|
-
async createEscrow(tokenAddress, trustedHandlers, jobRequesterId) {
|
|
179
|
-
if (!ethers_1.ethers.
|
|
172
|
+
async createEscrow(tokenAddress, trustedHandlers, jobRequesterId, txOptions = {}) {
|
|
173
|
+
if (!ethers_1.ethers.isAddress(tokenAddress)) {
|
|
180
174
|
throw error_1.ErrorInvalidTokenAddress;
|
|
181
175
|
}
|
|
182
176
|
trustedHandlers.forEach((trustedHandler) => {
|
|
183
|
-
if (!ethers_1.ethers.
|
|
177
|
+
if (!ethers_1.ethers.isAddress(trustedHandler)) {
|
|
184
178
|
throw new error_1.InvalidEthereumAddressError(trustedHandler);
|
|
185
179
|
}
|
|
186
180
|
});
|
|
187
181
|
try {
|
|
188
|
-
const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, trustedHandlers, jobRequesterId,
|
|
189
|
-
|
|
190
|
-
})).wait();
|
|
191
|
-
const event = result.events?.find(({ topics }) => topics.includes(ethers_1.ethers.utils.id('LaunchedV2(address,address,string)')))?.args;
|
|
182
|
+
const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, trustedHandlers, jobRequesterId, txOptions)).wait();
|
|
183
|
+
const event = result?.logs?.find(({ topics }) => topics.includes(ethers_1.ethers.id('LaunchedV2(address,address,string)')))?.args;
|
|
192
184
|
if (!event) {
|
|
193
185
|
throw error_1.ErrorLaunchedEventIsNotEmitted;
|
|
194
186
|
}
|
|
@@ -203,6 +195,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
203
195
|
*
|
|
204
196
|
* @param {string} escrowAddress Address of the escrow to set up.
|
|
205
197
|
* @param {IEscrowConfig} escrowConfig Escrow configuration parameters.
|
|
198
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
206
199
|
* @returns Returns void if successful. Throws error if any.
|
|
207
200
|
*
|
|
208
201
|
*
|
|
@@ -226,35 +219,35 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
226
219
|
* recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
227
220
|
* reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
228
221
|
* exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
229
|
-
* recordingOracleFee:
|
|
230
|
-
* reputationOracleFee:
|
|
231
|
-
* exchangeOracleFee:
|
|
222
|
+
* recordingOracleFee: bigint.from('10'),
|
|
223
|
+
* reputationOracleFee: bigint.from('10'),
|
|
224
|
+
* exchangeOracleFee: bigint.from('10'),
|
|
232
225
|
* manifestUrl: 'htttp://localhost/manifest.json',
|
|
233
226
|
* manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079',
|
|
234
227
|
* };
|
|
235
228
|
* await escrowClient.setup(escrowAddress, escrowConfig);
|
|
236
229
|
* ```
|
|
237
230
|
*/
|
|
238
|
-
async setup(escrowAddress, escrowConfig) {
|
|
231
|
+
async setup(escrowAddress, escrowConfig, txOptions = {}) {
|
|
239
232
|
const { recordingOracle, reputationOracle, exchangeOracle, recordingOracleFee, reputationOracleFee, exchangeOracleFee, manifestUrl, manifestHash, } = escrowConfig;
|
|
240
|
-
if (!ethers_1.ethers.
|
|
233
|
+
if (!ethers_1.ethers.isAddress(recordingOracle)) {
|
|
241
234
|
throw error_1.ErrorInvalidRecordingOracleAddressProvided;
|
|
242
235
|
}
|
|
243
|
-
if (!ethers_1.ethers.
|
|
236
|
+
if (!ethers_1.ethers.isAddress(reputationOracle)) {
|
|
244
237
|
throw error_1.ErrorInvalidReputationOracleAddressProvided;
|
|
245
238
|
}
|
|
246
|
-
if (!ethers_1.ethers.
|
|
239
|
+
if (!ethers_1.ethers.isAddress(exchangeOracle)) {
|
|
247
240
|
throw error_1.ErrorInvalidExchangeOracleAddressProvided;
|
|
248
241
|
}
|
|
249
|
-
if (!ethers_1.ethers.
|
|
242
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
250
243
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
251
244
|
}
|
|
252
|
-
if (recordingOracleFee
|
|
253
|
-
reputationOracleFee
|
|
254
|
-
exchangeOracleFee
|
|
245
|
+
if (recordingOracleFee <= 0 ||
|
|
246
|
+
reputationOracleFee <= 0 ||
|
|
247
|
+
exchangeOracleFee <= 0) {
|
|
255
248
|
throw error_1.ErrorAmountMustBeGreaterThanZero;
|
|
256
249
|
}
|
|
257
|
-
if (recordingOracleFee
|
|
250
|
+
if (recordingOracleFee + reputationOracleFee + exchangeOracleFee > 100) {
|
|
258
251
|
throw error_1.ErrorTotalFeeMustBeLessThanHundred;
|
|
259
252
|
}
|
|
260
253
|
if (!manifestUrl) {
|
|
@@ -271,9 +264,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
271
264
|
}
|
|
272
265
|
try {
|
|
273
266
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
274
|
-
await escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifestUrl, manifestHash,
|
|
275
|
-
...(await this.gasPriceOptions()),
|
|
276
|
-
});
|
|
267
|
+
await (await escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifestUrl, manifestHash, txOptions)).wait();
|
|
277
268
|
return;
|
|
278
269
|
}
|
|
279
270
|
catch (e) {
|
|
@@ -311,9 +302,9 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
311
302
|
* recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
312
303
|
* reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
313
304
|
* exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
314
|
-
* recordingOracleFee:
|
|
315
|
-
* reputationOracleFee:
|
|
316
|
-
* exchangeOracleFee:
|
|
305
|
+
* recordingOracleFee: bigint.from('10'),
|
|
306
|
+
* reputationOracleFee: bigint.from('10'),
|
|
307
|
+
* exchangeOracleFee: bigint.from('10'),
|
|
317
308
|
* manifestUrl: 'htttp://localhost/manifest.json',
|
|
318
309
|
* manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079',
|
|
319
310
|
* };
|
|
@@ -335,7 +326,8 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
335
326
|
* This function adds funds of the chosen token to the escrow.
|
|
336
327
|
*
|
|
337
328
|
* @param {string} escrowAddress Address of the escrow to fund.
|
|
338
|
-
* @param {
|
|
329
|
+
* @param {bigint} amount Amount to be added as funds.
|
|
330
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
339
331
|
* @returns Returns void if successful. Throws error if any.
|
|
340
332
|
*
|
|
341
333
|
*
|
|
@@ -352,15 +344,15 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
352
344
|
* const signer = new Wallet(privateKey, provider);
|
|
353
345
|
* const escrowClient = await EscrowClient.build(signer);
|
|
354
346
|
*
|
|
355
|
-
* const amount = ethers.
|
|
347
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
356
348
|
* await escrowClient.fund('0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
357
349
|
* ```
|
|
358
350
|
*/
|
|
359
|
-
async fund(escrowAddress, amount) {
|
|
360
|
-
if (!ethers_1.ethers.
|
|
351
|
+
async fund(escrowAddress, amount, txOptions = {}) {
|
|
352
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
361
353
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
362
354
|
}
|
|
363
|
-
if (amount
|
|
355
|
+
if (amount <= 0n) {
|
|
364
356
|
throw error_1.ErrorAmountMustBeGreaterThanZero;
|
|
365
357
|
}
|
|
366
358
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -369,10 +361,8 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
369
361
|
try {
|
|
370
362
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
371
363
|
const tokenAddress = await escrowContract.token();
|
|
372
|
-
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.
|
|
373
|
-
await tokenContract.transfer(escrowAddress, amount,
|
|
374
|
-
...(await this.gasPriceOptions()),
|
|
375
|
-
});
|
|
364
|
+
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.runner);
|
|
365
|
+
await (await tokenContract.transfer(escrowAddress, amount, txOptions)).wait;
|
|
376
366
|
return;
|
|
377
367
|
}
|
|
378
368
|
catch (e) {
|
|
@@ -385,6 +375,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
385
375
|
* @param {string} escrowAddress Address of the escrow.
|
|
386
376
|
* @param {string} url Results file url.
|
|
387
377
|
* @param {string} hash Results file hash.
|
|
378
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
388
379
|
* @returns Returns void if successful. Throws error if any.
|
|
389
380
|
*
|
|
390
381
|
*
|
|
@@ -406,8 +397,8 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
406
397
|
* await storeResults.storeResults('0x62dD51230A30401C455c8398d06F85e4EaB6309f', 'http://localhost/results.json', 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079');
|
|
407
398
|
* ```
|
|
408
399
|
*/
|
|
409
|
-
async storeResults(escrowAddress, url, hash) {
|
|
410
|
-
if (!ethers_1.ethers.
|
|
400
|
+
async storeResults(escrowAddress, url, hash, txOptions = {}) {
|
|
401
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
411
402
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
412
403
|
}
|
|
413
404
|
if (!url) {
|
|
@@ -424,9 +415,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
424
415
|
}
|
|
425
416
|
try {
|
|
426
417
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
427
|
-
await escrowContract.storeResults(url, hash,
|
|
428
|
-
...(await this.gasPriceOptions()),
|
|
429
|
-
});
|
|
418
|
+
await (await escrowContract.storeResults(url, hash, txOptions)).wait();
|
|
430
419
|
return;
|
|
431
420
|
}
|
|
432
421
|
catch (e) {
|
|
@@ -437,6 +426,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
437
426
|
* This function sets the status of an escrow to completed.
|
|
438
427
|
*
|
|
439
428
|
* @param {string} escrowAddress Address of the escrow.
|
|
429
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
440
430
|
* @returns Returns void if successful. Throws error if any.
|
|
441
431
|
*
|
|
442
432
|
*
|
|
@@ -458,8 +448,8 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
458
448
|
* await escrowClient.complete('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
459
449
|
* ```
|
|
460
450
|
*/
|
|
461
|
-
async complete(escrowAddress) {
|
|
462
|
-
if (!ethers_1.ethers.
|
|
451
|
+
async complete(escrowAddress, txOptions = {}) {
|
|
452
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
463
453
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
464
454
|
}
|
|
465
455
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -467,9 +457,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
467
457
|
}
|
|
468
458
|
try {
|
|
469
459
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
470
|
-
await escrowContract.complete(
|
|
471
|
-
...(await this.gasPriceOptions()),
|
|
472
|
-
});
|
|
460
|
+
await (await escrowContract.complete(txOptions)).wait();
|
|
473
461
|
return;
|
|
474
462
|
}
|
|
475
463
|
catch (e) {
|
|
@@ -481,9 +469,10 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
481
469
|
*
|
|
482
470
|
* @param {string} escrowAddress Escrow address to payout.
|
|
483
471
|
* @param {string[]} recipients Array of recipient addresses.
|
|
484
|
-
* @param {
|
|
472
|
+
* @param {bigint[]} amounts Array of amounts the recipients will receive.
|
|
485
473
|
* @param {string} finalResultsUrl Final results file url.
|
|
486
474
|
* @param {string} finalResultsHash Final results file hash.
|
|
475
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
487
476
|
* @returns Returns void if successful. Throws error if any.
|
|
488
477
|
*
|
|
489
478
|
*
|
|
@@ -503,15 +492,15 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
503
492
|
* const escrowClient = await EscrowClient.build(signer);
|
|
504
493
|
*
|
|
505
494
|
* const recipients = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'];
|
|
506
|
-
* const amounts = [ethers.
|
|
495
|
+
* const amounts = [ethers.parseUnits(5, 'ether'), ethers.parseUnits(10, 'ether')];
|
|
507
496
|
* const resultsUrl = 'http://localhost/results.json';
|
|
508
497
|
* const resultsHash'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079';
|
|
509
498
|
*
|
|
510
499
|
* await escrowClient.bulkPayOut('0x62dD51230A30401C455c8398d06F85e4EaB6309f', recipients, amounts, resultsUrl, resultsHash);
|
|
511
500
|
* ```
|
|
512
501
|
*/
|
|
513
|
-
async bulkPayOut(escrowAddress, recipients, amounts, finalResultsUrl, finalResultsHash) {
|
|
514
|
-
if (!ethers_1.ethers.
|
|
502
|
+
async bulkPayOut(escrowAddress, recipients, amounts, finalResultsUrl, finalResultsHash, txOptions = {}) {
|
|
503
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
515
504
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
516
505
|
}
|
|
517
506
|
if (recipients.length === 0) {
|
|
@@ -524,7 +513,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
524
513
|
throw error_1.ErrorRecipientAndAmountsMustBeSameLength;
|
|
525
514
|
}
|
|
526
515
|
recipients.forEach((recipient) => {
|
|
527
|
-
if (!ethers_1.ethers.
|
|
516
|
+
if (!ethers_1.ethers.isAddress(recipient)) {
|
|
528
517
|
throw new error_1.InvalidEthereumAddressError(recipient);
|
|
529
518
|
}
|
|
530
519
|
});
|
|
@@ -538,11 +527,11 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
538
527
|
throw error_1.ErrorHashIsEmptyString;
|
|
539
528
|
}
|
|
540
529
|
const balance = await this.getBalance(escrowAddress);
|
|
541
|
-
let totalAmount =
|
|
530
|
+
let totalAmount = 0n;
|
|
542
531
|
amounts.forEach((amount) => {
|
|
543
|
-
totalAmount = totalAmount
|
|
532
|
+
totalAmount = totalAmount + amount;
|
|
544
533
|
});
|
|
545
|
-
if (balance
|
|
534
|
+
if (balance < totalAmount) {
|
|
546
535
|
throw error_1.ErrorEscrowDoesNotHaveEnoughBalance;
|
|
547
536
|
}
|
|
548
537
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -550,9 +539,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
550
539
|
}
|
|
551
540
|
try {
|
|
552
541
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
553
|
-
await escrowContract.bulkPayOut(recipients, amounts, finalResultsUrl, finalResultsHash, constants_1.DEFAULT_TX_ID,
|
|
554
|
-
...(await this.gasPriceOptions()),
|
|
555
|
-
});
|
|
542
|
+
await (await escrowContract.bulkPayOut(recipients, amounts, finalResultsUrl, finalResultsHash, constants_1.DEFAULT_TX_ID, txOptions)).wait();
|
|
556
543
|
return;
|
|
557
544
|
}
|
|
558
545
|
catch (e) {
|
|
@@ -563,6 +550,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
563
550
|
* This function cancels the specified escrow and sends the balance to the canceler.
|
|
564
551
|
*
|
|
565
552
|
* @param {string} escrowAddress Address of the escrow to cancel.
|
|
553
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
566
554
|
* @returns {EscrowCancel} Returns the escrow cancellation data including transaction hash and refunded amount. Throws error if any.
|
|
567
555
|
*
|
|
568
556
|
*
|
|
@@ -584,8 +572,8 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
584
572
|
* await escrowClient.cancel('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
585
573
|
* ```
|
|
586
574
|
*/
|
|
587
|
-
async cancel(escrowAddress) {
|
|
588
|
-
if (!ethers_1.ethers.
|
|
575
|
+
async cancel(escrowAddress, txOptions = {}) {
|
|
576
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
589
577
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
590
578
|
}
|
|
591
579
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -593,28 +581,29 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
593
581
|
}
|
|
594
582
|
try {
|
|
595
583
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
596
|
-
const
|
|
597
|
-
...(await this.gasPriceOptions()),
|
|
598
|
-
});
|
|
599
|
-
const transactionReceipt = await tx.wait();
|
|
584
|
+
const transactionReceipt = await (await escrowContract.cancel(txOptions)).wait();
|
|
600
585
|
let amountTransferred = undefined;
|
|
601
586
|
const tokenAddress = await escrowContract.token();
|
|
602
|
-
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
587
|
+
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.runner);
|
|
588
|
+
if (transactionReceipt)
|
|
589
|
+
for (const log of transactionReceipt.logs) {
|
|
590
|
+
if (log.address === tokenAddress) {
|
|
591
|
+
const parsedLog = tokenContract.interface.parseLog({
|
|
592
|
+
topics: log.topics,
|
|
593
|
+
data: log.data,
|
|
594
|
+
});
|
|
595
|
+
const from = parsedLog?.args[0];
|
|
596
|
+
if (parsedLog?.name === 'Transfer' && from === escrowAddress) {
|
|
597
|
+
amountTransferred = parsedLog?.args[2];
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
610
600
|
}
|
|
611
601
|
}
|
|
612
|
-
}
|
|
613
602
|
if (amountTransferred === undefined) {
|
|
614
603
|
throw error_1.ErrorTransferEventNotFoundInTransactionLogs;
|
|
615
604
|
}
|
|
616
605
|
const escrowCancelData = {
|
|
617
|
-
txHash: transactionReceipt
|
|
606
|
+
txHash: transactionReceipt?.hash || '',
|
|
618
607
|
amountRefunded: amountTransferred,
|
|
619
608
|
};
|
|
620
609
|
return escrowCancelData;
|
|
@@ -627,6 +616,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
627
616
|
* This function cancels the specified escrow, sends the balance to the canceler and selfdestructs the escrow contract.
|
|
628
617
|
*
|
|
629
618
|
* @param {string} escrowAddress Address of the escrow.
|
|
619
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
630
620
|
* @returns Returns void if successful. Throws error if any.
|
|
631
621
|
*
|
|
632
622
|
*
|
|
@@ -648,8 +638,8 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
648
638
|
* await escrowClient.abort('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
649
639
|
* ```
|
|
650
640
|
*/
|
|
651
|
-
async abort(escrowAddress) {
|
|
652
|
-
if (!ethers_1.ethers.
|
|
641
|
+
async abort(escrowAddress, txOptions = {}) {
|
|
642
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
653
643
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
654
644
|
}
|
|
655
645
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -657,9 +647,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
657
647
|
}
|
|
658
648
|
try {
|
|
659
649
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
660
|
-
await escrowContract.abort(
|
|
661
|
-
...(await this.gasPriceOptions()),
|
|
662
|
-
});
|
|
650
|
+
await (await escrowContract.abort(txOptions)).wait();
|
|
663
651
|
return;
|
|
664
652
|
}
|
|
665
653
|
catch (e) {
|
|
@@ -671,6 +659,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
671
659
|
*
|
|
672
660
|
* @param {string} escrowAddress Address of the escrow.
|
|
673
661
|
* @param {string[]} trustedHandlers Array of addresses of trusted handlers to add.
|
|
662
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
674
663
|
* @returns Returns void if successful. Throws error if any.
|
|
675
664
|
*
|
|
676
665
|
*
|
|
@@ -693,15 +682,15 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
693
682
|
* await escrowClient.addTrustedHandlers('0x62dD51230A30401C455c8398d06F85e4EaB6309f', trustedHandlers);
|
|
694
683
|
* ```
|
|
695
684
|
*/
|
|
696
|
-
async addTrustedHandlers(escrowAddress, trustedHandlers) {
|
|
697
|
-
if (!ethers_1.ethers.
|
|
685
|
+
async addTrustedHandlers(escrowAddress, trustedHandlers, txOptions = {}) {
|
|
686
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
698
687
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
699
688
|
}
|
|
700
689
|
if (trustedHandlers.length === 0) {
|
|
701
690
|
throw error_1.ErrorListOfHandlersCannotBeEmpty;
|
|
702
691
|
}
|
|
703
692
|
trustedHandlers.forEach((trustedHandler) => {
|
|
704
|
-
if (!ethers_1.ethers.
|
|
693
|
+
if (!ethers_1.ethers.isAddress(trustedHandler)) {
|
|
705
694
|
throw new error_1.InvalidEthereumAddressError(trustedHandler);
|
|
706
695
|
}
|
|
707
696
|
});
|
|
@@ -710,9 +699,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
710
699
|
}
|
|
711
700
|
try {
|
|
712
701
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
713
|
-
await escrowContract.addTrustedHandlers(trustedHandlers,
|
|
714
|
-
...(await this.gasPriceOptions()),
|
|
715
|
-
});
|
|
702
|
+
await (await escrowContract.addTrustedHandlers(trustedHandlers, txOptions)).wait();
|
|
716
703
|
return;
|
|
717
704
|
}
|
|
718
705
|
catch (e) {
|
|
@@ -723,7 +710,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
723
710
|
* This function returns the balance for a specified escrow address.
|
|
724
711
|
*
|
|
725
712
|
* @param {string} escrowAddress Address of the escrow.
|
|
726
|
-
* @returns {
|
|
713
|
+
* @returns {bigint} Balance of the escrow in the token used to fund it.
|
|
727
714
|
*
|
|
728
715
|
* **Code example**
|
|
729
716
|
*
|
|
@@ -740,7 +727,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
740
727
|
* ```
|
|
741
728
|
*/
|
|
742
729
|
async getBalance(escrowAddress) {
|
|
743
|
-
if (!ethers_1.ethers.
|
|
730
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
744
731
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
745
732
|
}
|
|
746
733
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -775,7 +762,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
775
762
|
* ```
|
|
776
763
|
*/
|
|
777
764
|
async getManifestHash(escrowAddress) {
|
|
778
|
-
if (!ethers_1.ethers.
|
|
765
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
779
766
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
780
767
|
}
|
|
781
768
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -810,7 +797,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
810
797
|
* ```
|
|
811
798
|
*/
|
|
812
799
|
async getManifestUrl(escrowAddress) {
|
|
813
|
-
if (!ethers_1.ethers.
|
|
800
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
814
801
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
815
802
|
}
|
|
816
803
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -845,7 +832,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
845
832
|
* ```
|
|
846
833
|
*/
|
|
847
834
|
async getResultsUrl(escrowAddress) {
|
|
848
|
-
if (!ethers_1.ethers.
|
|
835
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
849
836
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
850
837
|
}
|
|
851
838
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -880,7 +867,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
880
867
|
* ```
|
|
881
868
|
*/
|
|
882
869
|
async getIntermediateResultsUrl(escrowAddress) {
|
|
883
|
-
if (!ethers_1.ethers.
|
|
870
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
884
871
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
885
872
|
}
|
|
886
873
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -915,7 +902,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
915
902
|
* ```
|
|
916
903
|
*/
|
|
917
904
|
async getTokenAddress(escrowAddress) {
|
|
918
|
-
if (!ethers_1.ethers.
|
|
905
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
919
906
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
920
907
|
}
|
|
921
908
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -950,7 +937,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
950
937
|
* ```
|
|
951
938
|
*/
|
|
952
939
|
async getStatus(escrowAddress) {
|
|
953
|
-
if (!ethers_1.ethers.
|
|
940
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
954
941
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
955
942
|
}
|
|
956
943
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -958,7 +945,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
958
945
|
}
|
|
959
946
|
try {
|
|
960
947
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
961
|
-
return escrowContract.status();
|
|
948
|
+
return Number(await escrowContract.status());
|
|
962
949
|
}
|
|
963
950
|
catch (e) {
|
|
964
951
|
return (0, utils_1.throwError)(e);
|
|
@@ -985,7 +972,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
985
972
|
* ```
|
|
986
973
|
*/
|
|
987
974
|
async getRecordingOracleAddress(escrowAddress) {
|
|
988
|
-
if (!ethers_1.ethers.
|
|
975
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
989
976
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
990
977
|
}
|
|
991
978
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -1020,7 +1007,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
1020
1007
|
* ```
|
|
1021
1008
|
*/
|
|
1022
1009
|
async getJobLauncherAddress(escrowAddress) {
|
|
1023
|
-
if (!ethers_1.ethers.
|
|
1010
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
1024
1011
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
1025
1012
|
}
|
|
1026
1013
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -1055,7 +1042,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
1055
1042
|
* ```
|
|
1056
1043
|
*/
|
|
1057
1044
|
async getReputationOracleAddress(escrowAddress) {
|
|
1058
|
-
if (!ethers_1.ethers.
|
|
1045
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
1059
1046
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
1060
1047
|
}
|
|
1061
1048
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -1090,7 +1077,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
1090
1077
|
* ```
|
|
1091
1078
|
*/
|
|
1092
1079
|
async getExchangeOracleAddress(escrowAddress) {
|
|
1093
|
-
if (!ethers_1.ethers.
|
|
1080
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
1094
1081
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
1095
1082
|
}
|
|
1096
1083
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -1125,7 +1112,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
1125
1112
|
* ```
|
|
1126
1113
|
*/
|
|
1127
1114
|
async getFactoryAddress(escrowAddress) {
|
|
1128
|
-
if (!ethers_1.ethers.
|
|
1115
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
1129
1116
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
1130
1117
|
}
|
|
1131
1118
|
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
@@ -1143,13 +1130,13 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
1143
1130
|
__decorate([
|
|
1144
1131
|
decorators_1.requiresSigner,
|
|
1145
1132
|
__metadata("design:type", Function),
|
|
1146
|
-
__metadata("design:paramtypes", [String, Array, String]),
|
|
1133
|
+
__metadata("design:paramtypes", [String, Array, String, Object]),
|
|
1147
1134
|
__metadata("design:returntype", Promise)
|
|
1148
1135
|
], EscrowClient.prototype, "createEscrow", null);
|
|
1149
1136
|
__decorate([
|
|
1150
1137
|
decorators_1.requiresSigner,
|
|
1151
1138
|
__metadata("design:type", Function),
|
|
1152
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
1139
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
1153
1140
|
__metadata("design:returntype", Promise)
|
|
1154
1141
|
], EscrowClient.prototype, "setup", null);
|
|
1155
1142
|
__decorate([
|
|
@@ -1161,43 +1148,43 @@ __decorate([
|
|
|
1161
1148
|
__decorate([
|
|
1162
1149
|
decorators_1.requiresSigner,
|
|
1163
1150
|
__metadata("design:type", Function),
|
|
1164
|
-
__metadata("design:paramtypes", [String,
|
|
1151
|
+
__metadata("design:paramtypes", [String, BigInt, Object]),
|
|
1165
1152
|
__metadata("design:returntype", Promise)
|
|
1166
1153
|
], EscrowClient.prototype, "fund", null);
|
|
1167
1154
|
__decorate([
|
|
1168
1155
|
decorators_1.requiresSigner,
|
|
1169
1156
|
__metadata("design:type", Function),
|
|
1170
|
-
__metadata("design:paramtypes", [String, String, String]),
|
|
1157
|
+
__metadata("design:paramtypes", [String, String, String, Object]),
|
|
1171
1158
|
__metadata("design:returntype", Promise)
|
|
1172
1159
|
], EscrowClient.prototype, "storeResults", null);
|
|
1173
1160
|
__decorate([
|
|
1174
1161
|
decorators_1.requiresSigner,
|
|
1175
1162
|
__metadata("design:type", Function),
|
|
1176
|
-
__metadata("design:paramtypes", [String]),
|
|
1163
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
1177
1164
|
__metadata("design:returntype", Promise)
|
|
1178
1165
|
], EscrowClient.prototype, "complete", null);
|
|
1179
1166
|
__decorate([
|
|
1180
1167
|
decorators_1.requiresSigner,
|
|
1181
1168
|
__metadata("design:type", Function),
|
|
1182
|
-
__metadata("design:paramtypes", [String, Array, Array, String, String]),
|
|
1169
|
+
__metadata("design:paramtypes", [String, Array, Array, String, String, Object]),
|
|
1183
1170
|
__metadata("design:returntype", Promise)
|
|
1184
1171
|
], EscrowClient.prototype, "bulkPayOut", null);
|
|
1185
1172
|
__decorate([
|
|
1186
1173
|
decorators_1.requiresSigner,
|
|
1187
1174
|
__metadata("design:type", Function),
|
|
1188
|
-
__metadata("design:paramtypes", [String]),
|
|
1175
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
1189
1176
|
__metadata("design:returntype", Promise)
|
|
1190
1177
|
], EscrowClient.prototype, "cancel", null);
|
|
1191
1178
|
__decorate([
|
|
1192
1179
|
decorators_1.requiresSigner,
|
|
1193
1180
|
__metadata("design:type", Function),
|
|
1194
|
-
__metadata("design:paramtypes", [String]),
|
|
1181
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
1195
1182
|
__metadata("design:returntype", Promise)
|
|
1196
1183
|
], EscrowClient.prototype, "abort", null);
|
|
1197
1184
|
__decorate([
|
|
1198
1185
|
decorators_1.requiresSigner,
|
|
1199
1186
|
__metadata("design:type", Function),
|
|
1200
|
-
__metadata("design:paramtypes", [String, Array]),
|
|
1187
|
+
__metadata("design:paramtypes", [String, Array, Object]),
|
|
1201
1188
|
__metadata("design:returntype", Promise)
|
|
1202
1189
|
], EscrowClient.prototype, "addTrustedHandlers", null);
|
|
1203
1190
|
exports.EscrowClient = EscrowClient;
|
|
@@ -1334,19 +1321,16 @@ class EscrowUtils {
|
|
|
1334
1321
|
if (!filter?.networks?.length) {
|
|
1335
1322
|
throw error_1.ErrorUnsupportedChainID;
|
|
1336
1323
|
}
|
|
1337
|
-
if (filter.launcher && !ethers_1.ethers.
|
|
1324
|
+
if (filter.launcher && !ethers_1.ethers.isAddress(filter.launcher)) {
|
|
1338
1325
|
throw error_1.ErrorInvalidAddress;
|
|
1339
1326
|
}
|
|
1340
|
-
if (filter.recordingOracle &&
|
|
1341
|
-
!ethers_1.ethers.utils.isAddress(filter.recordingOracle)) {
|
|
1327
|
+
if (filter.recordingOracle && !ethers_1.ethers.isAddress(filter.recordingOracle)) {
|
|
1342
1328
|
throw error_1.ErrorInvalidAddress;
|
|
1343
1329
|
}
|
|
1344
|
-
if (filter.reputationOracle &&
|
|
1345
|
-
!ethers_1.ethers.utils.isAddress(filter.reputationOracle)) {
|
|
1330
|
+
if (filter.reputationOracle && !ethers_1.ethers.isAddress(filter.reputationOracle)) {
|
|
1346
1331
|
throw error_1.ErrorInvalidAddress;
|
|
1347
1332
|
}
|
|
1348
|
-
if (filter.exchangeOracle &&
|
|
1349
|
-
!ethers_1.ethers.utils.isAddress(filter.exchangeOracle)) {
|
|
1333
|
+
if (filter.exchangeOracle && !ethers_1.ethers.isAddress(filter.exchangeOracle)) {
|
|
1350
1334
|
throw error_1.ErrorInvalidAddress;
|
|
1351
1335
|
}
|
|
1352
1336
|
try {
|
|
@@ -1451,7 +1435,7 @@ class EscrowUtils {
|
|
|
1451
1435
|
if (!networkData) {
|
|
1452
1436
|
throw error_1.ErrorUnsupportedChainID;
|
|
1453
1437
|
}
|
|
1454
|
-
if (escrowAddress && !ethers_1.ethers.
|
|
1438
|
+
if (escrowAddress && !ethers_1.ethers.isAddress(escrowAddress)) {
|
|
1455
1439
|
throw error_1.ErrorInvalidAddress;
|
|
1456
1440
|
}
|
|
1457
1441
|
try {
|