@human-protocol/sdk 1.1.18 → 1.1.19

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/src/constants.ts CHANGED
@@ -59,7 +59,7 @@ export const NETWORKS: {
59
59
  hmtAddress: '0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867',
60
60
  stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
61
61
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
62
- kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
62
+ kvstoreAddress: '0xB6d36B1CDaD50302BCB3DB43bAb0D349458e1b8D',
63
63
  subgraphUrl:
64
64
  'https://api.thegraph.com/subgraphs/name/humanprotocol/mainnet-v2',
65
65
  oldSubgraphUrl: '',
@@ -86,7 +86,7 @@ export const NETWORKS: {
86
86
  hmtAddress: '0xd3A31D57FDD790725d0F6B78095F62E8CD4ab317',
87
87
  stakingAddress: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
88
88
  rewardPoolAddress: '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4',
89
- kvstoreAddress: '0xc9Fe39c4b6e1d7A2991355Af159956982DADf842',
89
+ kvstoreAddress: '0x19Fc3e859C1813ac9427a7a78BeB9ae102CE96d3',
90
90
  subgraphUrl:
91
91
  'https://api.thegraph.com/subgraphs/name/humanprotocol/goerli-v2',
92
92
  oldSubgraphUrl:
@@ -101,7 +101,7 @@ export const NETWORKS: {
101
101
  hmtAddress: '0x711Fd6ab6d65A98904522d4e3586F492B989c527',
102
102
  stakingAddress: '0xdFbB79dC35a3A53741be54a2C9b587d6BafAbd1C',
103
103
  rewardPoolAddress: '0xf376443BCc6d4d4D63eeC086bc4A9E4a83878e0e',
104
- kvstoreAddress: '0x2B95bEcb6EBC4589f64CB000dFCF716b4aeF8aA6',
104
+ kvstoreAddress: '0x21A0C4CED7aE447fCf87D9FE3A29FA9B3AB20Ff1',
105
105
  subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc-v2',
106
106
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
107
107
  oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
@@ -114,7 +114,7 @@ export const NETWORKS: {
114
114
  hmtAddress: '0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d',
115
115
  stakingAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
116
116
  rewardPoolAddress: '0xB0A0500103eCEc431b73F6BAd923F0a2774E6e29',
117
- kvstoreAddress: '0x3aD4B091E054f192a822D1406f4535eAd38580e4',
117
+ kvstoreAddress: '0x32e27177BA6Ea91cf28dfd91a0Da9822A4b74EcF',
118
118
  subgraphUrl:
119
119
  'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest-v2',
120
120
  oldSubgraphUrl:
@@ -129,7 +129,7 @@ export const NETWORKS: {
129
129
  hmtAddress: '0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571BF',
130
130
  stakingAddress: '0xcbAd56bE3f504E98bd70875823d3CC0242B7bB29',
131
131
  rewardPoolAddress: '0xa8e32d777a3839440cc7c24D591A64B9481753B3',
132
- kvstoreAddress: '0x35Cf4beBD58F9C8D75B9eA2599479b6C173d406F',
132
+ kvstoreAddress: '0xbcB28672F826a50B03EE91B28145EAbddA73B2eD',
133
133
  subgraphUrl:
134
134
  'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon-v2',
135
135
  oldSubgraphUrl:
@@ -144,7 +144,7 @@ export const NETWORKS: {
144
144
  hmtAddress: '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4',
145
145
  stakingAddress: '0x7Fd3dF914E7b6Bd96B4c744Df32183b51368Bfac',
146
146
  rewardPoolAddress: '0xf0145eD99AC3c4f877aDa7dA4D1E059ec9116BAE',
147
- kvstoreAddress: '0xD7F61E812e139a5a02eDae9Dfec146E1b8eA3807',
147
+ kvstoreAddress: '0xD96158c7267Ea658a4688F4aEf1c85659851625d',
148
148
  subgraphUrl:
149
149
  'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai-v2',
150
150
  oldSubgraphUrl:
@@ -159,7 +159,7 @@ export const NETWORKS: {
159
159
  hmtAddress: '0x3b25BC1dC591D24d60560d0135D6750A561D4764',
160
160
  stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
161
161
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
162
- kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
162
+ kvstoreAddress: '0x2B95bEcb6EBC4589f64CB000dFCF716b4aeF8aA6',
163
163
  subgraphUrl:
164
164
  'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbeam-v2',
165
165
  oldSubgraphUrl:
@@ -174,7 +174,7 @@ export const NETWORKS: {
174
174
  hmtAddress: '0x2dd72db2bBA65cE663e476bA8b84A1aAF802A8e3',
175
175
  stakingAddress: '0xBFC7009F3371F93F3B54DdC8caCd02914a37495c',
176
176
  rewardPoolAddress: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
177
- kvstoreAddress: '0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d',
177
+ kvstoreAddress: '0xcC561f4482f4Ff051D2Dcc65c2cE1A0f291bbA46',
178
178
  subgraphUrl:
179
179
  'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbase-alpha-v2',
180
180
  oldSubgraphUrl: '',
@@ -188,7 +188,7 @@ export const NETWORKS: {
188
188
  hmtAddress: '0x9406d5c635AD22b0d76c75E52De57A2177919ca3',
189
189
  stakingAddress: '0x9890473B0b93E24d6D1a8Dfb739D577C6f25FFd3',
190
190
  rewardPoolAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
191
- kvstoreAddress: '0x707fb5A5d36BC15275Af3f73262bf9a1D8C470EB',
191
+ kvstoreAddress: '0x3aD4B091E054f192a822D1406f4535eAd38580e4',
192
192
  subgraphUrl:
193
193
  'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji-v2',
194
194
  oldSubgraphUrl:
@@ -203,7 +203,7 @@ export const NETWORKS: {
203
203
  hmtAddress: '0x12365293cb6477d4fc2686e46BB97E3Fb64f1550',
204
204
  stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
205
205
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
206
- kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
206
+ kvstoreAddress: '0x9Bc7bff35B2Be2413708d48c3B0aEF5c43646728',
207
207
  subgraphUrl:
208
208
  'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche-v2',
209
209
  oldSubgraphUrl:
@@ -273,3 +273,11 @@ export const KVStoreKeys = {
273
273
  webhookUrl: 'webhookUrl',
274
274
  url: 'url',
275
275
  };
276
+
277
+ export const Role = {
278
+ Validator: 'Validator',
279
+ JobLauncher: 'Job Launcher',
280
+ ExchangeOracle: 'Exchange Oracle',
281
+ ReputationOracle: 'Reputation Oracle',
282
+ RecordingOracle: 'Recording Oracle',
283
+ };
package/src/encryption.ts CHANGED
@@ -437,4 +437,44 @@ export class EncryptionUtils {
437
437
 
438
438
  return encrypted as string;
439
439
  }
440
+
441
+ /**
442
+ * Verifies if a message appears to be encrypted with OpenPGP.
443
+ *
444
+ * @param {string} message Message to verify.
445
+ * @returns {Promise<boolean>} `true` if the message appears to be encrypted, `false` if not.
446
+ *
447
+ * **Code example:**
448
+ *
449
+ * ```ts
450
+ * const message = `-----BEGIN PGP MESSAGE-----
451
+ *
452
+ * wV4DqdeRpqH+jaISAQdAsvBFxikvjxRqC7ZlDe98cLd7/aeCEI/AcL8PpVKK
453
+ * mC0wKlwxNg/ADi55z9jcYFuMC4kKE+C/teM+JqiI8DO9AwassQUvKFtULnpx
454
+ * h2jaOjC/0sAQASjUsIFK8zbuDgk/P8T9Npn6px+GlJPg9K90iwtPWiIp0eyW
455
+ * 4zXamJZT51k2DyaUX/Rsc6P4PYhQRKjt0yxtH0jHPmKkLC/9eBeFf4GP0zlZ
456
+ * 18xMZ8uCpQCma708Gz0sJYxEz3u/eZdHD7Mc7tWQKyJG8MsTwM1P+fdK1X75
457
+ * L9UryJG2AY+6kKZhG4dqjNxiO4fWluiB2u7iMF+iLEyE3SQCEYorWMC+NDWi
458
+ * QIJZ7oQ2w7BaPo1a991gvTOSNm5v2x44KfqPI1uj859BjsQTCA==
459
+ * =tsmI
460
+ * -----END PGP MESSAGE-----`;
461
+ *
462
+ * const isEncrypted = await EncriptionUtils.isEncrypted(message);
463
+ *
464
+ * if (isEncrypted) {
465
+ * console.log('The message is encrypted with OpenPGP.');
466
+ * } else {
467
+ * console.log('The message is not encrypted with OpenPGP.');
468
+ * }
469
+ * ```
470
+ */
471
+ public static isEncrypted(message: string): boolean {
472
+ const startMarker = '-----BEGIN PGP MESSAGE-----';
473
+ const endMarker = '-----END PGP MESSAGE-----';
474
+
475
+ const hasStartMarker = message.includes(startMarker);
476
+ const hasEndMarker = message.includes(endMarker);
477
+
478
+ return hasStartMarker && hasEndMarker;
479
+ }
440
480
  }
package/src/error.ts CHANGED
@@ -334,8 +334,3 @@ export class InvalidEthereumAddressError extends Error {
334
334
  * @constant {Error} - The Hash does not match
335
335
  */
336
336
  export const ErrorInvalidHash = new Error('Invalid hash');
337
-
338
- /**
339
- * @constant {Error} - The Hash does not match
340
- */
341
- export const ErrorMissingGasPrice = new Error('Missing gas price');
package/src/escrow.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  HMToken,
10
10
  HMToken__factory,
11
11
  } from '@human-protocol/core/typechain-types';
12
- import { BigNumber, ContractReceipt, Signer, ethers } from 'ethers';
12
+ import { BigNumber, ContractReceipt, Overrides, Signer, ethers } from 'ethers';
13
13
  import gqlFetch from 'graphql-request';
14
14
  import { BaseEthersClient } from './base';
15
15
  import { DEFAULT_TX_ID, NETWORKS } from './constants';
@@ -125,14 +125,9 @@ export class EscrowClient extends BaseEthersClient {
125
125
  *
126
126
  * @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
127
127
  * @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
128
  */
130
- constructor(
131
- signerOrProvider: Signer | Provider,
132
- networkData: NetworkData,
133
- gasPriceMultiplier?: number
134
- ) {
135
- super(signerOrProvider, networkData, gasPriceMultiplier);
129
+ constructor(signerOrProvider: Signer | Provider, networkData: NetworkData) {
130
+ super(signerOrProvider, networkData);
136
131
 
137
132
  this.escrowFactoryContract = EscrowFactory__factory.connect(
138
133
  networkData.factoryAddress,
@@ -144,16 +139,12 @@ export class EscrowClient extends BaseEthersClient {
144
139
  * Creates an instance of EscrowClient from a Signer or Provider.
145
140
  *
146
141
  * @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
147
- * @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
148
142
  *
149
143
  * @returns {Promise<EscrowClient>} An instance of EscrowClient
150
144
  * @throws {ErrorProviderDoesNotExist} Thrown if the provider does not exist for the provided Signer
151
145
  * @throws {ErrorUnsupportedChainID} Thrown if the network's chainId is not supported
152
146
  */
153
- public static async build(
154
- signerOrProvider: Signer | Provider,
155
- gasPriceMultiplier?: number
156
- ) {
147
+ public static async build(signerOrProvider: Signer | Provider) {
157
148
  let network: Network;
158
149
  if (Signer.isSigner(signerOrProvider)) {
159
150
  if (!signerOrProvider.provider) {
@@ -172,7 +163,7 @@ export class EscrowClient extends BaseEthersClient {
172
163
  throw ErrorUnsupportedChainID;
173
164
  }
174
165
 
175
- return new EscrowClient(signerOrProvider, networkData, gasPriceMultiplier);
166
+ return new EscrowClient(signerOrProvider, networkData);
176
167
  }
177
168
 
178
169
  /**
@@ -194,6 +185,7 @@ export class EscrowClient extends BaseEthersClient {
194
185
  * @param {string} tokenAddress Token address to use for pay outs.
195
186
  * @param {string[]} trustedHandlers Array of addresses that can perform actions on the contract.
196
187
  * @param {string} jobRequesterId Job Requester Id
188
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
197
189
  * @returns {Promise<string>} Return the address of the escrow created.
198
190
  *
199
191
  *
@@ -222,7 +214,8 @@ export class EscrowClient extends BaseEthersClient {
222
214
  public async createEscrow(
223
215
  tokenAddress: string,
224
216
  trustedHandlers: string[],
225
- jobRequesterId: string
217
+ jobRequesterId: string,
218
+ txOptions: Overrides = {}
226
219
  ): Promise<string> {
227
220
  if (!ethers.utils.isAddress(tokenAddress)) {
228
221
  throw ErrorInvalidTokenAddress;
@@ -240,9 +233,7 @@ export class EscrowClient extends BaseEthersClient {
240
233
  tokenAddress,
241
234
  trustedHandlers,
242
235
  jobRequesterId,
243
- {
244
- ...(await this.gasPriceOptions()),
245
- }
236
+ txOptions
246
237
  )
247
238
  ).wait();
248
239
 
@@ -265,6 +256,7 @@ export class EscrowClient extends BaseEthersClient {
265
256
  *
266
257
  * @param {string} escrowAddress Address of the escrow to set up.
267
258
  * @param {IEscrowConfig} escrowConfig Escrow configuration parameters.
259
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
268
260
  * @returns Returns void if successful. Throws error if any.
269
261
  *
270
262
  *
@@ -300,7 +292,8 @@ export class EscrowClient extends BaseEthersClient {
300
292
  @requiresSigner
301
293
  async setup(
302
294
  escrowAddress: string,
303
- escrowConfig: IEscrowConfig
295
+ escrowConfig: IEscrowConfig,
296
+ txOptions: Overrides = {}
304
297
  ): Promise<void> {
305
298
  const {
306
299
  recordingOracle,
@@ -362,19 +355,19 @@ export class EscrowClient extends BaseEthersClient {
362
355
  try {
363
356
  const escrowContract = this.getEscrowContract(escrowAddress);
364
357
 
365
- await escrowContract.setup(
366
- reputationOracle,
367
- recordingOracle,
368
- exchangeOracle,
369
- reputationOracleFee,
370
- recordingOracleFee,
371
- exchangeOracleFee,
372
- manifestUrl,
373
- manifestHash,
374
- {
375
- ...(await this.gasPriceOptions()),
376
- }
377
- );
358
+ await (
359
+ await escrowContract.setup(
360
+ reputationOracle,
361
+ recordingOracle,
362
+ exchangeOracle,
363
+ reputationOracleFee,
364
+ recordingOracleFee,
365
+ exchangeOracleFee,
366
+ manifestUrl,
367
+ manifestHash,
368
+ txOptions
369
+ )
370
+ ).wait();
378
371
 
379
372
  return;
380
373
  } catch (e) {
@@ -450,6 +443,7 @@ export class EscrowClient extends BaseEthersClient {
450
443
  *
451
444
  * @param {string} escrowAddress Address of the escrow to fund.
452
445
  * @param {BigNumber} amount Amount to be added as funds.
446
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
453
447
  * @returns Returns void if successful. Throws error if any.
454
448
  *
455
449
  *
@@ -471,7 +465,11 @@ export class EscrowClient extends BaseEthersClient {
471
465
  * ```
472
466
  */
473
467
  @requiresSigner
474
- async fund(escrowAddress: string, amount: BigNumber): Promise<void> {
468
+ async fund(
469
+ escrowAddress: string,
470
+ amount: BigNumber,
471
+ txOptions: Overrides = {}
472
+ ): Promise<void> {
475
473
  if (!ethers.utils.isAddress(escrowAddress)) {
476
474
  throw ErrorInvalidEscrowAddressProvided;
477
475
  }
@@ -493,10 +491,9 @@ export class EscrowClient extends BaseEthersClient {
493
491
  tokenAddress,
494
492
  this.signerOrProvider
495
493
  );
496
-
497
- await tokenContract.transfer(escrowAddress, amount, {
498
- ...(await this.gasPriceOptions()),
499
- });
494
+ await (
495
+ await tokenContract.transfer(escrowAddress, amount, txOptions)
496
+ ).wait;
500
497
 
501
498
  return;
502
499
  } catch (e) {
@@ -510,6 +507,7 @@ export class EscrowClient extends BaseEthersClient {
510
507
  * @param {string} escrowAddress Address of the escrow.
511
508
  * @param {string} url Results file url.
512
509
  * @param {string} hash Results file hash.
510
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
513
511
  * @returns Returns void if successful. Throws error if any.
514
512
  *
515
513
  *
@@ -535,7 +533,8 @@ export class EscrowClient extends BaseEthersClient {
535
533
  async storeResults(
536
534
  escrowAddress: string,
537
535
  url: string,
538
- hash: string
536
+ hash: string,
537
+ txOptions: Overrides = {}
539
538
  ): Promise<void> {
540
539
  if (!ethers.utils.isAddress(escrowAddress)) {
541
540
  throw ErrorInvalidEscrowAddressProvided;
@@ -560,9 +559,7 @@ export class EscrowClient extends BaseEthersClient {
560
559
  try {
561
560
  const escrowContract = this.getEscrowContract(escrowAddress);
562
561
 
563
- await escrowContract.storeResults(url, hash, {
564
- ...(await this.gasPriceOptions()),
565
- });
562
+ await (await escrowContract.storeResults(url, hash, txOptions)).wait();
566
563
 
567
564
  return;
568
565
  } catch (e) {
@@ -574,6 +571,7 @@ export class EscrowClient extends BaseEthersClient {
574
571
  * This function sets the status of an escrow to completed.
575
572
  *
576
573
  * @param {string} escrowAddress Address of the escrow.
574
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
577
575
  * @returns Returns void if successful. Throws error if any.
578
576
  *
579
577
  *
@@ -596,7 +594,10 @@ export class EscrowClient extends BaseEthersClient {
596
594
  * ```
597
595
  */
598
596
  @requiresSigner
599
- async complete(escrowAddress: string): Promise<void> {
597
+ async complete(
598
+ escrowAddress: string,
599
+ txOptions: Overrides = {}
600
+ ): Promise<void> {
600
601
  if (!ethers.utils.isAddress(escrowAddress)) {
601
602
  throw ErrorInvalidEscrowAddressProvided;
602
603
  }
@@ -608,9 +609,7 @@ export class EscrowClient extends BaseEthersClient {
608
609
  try {
609
610
  const escrowContract = this.getEscrowContract(escrowAddress);
610
611
 
611
- await escrowContract.complete({
612
- ...(await this.gasPriceOptions()),
613
- });
612
+ await (await escrowContract.complete(txOptions)).wait();
614
613
  return;
615
614
  } catch (e) {
616
615
  return throwError(e);
@@ -625,6 +624,7 @@ export class EscrowClient extends BaseEthersClient {
625
624
  * @param {BigNumber[]} amounts Array of amounts the recipients will receive.
626
625
  * @param {string} finalResultsUrl Final results file url.
627
626
  * @param {string} finalResultsHash Final results file hash.
627
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
628
628
  * @returns Returns void if successful. Throws error if any.
629
629
  *
630
630
  *
@@ -657,7 +657,8 @@ export class EscrowClient extends BaseEthersClient {
657
657
  recipients: string[],
658
658
  amounts: BigNumber[],
659
659
  finalResultsUrl: string,
660
- finalResultsHash: string
660
+ finalResultsHash: string,
661
+ txOptions: Overrides = {}
661
662
  ): Promise<void> {
662
663
  if (!ethers.utils.isAddress(escrowAddress)) {
663
664
  throw ErrorInvalidEscrowAddressProvided;
@@ -711,17 +712,16 @@ export class EscrowClient extends BaseEthersClient {
711
712
  try {
712
713
  const escrowContract = this.getEscrowContract(escrowAddress);
713
714
 
714
- await escrowContract.bulkPayOut(
715
- recipients,
716
- amounts,
717
- finalResultsUrl,
718
- finalResultsHash,
719
- DEFAULT_TX_ID,
720
-
721
- {
722
- ...(await this.gasPriceOptions()),
723
- }
724
- );
715
+ await (
716
+ await escrowContract.bulkPayOut(
717
+ recipients,
718
+ amounts,
719
+ finalResultsUrl,
720
+ finalResultsHash,
721
+ DEFAULT_TX_ID,
722
+ txOptions
723
+ )
724
+ ).wait();
725
725
  return;
726
726
  } catch (e) {
727
727
  return throwError(e);
@@ -732,6 +732,7 @@ export class EscrowClient extends BaseEthersClient {
732
732
  * This function cancels the specified escrow and sends the balance to the canceler.
733
733
  *
734
734
  * @param {string} escrowAddress Address of the escrow to cancel.
735
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
735
736
  * @returns {EscrowCancel} Returns the escrow cancellation data including transaction hash and refunded amount. Throws error if any.
736
737
  *
737
738
  *
@@ -754,7 +755,10 @@ export class EscrowClient extends BaseEthersClient {
754
755
  * ```
755
756
  */
756
757
  @requiresSigner
757
- async cancel(escrowAddress: string): Promise<EscrowCancel> {
758
+ async cancel(
759
+ escrowAddress: string,
760
+ txOptions: Overrides = {}
761
+ ): Promise<EscrowCancel> {
758
762
  if (!ethers.utils.isAddress(escrowAddress)) {
759
763
  throw ErrorInvalidEscrowAddressProvided;
760
764
  }
@@ -766,10 +770,9 @@ export class EscrowClient extends BaseEthersClient {
766
770
  try {
767
771
  const escrowContract = this.getEscrowContract(escrowAddress);
768
772
 
769
- const tx = await escrowContract.cancel({
770
- ...(await this.gasPriceOptions()),
771
- });
772
- const transactionReceipt = await tx.wait();
773
+ const transactionReceipt = await (
774
+ await escrowContract.cancel(txOptions)
775
+ ).wait();
773
776
 
774
777
  let amountTransferred: BigNumber | undefined = undefined;
775
778
  const tokenAddress = await escrowContract.token();
@@ -810,6 +813,7 @@ export class EscrowClient extends BaseEthersClient {
810
813
  * This function cancels the specified escrow, sends the balance to the canceler and selfdestructs the escrow contract.
811
814
  *
812
815
  * @param {string} escrowAddress Address of the escrow.
816
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
813
817
  * @returns Returns void if successful. Throws error if any.
814
818
  *
815
819
  *
@@ -832,7 +836,7 @@ export class EscrowClient extends BaseEthersClient {
832
836
  * ```
833
837
  */
834
838
  @requiresSigner
835
- async abort(escrowAddress: string): Promise<void> {
839
+ async abort(escrowAddress: string, txOptions: Overrides = {}): Promise<void> {
836
840
  if (!ethers.utils.isAddress(escrowAddress)) {
837
841
  throw ErrorInvalidEscrowAddressProvided;
838
842
  }
@@ -844,9 +848,7 @@ export class EscrowClient extends BaseEthersClient {
844
848
  try {
845
849
  const escrowContract = this.getEscrowContract(escrowAddress);
846
850
 
847
- await escrowContract.abort({
848
- ...(await this.gasPriceOptions()),
849
- });
851
+ await (await escrowContract.abort(txOptions)).wait();
850
852
  return;
851
853
  } catch (e) {
852
854
  return throwError(e);
@@ -858,6 +860,7 @@ export class EscrowClient extends BaseEthersClient {
858
860
  *
859
861
  * @param {string} escrowAddress Address of the escrow.
860
862
  * @param {string[]} trustedHandlers Array of addresses of trusted handlers to add.
863
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
861
864
  * @returns Returns void if successful. Throws error if any.
862
865
  *
863
866
  *
@@ -883,7 +886,8 @@ export class EscrowClient extends BaseEthersClient {
883
886
  @requiresSigner
884
887
  async addTrustedHandlers(
885
888
  escrowAddress: string,
886
- trustedHandlers: string[]
889
+ trustedHandlers: string[],
890
+ txOptions: Overrides = {}
887
891
  ): Promise<void> {
888
892
  if (!ethers.utils.isAddress(escrowAddress)) {
889
893
  throw ErrorInvalidEscrowAddressProvided;
@@ -906,9 +910,9 @@ export class EscrowClient extends BaseEthersClient {
906
910
  try {
907
911
  const escrowContract = this.getEscrowContract(escrowAddress);
908
912
 
909
- await escrowContract.addTrustedHandlers(trustedHandlers, {
910
- ...(await this.gasPriceOptions()),
911
- });
913
+ await (
914
+ await escrowContract.addTrustedHandlers(trustedHandlers, txOptions)
915
+ ).wait();
912
916
  return;
913
917
  } catch (e) {
914
918
  return throwError(e);
package/src/kvstore.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  KVStore,
5
5
  KVStore__factory,
6
6
  } from '@human-protocol/core/typechain-types';
7
- import { Signer, ethers } from 'ethers';
7
+ import { Overrides, Signer, ethers } from 'ethers';
8
8
  import { BaseEthersClient } from './base';
9
9
  import { NETWORKS } from './constants';
10
10
  import { requiresSigner } from './decorators';
@@ -99,14 +99,9 @@ export class KVStoreClient extends BaseEthersClient {
99
99
  *
100
100
  * @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
101
101
  * @param {NetworkData} network - The network information required to connect to the KVStore contract
102
- * @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
103
102
  */
104
- constructor(
105
- signerOrProvider: Signer | Provider,
106
- networkData: NetworkData,
107
- gasPriceMultiplier?: number
108
- ) {
109
- super(signerOrProvider, networkData, gasPriceMultiplier);
103
+ constructor(signerOrProvider: Signer | Provider, networkData: NetworkData) {
104
+ super(signerOrProvider, networkData);
110
105
 
111
106
  this.contract = KVStore__factory.connect(
112
107
  networkData.kvstoreAddress,
@@ -118,16 +113,12 @@ export class KVStoreClient extends BaseEthersClient {
118
113
  * Creates an instance of KVStoreClient from a Signer or Provider.
119
114
  *
120
115
  * @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
121
- * @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
122
116
  *
123
117
  * @returns {Promise<KVStoreClient>} - An instance of KVStoreClient
124
118
  * @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
125
119
  * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
126
120
  */
127
- public static async build(
128
- signerOrProvider: Signer | Provider,
129
- gasPriceMultiplier?: number
130
- ) {
121
+ public static async build(signerOrProvider: Signer | Provider) {
131
122
  let network: Network;
132
123
  if (Signer.isSigner(signerOrProvider)) {
133
124
  if (!signerOrProvider.provider) {
@@ -146,7 +137,7 @@ export class KVStoreClient extends BaseEthersClient {
146
137
  throw ErrorUnsupportedChainID;
147
138
  }
148
139
 
149
- return new KVStoreClient(signerOrProvider, networkData, gasPriceMultiplier);
140
+ return new KVStoreClient(signerOrProvider, networkData);
150
141
  }
151
142
 
152
143
  /**
@@ -154,6 +145,7 @@ export class KVStoreClient extends BaseEthersClient {
154
145
  *
155
146
  * @param {string} key Key of the key-value pair
156
147
  * @param {string} value Value of the key-value pair
148
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
157
149
  * @returns Returns void if successful. Throws error if any.
158
150
  *
159
151
  *
@@ -176,13 +168,15 @@ export class KVStoreClient extends BaseEthersClient {
176
168
  * ```
177
169
  */
178
170
  @requiresSigner
179
- public async set(key: string, value: string): Promise<void> {
171
+ public async set(
172
+ key: string,
173
+ value: string,
174
+ txOptions: Overrides = {}
175
+ ): Promise<void> {
180
176
  if (!Signer.isSigner(this.signerOrProvider)) throw ErrorSigner;
181
177
  if (key === '') throw ErrorKVStoreEmptyKey;
182
178
  try {
183
- await this.contract?.set(key, value, {
184
- ...(await this.gasPriceOptions()),
185
- });
179
+ await (await this.contract.set(key, value, txOptions)).wait();
186
180
  } catch (e) {
187
181
  if (e instanceof Error) throw Error(`Failed to set value: ${e.message}`);
188
182
  }
@@ -193,6 +187,7 @@ export class KVStoreClient extends BaseEthersClient {
193
187
  *
194
188
  * @param {string[]} keys Array of keys (keys and value must have the same order)
195
189
  * @param {string[]} values Array of values
190
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
196
191
  * @returns Returns void if successful. Throws error if any.
197
192
  *
198
193
  *
@@ -217,15 +212,17 @@ export class KVStoreClient extends BaseEthersClient {
217
212
  * ```
218
213
  */
219
214
  @requiresSigner
220
- public async setBulk(keys: string[], values: string[]): Promise<void> {
215
+ public async setBulk(
216
+ keys: string[],
217
+ values: string[],
218
+ txOptions: Overrides = {}
219
+ ): Promise<void> {
221
220
  if (!Signer.isSigner(this.signerOrProvider)) throw ErrorSigner;
222
221
  if (keys.length !== values.length) throw ErrorKVStoreArrayLength;
223
222
  if (keys.includes('')) throw ErrorKVStoreEmptyKey;
224
223
 
225
224
  try {
226
- await this.contract?.setBulk(keys, values, {
227
- ...(await this.gasPriceOptions()),
228
- });
225
+ await (await this.contract.setBulk(keys, values, txOptions)).wait();
229
226
  } catch (e) {
230
227
  if (e instanceof Error)
231
228
  throw Error(`Failed to set bulk values: ${e.message}`);
@@ -237,6 +234,7 @@ export class KVStoreClient extends BaseEthersClient {
237
234
  *
238
235
  * @param {string} url URL to set
239
236
  * @param {string | undefined} urlKey Configurable URL key. `url` by default.
237
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
240
238
  * @returns Returns void if successful. Throws error if any.
241
239
  *
242
240
  *
@@ -258,7 +256,11 @@ export class KVStoreClient extends BaseEthersClient {
258
256
  * ```
259
257
  */
260
258
  @requiresSigner
261
- public async setURL(url: string, urlKey = 'url'): Promise<void> {
259
+ public async setURL(
260
+ url: string,
261
+ urlKey = 'url',
262
+ txOptions: Overrides = {}
263
+ ): Promise<void> {
262
264
  if (!Signer.isSigner(this.signerOrProvider)) {
263
265
  throw ErrorSigner;
264
266
  }
@@ -275,9 +277,13 @@ export class KVStoreClient extends BaseEthersClient {
275
277
  const hashKey = urlKey + 'Hash';
276
278
 
277
279
  try {
278
- await this.contract.setBulk([urlKey, hashKey], [url, contentHash], {
279
- ...(await this.gasPriceOptions()),
280
- });
280
+ await (
281
+ await this.contract.setBulk(
282
+ [urlKey, hashKey],
283
+ [url, contentHash],
284
+ txOptions
285
+ )
286
+ ).wait();
281
287
  } catch (e) {
282
288
  if (e instanceof Error)
283
289
  throw Error(`Failed to set URL and hash: ${e.message}`);