@openocean.finance/openocean-sdk 1.7.69 → 1.7.71
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.
- package/lib/swapSdk/Swap.js +52 -26
- package/package.json +1 -1
package/lib/swapSdk/Swap.js
CHANGED
|
@@ -473,12 +473,12 @@ var Swap = /** @class */ (function () {
|
|
|
473
473
|
};
|
|
474
474
|
Swap.prototype.sendNearTransaction = function () {
|
|
475
475
|
return __awaiter(this, void 0, void 0, function () {
|
|
476
|
-
var transaction, wallet_2, transactions, currentTransactions, e_5, err, txResult, transaction_1, hash, error_2;
|
|
476
|
+
var transaction, wallet_2, transactions, currentTransactions, e_5, err, txs, txResult, transaction_1, hash, txs, txResult, transaction_2, hash, error_2;
|
|
477
477
|
var _this = this;
|
|
478
478
|
return __generator(this, function (_a) {
|
|
479
479
|
switch (_a.label) {
|
|
480
480
|
case 0:
|
|
481
|
-
_a.trys.push([0,
|
|
481
|
+
_a.trys.push([0, 11, , 12]);
|
|
482
482
|
transaction = this.res.transaction;
|
|
483
483
|
wallet_2 = this.wallet;
|
|
484
484
|
console.log("sendNearTransaction", transaction, wallet_2.key);
|
|
@@ -492,9 +492,7 @@ var Swap = /** @class */ (function () {
|
|
|
492
492
|
receiverId: t.receiverId,
|
|
493
493
|
nonceOffset: i + 1,
|
|
494
494
|
actions: t.functionCalls.map(function (fc) {
|
|
495
|
-
var data = wallet_2.functionCall(fc.methodName, fc.args, fc.gas ? new bn_js_1.default(fc.gas) : new bn_js_1.default('100000000000000'),
|
|
496
|
-
// fc.deposit ? new BN8(fc.deposit) : new BN8('0')
|
|
497
|
-
fc.deposit ? new bn_js_1.default(wallet_2.utils.format.parseNearAmount(fc.deposit) || '0') : new bn_js_1.default('0'));
|
|
495
|
+
var data = wallet_2.functionCall(fc.methodName, fc.args, fc.gas ? new bn_js_1.default(fc.gas) : new bn_js_1.default('100000000000000'), fc.deposit ? new bn_js_1.default(wallet_2.utils.format.parseNearAmount(fc.deposit)) : new bn_js_1.default('0'));
|
|
498
496
|
return data;
|
|
499
497
|
})
|
|
500
498
|
}, wallet_2);
|
|
@@ -514,27 +512,26 @@ var Swap = /** @class */ (function () {
|
|
|
514
512
|
console.log("Error: " + e_5.message);
|
|
515
513
|
this.errorCallback(e_5.message);
|
|
516
514
|
return [3 /*break*/, 5];
|
|
517
|
-
case 5: return [3 /*break*/,
|
|
515
|
+
case 5: return [3 /*break*/, 10];
|
|
518
516
|
case 6:
|
|
519
|
-
if (!(wallet_2.key === "MeteorWallet"
|
|
520
|
-
|
|
521
|
-
|
|
517
|
+
if (!(wallet_2.key === "MeteorWallet")) return [3 /*break*/, 8];
|
|
518
|
+
txs = transactions.map(function (t, i) {
|
|
519
|
+
return {
|
|
520
|
+
receiverId: t.receiverId,
|
|
521
|
+
nonceOffset: i + 1,
|
|
522
|
+
actions: t.functionCalls.map(function (fc) {
|
|
523
|
+
var actions = wallet_2.functionCall(fc.methodName, fc.args, fc.gas ? fc.gas : '100000000000000', fc.deposit ? wallet_2.utils.format.parseNearAmount(fc.deposit) : '0');
|
|
524
|
+
console.log("FunctionCall", actions);
|
|
522
525
|
return {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
var actions = wallet_2.functionCall(fc.methodName, fc.args, fc.gas ? fc.gas : '100000000000000',
|
|
527
|
-
// fc.deposit ? new BN8(fc.deposit) : new BN8('0')
|
|
528
|
-
fc.deposit ? wallet_2.utils.format.parseNearAmount(fc.deposit) : '0');
|
|
529
|
-
console.log("FunctionCall", actions);
|
|
530
|
-
return {
|
|
531
|
-
type: "FunctionCall",
|
|
532
|
-
enum: actions.enum,
|
|
533
|
-
params: actions.functionCall
|
|
534
|
-
};
|
|
535
|
-
})
|
|
526
|
+
type: "FunctionCall",
|
|
527
|
+
enum: actions.enum,
|
|
528
|
+
params: actions.functionCall
|
|
536
529
|
};
|
|
537
530
|
})
|
|
531
|
+
};
|
|
532
|
+
});
|
|
533
|
+
return [4 /*yield*/, wallet_2.sdk.signAndSendTransactions({
|
|
534
|
+
transactions: txs
|
|
538
535
|
})];
|
|
539
536
|
case 7:
|
|
540
537
|
txResult = _a.sent();
|
|
@@ -556,18 +553,47 @@ var Swap = /** @class */ (function () {
|
|
|
556
553
|
if (transaction_1 && transaction_1.length) {
|
|
557
554
|
transaction_1 = transaction_1[0].transaction;
|
|
558
555
|
}
|
|
556
|
+
else {
|
|
557
|
+
transaction_1 = txResult[txResult.length - 1].transaction || {};
|
|
558
|
+
}
|
|
559
559
|
}
|
|
560
560
|
console.log('signAndSendTransactions', transaction_1);
|
|
561
561
|
hash = transaction_1.hash;
|
|
562
562
|
this.transactionHashCallback(hash);
|
|
563
|
-
|
|
564
|
-
case 8:
|
|
563
|
+
return [3 /*break*/, 10];
|
|
564
|
+
case 8:
|
|
565
|
+
if (!(wallet_2.key === "SenderWallet")) return [3 /*break*/, 10];
|
|
566
|
+
txs = transactions.map(function (t, i) {
|
|
567
|
+
return {
|
|
568
|
+
receiverId: t.receiverId,
|
|
569
|
+
nonceOffset: i + 1,
|
|
570
|
+
actions: t.functionCalls.map(function (fc) {
|
|
571
|
+
if (fc.deposit) {
|
|
572
|
+
fc.deposit = wallet_2.utils.format.parseNearAmount(fc.deposit);
|
|
573
|
+
}
|
|
574
|
+
return fc;
|
|
575
|
+
})
|
|
576
|
+
};
|
|
577
|
+
});
|
|
578
|
+
return [4 /*yield*/, wallet_2.sdk.signAndSendTransactions({
|
|
579
|
+
transactions: txs
|
|
580
|
+
})];
|
|
565
581
|
case 9:
|
|
582
|
+
txResult = _a.sent();
|
|
583
|
+
transaction_2 = { hash: "" };
|
|
584
|
+
if (txResult && txResult.response && txResult.response.length > 0) {
|
|
585
|
+
transaction_2 = txResult.response[txResult.response.length - 1].transaction || {};
|
|
586
|
+
}
|
|
587
|
+
hash = transaction_2.hash;
|
|
588
|
+
this.transactionHashCallback(hash);
|
|
589
|
+
_a.label = 10;
|
|
590
|
+
case 10: return [3 /*break*/, 12];
|
|
591
|
+
case 11:
|
|
566
592
|
error_2 = _a.sent();
|
|
567
593
|
// see "Errors"
|
|
568
594
|
this.errorCallback(error_2);
|
|
569
|
-
return [3 /*break*/,
|
|
570
|
-
case
|
|
595
|
+
return [3 /*break*/, 12];
|
|
596
|
+
case 12: return [2 /*return*/];
|
|
571
597
|
}
|
|
572
598
|
});
|
|
573
599
|
});
|