@openocean.finance/openocean-sdk 1.2.55 → 1.2.57

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.
@@ -66,12 +66,17 @@ var Approve = /** @class */ (function () {
66
66
  this.key = 0;
67
67
  this.approveContract = reqApproveVo.approveContract;
68
68
  this.tokenAddress = reqApproveVo.tokenAddress;
69
+ if (reqApproveVo.gasPrice && (String(reqApproveVo.gasPrice).indexOf('.') > -1 || Number(reqApproveVo.gasPrice) < Math.pow(10, 6))) {
70
+ reqApproveVo.gasPrice = new bignumber_js_1.default(reqApproveVo.gasPrice + '').times(Math.pow(10, 9)).toFixed(0);
71
+ }
69
72
  return [4 /*yield*/, this.wallet.sdk.eth.getGasPrice()];
70
73
  case 1:
71
74
  _gasPrice = _c.sent();
72
- reqApproveVo.gasPrice = (0, bignumber_js_1.default)(_gasPrice).comparedTo(reqApproveVo.gasPrice) > 0 ? _gasPrice : reqApproveVo.gasPrice;
73
- if (String(reqApproveVo.gasPrice).indexOf('.') > -1 || Number(reqApproveVo.gasPrice) < Math.pow(10, 6)) {
74
- reqApproveVo.gasPrice = new bignumber_js_1.default(reqApproveVo.gasPrice + '').times(Math.pow(10, 9)).toFixed(0);
75
+ if (_gasPrice && reqApproveVo.gasPrice) {
76
+ reqApproveVo.gasPrice = (0, bignumber_js_1.default)(_gasPrice).comparedTo(reqApproveVo.gasPrice) > 0 ? reqApproveVo.gasPrice : _gasPrice;
77
+ }
78
+ else if (_gasPrice && !reqApproveVo.gasPrice) {
79
+ reqApproveVo.gasPrice = _gasPrice;
75
80
  }
76
81
  if (reqApproveVo.decimals) {
77
82
  reqApproveVo.amount = (0, bignumber_js_1.default)(reqApproveVo.amount).times(Math.pow(10, reqApproveVo.decimals)).toFixed(0);
@@ -35,6 +35,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
38
41
  Object.defineProperty(exports, "__esModule", { value: true });
39
42
  exports.swapSdk = exports.SwapSdk = void 0;
40
43
  var RequestVo_1 = require("./RequestVo");
@@ -45,6 +48,7 @@ var config_1 = require("../config");
45
48
  var Swap_1 = require("./Swap");
46
49
  var getBalance_1 = require("./getBalance");
47
50
  var getAllowance_1 = require("./getAllowance");
51
+ var bignumber_js_1 = __importDefault(require("bignumber.js"));
48
52
  var wallet_1 = require("@openocean.finance/wallet");
49
53
  var SwapSdk = /** @class */ (function () {
50
54
  function SwapSdk() {
@@ -79,11 +83,11 @@ var SwapSdk = /** @class */ (function () {
79
83
  SwapSdk.prototype.fastSwap = function (swapData) {
80
84
  var _this = this;
81
85
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
82
- var chainId;
86
+ var chainId, _gasPrice;
83
87
  return __generator(this, function (_a) {
84
88
  switch (_a.label) {
85
89
  case 0:
86
- if (!(this.chain.compiler == 'EVM')) return [3 /*break*/, 2];
90
+ if (!(this.chain.compiler == 'EVM' && swapData.chainId)) return [3 /*break*/, 2];
87
91
  return [4 /*yield*/, this.wallet.sdk.eth.getChainId()];
88
92
  case 1:
89
93
  chainId = _a.sent();
@@ -95,7 +99,15 @@ var SwapSdk = /** @class */ (function () {
95
99
  return [2 /*return*/];
96
100
  }
97
101
  _a.label = 2;
98
- case 2:
102
+ case 2: return [4 /*yield*/, this.wallet.sdk.eth.getGasPrice()];
103
+ case 3:
104
+ _gasPrice = _a.sent();
105
+ if (_gasPrice && swapData.gasPrice) {
106
+ swapData.gasPrice = (0, bignumber_js_1.default)(_gasPrice).comparedTo(swapData.gasPrice) > 0 ? swapData.gasPrice : _gasPrice;
107
+ }
108
+ else if (_gasPrice && !swapData.gasPrice) {
109
+ swapData.gasPrice = _gasPrice;
110
+ }
99
111
  this.swap(swapData)
100
112
  .on('transactionHash', resolve)
101
113
  .on('error', reject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/openocean-sdk",
3
- "version": "1.2.55",
3
+ "version": "1.2.57",
4
4
  "description": "Openocean sdk",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {