@openocean.finance/openocean-sdk 1.2.56 → 1.2.58

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.
@@ -57,7 +57,7 @@ var Approve = /** @class */ (function () {
57
57
  }
58
58
  Approve.prototype.send = function (reqApproveVo, address) {
59
59
  return __awaiter(this, void 0, void 0, function () {
60
- var _gasPrice, web3, data, safeTxHash, e_1, hash, e_2, _a, _b, gasAmount, error_1, json;
60
+ var _gasPrice, e_1, web3, data, safeTxHash, e_2, hash, e_3, _a, _b, gasAmount, error_1, json;
61
61
  var _this = this;
62
62
  return __generator(this, function (_c) {
63
63
  switch (_c.label) {
@@ -69,9 +69,18 @@ var Approve = /** @class */ (function () {
69
69
  if (reqApproveVo.gasPrice && (String(reqApproveVo.gasPrice).indexOf('.') > -1 || Number(reqApproveVo.gasPrice) < Math.pow(10, 6))) {
70
70
  reqApproveVo.gasPrice = new bignumber_js_1.default(reqApproveVo.gasPrice + '').times(Math.pow(10, 9)).toFixed(0);
71
71
  }
72
- return [4 /*yield*/, this.wallet.sdk.eth.getGasPrice()];
72
+ _c.label = 1;
73
73
  case 1:
74
+ _c.trys.push([1, 3, , 4]);
75
+ return [4 /*yield*/, this.wallet.sdk.eth.getGasPrice()];
76
+ case 2:
74
77
  _gasPrice = _c.sent();
78
+ return [3 /*break*/, 4];
79
+ case 3:
80
+ e_1 = _c.sent();
81
+ console.log('this.wallet.sdk.eth.getGasPrice', e_1);
82
+ return [3 /*break*/, 4];
83
+ case 4:
75
84
  if (_gasPrice && reqApproveVo.gasPrice) {
76
85
  reqApproveVo.gasPrice = (0, bignumber_js_1.default)(_gasPrice).comparedTo(reqApproveVo.gasPrice) > 0 ? reqApproveVo.gasPrice : _gasPrice;
77
86
  }
@@ -81,7 +90,7 @@ var Approve = /** @class */ (function () {
81
90
  if (reqApproveVo.decimals) {
82
91
  reqApproveVo.amount = (0, bignumber_js_1.default)(reqApproveVo.amount).times(Math.pow(10, reqApproveVo.decimals)).toFixed(0);
83
92
  }
84
- if (!(this.wallet.key === "GnosisSafeWallet")) return [3 /*break*/, 6];
93
+ if (!(this.wallet.key === "GnosisSafeWallet")) return [3 /*break*/, 9];
85
94
  web3 = new web3_1.default();
86
95
  data = web3.eth.abi.encodeFunctionCall({
87
96
  inputs: [
@@ -98,9 +107,9 @@ var Approve = /** @class */ (function () {
98
107
  type: "function",
99
108
  }, [this.approveContract, reqApproveVo.amount]);
100
109
  console.log("data", this.approveContract, reqApproveVo.amount, data);
101
- _c.label = 2;
102
- case 2:
103
- _c.trys.push([2, 4, , 5]);
110
+ _c.label = 5;
111
+ case 5:
112
+ _c.trys.push([5, 7, , 8]);
104
113
  return [4 /*yield*/, this.wallet.sdk.txs.send({
105
114
  txs: [
106
115
  {
@@ -110,31 +119,31 @@ var Approve = /** @class */ (function () {
110
119
  },
111
120
  ],
112
121
  })];
113
- case 3:
122
+ case 6:
114
123
  safeTxHash = (_c.sent()).safeTxHash;
115
124
  console.log("safeTxHash", safeTxHash);
116
125
  setTimeout(function () {
117
126
  console.log("successCallback");
118
127
  _this.successCallback(1);
119
128
  }, 3000);
120
- return [3 /*break*/, 5];
121
- case 4:
122
- e_1 = _c.sent();
129
+ return [3 /*break*/, 8];
130
+ case 7:
131
+ e_2 = _c.sent();
123
132
  setTimeout(function () {
124
- _this.errorCallback(e_1);
133
+ _this.errorCallback(e_2);
125
134
  }, 500);
126
- return [3 /*break*/, 5];
127
- case 5: return [3 /*break*/, 24];
128
- case 6:
129
- if (!(this.wallet.key === "LedgerWallet")) return [3 /*break*/, 7];
135
+ return [3 /*break*/, 8];
136
+ case 8: return [3 /*break*/, 27];
137
+ case 9:
138
+ if (!(this.wallet.key === "LedgerWallet")) return [3 /*break*/, 10];
130
139
  this.signEthTransactionByLedger(reqApproveVo, address);
131
- return [3 /*break*/, 24];
132
- case 7:
133
- if (!(this.wallet.key === "TronLink")) return [3 /*break*/, 15];
140
+ return [3 /*break*/, 27];
141
+ case 10:
142
+ if (!(this.wallet.key === "TronLink")) return [3 /*break*/, 18];
134
143
  this.approveContract = "TRtQA3D9BFRLFw3rajKBziAof2eAWkAL7B";
135
- _c.label = 8;
136
- case 8:
137
- _c.trys.push([8, 13, , 14]);
144
+ _c.label = 11;
145
+ case 11:
146
+ _c.trys.push([11, 16, , 17]);
138
147
  hash = "";
139
148
  this.amount = reqApproveVo.amount + "";
140
149
  if (!([
@@ -142,71 +151,71 @@ var Approve = /** @class */ (function () {
142
151
  "TCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9",
143
152
  "TKfjV9RNKJJCqPvBtK8L7Knykh7DNWvnYt",
144
153
  "TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR"
145
- ].indexOf(this.tokenAddress) >= 0)) return [3 /*break*/, 10];
154
+ ].indexOf(this.tokenAddress) >= 0)) return [3 /*break*/, 13];
146
155
  return [4 /*yield*/, this.contract.methods
147
156
  .approve(this.approveContract)
148
157
  .send({ feeLimit: 100000000 })];
149
- case 9:
158
+ case 12:
150
159
  hash = _c.sent();
151
- return [3 /*break*/, 12];
152
- case 10:
160
+ return [3 /*break*/, 15];
161
+ case 13:
153
162
  console.log('send approve', this.amount);
154
163
  return [4 /*yield*/, this.contract.methods
155
164
  .approve(this.approveContract, this.amount)
156
165
  .send({ feeLimit: 100000000 })];
157
- case 11:
166
+ case 14:
158
167
  hash = _c.sent();
159
- _c.label = 12;
160
- case 12:
168
+ _c.label = 15;
169
+ case 15:
161
170
  console.log('hash', hash);
162
171
  this.successCallback(1);
163
- return [3 /*break*/, 14];
164
- case 13:
165
- e_2 = _c.sent();
166
- this.errorCallback(e_2);
167
- return [3 /*break*/, 14];
168
- case 14: return [3 /*break*/, 24];
169
- case 15:
170
- if (!!reqApproveVo.amount) return [3 /*break*/, 17];
172
+ return [3 /*break*/, 17];
173
+ case 16:
174
+ e_3 = _c.sent();
175
+ this.errorCallback(e_3);
176
+ return [3 /*break*/, 17];
177
+ case 17: return [3 /*break*/, 27];
178
+ case 18:
179
+ if (!!reqApproveVo.amount) return [3 /*break*/, 20];
171
180
  _a = reqApproveVo;
172
181
  return [4 /*yield*/, this.contract.methods.totalSupply().call()];
173
- case 16:
182
+ case 19:
174
183
  _a.amount = _c.sent();
175
- _c.label = 17;
176
- case 17:
177
- if (!(this.tokenAddress === "0xfa17b330bcc4e7f3e2456996d89a5a54ab044831")) return [3 /*break*/, 19];
184
+ _c.label = 20;
185
+ case 20:
186
+ if (!(this.tokenAddress === "0xfa17b330bcc4e7f3e2456996d89a5a54ab044831")) return [3 /*break*/, 22];
178
187
  _b = reqApproveVo;
179
188
  return [4 /*yield*/, this.contract.methods
180
189
  .balanceOf(this.account)
181
190
  .call()];
182
- case 18:
191
+ case 21:
183
192
  _b.amount = _c.sent();
184
193
  if (Number(reqApproveVo.amount) == 0) {
185
194
  this.errorCallback("Insufficient Balance.");
186
195
  return [2 /*return*/];
187
196
  }
188
- _c.label = 19;
189
- case 19:
197
+ _c.label = 22;
198
+ case 22:
190
199
  this.amount = reqApproveVo.amount + "";
191
200
  gasAmount = "80000";
192
- _c.label = 20;
193
- case 20:
194
- _c.trys.push([20, 22, , 23]);
201
+ _c.label = 23;
202
+ case 23:
203
+ _c.trys.push([23, 25, , 26]);
195
204
  return [4 /*yield*/, this.contract.methods
196
205
  .approve(this.approveContract, this.amount)
197
206
  .estimateGas({
198
207
  from: this.account,
199
208
  })];
200
- case 21:
209
+ case 24:
201
210
  gasAmount = _c.sent();
202
- return [3 /*break*/, 23];
203
- case 22:
211
+ return [3 /*break*/, 26];
212
+ case 25:
204
213
  error_1 = _c.sent();
205
214
  setTimeout(function () {
206
215
  _this.errorCallback(error_1);
207
216
  }, 500);
208
217
  return [2 /*return*/];
209
- case 23:
218
+ case 26:
210
219
  json = {
211
220
  from: address,
212
221
  };
@@ -229,8 +238,8 @@ var Approve = /** @class */ (function () {
229
238
  _this.receiptCallback(receipt);
230
239
  _this.getSuccess(receipt);
231
240
  });
232
- _c.label = 24;
233
- case 24: return [2 /*return*/];
241
+ _c.label = 27;
242
+ case 27: return [2 /*return*/];
234
243
  }
235
244
  });
236
245
  });
@@ -252,7 +261,7 @@ var Approve = /** @class */ (function () {
252
261
  };
253
262
  Approve.prototype.signEthTransactionByLedger = function (reqApproveVo, address) {
254
263
  return __awaiter(this, void 0, void 0, function () {
255
- var web3, data, account, myWallet, gasPrice, txParams, serializedTx, signature, signedTx, hash, e_3;
264
+ var web3, data, account, myWallet, gasPrice, txParams, serializedTx, signature, signedTx, hash, e_4;
256
265
  var _a;
257
266
  var _this = this;
258
267
  return __generator(this, function (_b) {
@@ -316,9 +325,9 @@ var Approve = /** @class */ (function () {
316
325
  }, 3000);
317
326
  return [3 /*break*/, 6];
318
327
  case 5:
319
- e_3 = _b.sent();
328
+ e_4 = _b.sent();
320
329
  setTimeout(function () {
321
- _this.errorCallback(e_3);
330
+ _this.errorCallback(e_4);
322
331
  }, 500);
323
332
  return [3 /*break*/, 6];
324
333
  case 6: return [2 /*return*/];
@@ -83,11 +83,11 @@ var SwapSdk = /** @class */ (function () {
83
83
  SwapSdk.prototype.fastSwap = function (swapData) {
84
84
  var _this = this;
85
85
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
86
- var chainId, _gasPrice;
86
+ var chainId, _gasPrice, e_1;
87
87
  return __generator(this, function (_a) {
88
88
  switch (_a.label) {
89
89
  case 0:
90
- if (!(this.chain.compiler == 'EVM')) return [3 /*break*/, 2];
90
+ if (!(this.chain.compiler == 'EVM' && swapData.chainId)) return [3 /*break*/, 2];
91
91
  return [4 /*yield*/, this.wallet.sdk.eth.getChainId()];
92
92
  case 1:
93
93
  chainId = _a.sent();
@@ -99,9 +99,17 @@ var SwapSdk = /** @class */ (function () {
99
99
  return [2 /*return*/];
100
100
  }
101
101
  _a.label = 2;
102
- case 2: return [4 /*yield*/, this.wallet.sdk.eth.getGasPrice()];
102
+ case 2:
103
+ _a.trys.push([2, 4, , 5]);
104
+ return [4 /*yield*/, this.wallet.sdk.eth.getGasPrice()];
103
105
  case 3:
104
106
  _gasPrice = _a.sent();
107
+ return [3 /*break*/, 5];
108
+ case 4:
109
+ e_1 = _a.sent();
110
+ console.log('this.wallet.sdk.eth.getGasPrice', e_1);
111
+ return [3 /*break*/, 5];
112
+ case 5:
105
113
  if (_gasPrice && swapData.gasPrice) {
106
114
  swapData.gasPrice = (0, bignumber_js_1.default)(_gasPrice).comparedTo(swapData.gasPrice) > 0 ? swapData.gasPrice : _gasPrice;
107
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/openocean-sdk",
3
- "version": "1.2.56",
3
+ "version": "1.2.58",
4
4
  "description": "Openocean sdk",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {