@lifi/sdk 2.0.0-beta.15 → 2.0.0-beta.16

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.
@@ -90,10 +90,18 @@ class StepExecutionManager {
90
90
  transactionRequest.maxFeePerGas = customConfig.maxFeePerGas;
91
91
  }
92
92
  else {
93
- const estimatedGasLimit = await signer.estimateGas(transactionRequest);
94
- if (estimatedGasLimit) {
95
- transactionRequest.gasLimit = `${(BigInt(estimatedGasLimit.toString()) * 125n) / 100n}`;
93
+ try {
94
+ const estimatedGasLimit = await signer.estimateGas(transactionRequest);
95
+ if (estimatedGasLimit) {
96
+ transactionRequest.gasLimit = `${(BigInt(estimatedGasLimit.toString()) * 125n) / 100n}`;
97
+ }
98
+ // Fetch latest gasPrice from provider and use it
99
+ const gasPrice = await signer.getGasPrice();
100
+ if (gasPrice) {
101
+ transactionRequest.gasPrice = gasPrice;
102
+ }
96
103
  }
104
+ catch (error) { }
97
105
  }
98
106
  // Submit the transaction
99
107
  transaction = await signer.sendTransaction(transactionRequest);
@@ -30,13 +30,13 @@ var LifiErrorCode;
30
30
  LifiErrorCode[LifiErrorCode["BalanceError"] = 1013] = "BalanceError";
31
31
  LifiErrorCode[LifiErrorCode["AllowanceRequired"] = 1014] = "AllowanceRequired";
32
32
  LifiErrorCode[LifiErrorCode["InsufficientFunds"] = 1015] = "InsufficientFunds";
33
- })(LifiErrorCode = exports.LifiErrorCode || (exports.LifiErrorCode = {}));
33
+ })(LifiErrorCode || (exports.LifiErrorCode = LifiErrorCode = {}));
34
34
  var EthersErrorType;
35
35
  (function (EthersErrorType) {
36
36
  EthersErrorType["ActionRejected"] = "ACTION_REJECTED";
37
37
  EthersErrorType["CallExecption"] = "CALL_EXCEPTION";
38
38
  EthersErrorType["InsufficientFunds"] = "INSUFFICIENT_FUNDS";
39
- })(EthersErrorType = exports.EthersErrorType || (exports.EthersErrorType = {}));
39
+ })(EthersErrorType || (exports.EthersErrorType = EthersErrorType = {}));
40
40
  var EthersErrorMessage;
41
41
  (function (EthersErrorMessage) {
42
42
  EthersErrorMessage["ERC20Allowance"] = "ERC20: transfer amount exceeds allowance";
@@ -44,7 +44,7 @@ var EthersErrorMessage;
44
44
  EthersErrorMessage["OutOfGas"] = "out of gas";
45
45
  EthersErrorMessage["Underpriced"] = "underpriced";
46
46
  EthersErrorMessage["LowReplacementFee"] = "replacement fee too low";
47
- })(EthersErrorMessage = exports.EthersErrorMessage || (exports.EthersErrorMessage = {}));
47
+ })(EthersErrorMessage || (exports.EthersErrorMessage = EthersErrorMessage = {}));
48
48
  var ErrorMessage;
49
49
  (function (ErrorMessage) {
50
50
  ErrorMessage["UnknownError"] = "Unknown error occurred.";
@@ -52,7 +52,7 @@ var ErrorMessage;
52
52
  ErrorMessage["GasLimitLow"] = "Gas limit is too low.";
53
53
  ErrorMessage["TransactionUnderpriced"] = "Transaction is underpriced.";
54
54
  ErrorMessage["Default"] = "Something went wrong.";
55
- })(ErrorMessage = exports.ErrorMessage || (exports.ErrorMessage = {}));
55
+ })(ErrorMessage || (exports.ErrorMessage = ErrorMessage = {}));
56
56
  var MetaMaskRPCErrorCode;
57
57
  (function (MetaMaskRPCErrorCode) {
58
58
  MetaMaskRPCErrorCode[MetaMaskRPCErrorCode["invalidInput"] = -32000] = "invalidInput";
@@ -66,7 +66,7 @@ var MetaMaskRPCErrorCode;
66
66
  MetaMaskRPCErrorCode[MetaMaskRPCErrorCode["methodNotFound"] = -32601] = "methodNotFound";
67
67
  MetaMaskRPCErrorCode[MetaMaskRPCErrorCode["invalidParams"] = -32602] = "invalidParams";
68
68
  MetaMaskRPCErrorCode[MetaMaskRPCErrorCode["internal"] = -32603] = "internal";
69
- })(MetaMaskRPCErrorCode = exports.MetaMaskRPCErrorCode || (exports.MetaMaskRPCErrorCode = {}));
69
+ })(MetaMaskRPCErrorCode || (exports.MetaMaskRPCErrorCode = MetaMaskRPCErrorCode = {}));
70
70
  var MetaMaskProviderErrorCode;
71
71
  (function (MetaMaskProviderErrorCode) {
72
72
  MetaMaskProviderErrorCode[MetaMaskProviderErrorCode["userRejectedRequest"] = 4001] = "userRejectedRequest";
@@ -74,7 +74,7 @@ var MetaMaskProviderErrorCode;
74
74
  MetaMaskProviderErrorCode[MetaMaskProviderErrorCode["unsupportedMethod"] = 4200] = "unsupportedMethod";
75
75
  MetaMaskProviderErrorCode[MetaMaskProviderErrorCode["disconnected"] = 4900] = "disconnected";
76
76
  MetaMaskProviderErrorCode[MetaMaskProviderErrorCode["chainDisconnected"] = 4901] = "chainDisconnected";
77
- })(MetaMaskProviderErrorCode = exports.MetaMaskProviderErrorCode || (exports.MetaMaskProviderErrorCode = {}));
77
+ })(MetaMaskProviderErrorCode || (exports.MetaMaskProviderErrorCode = MetaMaskProviderErrorCode = {}));
78
78
  class LifiError extends Error {
79
79
  constructor(type, code, message, htmlMessage, stack) {
80
80
  super(message);
@@ -31,6 +31,16 @@ const handleErrorType = async (route, index, signer) => {
31
31
  route.steps[index].estimate.gasCosts?.forEach((gasCost) => (gasCost.limit = `${Math.round(Number(gasCost.limit) * 1.25)}`));
32
32
  }
33
33
  if (isGasPriceError) {
34
+ if (transactionRequest) {
35
+ let gasPrice = transactionRequest.gasPrice;
36
+ try {
37
+ gasPrice = await signer.getGasPrice();
38
+ }
39
+ catch (error) { }
40
+ if (gasPrice) {
41
+ transactionRequest.gasPrice = `${(BigInt(gasPrice.toString()) * 125n) / 100n}`;
42
+ }
43
+ }
34
44
  route.steps[index].estimate.gasCosts?.forEach((gasCost) => (gasCost.price = `${Math.round(Number(gasCost.price) * 1.25)}`));
35
45
  }
36
46
  };
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "2.0.0-beta.15";
2
+ export declare const version = "2.0.0-beta.16";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/sdk';
5
- exports.version = '2.0.0-beta.15';
5
+ exports.version = '2.0.0-beta.16';
@@ -84,10 +84,18 @@ export class StepExecutionManager {
84
84
  transactionRequest.maxFeePerGas = customConfig.maxFeePerGas;
85
85
  }
86
86
  else {
87
- const estimatedGasLimit = await signer.estimateGas(transactionRequest);
88
- if (estimatedGasLimit) {
89
- transactionRequest.gasLimit = `${(BigInt(estimatedGasLimit.toString()) * 125n) / 100n}`;
87
+ try {
88
+ const estimatedGasLimit = await signer.estimateGas(transactionRequest);
89
+ if (estimatedGasLimit) {
90
+ transactionRequest.gasLimit = `${(BigInt(estimatedGasLimit.toString()) * 125n) / 100n}`;
91
+ }
92
+ // Fetch latest gasPrice from provider and use it
93
+ const gasPrice = await signer.getGasPrice();
94
+ if (gasPrice) {
95
+ transactionRequest.gasPrice = gasPrice;
96
+ }
90
97
  }
98
+ catch (error) { }
91
99
  }
92
100
  // Submit the transaction
93
101
  transaction = await signer.sendTransaction(transactionRequest);
@@ -27,6 +27,16 @@ const handleErrorType = async (route, index, signer) => {
27
27
  route.steps[index].estimate.gasCosts?.forEach((gasCost) => (gasCost.limit = `${Math.round(Number(gasCost.limit) * 1.25)}`));
28
28
  }
29
29
  if (isGasPriceError) {
30
+ if (transactionRequest) {
31
+ let gasPrice = transactionRequest.gasPrice;
32
+ try {
33
+ gasPrice = await signer.getGasPrice();
34
+ }
35
+ catch (error) { }
36
+ if (gasPrice) {
37
+ transactionRequest.gasPrice = `${(BigInt(gasPrice.toString()) * 125n) / 100n}`;
38
+ }
39
+ }
30
40
  route.steps[index].estimate.gasCosts?.forEach((gasCost) => (gasCost.price = `${Math.round(Number(gasCost.price) * 1.25)}`));
31
41
  }
32
42
  };
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/sdk";
2
- export declare const version = "2.0.0-beta.15";
2
+ export declare const version = "2.0.0-beta.16";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk';
2
- export const version = '2.0.0-beta.15';
2
+ export const version = '2.0.0-beta.16';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "2.0.0-beta.15",
3
+ "version": "2.0.0-beta.16",
4
4
  "description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/index.js",
@@ -82,14 +82,14 @@
82
82
  "ethers": "^5.7.2"
83
83
  },
84
84
  "devDependencies": {
85
- "@commitlint/cli": "^17.6.3",
86
- "@commitlint/config-conventional": "^17.6.3",
85
+ "@commitlint/cli": "^17.6.5",
86
+ "@commitlint/config-conventional": "^17.6.5",
87
87
  "@mswjs/interceptors": "^0.22.15",
88
- "@typescript-eslint/eslint-plugin": "^5.59.7",
89
- "@typescript-eslint/parser": "^5.59.7",
90
- "@vitest/coverage-c8": "^0.31.1",
88
+ "@typescript-eslint/eslint-plugin": "^5.59.9",
89
+ "@typescript-eslint/parser": "^5.59.9",
90
+ "@vitest/coverage-c8": "^0.32.0",
91
91
  "cross-fetch": "^3.1.6",
92
- "eslint": "^8.41.0",
92
+ "eslint": "^8.42.0",
93
93
  "eslint-config-prettier": "^8.8.0",
94
94
  "eslint-plugin-prettier": "^4.2.1",
95
95
  "husky": "^8.0.3",
@@ -99,8 +99,8 @@
99
99
  "pinst": "^3.0.0",
100
100
  "prettier": "^2.8.8",
101
101
  "standard-version": "^9.5.0",
102
- "typescript": "^5.0.4",
103
- "vitest": "^0.31.1"
102
+ "typescript": "^5.1.3",
103
+ "vitest": "^0.32.0"
104
104
  },
105
105
  "directories": {
106
106
  "test": "test"