@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/src/escrow.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { Provider } from '@ethersproject/abstract-provider';
|
|
3
|
-
import { Network } from '@ethersproject/networks';
|
|
4
2
|
import {
|
|
5
3
|
Escrow,
|
|
6
4
|
EscrowFactory,
|
|
@@ -9,7 +7,7 @@ import {
|
|
|
9
7
|
HMToken,
|
|
10
8
|
HMToken__factory,
|
|
11
9
|
} from '@human-protocol/core/typechain-types';
|
|
12
|
-
import {
|
|
10
|
+
import { ContractRunner, EventLog, Overrides, ethers } from 'ethers';
|
|
13
11
|
import gqlFetch from 'graphql-request';
|
|
14
12
|
import { BaseEthersClient } from './base';
|
|
15
13
|
import { DEFAULT_TX_ID, NETWORKS } from './constants';
|
|
@@ -21,43 +19,43 @@ import {
|
|
|
21
19
|
ErrorEscrowAddressIsNotProvidedByFactory,
|
|
22
20
|
ErrorEscrowDoesNotHaveEnoughBalance,
|
|
23
21
|
ErrorHashIsEmptyString,
|
|
24
|
-
ErrorProviderDoesNotExist,
|
|
25
|
-
ErrorUnsupportedChainID,
|
|
26
22
|
ErrorInvalidAddress,
|
|
27
23
|
ErrorInvalidEscrowAddressProvided,
|
|
24
|
+
ErrorInvalidExchangeOracleAddressProvided,
|
|
28
25
|
ErrorInvalidRecordingOracleAddressProvided,
|
|
29
26
|
ErrorInvalidReputationOracleAddressProvided,
|
|
30
27
|
ErrorInvalidTokenAddress,
|
|
31
28
|
ErrorInvalidUrl,
|
|
32
29
|
ErrorLaunchedEventIsNotEmitted,
|
|
33
30
|
ErrorListOfHandlersCannotBeEmpty,
|
|
31
|
+
ErrorProviderDoesNotExist,
|
|
34
32
|
ErrorRecipientAndAmountsMustBeSameLength,
|
|
35
33
|
ErrorRecipientCannotBeEmptyArray,
|
|
36
34
|
ErrorTotalFeeMustBeLessThanHundred,
|
|
35
|
+
ErrorTransferEventNotFoundInTransactionLogs,
|
|
36
|
+
ErrorUnsupportedChainID,
|
|
37
37
|
ErrorUrlIsEmptyString,
|
|
38
38
|
InvalidEthereumAddressError,
|
|
39
|
-
ErrorInvalidExchangeOracleAddressProvided,
|
|
40
|
-
ErrorTransferEventNotFoundInTransactionLogs,
|
|
41
39
|
} from './error';
|
|
42
|
-
import { IEscrowConfig, IEscrowsFilter } from './interfaces';
|
|
43
|
-
import { EscrowCancel, EscrowStatus, NetworkData } from './types';
|
|
44
|
-
import { isValidUrl, throwError } from './utils';
|
|
45
40
|
import {
|
|
46
41
|
EscrowData,
|
|
47
42
|
GET_ESCROWS_QUERY,
|
|
48
43
|
GET_ESCROW_BY_ADDRESS_QUERY,
|
|
49
44
|
} from './graphql';
|
|
45
|
+
import { IEscrowConfig, IEscrowsFilter } from './interfaces';
|
|
46
|
+
import { EscrowCancel, EscrowStatus, NetworkData } from './types';
|
|
47
|
+
import { isValidUrl, throwError } from './utils';
|
|
50
48
|
|
|
51
49
|
/**
|
|
52
50
|
* ## Introduction
|
|
53
51
|
*
|
|
54
52
|
* This client enables to perform actions on Escrow contracts and obtain information from both the contracts and subgraph.
|
|
55
53
|
*
|
|
56
|
-
* Internally, the SDK will use one network or another according to the network ID of the `
|
|
54
|
+
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
57
55
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
58
56
|
*
|
|
59
57
|
* ```ts
|
|
60
|
-
* static async build(
|
|
58
|
+
* static async build(runner: ContractRunner);
|
|
61
59
|
* ```
|
|
62
60
|
*
|
|
63
61
|
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
@@ -123,56 +121,42 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
123
121
|
/**
|
|
124
122
|
* **EscrowClient constructor**
|
|
125
123
|
*
|
|
126
|
-
* @param {
|
|
124
|
+
* @param {ContractRunner} runner The Runner object to interact with the Ethereum network
|
|
127
125
|
* @param {NetworkData} network The network information required to connect to the Escrow contract
|
|
128
|
-
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
129
126
|
*/
|
|
130
|
-
constructor(
|
|
131
|
-
|
|
132
|
-
networkData: NetworkData,
|
|
133
|
-
gasPriceMultiplier?: number
|
|
134
|
-
) {
|
|
135
|
-
super(signerOrProvider, networkData, gasPriceMultiplier);
|
|
127
|
+
constructor(runner: ContractRunner, networkData: NetworkData) {
|
|
128
|
+
super(runner, networkData);
|
|
136
129
|
|
|
137
130
|
this.escrowFactoryContract = EscrowFactory__factory.connect(
|
|
138
131
|
networkData.factoryAddress,
|
|
139
|
-
|
|
132
|
+
runner
|
|
140
133
|
);
|
|
141
134
|
}
|
|
142
135
|
|
|
143
136
|
/**
|
|
144
|
-
* Creates an instance of EscrowClient from a
|
|
137
|
+
* Creates an instance of EscrowClient from a Runner.
|
|
145
138
|
*
|
|
146
|
-
* @param {
|
|
147
|
-
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
139
|
+
* @param {ContractRunner} runner The Runner object to interact with the Ethereum network
|
|
148
140
|
*
|
|
149
141
|
* @returns {Promise<EscrowClient>} An instance of EscrowClient
|
|
150
142
|
* @throws {ErrorProviderDoesNotExist} Thrown if the provider does not exist for the provided Signer
|
|
151
143
|
* @throws {ErrorUnsupportedChainID} Thrown if the network's chainId is not supported
|
|
152
144
|
*/
|
|
153
|
-
public static async build(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
) {
|
|
157
|
-
let network: Network;
|
|
158
|
-
if (Signer.isSigner(signerOrProvider)) {
|
|
159
|
-
if (!signerOrProvider.provider) {
|
|
160
|
-
throw ErrorProviderDoesNotExist;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
network = await signerOrProvider.provider.getNetwork();
|
|
164
|
-
} else {
|
|
165
|
-
network = await signerOrProvider.getNetwork();
|
|
145
|
+
public static async build(runner: ContractRunner) {
|
|
146
|
+
if (!runner.provider) {
|
|
147
|
+
throw ErrorProviderDoesNotExist;
|
|
166
148
|
}
|
|
167
149
|
|
|
168
|
-
const
|
|
150
|
+
const network = await runner.provider?.getNetwork();
|
|
151
|
+
|
|
152
|
+
const chainId: ChainId = Number(network?.chainId);
|
|
169
153
|
const networkData = NETWORKS[chainId];
|
|
170
154
|
|
|
171
155
|
if (!networkData) {
|
|
172
156
|
throw ErrorUnsupportedChainID;
|
|
173
157
|
}
|
|
174
158
|
|
|
175
|
-
return new EscrowClient(
|
|
159
|
+
return new EscrowClient(runner, networkData);
|
|
176
160
|
}
|
|
177
161
|
|
|
178
162
|
/**
|
|
@@ -182,7 +166,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
182
166
|
*/
|
|
183
167
|
private getEscrowContract(escrowAddress: string): Escrow {
|
|
184
168
|
try {
|
|
185
|
-
return Escrow__factory.connect(escrowAddress, this.
|
|
169
|
+
return Escrow__factory.connect(escrowAddress, this.runner);
|
|
186
170
|
} catch (e) {
|
|
187
171
|
return throwError(e);
|
|
188
172
|
}
|
|
@@ -194,6 +178,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
194
178
|
* @param {string} tokenAddress Token address to use for pay outs.
|
|
195
179
|
* @param {string[]} trustedHandlers Array of addresses that can perform actions on the contract.
|
|
196
180
|
* @param {string} jobRequesterId Job Requester Id
|
|
181
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
197
182
|
* @returns {Promise<string>} Return the address of the escrow created.
|
|
198
183
|
*
|
|
199
184
|
*
|
|
@@ -222,32 +207,33 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
222
207
|
public async createEscrow(
|
|
223
208
|
tokenAddress: string,
|
|
224
209
|
trustedHandlers: string[],
|
|
225
|
-
jobRequesterId: string
|
|
210
|
+
jobRequesterId: string,
|
|
211
|
+
txOptions: Overrides = {}
|
|
226
212
|
): Promise<string> {
|
|
227
|
-
if (!ethers.
|
|
213
|
+
if (!ethers.isAddress(tokenAddress)) {
|
|
228
214
|
throw ErrorInvalidTokenAddress;
|
|
229
215
|
}
|
|
230
216
|
|
|
231
217
|
trustedHandlers.forEach((trustedHandler) => {
|
|
232
|
-
if (!ethers.
|
|
218
|
+
if (!ethers.isAddress(trustedHandler)) {
|
|
233
219
|
throw new InvalidEthereumAddressError(trustedHandler);
|
|
234
220
|
}
|
|
235
221
|
});
|
|
236
222
|
|
|
237
223
|
try {
|
|
238
|
-
const result
|
|
224
|
+
const result = await (
|
|
239
225
|
await this.escrowFactoryContract.createEscrow(
|
|
240
226
|
tokenAddress,
|
|
241
227
|
trustedHandlers,
|
|
242
228
|
jobRequesterId,
|
|
243
|
-
|
|
244
|
-
...(await this.gasPriceOptions()),
|
|
245
|
-
}
|
|
229
|
+
txOptions
|
|
246
230
|
)
|
|
247
231
|
).wait();
|
|
248
232
|
|
|
249
|
-
const event =
|
|
250
|
-
|
|
233
|
+
const event = (
|
|
234
|
+
result?.logs?.find(({ topics }) =>
|
|
235
|
+
topics.includes(ethers.id('LaunchedV2(address,address,string)'))
|
|
236
|
+
) as EventLog
|
|
251
237
|
)?.args;
|
|
252
238
|
|
|
253
239
|
if (!event) {
|
|
@@ -265,6 +251,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
265
251
|
*
|
|
266
252
|
* @param {string} escrowAddress Address of the escrow to set up.
|
|
267
253
|
* @param {IEscrowConfig} escrowConfig Escrow configuration parameters.
|
|
254
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
268
255
|
* @returns Returns void if successful. Throws error if any.
|
|
269
256
|
*
|
|
270
257
|
*
|
|
@@ -288,9 +275,9 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
288
275
|
* recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
289
276
|
* reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
290
277
|
* exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
291
|
-
* recordingOracleFee:
|
|
292
|
-
* reputationOracleFee:
|
|
293
|
-
* exchangeOracleFee:
|
|
278
|
+
* recordingOracleFee: bigint.from('10'),
|
|
279
|
+
* reputationOracleFee: bigint.from('10'),
|
|
280
|
+
* exchangeOracleFee: bigint.from('10'),
|
|
294
281
|
* manifestUrl: 'htttp://localhost/manifest.json',
|
|
295
282
|
* manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079',
|
|
296
283
|
* };
|
|
@@ -300,7 +287,8 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
300
287
|
@requiresSigner
|
|
301
288
|
async setup(
|
|
302
289
|
escrowAddress: string,
|
|
303
|
-
escrowConfig: IEscrowConfig
|
|
290
|
+
escrowConfig: IEscrowConfig,
|
|
291
|
+
txOptions: Overrides = {}
|
|
304
292
|
): Promise<void> {
|
|
305
293
|
const {
|
|
306
294
|
recordingOracle,
|
|
@@ -313,33 +301,31 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
313
301
|
manifestHash,
|
|
314
302
|
} = escrowConfig;
|
|
315
303
|
|
|
316
|
-
if (!ethers.
|
|
304
|
+
if (!ethers.isAddress(recordingOracle)) {
|
|
317
305
|
throw ErrorInvalidRecordingOracleAddressProvided;
|
|
318
306
|
}
|
|
319
307
|
|
|
320
|
-
if (!ethers.
|
|
308
|
+
if (!ethers.isAddress(reputationOracle)) {
|
|
321
309
|
throw ErrorInvalidReputationOracleAddressProvided;
|
|
322
310
|
}
|
|
323
311
|
|
|
324
|
-
if (!ethers.
|
|
312
|
+
if (!ethers.isAddress(exchangeOracle)) {
|
|
325
313
|
throw ErrorInvalidExchangeOracleAddressProvided;
|
|
326
314
|
}
|
|
327
315
|
|
|
328
|
-
if (!ethers.
|
|
316
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
329
317
|
throw ErrorInvalidEscrowAddressProvided;
|
|
330
318
|
}
|
|
331
319
|
|
|
332
320
|
if (
|
|
333
|
-
recordingOracleFee
|
|
334
|
-
reputationOracleFee
|
|
335
|
-
exchangeOracleFee
|
|
321
|
+
recordingOracleFee <= 0 ||
|
|
322
|
+
reputationOracleFee <= 0 ||
|
|
323
|
+
exchangeOracleFee <= 0
|
|
336
324
|
) {
|
|
337
325
|
throw ErrorAmountMustBeGreaterThanZero;
|
|
338
326
|
}
|
|
339
327
|
|
|
340
|
-
if (
|
|
341
|
-
recordingOracleFee.add(reputationOracleFee).add(exchangeOracleFee).gt(100)
|
|
342
|
-
) {
|
|
328
|
+
if (recordingOracleFee + reputationOracleFee + exchangeOracleFee > 100) {
|
|
343
329
|
throw ErrorTotalFeeMustBeLessThanHundred;
|
|
344
330
|
}
|
|
345
331
|
|
|
@@ -362,19 +348,19 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
362
348
|
try {
|
|
363
349
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
364
350
|
|
|
365
|
-
await
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
);
|
|
351
|
+
await (
|
|
352
|
+
await escrowContract.setup(
|
|
353
|
+
reputationOracle,
|
|
354
|
+
recordingOracle,
|
|
355
|
+
exchangeOracle,
|
|
356
|
+
reputationOracleFee,
|
|
357
|
+
recordingOracleFee,
|
|
358
|
+
exchangeOracleFee,
|
|
359
|
+
manifestUrl,
|
|
360
|
+
manifestHash,
|
|
361
|
+
txOptions
|
|
362
|
+
)
|
|
363
|
+
).wait();
|
|
378
364
|
|
|
379
365
|
return;
|
|
380
366
|
} catch (e) {
|
|
@@ -413,9 +399,9 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
413
399
|
* recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
414
400
|
* reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
415
401
|
* exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
416
|
-
* recordingOracleFee:
|
|
417
|
-
* reputationOracleFee:
|
|
418
|
-
* exchangeOracleFee:
|
|
402
|
+
* recordingOracleFee: bigint.from('10'),
|
|
403
|
+
* reputationOracleFee: bigint.from('10'),
|
|
404
|
+
* exchangeOracleFee: bigint.from('10'),
|
|
419
405
|
* manifestUrl: 'htttp://localhost/manifest.json',
|
|
420
406
|
* manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079',
|
|
421
407
|
* };
|
|
@@ -449,7 +435,8 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
449
435
|
* This function adds funds of the chosen token to the escrow.
|
|
450
436
|
*
|
|
451
437
|
* @param {string} escrowAddress Address of the escrow to fund.
|
|
452
|
-
* @param {
|
|
438
|
+
* @param {bigint} amount Amount to be added as funds.
|
|
439
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
453
440
|
* @returns Returns void if successful. Throws error if any.
|
|
454
441
|
*
|
|
455
442
|
*
|
|
@@ -466,17 +453,21 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
466
453
|
* const signer = new Wallet(privateKey, provider);
|
|
467
454
|
* const escrowClient = await EscrowClient.build(signer);
|
|
468
455
|
*
|
|
469
|
-
* const amount = ethers.
|
|
456
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
470
457
|
* await escrowClient.fund('0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
471
458
|
* ```
|
|
472
459
|
*/
|
|
473
460
|
@requiresSigner
|
|
474
|
-
async fund(
|
|
475
|
-
|
|
461
|
+
async fund(
|
|
462
|
+
escrowAddress: string,
|
|
463
|
+
amount: bigint,
|
|
464
|
+
txOptions: Overrides = {}
|
|
465
|
+
): Promise<void> {
|
|
466
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
476
467
|
throw ErrorInvalidEscrowAddressProvided;
|
|
477
468
|
}
|
|
478
469
|
|
|
479
|
-
if (amount
|
|
470
|
+
if (amount <= 0n) {
|
|
480
471
|
throw ErrorAmountMustBeGreaterThanZero;
|
|
481
472
|
}
|
|
482
473
|
|
|
@@ -491,12 +482,11 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
491
482
|
|
|
492
483
|
const tokenContract: HMToken = HMToken__factory.connect(
|
|
493
484
|
tokenAddress,
|
|
494
|
-
this.
|
|
485
|
+
this.runner
|
|
495
486
|
);
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
});
|
|
487
|
+
await (
|
|
488
|
+
await tokenContract.transfer(escrowAddress, amount, txOptions)
|
|
489
|
+
).wait;
|
|
500
490
|
|
|
501
491
|
return;
|
|
502
492
|
} catch (e) {
|
|
@@ -510,6 +500,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
510
500
|
* @param {string} escrowAddress Address of the escrow.
|
|
511
501
|
* @param {string} url Results file url.
|
|
512
502
|
* @param {string} hash Results file hash.
|
|
503
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
513
504
|
* @returns Returns void if successful. Throws error if any.
|
|
514
505
|
*
|
|
515
506
|
*
|
|
@@ -535,9 +526,10 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
535
526
|
async storeResults(
|
|
536
527
|
escrowAddress: string,
|
|
537
528
|
url: string,
|
|
538
|
-
hash: string
|
|
529
|
+
hash: string,
|
|
530
|
+
txOptions: Overrides = {}
|
|
539
531
|
): Promise<void> {
|
|
540
|
-
if (!ethers.
|
|
532
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
541
533
|
throw ErrorInvalidEscrowAddressProvided;
|
|
542
534
|
}
|
|
543
535
|
|
|
@@ -560,9 +552,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
560
552
|
try {
|
|
561
553
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
562
554
|
|
|
563
|
-
await escrowContract.storeResults(url, hash,
|
|
564
|
-
...(await this.gasPriceOptions()),
|
|
565
|
-
});
|
|
555
|
+
await (await escrowContract.storeResults(url, hash, txOptions)).wait();
|
|
566
556
|
|
|
567
557
|
return;
|
|
568
558
|
} catch (e) {
|
|
@@ -574,6 +564,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
574
564
|
* This function sets the status of an escrow to completed.
|
|
575
565
|
*
|
|
576
566
|
* @param {string} escrowAddress Address of the escrow.
|
|
567
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
577
568
|
* @returns Returns void if successful. Throws error if any.
|
|
578
569
|
*
|
|
579
570
|
*
|
|
@@ -596,8 +587,11 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
596
587
|
* ```
|
|
597
588
|
*/
|
|
598
589
|
@requiresSigner
|
|
599
|
-
async complete(
|
|
600
|
-
|
|
590
|
+
async complete(
|
|
591
|
+
escrowAddress: string,
|
|
592
|
+
txOptions: Overrides = {}
|
|
593
|
+
): Promise<void> {
|
|
594
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
601
595
|
throw ErrorInvalidEscrowAddressProvided;
|
|
602
596
|
}
|
|
603
597
|
|
|
@@ -608,9 +602,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
608
602
|
try {
|
|
609
603
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
610
604
|
|
|
611
|
-
await escrowContract.complete(
|
|
612
|
-
...(await this.gasPriceOptions()),
|
|
613
|
-
});
|
|
605
|
+
await (await escrowContract.complete(txOptions)).wait();
|
|
614
606
|
return;
|
|
615
607
|
} catch (e) {
|
|
616
608
|
return throwError(e);
|
|
@@ -622,9 +614,10 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
622
614
|
*
|
|
623
615
|
* @param {string} escrowAddress Escrow address to payout.
|
|
624
616
|
* @param {string[]} recipients Array of recipient addresses.
|
|
625
|
-
* @param {
|
|
617
|
+
* @param {bigint[]} amounts Array of amounts the recipients will receive.
|
|
626
618
|
* @param {string} finalResultsUrl Final results file url.
|
|
627
619
|
* @param {string} finalResultsHash Final results file hash.
|
|
620
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
628
621
|
* @returns Returns void if successful. Throws error if any.
|
|
629
622
|
*
|
|
630
623
|
*
|
|
@@ -644,7 +637,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
644
637
|
* const escrowClient = await EscrowClient.build(signer);
|
|
645
638
|
*
|
|
646
639
|
* const recipients = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'];
|
|
647
|
-
* const amounts = [ethers.
|
|
640
|
+
* const amounts = [ethers.parseUnits(5, 'ether'), ethers.parseUnits(10, 'ether')];
|
|
648
641
|
* const resultsUrl = 'http://localhost/results.json';
|
|
649
642
|
* const resultsHash'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079';
|
|
650
643
|
*
|
|
@@ -655,11 +648,12 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
655
648
|
async bulkPayOut(
|
|
656
649
|
escrowAddress: string,
|
|
657
650
|
recipients: string[],
|
|
658
|
-
amounts:
|
|
651
|
+
amounts: bigint[],
|
|
659
652
|
finalResultsUrl: string,
|
|
660
|
-
finalResultsHash: string
|
|
653
|
+
finalResultsHash: string,
|
|
654
|
+
txOptions: Overrides = {}
|
|
661
655
|
): Promise<void> {
|
|
662
|
-
if (!ethers.
|
|
656
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
663
657
|
throw ErrorInvalidEscrowAddressProvided;
|
|
664
658
|
}
|
|
665
659
|
|
|
@@ -676,7 +670,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
676
670
|
}
|
|
677
671
|
|
|
678
672
|
recipients.forEach((recipient) => {
|
|
679
|
-
if (!ethers.
|
|
673
|
+
if (!ethers.isAddress(recipient)) {
|
|
680
674
|
throw new InvalidEthereumAddressError(recipient);
|
|
681
675
|
}
|
|
682
676
|
});
|
|
@@ -695,12 +689,12 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
695
689
|
|
|
696
690
|
const balance = await this.getBalance(escrowAddress);
|
|
697
691
|
|
|
698
|
-
let totalAmount =
|
|
692
|
+
let totalAmount = 0n;
|
|
699
693
|
amounts.forEach((amount) => {
|
|
700
|
-
totalAmount = totalAmount
|
|
694
|
+
totalAmount = totalAmount + amount;
|
|
701
695
|
});
|
|
702
696
|
|
|
703
|
-
if (balance
|
|
697
|
+
if (balance < totalAmount) {
|
|
704
698
|
throw ErrorEscrowDoesNotHaveEnoughBalance;
|
|
705
699
|
}
|
|
706
700
|
|
|
@@ -711,17 +705,16 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
711
705
|
try {
|
|
712
706
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
713
707
|
|
|
714
|
-
await
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
);
|
|
708
|
+
await (
|
|
709
|
+
await escrowContract.bulkPayOut(
|
|
710
|
+
recipients,
|
|
711
|
+
amounts,
|
|
712
|
+
finalResultsUrl,
|
|
713
|
+
finalResultsHash,
|
|
714
|
+
DEFAULT_TX_ID,
|
|
715
|
+
txOptions
|
|
716
|
+
)
|
|
717
|
+
).wait();
|
|
725
718
|
return;
|
|
726
719
|
} catch (e) {
|
|
727
720
|
return throwError(e);
|
|
@@ -732,6 +725,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
732
725
|
* This function cancels the specified escrow and sends the balance to the canceler.
|
|
733
726
|
*
|
|
734
727
|
* @param {string} escrowAddress Address of the escrow to cancel.
|
|
728
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
735
729
|
* @returns {EscrowCancel} Returns the escrow cancellation data including transaction hash and refunded amount. Throws error if any.
|
|
736
730
|
*
|
|
737
731
|
*
|
|
@@ -754,8 +748,11 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
754
748
|
* ```
|
|
755
749
|
*/
|
|
756
750
|
@requiresSigner
|
|
757
|
-
async cancel(
|
|
758
|
-
|
|
751
|
+
async cancel(
|
|
752
|
+
escrowAddress: string,
|
|
753
|
+
txOptions: Overrides = {}
|
|
754
|
+
): Promise<EscrowCancel> {
|
|
755
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
759
756
|
throw ErrorInvalidEscrowAddressProvided;
|
|
760
757
|
}
|
|
761
758
|
|
|
@@ -766,37 +763,39 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
766
763
|
try {
|
|
767
764
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
768
765
|
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
const transactionReceipt = await tx.wait();
|
|
766
|
+
const transactionReceipt = await (
|
|
767
|
+
await escrowContract.cancel(txOptions)
|
|
768
|
+
).wait();
|
|
773
769
|
|
|
774
|
-
let amountTransferred:
|
|
770
|
+
let amountTransferred: bigint | undefined = undefined;
|
|
775
771
|
const tokenAddress = await escrowContract.token();
|
|
776
772
|
|
|
777
773
|
const tokenContract: HMToken = HMToken__factory.connect(
|
|
778
774
|
tokenAddress,
|
|
779
|
-
this.
|
|
775
|
+
this.runner
|
|
780
776
|
);
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
777
|
+
if (transactionReceipt)
|
|
778
|
+
for (const log of transactionReceipt.logs) {
|
|
779
|
+
if (log.address === tokenAddress) {
|
|
780
|
+
const parsedLog = tokenContract.interface.parseLog({
|
|
781
|
+
topics: log.topics as string[],
|
|
782
|
+
data: log.data,
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
const from = parsedLog?.args[0];
|
|
786
|
+
if (parsedLog?.name === 'Transfer' && from === escrowAddress) {
|
|
787
|
+
amountTransferred = parsedLog?.args[2];
|
|
788
|
+
break;
|
|
789
|
+
}
|
|
790
790
|
}
|
|
791
791
|
}
|
|
792
|
-
}
|
|
793
792
|
|
|
794
793
|
if (amountTransferred === undefined) {
|
|
795
794
|
throw ErrorTransferEventNotFoundInTransactionLogs;
|
|
796
795
|
}
|
|
797
796
|
|
|
798
797
|
const escrowCancelData: EscrowCancel = {
|
|
799
|
-
txHash: transactionReceipt
|
|
798
|
+
txHash: transactionReceipt?.hash || '',
|
|
800
799
|
amountRefunded: amountTransferred,
|
|
801
800
|
};
|
|
802
801
|
|
|
@@ -810,6 +809,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
810
809
|
* This function cancels the specified escrow, sends the balance to the canceler and selfdestructs the escrow contract.
|
|
811
810
|
*
|
|
812
811
|
* @param {string} escrowAddress Address of the escrow.
|
|
812
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
813
813
|
* @returns Returns void if successful. Throws error if any.
|
|
814
814
|
*
|
|
815
815
|
*
|
|
@@ -832,8 +832,8 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
832
832
|
* ```
|
|
833
833
|
*/
|
|
834
834
|
@requiresSigner
|
|
835
|
-
async abort(escrowAddress: string): Promise<void> {
|
|
836
|
-
if (!ethers.
|
|
835
|
+
async abort(escrowAddress: string, txOptions: Overrides = {}): Promise<void> {
|
|
836
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
837
837
|
throw ErrorInvalidEscrowAddressProvided;
|
|
838
838
|
}
|
|
839
839
|
|
|
@@ -844,9 +844,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
844
844
|
try {
|
|
845
845
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
846
846
|
|
|
847
|
-
await escrowContract.abort(
|
|
848
|
-
...(await this.gasPriceOptions()),
|
|
849
|
-
});
|
|
847
|
+
await (await escrowContract.abort(txOptions)).wait();
|
|
850
848
|
return;
|
|
851
849
|
} catch (e) {
|
|
852
850
|
return throwError(e);
|
|
@@ -858,6 +856,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
858
856
|
*
|
|
859
857
|
* @param {string} escrowAddress Address of the escrow.
|
|
860
858
|
* @param {string[]} trustedHandlers Array of addresses of trusted handlers to add.
|
|
859
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
861
860
|
* @returns Returns void if successful. Throws error if any.
|
|
862
861
|
*
|
|
863
862
|
*
|
|
@@ -883,9 +882,10 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
883
882
|
@requiresSigner
|
|
884
883
|
async addTrustedHandlers(
|
|
885
884
|
escrowAddress: string,
|
|
886
|
-
trustedHandlers: string[]
|
|
885
|
+
trustedHandlers: string[],
|
|
886
|
+
txOptions: Overrides = {}
|
|
887
887
|
): Promise<void> {
|
|
888
|
-
if (!ethers.
|
|
888
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
889
889
|
throw ErrorInvalidEscrowAddressProvided;
|
|
890
890
|
}
|
|
891
891
|
|
|
@@ -894,7 +894,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
894
894
|
}
|
|
895
895
|
|
|
896
896
|
trustedHandlers.forEach((trustedHandler) => {
|
|
897
|
-
if (!ethers.
|
|
897
|
+
if (!ethers.isAddress(trustedHandler)) {
|
|
898
898
|
throw new InvalidEthereumAddressError(trustedHandler);
|
|
899
899
|
}
|
|
900
900
|
});
|
|
@@ -906,9 +906,9 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
906
906
|
try {
|
|
907
907
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
908
908
|
|
|
909
|
-
await
|
|
910
|
-
|
|
911
|
-
|
|
909
|
+
await (
|
|
910
|
+
await escrowContract.addTrustedHandlers(trustedHandlers, txOptions)
|
|
911
|
+
).wait();
|
|
912
912
|
return;
|
|
913
913
|
} catch (e) {
|
|
914
914
|
return throwError(e);
|
|
@@ -919,7 +919,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
919
919
|
* This function returns the balance for a specified escrow address.
|
|
920
920
|
*
|
|
921
921
|
* @param {string} escrowAddress Address of the escrow.
|
|
922
|
-
* @returns {
|
|
922
|
+
* @returns {bigint} Balance of the escrow in the token used to fund it.
|
|
923
923
|
*
|
|
924
924
|
* **Code example**
|
|
925
925
|
*
|
|
@@ -935,8 +935,8 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
935
935
|
* const balance = await escrowClient.getBalance('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
936
936
|
* ```
|
|
937
937
|
*/
|
|
938
|
-
async getBalance(escrowAddress: string): Promise<
|
|
939
|
-
if (!ethers.
|
|
938
|
+
async getBalance(escrowAddress: string): Promise<bigint> {
|
|
939
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
940
940
|
throw ErrorInvalidEscrowAddressProvided;
|
|
941
941
|
}
|
|
942
942
|
|
|
@@ -974,7 +974,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
974
974
|
* ```
|
|
975
975
|
*/
|
|
976
976
|
async getManifestHash(escrowAddress: string): Promise<string> {
|
|
977
|
-
if (!ethers.
|
|
977
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
978
978
|
throw ErrorInvalidEscrowAddressProvided;
|
|
979
979
|
}
|
|
980
980
|
|
|
@@ -1012,7 +1012,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1012
1012
|
* ```
|
|
1013
1013
|
*/
|
|
1014
1014
|
async getManifestUrl(escrowAddress: string): Promise<string> {
|
|
1015
|
-
if (!ethers.
|
|
1015
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1016
1016
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1017
1017
|
}
|
|
1018
1018
|
|
|
@@ -1050,7 +1050,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1050
1050
|
* ```
|
|
1051
1051
|
*/
|
|
1052
1052
|
async getResultsUrl(escrowAddress: string): Promise<string> {
|
|
1053
|
-
if (!ethers.
|
|
1053
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1054
1054
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1055
1055
|
}
|
|
1056
1056
|
|
|
@@ -1088,7 +1088,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1088
1088
|
* ```
|
|
1089
1089
|
*/
|
|
1090
1090
|
async getIntermediateResultsUrl(escrowAddress: string): Promise<string> {
|
|
1091
|
-
if (!ethers.
|
|
1091
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1092
1092
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1093
1093
|
}
|
|
1094
1094
|
|
|
@@ -1126,7 +1126,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1126
1126
|
* ```
|
|
1127
1127
|
*/
|
|
1128
1128
|
async getTokenAddress(escrowAddress: string): Promise<string> {
|
|
1129
|
-
if (!ethers.
|
|
1129
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1130
1130
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1131
1131
|
}
|
|
1132
1132
|
|
|
@@ -1164,7 +1164,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1164
1164
|
* ```
|
|
1165
1165
|
*/
|
|
1166
1166
|
async getStatus(escrowAddress: string): Promise<EscrowStatus> {
|
|
1167
|
-
if (!ethers.
|
|
1167
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1168
1168
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1169
1169
|
}
|
|
1170
1170
|
|
|
@@ -1175,7 +1175,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1175
1175
|
try {
|
|
1176
1176
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
1177
1177
|
|
|
1178
|
-
return escrowContract.status();
|
|
1178
|
+
return Number(await escrowContract.status());
|
|
1179
1179
|
} catch (e) {
|
|
1180
1180
|
return throwError(e);
|
|
1181
1181
|
}
|
|
@@ -1202,7 +1202,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1202
1202
|
* ```
|
|
1203
1203
|
*/
|
|
1204
1204
|
async getRecordingOracleAddress(escrowAddress: string): Promise<string> {
|
|
1205
|
-
if (!ethers.
|
|
1205
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1206
1206
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1207
1207
|
}
|
|
1208
1208
|
|
|
@@ -1240,7 +1240,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1240
1240
|
* ```
|
|
1241
1241
|
*/
|
|
1242
1242
|
async getJobLauncherAddress(escrowAddress: string): Promise<string> {
|
|
1243
|
-
if (!ethers.
|
|
1243
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1244
1244
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1245
1245
|
}
|
|
1246
1246
|
|
|
@@ -1278,7 +1278,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1278
1278
|
* ```
|
|
1279
1279
|
*/
|
|
1280
1280
|
async getReputationOracleAddress(escrowAddress: string): Promise<string> {
|
|
1281
|
-
if (!ethers.
|
|
1281
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1282
1282
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1283
1283
|
}
|
|
1284
1284
|
|
|
@@ -1316,7 +1316,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1316
1316
|
* ```
|
|
1317
1317
|
*/
|
|
1318
1318
|
async getExchangeOracleAddress(escrowAddress: string): Promise<string> {
|
|
1319
|
-
if (!ethers.
|
|
1319
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1320
1320
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
@@ -1354,7 +1354,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1354
1354
|
* ```
|
|
1355
1355
|
*/
|
|
1356
1356
|
async getFactoryAddress(escrowAddress: string): Promise<string> {
|
|
1357
|
-
if (!ethers.
|
|
1357
|
+
if (!ethers.isAddress(escrowAddress)) {
|
|
1358
1358
|
throw ErrorInvalidEscrowAddressProvided;
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
@@ -1507,28 +1507,19 @@ export class EscrowUtils {
|
|
|
1507
1507
|
if (!filter?.networks?.length) {
|
|
1508
1508
|
throw ErrorUnsupportedChainID;
|
|
1509
1509
|
}
|
|
1510
|
-
if (filter.launcher && !ethers.
|
|
1510
|
+
if (filter.launcher && !ethers.isAddress(filter.launcher)) {
|
|
1511
1511
|
throw ErrorInvalidAddress;
|
|
1512
1512
|
}
|
|
1513
1513
|
|
|
1514
|
-
if (
|
|
1515
|
-
filter.recordingOracle &&
|
|
1516
|
-
!ethers.utils.isAddress(filter.recordingOracle)
|
|
1517
|
-
) {
|
|
1514
|
+
if (filter.recordingOracle && !ethers.isAddress(filter.recordingOracle)) {
|
|
1518
1515
|
throw ErrorInvalidAddress;
|
|
1519
1516
|
}
|
|
1520
1517
|
|
|
1521
|
-
if (
|
|
1522
|
-
filter.reputationOracle &&
|
|
1523
|
-
!ethers.utils.isAddress(filter.reputationOracle)
|
|
1524
|
-
) {
|
|
1518
|
+
if (filter.reputationOracle && !ethers.isAddress(filter.reputationOracle)) {
|
|
1525
1519
|
throw ErrorInvalidAddress;
|
|
1526
1520
|
}
|
|
1527
1521
|
|
|
1528
|
-
if (
|
|
1529
|
-
filter.exchangeOracle &&
|
|
1530
|
-
!ethers.utils.isAddress(filter.exchangeOracle)
|
|
1531
|
-
) {
|
|
1522
|
+
if (filter.exchangeOracle && !ethers.isAddress(filter.exchangeOracle)) {
|
|
1532
1523
|
throw ErrorInvalidAddress;
|
|
1533
1524
|
}
|
|
1534
1525
|
|
|
@@ -1648,7 +1639,7 @@ export class EscrowUtils {
|
|
|
1648
1639
|
throw ErrorUnsupportedChainID;
|
|
1649
1640
|
}
|
|
1650
1641
|
|
|
1651
|
-
if (escrowAddress && !ethers.
|
|
1642
|
+
if (escrowAddress && !ethers.isAddress(escrowAddress)) {
|
|
1652
1643
|
throw ErrorInvalidAddress;
|
|
1653
1644
|
}
|
|
1654
1645
|
|