@openocean.finance/openocean-sdk 1.7.70 → 1.7.72
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 +49 -35
- package/package.json +2 -2
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,35 +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
|
-
if (fc.methodName === 'transfer') {
|
|
527
|
-
return {
|
|
528
|
-
type: "Transfer",
|
|
529
|
-
params: {
|
|
530
|
-
deposit: wallet_2.utils.format.parseNearAmount(fc.deposit)
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
var actions = wallet_2.functionCall(fc.methodName, fc.args, fc.gas ? fc.gas : '100000000000000',
|
|
535
|
-
// fc.deposit ? new BN8(fc.deposit) : new BN8('0')
|
|
536
|
-
fc.deposit ? wallet_2.utils.format.parseNearAmount(fc.deposit) : '0');
|
|
537
|
-
console.log("FunctionCall", actions);
|
|
538
|
-
return {
|
|
539
|
-
type: "FunctionCall",
|
|
540
|
-
enum: actions.enum,
|
|
541
|
-
params: actions.functionCall
|
|
542
|
-
};
|
|
543
|
-
})
|
|
526
|
+
type: "FunctionCall",
|
|
527
|
+
enum: actions.enum,
|
|
528
|
+
params: actions.functionCall
|
|
544
529
|
};
|
|
545
530
|
})
|
|
531
|
+
};
|
|
532
|
+
});
|
|
533
|
+
return [4 /*yield*/, wallet_2.sdk.signAndSendTransactions({
|
|
534
|
+
transactions: txs
|
|
546
535
|
})];
|
|
547
536
|
case 7:
|
|
548
537
|
txResult = _a.sent();
|
|
@@ -552,7 +541,6 @@ var Swap = /** @class */ (function () {
|
|
|
552
541
|
transaction_1 = txResult[txResult.length - 1].transaction || {};
|
|
553
542
|
}
|
|
554
543
|
else if (txResult && txResult.length > 1) {
|
|
555
|
-
debugger;
|
|
556
544
|
transaction_1 = txResult.filter(function (item) {
|
|
557
545
|
var _a = (item && item.transaction || {}).actions, actions = _a === void 0 ? [] : _a;
|
|
558
546
|
var _actions = actions.filter(function (fc) {
|
|
@@ -572,14 +560,40 @@ var Swap = /** @class */ (function () {
|
|
|
572
560
|
console.log('signAndSendTransactions', transaction_1);
|
|
573
561
|
hash = transaction_1.hash;
|
|
574
562
|
this.transactionHashCallback(hash);
|
|
575
|
-
|
|
576
|
-
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
|
+
})];
|
|
577
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:
|
|
578
592
|
error_2 = _a.sent();
|
|
579
593
|
// see "Errors"
|
|
580
594
|
this.errorCallback(error_2);
|
|
581
|
-
return [3 /*break*/,
|
|
582
|
-
case
|
|
595
|
+
return [3 /*break*/, 12];
|
|
596
|
+
case 12: return [2 /*return*/];
|
|
583
597
|
}
|
|
584
598
|
});
|
|
585
599
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openocean.finance/openocean-sdk",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.72",
|
|
4
4
|
"description": "Openocean sdk",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@looksrare/sdk": "^0.12.1",
|
|
29
29
|
"@mysten/sui": "^1.17.0",
|
|
30
30
|
"@ont-dev/ontology-dapi": "^0.7.3",
|
|
31
|
-
"@openocean.finance/wallet": "^1.10.
|
|
31
|
+
"@openocean.finance/wallet": "^1.10.63",
|
|
32
32
|
"@solana/web3.js": "^1.98.0",
|
|
33
33
|
"@terra-money/terra.js": "^3.1.10",
|
|
34
34
|
"@uniswap/v2-core": "^1.0.1",
|