@openocean.finance/openocean-sdk 1.7.64 → 1.7.66

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.
@@ -16,7 +16,7 @@ export declare class Swap {
16
16
  getGas(): Promise<unknown>;
17
17
  sendONTTransaction(): Promise<void>;
18
18
  sendSolanaTransaction(): Promise<void>;
19
- sendSolanaTransactionToBlockRust(serializedTransaction: any): Promise<void>;
19
+ sendSolanaTransactionToBlockRust(res: any, serializedTransaction: any): Promise<void>;
20
20
  sendSuiTransaction(): Promise<void>;
21
21
  sendStarknetTransaction(): Promise<void>;
22
22
  sendAptosTransaction(): Promise<void>;
@@ -250,7 +250,7 @@ var Swap = /** @class */ (function () {
250
250
  });
251
251
  console.log('sendSolanaTransactionToBlockRust', res, serializedTransaction);
252
252
  if (!res.isTip) return [3 /*break*/, 9];
253
- return [4 /*yield*/, this.sendSolanaTransactionToBlockRust(serializedTransaction)];
253
+ return [4 /*yield*/, this.sendSolanaTransactionToBlockRust(res, serializedTransaction)];
254
254
  case 8:
255
255
  _d.sent();
256
256
  return [2 /*return*/];
@@ -282,10 +282,9 @@ var Swap = /** @class */ (function () {
282
282
  });
283
283
  });
284
284
  };
285
- Swap.prototype.sendSolanaTransactionToBlockRust = function (serializedTransaction) {
285
+ Swap.prototype.sendSolanaTransactionToBlockRust = function (res, serializedTransaction) {
286
286
  return __awaiter(this, void 0, void 0, function () {
287
- var headers, body, res, err_1;
288
- var _a;
287
+ var headers, body, blockrushUrl, data, _a, error, result, e_2;
289
288
  return __generator(this, function (_b) {
290
289
  switch (_b.label) {
291
290
  case 0:
@@ -307,14 +306,22 @@ var Swap = /** @class */ (function () {
307
306
  _b.label = 1;
308
307
  case 1:
309
308
  _b.trys.push([1, 3, , 4]);
310
- return [4 /*yield*/, axios_1.default.post('https://jp1.rpc.blockrush.io', body, { headers: headers })];
309
+ blockrushUrl = res.blockrushUrl;
310
+ return [4 /*yield*/, axios_1.default.post(blockrushUrl || 'https://jp.rpc.blockrush.io', body, { headers: headers })];
311
311
  case 2:
312
- res = _b.sent();
313
- console.log('RPC Response:', res.data);
312
+ data = (_b.sent()).data;
313
+ _a = data || {}, error = _a.error, result = _a.result;
314
+ console.log('RPC Response:', result.data);
315
+ if (result) {
316
+ this.transactionHashCallback(result);
317
+ }
318
+ else {
319
+ this.errorCallback(error && error.message || 'server error');
320
+ }
314
321
  return [3 /*break*/, 4];
315
322
  case 3:
316
- err_1 = _b.sent();
317
- console.error('RPC Error:', ((_a = err_1.response) === null || _a === void 0 ? void 0 : _a.data) || err_1.message);
323
+ e_2 = _b.sent();
324
+ this.errorCallback(e_2.message);
318
325
  return [3 /*break*/, 4];
319
326
  case 4: return [2 /*return*/];
320
327
  }
@@ -323,7 +330,7 @@ var Swap = /** @class */ (function () {
323
330
  };
324
331
  Swap.prototype.sendSuiTransaction = function () {
325
332
  return __awaiter(this, void 0, void 0, function () {
326
- var transaction, tx, signature, e_2;
333
+ var transaction, tx, signature, e_3;
327
334
  return __generator(this, function (_a) {
328
335
  switch (_a.label) {
329
336
  case 0:
@@ -343,9 +350,9 @@ var Swap = /** @class */ (function () {
343
350
  this.transactionHashCallback(signature.digest);
344
351
  return [3 /*break*/, 3];
345
352
  case 2:
346
- e_2 = _a.sent();
347
- console.log('sendSuiTransaction 3', e_2);
348
- this.errorCallback(e_2.message);
353
+ e_3 = _a.sent();
354
+ console.log('sendSuiTransaction 3', e_3);
355
+ this.errorCallback(e_3.message);
349
356
  return [3 /*break*/, 3];
350
357
  case 3: return [2 /*return*/];
351
358
  }
@@ -354,7 +361,7 @@ var Swap = /** @class */ (function () {
354
361
  };
355
362
  Swap.prototype.sendStarknetTransaction = function () {
356
363
  return __awaiter(this, void 0, void 0, function () {
357
- var transaction, signature, transaction_hash, e_3;
364
+ var transaction, signature, transaction_hash, e_4;
358
365
  return __generator(this, function (_a) {
359
366
  switch (_a.label) {
360
367
  case 0:
@@ -369,8 +376,8 @@ var Swap = /** @class */ (function () {
369
376
  this.transactionHashCallback(transaction_hash);
370
377
  return [3 /*break*/, 3];
371
378
  case 2:
372
- e_3 = _a.sent();
373
- this.errorCallback(e_3.message);
379
+ e_4 = _a.sent();
380
+ this.errorCallback(e_4.message);
374
381
  return [3 /*break*/, 3];
375
382
  case 3: return [2 /*return*/];
376
383
  }
@@ -466,7 +473,7 @@ var Swap = /** @class */ (function () {
466
473
  };
467
474
  Swap.prototype.sendNearTransaction = function () {
468
475
  return __awaiter(this, void 0, void 0, function () {
469
- var transaction, wallet_2, transactions, currentTransactions, e_4, err, txResult, transaction_1, hash, error_2;
476
+ var transaction, wallet_2, transactions, currentTransactions, e_5, err, txResult, transaction_1, hash, error_2;
470
477
  var _this = this;
471
478
  return __generator(this, function (_a) {
472
479
  switch (_a.label) {
@@ -501,11 +508,11 @@ var Swap = /** @class */ (function () {
501
508
  _a.sent();
502
509
  return [3 /*break*/, 5];
503
510
  case 4:
504
- e_4 = _a.sent();
505
- err = e_4;
506
- console.warn(e_4);
507
- console.log("Error: " + e_4.message);
508
- this.errorCallback(e_4.message);
511
+ e_5 = _a.sent();
512
+ err = e_5;
513
+ console.warn(e_5);
514
+ console.log("Error: " + e_5.message);
515
+ this.errorCallback(e_5.message);
509
516
  return [3 /*break*/, 5];
510
517
  case 5: return [3 /*break*/, 8];
511
518
  case 6:
@@ -567,7 +574,7 @@ var Swap = /** @class */ (function () {
567
574
  };
568
575
  Swap.prototype.sendCosmosTransaction = function () {
569
576
  return __awaiter(this, void 0, void 0, function () {
570
- var _a, transaction, cosmosReceiver, wallet, transactions, result, e_5, err, error_3;
577
+ var _a, transaction, cosmosReceiver, wallet, transactions, result, e_6, err, error_3;
571
578
  return __generator(this, function (_b) {
572
579
  switch (_b.label) {
573
580
  case 0:
@@ -598,11 +605,11 @@ var Swap = /** @class */ (function () {
598
605
  }
599
606
  return [3 /*break*/, 4];
600
607
  case 3:
601
- e_5 = _b.sent();
602
- err = e_5;
603
- console.warn(e_5);
604
- console.log("Error: " + e_5.message);
605
- this.errorCallback(e_5.message);
608
+ e_6 = _b.sent();
609
+ err = e_6;
610
+ console.warn(e_6);
611
+ console.log("Error: " + e_6.message);
612
+ this.errorCallback(e_6.message);
606
613
  return [3 /*break*/, 4];
607
614
  case 4: return [3 /*break*/, 6];
608
615
  case 5:
@@ -671,7 +678,7 @@ var Swap = /** @class */ (function () {
671
678
  };
672
679
  Swap.prototype.sendEthTransactionNew = function () {
673
680
  return __awaiter(this, void 0, void 0, function () {
674
- var _a, inToken, inAmount, outAmount, outToken, data, to, ethGasPrice, gasPrice, gmxFee, myWallet, contract, invitee, path, amounts, swapAddr, swapExtraData, swapParams, gas, e_6, maxFeePerGas, maxPriorityFeePerGas;
681
+ var _a, inToken, inAmount, outAmount, outToken, data, to, ethGasPrice, gasPrice, gmxFee, myWallet, contract, invitee, path, amounts, swapAddr, swapExtraData, swapParams, gas, e_7, maxFeePerGas, maxPriorityFeePerGas;
675
682
  var _this = this;
676
683
  return __generator(this, function (_b) {
677
684
  switch (_b.label) {
@@ -699,11 +706,11 @@ var Swap = /** @class */ (function () {
699
706
  swapParams.gas = gas;
700
707
  return [3 /*break*/, 4];
701
708
  case 3:
702
- e_6 = _b.sent();
703
- if (e_6 && e_6.message.indexOf("JSON-RPC error.") != -1) {
704
- e_6 = JSON.parse(e_6.message.split("JSON-RPC error.")[1]);
709
+ e_7 = _b.sent();
710
+ if (e_7 && e_7.message.indexOf("JSON-RPC error.") != -1) {
711
+ e_7 = JSON.parse(e_7.message.split("JSON-RPC error.")[1]);
705
712
  }
706
- this.errorCallback((e_6 && e_6.message) || e_6);
713
+ this.errorCallback((e_7 && e_7.message) || e_7);
707
714
  return [2 /*return*/];
708
715
  case 4:
709
716
  if (ethGasPrice) {
@@ -744,7 +751,7 @@ var Swap = /** @class */ (function () {
744
751
  };
745
752
  Swap.prototype.sendEthTransaction = function () {
746
753
  return __awaiter(this, void 0, void 0, function () {
747
- var _a, inToken, inAmount, data, to, ethGasPrice, gasPrice, estimatedGas, gmxFee, swapParams, maxFeePerGas, maxPriorityFeePerGas, safeTxHash, e_7, gas, e_8;
754
+ var _a, inToken, inAmount, data, to, ethGasPrice, gasPrice, estimatedGas, gmxFee, swapParams, maxFeePerGas, maxPriorityFeePerGas, safeTxHash, e_8, gas, e_9;
748
755
  var _this = this;
749
756
  return __generator(this, function (_b) {
750
757
  switch (_b.label) {
@@ -791,8 +798,8 @@ var Swap = /** @class */ (function () {
791
798
  this.getGnosisSafeTransaction(safeTxHash);
792
799
  return [3 /*break*/, 4];
793
800
  case 3:
794
- e_7 = _b.sent();
795
- this.errorCallback((e_7 && e_7.message) || e_7);
801
+ e_8 = _b.sent();
802
+ this.errorCallback((e_8 && e_8.message) || e_8);
796
803
  return [3 /*break*/, 4];
797
804
  case 4: return [2 /*return*/];
798
805
  case 5:
@@ -811,11 +818,11 @@ var Swap = /** @class */ (function () {
811
818
  swapParams.gas = gas;
812
819
  return [3 /*break*/, 9];
813
820
  case 8:
814
- e_8 = _b.sent();
815
- if (e_8 && e_8.message.indexOf("JSON-RPC error.") != -1) {
816
- e_8 = JSON.parse(e_8.message.split("JSON-RPC error.")[1]);
821
+ e_9 = _b.sent();
822
+ if (e_9 && e_9.message.indexOf("JSON-RPC error.") != -1) {
823
+ e_9 = JSON.parse(e_9.message.split("JSON-RPC error.")[1]);
817
824
  }
818
- this.errorCallback((e_8 && e_8.message) || e_8);
825
+ this.errorCallback((e_9 && e_9.message) || e_9);
819
826
  return [2 /*return*/];
820
827
  case 9:
821
828
  console.log('sendEthTransaction swapParams', JSON.stringify(swapParams));
@@ -839,7 +846,7 @@ var Swap = /** @class */ (function () {
839
846
  };
840
847
  Swap.prototype.signEthTransactionByLedger = function (swapParams) {
841
848
  return __awaiter(this, void 0, void 0, function () {
842
- var account, myWallet, gasPrice, txParams, serializedTx, signature, signedTx, hash, e_9;
849
+ var account, myWallet, gasPrice, txParams, serializedTx, signature, signedTx, hash, e_10;
843
850
  var _a;
844
851
  return __generator(this, function (_b) {
845
852
  switch (_b.label) {
@@ -883,8 +890,8 @@ var Swap = /** @class */ (function () {
883
890
  this.transactionHashCallback(hash);
884
891
  return [3 /*break*/, 6];
885
892
  case 5:
886
- e_9 = _b.sent();
887
- this.errorCallback(e_9);
893
+ e_10 = _b.sent();
894
+ this.errorCallback(e_10);
888
895
  return [3 /*break*/, 6];
889
896
  case 6: return [2 /*return*/];
890
897
  }
@@ -923,7 +930,7 @@ var Swap = /** @class */ (function () {
923
930
  };
924
931
  Swap.prototype.sendTronTransaction = function () {
925
932
  return __awaiter(this, void 0, void 0, function () {
926
- var _a, inToken, outToken, inAmount, outAmount, minOutAmount, addresses, calldata, offsets, gasLimitsAndValues, abi, contract, _contract, swapParams, e_10;
933
+ var _a, inToken, outToken, inAmount, outAmount, minOutAmount, addresses, calldata, offsets, gasLimitsAndValues, abi, contract, _contract, swapParams, e_11;
927
934
  var _this = this;
928
935
  return __generator(this, function (_b) {
929
936
  switch (_b.label) {
@@ -1008,8 +1015,8 @@ var Swap = /** @class */ (function () {
1008
1015
  _b.sent();
1009
1016
  return [3 /*break*/, 5];
1010
1017
  case 4:
1011
- e_10 = _b.sent();
1012
- this.errorCallback(e_10 || e_10.message);
1018
+ e_11 = _b.sent();
1019
+ this.errorCallback(e_11 || e_11.message);
1013
1020
  return [3 /*break*/, 5];
1014
1021
  case 5: return [2 /*return*/];
1015
1022
  }
@@ -1018,7 +1025,7 @@ var Swap = /** @class */ (function () {
1018
1025
  };
1019
1026
  Swap.prototype.sendTerraTransaction = function () {
1020
1027
  return __awaiter(this, void 0, void 0, function () {
1021
- var data, address, gasPrices, msg, _a, fee, accountInfo, e_11;
1028
+ var data, address, gasPrices, msg, _a, fee, accountInfo, e_12;
1022
1029
  var _this = this;
1023
1030
  return __generator(this, function (_b) {
1024
1031
  switch (_b.label) {
@@ -1060,8 +1067,8 @@ var Swap = /** @class */ (function () {
1060
1067
  });
1061
1068
  return [3 /*break*/, 7];
1062
1069
  case 6:
1063
- e_11 = _b.sent();
1064
- this.errorCallback(e_11.message || e_11);
1070
+ e_12 = _b.sent();
1071
+ this.errorCallback(e_12.message || e_12);
1065
1072
  return [3 /*break*/, 7];
1066
1073
  case 7: return [2 /*return*/];
1067
1074
  }
@@ -1070,7 +1077,7 @@ var Swap = /** @class */ (function () {
1070
1077
  };
1071
1078
  Swap.prototype.approveOnt = function (transaction, _amount, inToken) {
1072
1079
  return __awaiter(this, void 0, void 0, function () {
1073
- var scriptHash, operation, gasLimit, args, params, result, e_12;
1080
+ var scriptHash, operation, gasLimit, args, params, result, e_13;
1074
1081
  return __generator(this, function (_a) {
1075
1082
  switch (_a.label) {
1076
1083
  case 0:
@@ -1103,10 +1110,10 @@ var Swap = /** @class */ (function () {
1103
1110
  this.sendOntTransactionSdk(transaction);
1104
1111
  return [3 /*break*/, 3];
1105
1112
  case 2:
1106
- e_12 = _a.sent();
1113
+ e_13 = _a.sent();
1107
1114
  // tslint:disable-next-line:no-console
1108
- console.log("onScCall error:", e_12);
1109
- this.errorCallback((e_12 && e_12.message) || e_12);
1115
+ console.log("onScCall error:", e_13);
1116
+ this.errorCallback((e_13 && e_13.message) || e_13);
1110
1117
  return [3 /*break*/, 3];
1111
1118
  case 3: return [2 /*return*/];
1112
1119
  }
@@ -1115,7 +1122,7 @@ var Swap = /** @class */ (function () {
1115
1122
  };
1116
1123
  Swap.prototype.sendOntTransactionSdk = function (transaction) {
1117
1124
  return __awaiter(this, void 0, void 0, function () {
1118
- var scriptHash, operation, gasLimit, args, params, result, e_13;
1125
+ var scriptHash, operation, gasLimit, args, params, result, e_14;
1119
1126
  return __generator(this, function (_a) {
1120
1127
  switch (_a.label) {
1121
1128
  case 0:
@@ -1146,8 +1153,8 @@ var Swap = /** @class */ (function () {
1146
1153
  }
1147
1154
  return [3 /*break*/, 3];
1148
1155
  case 2:
1149
- e_13 = _a.sent();
1150
- this.errorCallback((e_13 && e_13.message) || e_13);
1156
+ e_14 = _a.sent();
1157
+ this.errorCallback((e_14 && e_14.message) || e_14);
1151
1158
  return [3 /*break*/, 3];
1152
1159
  case 3: return [2 /*return*/];
1153
1160
  }
@@ -1156,7 +1163,7 @@ var Swap = /** @class */ (function () {
1156
1163
  };
1157
1164
  Swap.prototype.getTerraFee = function (address, msg, gasPrices) {
1158
1165
  return __awaiter(this, void 0, void 0, function () {
1159
- var terra, accountInfo, fee, e_14;
1166
+ var terra, accountInfo, fee, e_15;
1160
1167
  return __generator(this, function (_a) {
1161
1168
  switch (_a.label) {
1162
1169
  case 0:
@@ -1186,7 +1193,7 @@ var Swap = /** @class */ (function () {
1186
1193
  accountInfo: accountInfo,
1187
1194
  }];
1188
1195
  case 3:
1189
- e_14 = _a.sent();
1196
+ e_15 = _a.sent();
1190
1197
  return [2 /*return*/, null];
1191
1198
  case 4: return [2 /*return*/];
1192
1199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/openocean-sdk",
3
- "version": "1.7.64",
3
+ "version": "1.7.66",
4
4
  "description": "Openocean sdk",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {