@human-protocol/sdk 4.2.0 → 4.4.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 CHANGED
@@ -1,4 +1,4 @@
1
- import { ContractRunner } from 'ethers';
1
+ import { ContractRunner, Overrides } from 'ethers';
2
2
  import { NetworkData } from './types';
3
3
  /**
4
4
  * ## Introduction
@@ -16,5 +16,14 @@ export declare abstract class BaseEthersClient {
16
16
  * @param {NetworkData} networkData The network information required to connect to the contracts
17
17
  */
18
18
  constructor(runner: ContractRunner, networkData: NetworkData);
19
+ /**
20
+ * Internal helper to enrich transaction overrides with network specific defaults.
21
+ *
22
+ * Aurora networks use a fixed gas price. We always override any user provided
23
+ * gasPrice with the canonical DEFAULT_AURORA_GAS_PRICE to avoid mismatches
24
+ * or tx failures due to an unexpected value. For other networks the user
25
+ * supplied fee parameters are left untouched.
26
+ */
27
+ protected applyTxDefaults(txOptions?: Overrides): Overrides;
19
28
  }
20
29
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;GAKG;AACH,8BAAsB,gBAAgB;IACpC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;CAI7D"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;GAKG;AACH,8BAAsB,gBAAgB;IACpC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAK5D;;;;;;;OAOG;IACH,SAAS,CAAC,eAAe,CAAC,SAAS,GAAE,SAAc,GAAG,SAAS;CAWhE"}
package/dist/base.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseEthersClient = void 0;
4
+ const enums_1 = require("./enums");
5
+ const constants_1 = require("./constants");
4
6
  /**
5
7
  * ## Introduction
6
8
  *
@@ -18,5 +20,24 @@ class BaseEthersClient {
18
20
  this.networkData = networkData;
19
21
  this.runner = runner;
20
22
  }
23
+ /**
24
+ * Internal helper to enrich transaction overrides with network specific defaults.
25
+ *
26
+ * Aurora networks use a fixed gas price. We always override any user provided
27
+ * gasPrice with the canonical DEFAULT_AURORA_GAS_PRICE to avoid mismatches
28
+ * or tx failures due to an unexpected value. For other networks the user
29
+ * supplied fee parameters are left untouched.
30
+ */
31
+ applyTxDefaults(txOptions = {}) {
32
+ if (this.networkData.chainId === enums_1.ChainId.AURORA_TESTNET) {
33
+ return {
34
+ ...txOptions,
35
+ gasPrice: constants_1.DEFAULT_AURORA_GAS_PRICE,
36
+ maxFeePerGas: undefined,
37
+ maxPriorityFeePerGas: undefined,
38
+ };
39
+ }
40
+ return txOptions;
41
+ }
21
42
  }
22
43
  exports.BaseEthersClient = BaseEthersClient;
@@ -5,6 +5,7 @@ export declare const DEFAULT_ENDPOINT = "localhost";
5
5
  export declare const DEFAULT_REGION = "eu";
6
6
  export declare const DEFAULT_PORT = 9000;
7
7
  export declare const DEFAULT_USE_SSL = false;
8
+ export declare const DEFAULT_AURORA_GAS_PRICE: bigint;
8
9
  export declare enum HttpStatus {
9
10
  OK = 200,
10
11
  CREATED = 201,
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,oBAAY,UAAU;IACpB,EAAE,MAAM;IACR,OAAO,MAAM;IACb,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,gBAAgB,MAAM;IACtB,SAAS,MAAM;IACf,SAAS,MAAM;IACf,qBAAqB,MAAM;CAC5B;AAED,eAAO,MAAM,QAAQ,EAAE;KACpB,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,WAAW;CA0HnC,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAavB,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;CAKhB,CAAC;AAEF,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AAEjE,eAAO,MAAM,4BAA4B,KAAK,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,eAAO,MAAM,wBAAwB,QAAoC,CAAC;AAE1E,oBAAY,UAAU;IACpB,EAAE,MAAM;IACR,OAAO,MAAM;IACb,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,gBAAgB,MAAM;IACtB,SAAS,MAAM;IACf,SAAS,MAAM;IACf,qBAAqB,MAAM;CAC5B;AAED,eAAO,MAAM,QAAQ,EAAE;KACpB,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,WAAW;CA0HnC,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAavB,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;CAKhB,CAAC;AAEF,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AAEjE,eAAO,MAAM,4BAA4B,KAAK,CAAC"}
package/dist/constants.js CHANGED
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ESCROW_BULK_PAYOUT_MAX_ITEMS = exports.SUBGRAPH_API_KEY_PLACEHOLDER = exports.Role = exports.KVStoreKeys = exports.NETWORKS = exports.HttpStatus = exports.DEFAULT_USE_SSL = exports.DEFAULT_PORT = exports.DEFAULT_REGION = exports.DEFAULT_ENDPOINT = exports.DEFAULT_PUBLIC_BUCKET = void 0;
3
+ exports.ESCROW_BULK_PAYOUT_MAX_ITEMS = exports.SUBGRAPH_API_KEY_PLACEHOLDER = exports.Role = exports.KVStoreKeys = exports.NETWORKS = exports.HttpStatus = exports.DEFAULT_AURORA_GAS_PRICE = exports.DEFAULT_USE_SSL = exports.DEFAULT_PORT = exports.DEFAULT_REGION = exports.DEFAULT_ENDPOINT = exports.DEFAULT_PUBLIC_BUCKET = void 0;
4
+ const ethers_1 = require("ethers");
4
5
  const enums_1 = require("./enums");
5
6
  exports.DEFAULT_PUBLIC_BUCKET = 'escrow-public-results';
6
7
  exports.DEFAULT_ENDPOINT = 'localhost';
7
8
  exports.DEFAULT_REGION = 'eu';
8
9
  exports.DEFAULT_PORT = 9000;
9
10
  exports.DEFAULT_USE_SSL = false;
11
+ exports.DEFAULT_AURORA_GAS_PRICE = ethers_1.ethers.parseUnits('0.07', 'gwei');
10
12
  var HttpStatus;
11
13
  (function (HttpStatus) {
12
14
  HttpStatus[HttpStatus["OK"] = 200] = "OK";
package/dist/escrow.d.ts CHANGED
@@ -849,7 +849,7 @@ export declare class EscrowUtils {
849
849
  *
850
850
  * @param {ChainId} chainId Network in which the escrow has been deployed
851
851
  * @param {string} escrowAddress Address of the escrow
852
- * @returns {IEscrow} Escrow data
852
+ * @returns {Promise<IEscrow | null>} - Escrow data or null if not found.
853
853
  *
854
854
  * **Code example**
855
855
  *
@@ -859,7 +859,7 @@ export declare class EscrowUtils {
859
859
  * const escrow = new EscrowUtils.getEscrow(ChainId.POLYGON_AMOY, "0x1234567890123456789012345678901234567890");
860
860
  * ```
861
861
  */
862
- static getEscrow(chainId: ChainId, escrowAddress: string): Promise<IEscrow>;
862
+ static getEscrow(chainId: ChainId, escrowAddress: string): Promise<IEscrow | null>;
863
863
  /**
864
864
  * This function returns the status events for a given set of networks within an optional date range.
865
865
  *
@@ -1 +1 @@
1
- {"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAY,SAAS,EAAkB,MAAM,QAAQ,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AA0BlD,OAAO,EAML,WAAW,EACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,OAAO,EACP,aAAa,EACb,cAAc,EACd,aAAa,EACb,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,WAAW,EACX,wBAAwB,EACxB,MAAM,EACP,MAAM,SAAS,CAAC;AASjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,OAAO,CAAC,q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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuDG;WACiB,eAAe,CACjC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,WAAW,EAAE,CAAC;IA+DzB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;WACiB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAiCzE"}
package/dist/escrow.js CHANGED
@@ -180,7 +180,7 @@ class EscrowClient extends base_1.BaseEthersClient {
180
180
  }
181
181
  });
182
182
  try {
183
- const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, trustedHandlers, jobRequesterId, txOptions)).wait();
183
+ const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, trustedHandlers, jobRequesterId, this.applyTxDefaults(txOptions))).wait();
184
184
  const event = result?.logs?.find(({ topics }) => topics.includes(ethers_1.ethers.id('LaunchedV2(address,address,string)')))?.args;
185
185
  if (!event) {
186
186
  throw error_1.ErrorLaunchedEventIsNotEmitted;
@@ -263,7 +263,7 @@ class EscrowClient extends base_1.BaseEthersClient {
263
263
  }
264
264
  try {
265
265
  const escrowContract = this.getEscrowContract(escrowAddress);
266
- await (await escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash, txOptions)).wait();
266
+ await (await escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash, this.applyTxDefaults(txOptions))).wait();
267
267
  return;
268
268
  }
269
269
  catch (e) {
@@ -310,7 +310,7 @@ class EscrowClient extends base_1.BaseEthersClient {
310
310
  const escrowContract = this.getEscrowContract(escrowAddress);
311
311
  const tokenAddress = await escrowContract.token();
312
312
  const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.runner);
313
- await (await tokenContract.transfer(escrowAddress, amount, txOptions)).wait();
313
+ await (await tokenContract.transfer(escrowAddress, amount, this.applyTxDefaults(txOptions))).wait();
314
314
  return;
315
315
  }
316
316
  catch (e) {
@@ -363,7 +363,7 @@ class EscrowClient extends base_1.BaseEthersClient {
363
363
  }
364
364
  try {
365
365
  const escrowContract = this.getEscrowContract(escrowAddress);
366
- await (await escrowContract.storeResults(url, hash, txOptions)).wait();
366
+ await (await escrowContract.storeResults(url, hash, this.applyTxDefaults(txOptions))).wait();
367
367
  return;
368
368
  }
369
369
  catch (e) {
@@ -405,7 +405,7 @@ class EscrowClient extends base_1.BaseEthersClient {
405
405
  }
406
406
  try {
407
407
  const escrowContract = this.getEscrowContract(escrowAddress);
408
- await (await escrowContract.complete(txOptions)).wait();
408
+ await (await escrowContract.complete(this.applyTxDefaults(txOptions))).wait();
409
409
  return;
410
410
  }
411
411
  catch (e) {
@@ -455,10 +455,10 @@ class EscrowClient extends base_1.BaseEthersClient {
455
455
  try {
456
456
  const escrowContract = this.getEscrowContract(escrowAddress);
457
457
  if (forceComplete) {
458
- await (await escrowContract['bulkPayOut(address[],uint256[],string,string,uint256,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, txId, forceComplete, txOptions)).wait();
458
+ await (await escrowContract['bulkPayOut(address[],uint256[],string,string,uint256,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, txId, forceComplete, this.applyTxDefaults(txOptions))).wait();
459
459
  }
460
460
  else {
461
- await (await escrowContract['bulkPayOut(address[],uint256[],string,string,uint256)'](recipients, amounts, finalResultsUrl, finalResultsHash, txId, txOptions)).wait();
461
+ await (await escrowContract['bulkPayOut(address[],uint256[],string,string,uint256)'](recipients, amounts, finalResultsUrl, finalResultsHash, txId, this.applyTxDefaults(txOptions))).wait();
462
462
  }
463
463
  return;
464
464
  }
@@ -501,7 +501,7 @@ class EscrowClient extends base_1.BaseEthersClient {
501
501
  }
502
502
  try {
503
503
  const escrowContract = this.getEscrowContract(escrowAddress);
504
- const transactionReceipt = await (await escrowContract.cancel(txOptions)).wait();
504
+ const transactionReceipt = await (await escrowContract.cancel(this.applyTxDefaults(txOptions))).wait();
505
505
  let amountTransferred = undefined;
506
506
  const tokenAddress = await escrowContract.token();
507
507
  const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.runner);
@@ -577,7 +577,7 @@ class EscrowClient extends base_1.BaseEthersClient {
577
577
  }
578
578
  try {
579
579
  const escrowContract = this.getEscrowContract(escrowAddress);
580
- await (await escrowContract.addTrustedHandlers(trustedHandlers, txOptions)).wait();
580
+ await (await escrowContract.addTrustedHandlers(trustedHandlers, this.applyTxDefaults(txOptions))).wait();
581
581
  return;
582
582
  }
583
583
  catch (e) {
@@ -626,7 +626,7 @@ class EscrowClient extends base_1.BaseEthersClient {
626
626
  }
627
627
  try {
628
628
  const escrowContract = this.getEscrowContract(escrowAddress);
629
- const transactionReceipt = await (await escrowContract.withdraw(tokenAddress, txOptions)).wait();
629
+ const transactionReceipt = await (await escrowContract.withdraw(tokenAddress, this.applyTxDefaults(txOptions))).wait();
630
630
  let amountTransferred = undefined;
631
631
  const tokenContract = typechain_types_1.ERC20__factory.connect(tokenAddress, this.runner);
632
632
  if (transactionReceipt)
@@ -698,6 +698,7 @@ class EscrowClient extends base_1.BaseEthersClient {
698
698
  * (await signer.sendTransaction(rawTransaction)).wait();
699
699
  */
700
700
  async createBulkPayoutTransaction(escrowAddress, recipients, amounts, finalResultsUrl, finalResultsHash, txId, forceComplete = false, txOptions = {}) {
701
+ txOptions = this.applyTxDefaults(txOptions);
701
702
  await this.ensureCorrectBulkPayoutInput(escrowAddress, recipients, amounts, finalResultsUrl, finalResultsHash);
702
703
  const signer = this.runner;
703
704
  try {
@@ -1481,7 +1482,7 @@ class EscrowUtils {
1481
1482
  *
1482
1483
  * @param {ChainId} chainId Network in which the escrow has been deployed
1483
1484
  * @param {string} escrowAddress Address of the escrow
1484
- * @returns {IEscrow} Escrow data
1485
+ * @returns {Promise<IEscrow | null>} - Escrow data or null if not found.
1485
1486
  *
1486
1487
  * **Code example**
1487
1488
  *
@@ -1500,6 +1501,7 @@ class EscrowUtils {
1500
1501
  throw error_1.ErrorInvalidAddress;
1501
1502
  }
1502
1503
  const { escrow } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_ESCROW_BY_ADDRESS_QUERY)(), { escrowAddress: escrowAddress.toLowerCase() });
1504
+ escrow.chainId = networkData.chainId;
1503
1505
  return escrow || null;
1504
1506
  }
1505
1507
  /**
package/dist/index.d.ts CHANGED
@@ -11,5 +11,6 @@ export * from './constants';
11
11
  export * from './types';
12
12
  export * from './enums';
13
13
  export * from './interfaces';
14
+ export { EthereumError, InvalidArgumentError, ReplacementUnderpriced, NumericFault, NonceExpired, TransactionReplaced, ContractExecutionError, InvalidEthereumAddressError, InvalidKeyError, } from './error';
14
15
  export { StakingClient, StorageClient, KVStoreClient, KVStoreUtils, EscrowClient, EscrowUtils, StatisticsClient, Encryption, EncryptionUtils, OperatorUtils, TransactionUtils, WorkerUtils, };
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,CAAC"}
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.WorkerUtils = exports.TransactionUtils = exports.OperatorUtils = exports.EncryptionUtils = exports.Encryption = exports.StatisticsClient = exports.EscrowUtils = exports.EscrowClient = exports.KVStoreUtils = exports.KVStoreClient = exports.StorageClient = exports.StakingClient = void 0;
17
+ exports.WorkerUtils = exports.TransactionUtils = exports.OperatorUtils = exports.EncryptionUtils = exports.Encryption = exports.StatisticsClient = exports.EscrowUtils = exports.EscrowClient = exports.KVStoreUtils = exports.KVStoreClient = exports.StorageClient = exports.StakingClient = exports.InvalidKeyError = exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = exports.NonceExpired = exports.NumericFault = exports.ReplacementUnderpriced = exports.InvalidArgumentError = exports.EthereumError = void 0;
18
18
  const staking_1 = require("./staking");
19
19
  Object.defineProperty(exports, "StakingClient", { enumerable: true, get: function () { return staking_1.StakingClient; } });
20
20
  const storage_1 = require("./storage");
@@ -40,3 +40,13 @@ __exportStar(require("./constants"), exports);
40
40
  __exportStar(require("./types"), exports);
41
41
  __exportStar(require("./enums"), exports);
42
42
  __exportStar(require("./interfaces"), exports);
43
+ var error_1 = require("./error");
44
+ Object.defineProperty(exports, "EthereumError", { enumerable: true, get: function () { return error_1.EthereumError; } });
45
+ Object.defineProperty(exports, "InvalidArgumentError", { enumerable: true, get: function () { return error_1.InvalidArgumentError; } });
46
+ Object.defineProperty(exports, "ReplacementUnderpriced", { enumerable: true, get: function () { return error_1.ReplacementUnderpriced; } });
47
+ Object.defineProperty(exports, "NumericFault", { enumerable: true, get: function () { return error_1.NumericFault; } });
48
+ Object.defineProperty(exports, "NonceExpired", { enumerable: true, get: function () { return error_1.NonceExpired; } });
49
+ Object.defineProperty(exports, "TransactionReplaced", { enumerable: true, get: function () { return error_1.TransactionReplaced; } });
50
+ Object.defineProperty(exports, "ContractExecutionError", { enumerable: true, get: function () { return error_1.ContractExecutionError; } });
51
+ Object.defineProperty(exports, "InvalidEthereumAddressError", { enumerable: true, get: function () { return error_1.InvalidEthereumAddressError; } });
52
+ Object.defineProperty(exports, "InvalidKeyError", { enumerable: true, get: function () { return error_1.InvalidKeyError; } });
package/dist/kvstore.d.ts CHANGED
@@ -176,6 +176,31 @@ export declare class KVStoreClient extends BaseEthersClient {
176
176
  * ```
177
177
  */
178
178
  setFileUrlAndHash(url: string, urlKey?: string, txOptions?: Overrides): Promise<void>;
179
+ /**
180
+ * Gets the value of a key-value pair in the contract.
181
+ *
182
+ * @param {string} address Address from which to get the key value.
183
+ * @param {string} key Key to obtain the value.
184
+ * @returns {string} Value of the key.
185
+ *
186
+ *
187
+ * **Code example**
188
+ *
189
+ * > Need to have available stake.
190
+ *
191
+ * ```ts
192
+ * import { providers } from 'ethers';
193
+ * import { KVStoreClient } from '@human-protocol/sdk';
194
+ *
195
+ * const rpcUrl = 'YOUR_RPC_URL';
196
+ *
197
+ * const provider = new providers.JsonRpcProvider(rpcUrl);
198
+ * const kvstoreClient = await KVStoreClient.build(provider);
199
+ *
200
+ * const value = await kvstoreClient.get('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'Role');
201
+ * ```
202
+ */
203
+ get(address: string, key: string): Promise<string>;
179
204
  }
180
205
  /**
181
206
  * ## Introduction
@@ -1 +1 @@
1
- {"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAYlC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC;;;;;;;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GAAG,EAAE,MAAM,EACX,MAAM,SAAQ,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAuBhB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAYhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,YAAY;IACvB;;;;;;;;;;;;;;;;;OAiBG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,QAAQ,EAAE,CAAC;IAyBtB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;WACiB,GAAG,CACrB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC;IAuBlB;;;;;;;;;;;;;;;;;;;OAmBG;WACiB,uBAAuB,CACzC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,SAAQ,GACb,OAAO,CAAC,MAAM,CAAC;IAqClB;;;;;;;;;;;;;;;;;;OAkBG;WACiB,YAAY,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;CAenB"}
package/dist/kvstore.js CHANGED
@@ -154,7 +154,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
154
154
  if (key === '')
155
155
  throw error_1.ErrorKVStoreEmptyKey;
156
156
  try {
157
- await (await this.contract.set(key, value, txOptions)).wait();
157
+ await (await this.contract.set(key, value, this.applyTxDefaults(txOptions))).wait();
158
158
  }
159
159
  catch (e) {
160
160
  if (e instanceof Error)
@@ -196,7 +196,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
196
196
  if (keys.includes(''))
197
197
  throw error_1.ErrorKVStoreEmptyKey;
198
198
  try {
199
- await (await this.contract.setBulk(keys, values, txOptions)).wait();
199
+ await (await this.contract.setBulk(keys, values, this.applyTxDefaults(txOptions))).wait();
200
200
  }
201
201
  catch (e) {
202
202
  if (e instanceof Error)
@@ -237,13 +237,52 @@ class KVStoreClient extends base_1.BaseEthersClient {
237
237
  const contentHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(content));
238
238
  const hashKey = urlKey + '_hash';
239
239
  try {
240
- await (await this.contract.setBulk([urlKey, hashKey], [url, contentHash], txOptions)).wait();
240
+ await (await this.contract.setBulk([urlKey, hashKey], [url, contentHash], this.applyTxDefaults(txOptions))).wait();
241
241
  }
242
242
  catch (e) {
243
243
  if (e instanceof Error)
244
244
  throw Error(`Failed to set URL and hash: ${e.message}`);
245
245
  }
246
246
  }
247
+ /**
248
+ * Gets the value of a key-value pair in the contract.
249
+ *
250
+ * @param {string} address Address from which to get the key value.
251
+ * @param {string} key Key to obtain the value.
252
+ * @returns {string} Value of the key.
253
+ *
254
+ *
255
+ * **Code example**
256
+ *
257
+ * > Need to have available stake.
258
+ *
259
+ * ```ts
260
+ * import { providers } from 'ethers';
261
+ * import { KVStoreClient } from '@human-protocol/sdk';
262
+ *
263
+ * const rpcUrl = 'YOUR_RPC_URL';
264
+ *
265
+ * const provider = new providers.JsonRpcProvider(rpcUrl);
266
+ * const kvstoreClient = await KVStoreClient.build(provider);
267
+ *
268
+ * const value = await kvstoreClient.get('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'Role');
269
+ * ```
270
+ */
271
+ async get(address, key) {
272
+ if (key === '')
273
+ throw error_1.ErrorKVStoreEmptyKey;
274
+ if (!ethers_1.ethers.isAddress(address))
275
+ throw error_1.ErrorInvalidAddress;
276
+ try {
277
+ const result = await this.contract?.get(address, key);
278
+ return result;
279
+ }
280
+ catch (e) {
281
+ if (e instanceof Error)
282
+ throw Error(`Failed to get value: ${e.message}`);
283
+ return e;
284
+ }
285
+ }
247
286
  }
248
287
  exports.KVStoreClient = KVStoreClient;
249
288
  __decorate([
@@ -6,7 +6,7 @@ export declare class OperatorUtils {
6
6
  *
7
7
  * @param {ChainId} chainId Network in which the operator is deployed
8
8
  * @param {string} address Operator address.
9
- * @returns {Promise<IOperator>} Returns the operator details.
9
+ * @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
10
10
  *
11
11
  * **Code example**
12
12
  *
@@ -16,7 +16,7 @@ export declare class OperatorUtils {
16
16
  * const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
17
17
  * ```
18
18
  */
19
- static getOperator(chainId: ChainId, address: string): Promise<IOperator>;
19
+ static getOperator(chainId: ChainId, address: string): Promise<IOperator | null>;
20
20
  /**
21
21
  * This function returns all the operator details of the protocol.
22
22
  *
@@ -1 +1 @@
1
- {"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EAET,gBAAgB,EAEhB,OAAO,EACR,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAGlD,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;OAcG;WACiB,WAAW,CAC7B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC;IA8CrB;;;;;;;;;;;;;;;;OAgBG;WACiB,YAAY,CAC9B,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,SAAS,EAAE,CAAC;IA+DvB;;;;;;;;;;;;;;;OAeG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,EAAE,CAAC;IAmCvB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,EAAE,CAAC;CAyBtB"}
1
+ {"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EAET,gBAAgB,EAEhB,OAAO,EACR,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAGlD,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;OAcG;WACiB,WAAW,CAC7B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IA8C5B;;;;;;;;;;;;;;;;OAgBG;WACiB,YAAY,CAC9B,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,SAAS,EAAE,CAAC;IA+DvB;;;;;;;;;;;;;;;OAeG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,EAAE,CAAC;IAmCvB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,EAAE,CAAC;CAyBtB"}
package/dist/operator.js CHANGED
@@ -19,7 +19,7 @@ class OperatorUtils {
19
19
  *
20
20
  * @param {ChainId} chainId Network in which the operator is deployed
21
21
  * @param {string} address Operator address.
22
- * @returns {Promise<IOperator>} Returns the operator details.
22
+ * @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
23
23
  *
24
24
  * **Code example**
25
25
  *
@@ -41,7 +41,7 @@ class OperatorUtils {
41
41
  address: address.toLowerCase(),
42
42
  });
43
43
  if (!operator) {
44
- return operator || null;
44
+ return null;
45
45
  }
46
46
  let jobTypes = [];
47
47
  let reputationNetworks = [];
@@ -1 +1 @@
1
- {"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP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S,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB5E;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IAEU,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAsBhB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,QAAQ,CAAC,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/D;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAoChB;;;;;;;;;;;;;;;;;;;OAmBG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAiCvE"}
package/dist/staking.js CHANGED
@@ -165,7 +165,7 @@ class StakingClient extends base_1.BaseEthersClient {
165
165
  throw error_1.ErrorInvalidStakingValueSign;
166
166
  }
167
167
  try {
168
- await (await this.tokenContract.approve(await this.stakingContract.getAddress(), amount, txOptions)).wait();
168
+ await (await this.tokenContract.approve(await this.stakingContract.getAddress(), amount, this.applyTxDefaults(txOptions))).wait();
169
169
  return;
170
170
  }
171
171
  catch (e) {
@@ -207,7 +207,7 @@ class StakingClient extends base_1.BaseEthersClient {
207
207
  throw error_1.ErrorInvalidStakingValueSign;
208
208
  }
209
209
  try {
210
- await (await this.stakingContract.stake(amount, txOptions)).wait();
210
+ await (await this.stakingContract.stake(amount, this.applyTxDefaults(txOptions))).wait();
211
211
  return;
212
212
  }
213
213
  catch (e) {
@@ -248,7 +248,7 @@ class StakingClient extends base_1.BaseEthersClient {
248
248
  throw error_1.ErrorInvalidStakingValueSign;
249
249
  }
250
250
  try {
251
- await (await this.stakingContract.unstake(amount, txOptions)).wait();
251
+ await (await this.stakingContract.unstake(amount, this.applyTxDefaults(txOptions))).wait();
252
252
  return;
253
253
  }
254
254
  catch (e) {
@@ -281,7 +281,7 @@ class StakingClient extends base_1.BaseEthersClient {
281
281
  */
282
282
  async withdraw(txOptions = {}) {
283
283
  try {
284
- await (await this.stakingContract.withdraw(txOptions)).wait();
284
+ await (await this.stakingContract.withdraw(this.applyTxDefaults(txOptions))).wait();
285
285
  return;
286
286
  }
287
287
  catch (e) {
@@ -330,7 +330,7 @@ class StakingClient extends base_1.BaseEthersClient {
330
330
  }
331
331
  await this.checkValidEscrow(escrowAddress);
332
332
  try {
333
- await (await this.stakingContract.slash(slasher, staker, escrowAddress, amount, txOptions)).wait();
333
+ await (await this.stakingContract.slash(slasher, staker, escrowAddress, amount, this.applyTxDefaults(txOptions))).wait();
334
334
  return;
335
335
  }
336
336
  catch (e) {
@@ -363,6 +363,7 @@ class StakingClient extends base_1.BaseEthersClient {
363
363
  }
364
364
  try {
365
365
  const stakerInfo = await this.stakingContract.stakes(stakerAddress);
366
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
366
367
  const currentBlock = await this.runner.provider.getBlockNumber();
367
368
  const tokensWithdrawable = stakerInfo.tokensLockedUntil !== 0n &&
368
369
  currentBlock >= stakerInfo.tokensLockedUntil
@@ -22,7 +22,7 @@ export declare class TransactionUtils {
22
22
  *
23
23
  * @param {ChainId} chainId The chain ID.
24
24
  * @param {string} hash The transaction hash.
25
- * @returns {Promise<ITransaction>} Returns the transaction details.
25
+ * @returns {Promise<ITransaction | null>} - Returns the transaction details or null if not found.
26
26
  *
27
27
  * **Code example**
28
28
  *
@@ -32,7 +32,7 @@ export declare class TransactionUtils {
32
32
  * const transaction = await TransactionUtils.getTransaction(ChainId.POLYGON, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
33
33
  * ```
34
34
  */
35
- static getTransaction(chainId: ChainId, hash: string): Promise<ITransaction>;
35
+ static getTransaction(chainId: ChainId, hash: string): Promise<ITransaction | null>;
36
36
  /**
37
37
  * This function returns all transaction details based on the provided filter.
38
38
  *
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAUlD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGjE,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC;IAmBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2DG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CA2C3B"}
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAUlD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGjE,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAmB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2DG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CA2C3B"}
@@ -34,7 +34,7 @@ class TransactionUtils {
34
34
  *
35
35
  * @param {ChainId} chainId The chain ID.
36
36
  * @param {string} hash The transaction hash.
37
- * @returns {Promise<ITransaction>} Returns the transaction details.
37
+ * @returns {Promise<ITransaction | null>} - Returns the transaction details or null if not found.
38
38
  *
39
39
  * **Code example**
40
40
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,GAAG,GAAG,UAgBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,YAOrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,OAO3C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,aAAa,WAAW,WAatD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,KAAG,MAE7C,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,GAAG,GAAG,UAgBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,OAMxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,OAO3C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,aAAa,WAAW,WAatD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,KAAG,MAE7C,CAAC"}
package/dist/utils.js CHANGED
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUnixTimestamp = exports.getSubgraphUrl = exports.isValidJson = exports.isValidUrl = exports.throwError = void 0;
4
4
  /* eslint-disable @typescript-eslint/no-explicit-any */
5
5
  const ethers_1 = require("ethers");
6
+ const validator_1 = require("validator");
7
+ const constants_1 = require("./constants");
6
8
  const enums_1 = require("./enums");
7
9
  const error_1 = require("./error");
8
- const constants_1 = require("./constants");
9
10
  /**
10
11
  * **Handle and throw the error.*
11
12
  *
@@ -43,13 +44,11 @@ exports.throwError = throwError;
43
44
  * @returns
44
45
  */
45
46
  const isValidUrl = (url) => {
46
- try {
47
- new URL(url);
48
- return true;
49
- }
50
- catch (err) {
51
- return false;
52
- }
47
+ return (0, validator_1.isURL)(url, {
48
+ require_protocol: true,
49
+ protocols: ['http', 'https'],
50
+ require_tld: false,
51
+ });
53
52
  };
54
53
  exports.isValidUrl = isValidUrl;
55
54
  /**
package/dist/worker.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare class WorkerUtils {
6
6
  *
7
7
  * @param {ChainId} chainId The chain ID.
8
8
  * @param {string} address The worker address.
9
- * @returns {Promise<IWorker>} Returns the worker details.
9
+ * @returns {Promise<IWorker | null>} - Returns the worker details or null if not found.
10
10
  *
11
11
  * **Code example**
12
12
  *
package/dist/worker.js CHANGED
@@ -17,7 +17,7 @@ class WorkerUtils {
17
17
  *
18
18
  * @param {ChainId} chainId The chain ID.
19
19
  * @param {string} address The worker address.
20
- * @returns {Promise<IWorker>} Returns the worker details.
20
+ * @returns {Promise<IWorker | null>} - Returns the worker details or null if not found.
21
21
  *
22
22
  * **Code example**
23
23
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@human-protocol/sdk",
3
3
  "description": "Human Protocol SDK",
4
- "version": "4.2.0",
4
+ "version": "4.4.0",
5
5
  "files": [
6
6
  "src",
7
7
  "dist"
@@ -11,13 +11,13 @@
11
11
  "scripts": {
12
12
  "clean": "tsc --build --clean && rm -rf ./dist",
13
13
  "clean:doc": "rm -rf ../../../../docs/sdk/typescript/",
14
- "build": "tsc --build",
14
+ "build": "yarn clean && tsc --build",
15
15
  "build:doc": "yarn clean:doc && typedoc --plugin typedoc-plugin-markdown --out ../../../../docs/sdk/typescript/",
16
- "prepublish": "yarn build",
17
16
  "test": "vitest -u",
18
17
  "lint": "eslint .",
19
18
  "lint:fix": "eslint . --fix",
20
- "format": "prettier --write '**/*.{ts,json}'"
19
+ "format": "prettier --write '**/*.{ts,json}'",
20
+ "prepack": "[ \"${SKIP_PREPACK:-}\" = \"true\" ] && exit 0 || yarn build"
21
21
  },
22
22
  "repository": {
23
23
  "url": "https://github.com/humanprotocol/human-protocol.git",
@@ -38,15 +38,16 @@
38
38
  ]
39
39
  },
40
40
  "dependencies": {
41
- "@human-protocol/core": "x",
41
+ "@human-protocol/core": "4.2.1",
42
42
  "axios": "^1.4.0",
43
- "ethers": "~6.13.5",
43
+ "ethers": "~6.15.0",
44
44
  "graphql": "^16.8.1",
45
45
  "graphql-request": "^6.1.0",
46
46
  "graphql-tag": "^2.12.6",
47
47
  "minio": "7.1.3",
48
48
  "openpgp": "^5.11.2",
49
49
  "secp256k1": "^5.0.1",
50
+ "validator": "^13.12.0",
50
51
  "vitest": "^3.0.9"
51
52
  },
52
53
  "devDependencies": {
package/src/base.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { ContractRunner } from 'ethers';
1
+ import { ContractRunner, Overrides } from 'ethers';
2
2
  import { NetworkData } from './types';
3
+ import { ChainId } from './enums';
4
+ import { DEFAULT_AURORA_GAS_PRICE } from './constants';
3
5
 
4
6
  /**
5
7
  * ## Introduction
@@ -21,4 +23,24 @@ export abstract class BaseEthersClient {
21
23
  this.networkData = networkData;
22
24
  this.runner = runner;
23
25
  }
26
+
27
+ /**
28
+ * Internal helper to enrich transaction overrides with network specific defaults.
29
+ *
30
+ * Aurora networks use a fixed gas price. We always override any user provided
31
+ * gasPrice with the canonical DEFAULT_AURORA_GAS_PRICE to avoid mismatches
32
+ * or tx failures due to an unexpected value. For other networks the user
33
+ * supplied fee parameters are left untouched.
34
+ */
35
+ protected applyTxDefaults(txOptions: Overrides = {}): Overrides {
36
+ if (this.networkData.chainId === ChainId.AURORA_TESTNET) {
37
+ return {
38
+ ...txOptions,
39
+ gasPrice: DEFAULT_AURORA_GAS_PRICE,
40
+ maxFeePerGas: undefined,
41
+ maxPriorityFeePerGas: undefined,
42
+ } as Overrides;
43
+ }
44
+ return txOptions;
45
+ }
24
46
  }
package/src/constants.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ethers } from 'ethers';
1
2
  import { ChainId } from './enums';
2
3
  import { NetworkData } from './types';
3
4
 
@@ -11,6 +12,8 @@ export const DEFAULT_PORT = 9000;
11
12
 
12
13
  export const DEFAULT_USE_SSL = false;
13
14
 
15
+ export const DEFAULT_AURORA_GAS_PRICE = ethers.parseUnits('0.07', 'gwei');
16
+
14
17
  export enum HttpStatus {
15
18
  OK = 200,
16
19
  CREATED = 201,
package/src/escrow.ts CHANGED
@@ -251,7 +251,7 @@ export class EscrowClient extends BaseEthersClient {
251
251
  tokenAddress,
252
252
  trustedHandlers,
253
253
  jobRequesterId,
254
- txOptions
254
+ this.applyTxDefaults(txOptions)
255
255
  )
256
256
  ).wait();
257
257
 
@@ -380,7 +380,7 @@ export class EscrowClient extends BaseEthersClient {
380
380
  exchangeOracleFee,
381
381
  manifest,
382
382
  manifestHash,
383
- txOptions
383
+ this.applyTxDefaults(txOptions)
384
384
  )
385
385
  ).wait();
386
386
 
@@ -444,7 +444,11 @@ export class EscrowClient extends BaseEthersClient {
444
444
  this.runner
445
445
  );
446
446
  await (
447
- await tokenContract.transfer(escrowAddress, amount, txOptions)
447
+ await tokenContract.transfer(
448
+ escrowAddress,
449
+ amount,
450
+ this.applyTxDefaults(txOptions)
451
+ )
448
452
  ).wait();
449
453
 
450
454
  return;
@@ -511,7 +515,13 @@ export class EscrowClient extends BaseEthersClient {
511
515
  try {
512
516
  const escrowContract = this.getEscrowContract(escrowAddress);
513
517
 
514
- await (await escrowContract.storeResults(url, hash, txOptions)).wait();
518
+ await (
519
+ await escrowContract.storeResults(
520
+ url,
521
+ hash,
522
+ this.applyTxDefaults(txOptions)
523
+ )
524
+ ).wait();
515
525
 
516
526
  return;
517
527
  } catch (e) {
@@ -561,7 +571,9 @@ export class EscrowClient extends BaseEthersClient {
561
571
  try {
562
572
  const escrowContract = this.getEscrowContract(escrowAddress);
563
573
 
564
- await (await escrowContract.complete(txOptions)).wait();
574
+ await (
575
+ await escrowContract.complete(this.applyTxDefaults(txOptions))
576
+ ).wait();
565
577
  return;
566
578
  } catch (e) {
567
579
  return throwError(e);
@@ -638,7 +650,7 @@ export class EscrowClient extends BaseEthersClient {
638
650
  finalResultsHash,
639
651
  txId,
640
652
  forceComplete,
641
- txOptions
653
+ this.applyTxDefaults(txOptions)
642
654
  )
643
655
  ).wait();
644
656
  } else {
@@ -651,7 +663,7 @@ export class EscrowClient extends BaseEthersClient {
651
663
  finalResultsUrl,
652
664
  finalResultsHash,
653
665
  txId,
654
- txOptions
666
+ this.applyTxDefaults(txOptions)
655
667
  )
656
668
  ).wait();
657
669
  }
@@ -704,7 +716,7 @@ export class EscrowClient extends BaseEthersClient {
704
716
  const escrowContract = this.getEscrowContract(escrowAddress);
705
717
 
706
718
  const transactionReceipt = await (
707
- await escrowContract.cancel(txOptions)
719
+ await escrowContract.cancel(this.applyTxDefaults(txOptions))
708
720
  ).wait();
709
721
 
710
722
  let amountTransferred: bigint | undefined = undefined;
@@ -801,7 +813,10 @@ export class EscrowClient extends BaseEthersClient {
801
813
  const escrowContract = this.getEscrowContract(escrowAddress);
802
814
 
803
815
  await (
804
- await escrowContract.addTrustedHandlers(trustedHandlers, txOptions)
816
+ await escrowContract.addTrustedHandlers(
817
+ trustedHandlers,
818
+ this.applyTxDefaults(txOptions)
819
+ )
805
820
  ).wait();
806
821
  return;
807
822
  } catch (e) {
@@ -861,7 +876,10 @@ export class EscrowClient extends BaseEthersClient {
861
876
  const escrowContract = this.getEscrowContract(escrowAddress);
862
877
 
863
878
  const transactionReceipt = await (
864
- await escrowContract.withdraw(tokenAddress, txOptions)
879
+ await escrowContract.withdraw(
880
+ tokenAddress,
881
+ this.applyTxDefaults(txOptions)
882
+ )
865
883
  ).wait();
866
884
 
867
885
  let amountTransferred: bigint | undefined = undefined;
@@ -953,6 +971,7 @@ export class EscrowClient extends BaseEthersClient {
953
971
  forceComplete = false,
954
972
  txOptions: Overrides = {}
955
973
  ): Promise<TransactionLikeWithNonce> {
974
+ txOptions = this.applyTxDefaults(txOptions);
956
975
  await this.ensureCorrectBulkPayoutInput(
957
976
  escrowAddress,
958
977
  recipients,
@@ -1764,7 +1783,7 @@ export class EscrowUtils {
1764
1783
  *
1765
1784
  * @param {ChainId} chainId Network in which the escrow has been deployed
1766
1785
  * @param {string} escrowAddress Address of the escrow
1767
- * @returns {IEscrow} Escrow data
1786
+ * @returns {Promise<IEscrow | null>} - Escrow data or null if not found.
1768
1787
  *
1769
1788
  * **Code example**
1770
1789
  *
@@ -1777,7 +1796,7 @@ export class EscrowUtils {
1777
1796
  public static async getEscrow(
1778
1797
  chainId: ChainId,
1779
1798
  escrowAddress: string
1780
- ): Promise<IEscrow> {
1799
+ ): Promise<IEscrow | null> {
1781
1800
  const networkData = NETWORKS[chainId];
1782
1801
 
1783
1802
  if (!networkData) {
@@ -1793,6 +1812,7 @@ export class EscrowUtils {
1793
1812
  GET_ESCROW_BY_ADDRESS_QUERY(),
1794
1813
  { escrowAddress: escrowAddress.toLowerCase() }
1795
1814
  );
1815
+ escrow.chainId = networkData.chainId;
1796
1816
 
1797
1817
  return escrow || null;
1798
1818
  }
package/src/index.ts CHANGED
@@ -13,6 +13,18 @@ export * from './types';
13
13
  export * from './enums';
14
14
  export * from './interfaces';
15
15
 
16
+ export {
17
+ EthereumError,
18
+ InvalidArgumentError,
19
+ ReplacementUnderpriced,
20
+ NumericFault,
21
+ NonceExpired,
22
+ TransactionReplaced,
23
+ ContractExecutionError,
24
+ InvalidEthereumAddressError,
25
+ InvalidKeyError,
26
+ } from './error';
27
+
16
28
  export {
17
29
  StakingClient,
18
30
  StorageClient,
package/src/kvstore.ts CHANGED
@@ -175,7 +175,9 @@ export class KVStoreClient extends BaseEthersClient {
175
175
  ): Promise<void> {
176
176
  if (key === '') throw ErrorKVStoreEmptyKey;
177
177
  try {
178
- await (await this.contract.set(key, value, txOptions)).wait();
178
+ await (
179
+ await this.contract.set(key, value, this.applyTxDefaults(txOptions))
180
+ ).wait();
179
181
  } catch (e) {
180
182
  if (e instanceof Error) throw Error(`Failed to set value: ${e.message}`);
181
183
  }
@@ -220,7 +222,13 @@ export class KVStoreClient extends BaseEthersClient {
220
222
  if (keys.includes('')) throw ErrorKVStoreEmptyKey;
221
223
 
222
224
  try {
223
- await (await this.contract.setBulk(keys, values, txOptions)).wait();
225
+ await (
226
+ await this.contract.setBulk(
227
+ keys,
228
+ values,
229
+ this.applyTxDefaults(txOptions)
230
+ )
231
+ ).wait();
224
232
  } catch (e) {
225
233
  if (e instanceof Error)
226
234
  throw Error(`Failed to set bulk values: ${e.message}`);
@@ -273,7 +281,7 @@ export class KVStoreClient extends BaseEthersClient {
273
281
  await this.contract.setBulk(
274
282
  [urlKey, hashKey],
275
283
  [url, contentHash],
276
- txOptions
284
+ this.applyTxDefaults(txOptions)
277
285
  )
278
286
  ).wait();
279
287
  } catch (e) {
@@ -281,6 +289,42 @@ export class KVStoreClient extends BaseEthersClient {
281
289
  throw Error(`Failed to set URL and hash: ${e.message}`);
282
290
  }
283
291
  }
292
+ /**
293
+ * Gets the value of a key-value pair in the contract.
294
+ *
295
+ * @param {string} address Address from which to get the key value.
296
+ * @param {string} key Key to obtain the value.
297
+ * @returns {string} Value of the key.
298
+ *
299
+ *
300
+ * **Code example**
301
+ *
302
+ * > Need to have available stake.
303
+ *
304
+ * ```ts
305
+ * import { providers } from 'ethers';
306
+ * import { KVStoreClient } from '@human-protocol/sdk';
307
+ *
308
+ * const rpcUrl = 'YOUR_RPC_URL';
309
+ *
310
+ * const provider = new providers.JsonRpcProvider(rpcUrl);
311
+ * const kvstoreClient = await KVStoreClient.build(provider);
312
+ *
313
+ * const value = await kvstoreClient.get('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'Role');
314
+ * ```
315
+ */
316
+ public async get(address: string, key: string): Promise<string> {
317
+ if (key === '') throw ErrorKVStoreEmptyKey;
318
+ if (!ethers.isAddress(address)) throw ErrorInvalidAddress;
319
+
320
+ try {
321
+ const result = await this.contract?.get(address, key);
322
+ return result;
323
+ } catch (e) {
324
+ if (e instanceof Error) throw Error(`Failed to get value: ${e.message}`);
325
+ return e;
326
+ }
327
+ }
284
328
  }
285
329
 
286
330
  /**
package/src/operator.ts CHANGED
@@ -30,7 +30,7 @@ export class OperatorUtils {
30
30
  *
31
31
  * @param {ChainId} chainId Network in which the operator is deployed
32
32
  * @param {string} address Operator address.
33
- * @returns {Promise<IOperator>} Returns the operator details.
33
+ * @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
34
34
  *
35
35
  * **Code example**
36
36
  *
@@ -43,7 +43,7 @@ export class OperatorUtils {
43
43
  public static async getOperator(
44
44
  chainId: ChainId,
45
45
  address: string
46
- ): Promise<IOperator> {
46
+ ): Promise<IOperator | null> {
47
47
  if (!ethers.isAddress(address)) {
48
48
  throw ErrorInvalidStakerAddressProvided;
49
49
  }
@@ -60,7 +60,7 @@ export class OperatorUtils {
60
60
  });
61
61
 
62
62
  if (!operator) {
63
- return (operator as IOperator) || null;
63
+ return null;
64
64
  }
65
65
 
66
66
  let jobTypes: string[] = [];
package/src/staking.ts CHANGED
@@ -207,7 +207,7 @@ export class StakingClient extends BaseEthersClient {
207
207
  await this.tokenContract.approve(
208
208
  await this.stakingContract.getAddress(),
209
209
  amount,
210
- txOptions
210
+ this.applyTxDefaults(txOptions)
211
211
  )
212
212
  ).wait();
213
213
  return;
@@ -254,7 +254,12 @@ export class StakingClient extends BaseEthersClient {
254
254
  }
255
255
 
256
256
  try {
257
- await (await this.stakingContract.stake(amount, txOptions)).wait();
257
+ await (
258
+ await this.stakingContract.stake(
259
+ amount,
260
+ this.applyTxDefaults(txOptions)
261
+ )
262
+ ).wait();
258
263
  return;
259
264
  } catch (e) {
260
265
  return throwError(e);
@@ -301,7 +306,12 @@ export class StakingClient extends BaseEthersClient {
301
306
  }
302
307
 
303
308
  try {
304
- await (await this.stakingContract.unstake(amount, txOptions)).wait();
309
+ await (
310
+ await this.stakingContract.unstake(
311
+ amount,
312
+ this.applyTxDefaults(txOptions)
313
+ )
314
+ ).wait();
305
315
  return;
306
316
  } catch (e) {
307
317
  return throwError(e);
@@ -335,7 +345,9 @@ export class StakingClient extends BaseEthersClient {
335
345
  @requiresSigner
336
346
  public async withdraw(txOptions: Overrides = {}): Promise<void> {
337
347
  try {
338
- await (await this.stakingContract.withdraw(txOptions)).wait();
348
+ await (
349
+ await this.stakingContract.withdraw(this.applyTxDefaults(txOptions))
350
+ ).wait();
339
351
  return;
340
352
  } catch (e) {
341
353
  return throwError(e);
@@ -402,7 +414,7 @@ export class StakingClient extends BaseEthersClient {
402
414
  staker,
403
415
  escrowAddress,
404
416
  amount,
405
- txOptions
417
+ this.applyTxDefaults(txOptions)
406
418
  )
407
419
  ).wait();
408
420
 
@@ -439,6 +451,7 @@ export class StakingClient extends BaseEthersClient {
439
451
 
440
452
  try {
441
453
  const stakerInfo = await this.stakingContract.stakes(stakerAddress);
454
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
442
455
  const currentBlock = await this.runner.provider!.getBlockNumber();
443
456
 
444
457
  const tokensWithdrawable =
@@ -37,7 +37,7 @@ export class TransactionUtils {
37
37
  *
38
38
  * @param {ChainId} chainId The chain ID.
39
39
  * @param {string} hash The transaction hash.
40
- * @returns {Promise<ITransaction>} Returns the transaction details.
40
+ * @returns {Promise<ITransaction | null>} - Returns the transaction details or null if not found.
41
41
  *
42
42
  * **Code example**
43
43
  *
@@ -50,7 +50,7 @@ export class TransactionUtils {
50
50
  public static async getTransaction(
51
51
  chainId: ChainId,
52
52
  hash: string
53
- ): Promise<ITransaction> {
53
+ ): Promise<ITransaction | null> {
54
54
  if (!ethers.isHexString(hash)) {
55
55
  throw ErrorInvalidHashProvided;
56
56
  }
package/src/utils.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { ethers } from 'ethers';
3
3
 
4
+ import { isURL } from 'validator';
5
+ import { SUBGRAPH_API_KEY_PLACEHOLDER } from './constants';
4
6
  import { ChainId } from './enums';
5
7
  import {
6
8
  ContractExecutionError,
@@ -13,7 +15,6 @@ import {
13
15
  WarnSubgraphApiKeyNotProvided,
14
16
  } from './error';
15
17
  import { NetworkData } from './types';
16
- import { SUBGRAPH_API_KEY_PLACEHOLDER } from './constants';
17
18
 
18
19
  /**
19
20
  * **Handle and throw the error.*
@@ -45,13 +46,12 @@ export const throwError = (e: any) => {
45
46
  * @param {string} url
46
47
  * @returns
47
48
  */
48
- export const isValidUrl = (url: string) => {
49
- try {
50
- new URL(url);
51
- return true;
52
- } catch (err) {
53
- return false;
54
- }
49
+ export const isValidUrl = (url: string): boolean => {
50
+ return isURL(url, {
51
+ require_protocol: true,
52
+ protocols: ['http', 'https'],
53
+ require_tld: false,
54
+ });
55
55
  };
56
56
 
57
57
  /**
package/src/worker.ts CHANGED
@@ -13,7 +13,7 @@ export class WorkerUtils {
13
13
  *
14
14
  * @param {ChainId} chainId The chain ID.
15
15
  * @param {string} address The worker address.
16
- * @returns {Promise<IWorker>} Returns the worker details.
16
+ * @returns {Promise<IWorker | null>} - Returns the worker details or null if not found.
17
17
  *
18
18
  * **Code example**
19
19
  *