@openocean.finance/openocean-sdk 1.6.21 → 1.6.23

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.
@@ -22,7 +22,7 @@ export declare class Swap {
22
22
  sendNearTransaction(): Promise<void>;
23
23
  sendCosmosTransaction(): Promise<void>;
24
24
  getGasOld(): Promise<number>;
25
- getGasNew(): Promise<number | undefined>;
25
+ getGasNew(): Promise<number>;
26
26
  sendEthTransactionNew(): Promise<void>;
27
27
  sendEthTransaction(): Promise<void>;
28
28
  signEthTransactionByLedger(swapParams: any): Promise<void>;
@@ -578,11 +578,10 @@ var Swap = /** @class */ (function () {
578
578
  };
579
579
  Swap.prototype.getGasNew = function () {
580
580
  return __awaiter(this, void 0, void 0, function () {
581
- var _a, inToken, inAmount, outAmount, outToken, data, to, gmxFee, myWallet, contract, invitee, path, amounts, swapAddr, swapExtraData, value, gas, e_5;
581
+ var _a, inToken, inAmount, outAmount, outToken, data, to, gmxFee, myWallet, contract, invitee, path, amounts, swapAddr, swapExtraData, value, gas;
582
582
  return __generator(this, function (_b) {
583
583
  switch (_b.label) {
584
584
  case 0:
585
- _b.trys.push([0, 2, , 3]);
586
585
  console.log('getGasNew');
587
586
  _a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, outAmount = _a.outAmount, outToken = _a.outToken, data = _a.data, to = _a.to, gmxFee = _a.gmxFee;
588
587
  myWallet = this.wallet.sdk;
@@ -604,22 +603,16 @@ var Swap = /** @class */ (function () {
604
603
  case 1:
605
604
  gas = _b.sent();
606
605
  return [2 /*return*/, Math.ceil(gas * 1.5)];
607
- case 2:
608
- e_5 = _b.sent();
609
- console.log('getGasNew error', e_5);
610
- return [3 /*break*/, 3];
611
- case 3: return [2 /*return*/];
612
606
  }
613
607
  });
614
608
  });
615
609
  };
616
610
  Swap.prototype.sendEthTransactionNew = function () {
617
611
  return __awaiter(this, void 0, void 0, function () {
618
- var _a, inToken, inAmount, outAmount, outToken, data, to, ethGasPrice, gasPrice, gmxFee, myWallet, contract, invitee, path, amounts, swapAddr, swapExtraData, swapParams, maxFeePerGas, maxPriorityFeePerGas;
619
- var _b;
612
+ var _a, inToken, inAmount, outAmount, outToken, data, to, ethGasPrice, gasPrice, gmxFee, myWallet, contract, invitee, path, amounts, swapAddr, swapExtraData, swapParams, gas, e_5, maxFeePerGas, maxPriorityFeePerGas;
620
613
  var _this = this;
621
- return __generator(this, function (_c) {
622
- switch (_c.label) {
614
+ return __generator(this, function (_b) {
615
+ switch (_b.label) {
623
616
  case 0:
624
617
  _a = this.res, inToken = _a.inToken, inAmount = _a.inAmount, outAmount = _a.outAmount, outToken = _a.outToken, data = _a.data, to = _a.to, ethGasPrice = _a.ethGasPrice, gasPrice = _a.gasPrice, gmxFee = _a.gmxFee;
625
618
  console.log('sendEthTransactionNew', JSON.stringify(this.res));
@@ -630,15 +623,27 @@ var Swap = /** @class */ (function () {
630
623
  amounts = [inAmount, outAmount];
631
624
  swapAddr = to;
632
625
  swapExtraData = data;
633
- _b = {
634
- from: this.wallet.address
626
+ swapParams = {
627
+ from: this.wallet.address,
628
+ to: to,
629
+ data: data,
635
630
  };
636
- return [4 /*yield*/, this.getGasNew()];
631
+ _b.label = 1;
637
632
  case 1:
638
- swapParams = (_b.gas = _c.sent(),
639
- _b.to = to,
640
- _b.data = data,
641
- _b);
633
+ _b.trys.push([1, 3, , 4]);
634
+ return [4 /*yield*/, this.getGasNew()];
635
+ case 2:
636
+ gas = _b.sent();
637
+ swapParams.gas = gas;
638
+ return [3 /*break*/, 4];
639
+ case 3:
640
+ e_5 = _b.sent();
641
+ if (e_5 && e_5.message.indexOf("JSON-RPC error.") != -1) {
642
+ e_5 = JSON.parse(e_5.message.split("JSON-RPC error.")[1]);
643
+ }
644
+ this.errorCallback((e_5 && e_5.message) || e_5);
645
+ return [2 /*return*/];
646
+ case 4:
642
647
  if (ethGasPrice) {
643
648
  maxFeePerGas = ethGasPrice.maxFeePerGas, maxPriorityFeePerGas = ethGasPrice.maxPriorityFeePerGas;
644
649
  if (maxFeePerGas && maxPriorityFeePerGas) {
@@ -747,7 +752,7 @@ var Swap = /** @class */ (function () {
747
752
  e_7 = JSON.parse(e_7.message.split("JSON-RPC error.")[1]);
748
753
  }
749
754
  this.errorCallback((e_7 && e_7.message) || e_7);
750
- return [3 /*break*/, 9];
755
+ return [2 /*return*/];
751
756
  case 9:
752
757
  console.log('sendEthTransaction swapParams', JSON.stringify(swapParams));
753
758
  this.wallet.sdk.eth
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/openocean-sdk",
3
- "version": "1.6.21",
3
+ "version": "1.6.23",
4
4
  "description": "Openocean sdk",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {