@paraspell/sdk-pjs 8.6.2 → 8.7.1
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/README.md +3 -2
- package/dist/index.cjs +165 -131
- package/dist/index.mjs +165 -131
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -96,8 +96,9 @@ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
|
|
|
96
96
|
.to(NODE /*,customParaId - optional*/ | Multilocation object /*Only works for PolkadotXCM pallet*/)
|
|
97
97
|
.currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {multilocation: AssetMultilocationString, amount: amount | AssetMultilocationJson, amount: amount} | {multilocation: Override('Custom Multilocation'), amount: amount} | {multiasset: {currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or multilocation: multilocation*/, amount: amount}})
|
|
98
98
|
.address(address | Multilocation object /*If you are sending through xTokens, you need to pass the destination and address multilocation in one object (x2)*/)
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
/*.feeAsset({symbol: 'symbol'} || {id: 'id'} || {multilocation: 'multilocation'}) // Optional parameter used when multiasset is provided or when origin is AssetHub - so user can pay in fees different than DOT
|
|
100
|
+
.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
|
|
101
|
+
.customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some node but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
|
|
101
102
|
|
|
102
103
|
const tx = await builder.build()
|
|
103
104
|
|
package/dist/index.cjs
CHANGED
|
@@ -608,25 +608,52 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
608
608
|
return calculateTransactionFee;
|
|
609
609
|
}()
|
|
610
610
|
}, {
|
|
611
|
-
key: "
|
|
611
|
+
key: "quoteAhPrice",
|
|
612
612
|
value: function () {
|
|
613
|
-
var
|
|
614
|
-
var
|
|
613
|
+
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(fromMl, toMl, amountIn) {
|
|
614
|
+
var includeFee,
|
|
615
|
+
quoted,
|
|
616
|
+
_args4 = arguments;
|
|
615
617
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
616
618
|
while (1) switch (_context4.prev = _context4.next) {
|
|
617
619
|
case 0:
|
|
618
|
-
|
|
620
|
+
includeFee = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : true;
|
|
621
|
+
_context4.next = 3;
|
|
622
|
+
return this.api.call.assetConversionApi.quotePriceExactTokensForTokens(fromMl, toMl, amountIn.toString(), includeFee);
|
|
623
|
+
case 3:
|
|
624
|
+
quoted = _context4.sent;
|
|
625
|
+
return _context4.abrupt("return", quoted.toJSON() !== null ? BigInt(quoted.toString()) : undefined);
|
|
626
|
+
case 5:
|
|
627
|
+
case "end":
|
|
628
|
+
return _context4.stop();
|
|
629
|
+
}
|
|
630
|
+
}, _callee4, this);
|
|
631
|
+
}));
|
|
632
|
+
function quoteAhPrice(_x5, _x6, _x7) {
|
|
633
|
+
return _quoteAhPrice.apply(this, arguments);
|
|
634
|
+
}
|
|
635
|
+
return quoteAhPrice;
|
|
636
|
+
}()
|
|
637
|
+
}, {
|
|
638
|
+
key: "getBalanceNative",
|
|
639
|
+
value: function () {
|
|
640
|
+
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(address) {
|
|
641
|
+
var response;
|
|
642
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
643
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
644
|
+
case 0:
|
|
645
|
+
_context5.next = 2;
|
|
619
646
|
return this.api.query.system.account(address);
|
|
620
647
|
case 2:
|
|
621
|
-
response =
|
|
622
|
-
return
|
|
648
|
+
response = _context5.sent;
|
|
649
|
+
return _context5.abrupt("return", response.data.free.toBigInt());
|
|
623
650
|
case 4:
|
|
624
651
|
case "end":
|
|
625
|
-
return
|
|
652
|
+
return _context5.stop();
|
|
626
653
|
}
|
|
627
|
-
},
|
|
654
|
+
}, _callee5, this);
|
|
628
655
|
}));
|
|
629
|
-
function getBalanceNative(
|
|
656
|
+
function getBalanceNative(_x8) {
|
|
630
657
|
return _getBalanceNative.apply(this, arguments);
|
|
631
658
|
}
|
|
632
659
|
return getBalanceNative;
|
|
@@ -634,25 +661,25 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
634
661
|
}, {
|
|
635
662
|
key: "getBalanceForeignPolkadotXcm",
|
|
636
663
|
value: function () {
|
|
637
|
-
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
664
|
+
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address, id) {
|
|
638
665
|
var parsedId, response, obj;
|
|
639
|
-
return _regeneratorRuntime().wrap(function
|
|
640
|
-
while (1) switch (
|
|
666
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
667
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
641
668
|
case 0:
|
|
642
669
|
parsedId = new types.u32(this.api.registry, id);
|
|
643
|
-
|
|
670
|
+
_context6.next = 3;
|
|
644
671
|
return this.api.query.assets.account(parsedId, address);
|
|
645
672
|
case 3:
|
|
646
|
-
response =
|
|
673
|
+
response = _context6.sent;
|
|
647
674
|
obj = response.toJSON();
|
|
648
|
-
return
|
|
675
|
+
return _context6.abrupt("return", obj.balance ? BigInt(obj.balance) : 0n);
|
|
649
676
|
case 6:
|
|
650
677
|
case "end":
|
|
651
|
-
return
|
|
678
|
+
return _context6.stop();
|
|
652
679
|
}
|
|
653
|
-
},
|
|
680
|
+
}, _callee6, this);
|
|
654
681
|
}));
|
|
655
|
-
function getBalanceForeignPolkadotXcm(
|
|
682
|
+
function getBalanceForeignPolkadotXcm(_x9, _x10) {
|
|
656
683
|
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
657
684
|
}
|
|
658
685
|
return getBalanceForeignPolkadotXcm;
|
|
@@ -660,24 +687,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
660
687
|
}, {
|
|
661
688
|
key: "getMythosForeignBalance",
|
|
662
689
|
value: function () {
|
|
663
|
-
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
690
|
+
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(address) {
|
|
664
691
|
var response, obj;
|
|
665
|
-
return _regeneratorRuntime().wrap(function
|
|
666
|
-
while (1) switch (
|
|
692
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
693
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
667
694
|
case 0:
|
|
668
|
-
|
|
695
|
+
_context7.next = 2;
|
|
669
696
|
return this.api.query.balances.account(address);
|
|
670
697
|
case 2:
|
|
671
|
-
response =
|
|
698
|
+
response = _context7.sent;
|
|
672
699
|
obj = response.toJSON();
|
|
673
|
-
return
|
|
700
|
+
return _context7.abrupt("return", obj.free ? BigInt(obj.free) : 0n);
|
|
674
701
|
case 5:
|
|
675
702
|
case "end":
|
|
676
|
-
return
|
|
703
|
+
return _context7.stop();
|
|
677
704
|
}
|
|
678
|
-
},
|
|
705
|
+
}, _callee7, this);
|
|
679
706
|
}));
|
|
680
|
-
function getMythosForeignBalance(
|
|
707
|
+
function getMythosForeignBalance(_x11) {
|
|
681
708
|
return _getMythosForeignBalance.apply(this, arguments);
|
|
682
709
|
}
|
|
683
710
|
return getMythosForeignBalance;
|
|
@@ -685,24 +712,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
685
712
|
}, {
|
|
686
713
|
key: "getAssetHubForeignBalance",
|
|
687
714
|
value: function () {
|
|
688
|
-
var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
715
|
+
var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(address, multiLocation) {
|
|
689
716
|
var response, obj;
|
|
690
|
-
return _regeneratorRuntime().wrap(function
|
|
691
|
-
while (1) switch (
|
|
717
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
718
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
692
719
|
case 0:
|
|
693
|
-
|
|
720
|
+
_context8.next = 2;
|
|
694
721
|
return this.api.query.foreignAssets.account(multiLocation, address);
|
|
695
722
|
case 2:
|
|
696
|
-
response =
|
|
723
|
+
response = _context8.sent;
|
|
697
724
|
obj = response.toJSON();
|
|
698
|
-
return
|
|
725
|
+
return _context8.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
699
726
|
case 5:
|
|
700
727
|
case "end":
|
|
701
|
-
return
|
|
728
|
+
return _context8.stop();
|
|
702
729
|
}
|
|
703
|
-
},
|
|
730
|
+
}, _callee8, this);
|
|
704
731
|
}));
|
|
705
|
-
function getAssetHubForeignBalance(
|
|
732
|
+
function getAssetHubForeignBalance(_x12, _x13) {
|
|
706
733
|
return _getAssetHubForeignBalance.apply(this, arguments);
|
|
707
734
|
}
|
|
708
735
|
return getAssetHubForeignBalance;
|
|
@@ -710,24 +737,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
710
737
|
}, {
|
|
711
738
|
key: "getForeignAssetsByIdBalance",
|
|
712
739
|
value: function () {
|
|
713
|
-
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
740
|
+
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(address, assetId) {
|
|
714
741
|
var response, obj;
|
|
715
|
-
return _regeneratorRuntime().wrap(function
|
|
716
|
-
while (1) switch (
|
|
742
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
743
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
717
744
|
case 0:
|
|
718
|
-
|
|
745
|
+
_context9.next = 2;
|
|
719
746
|
return this.api.query.foreignAssets.account(assetId, address);
|
|
720
747
|
case 2:
|
|
721
|
-
response =
|
|
748
|
+
response = _context9.sent;
|
|
722
749
|
obj = response.toJSON();
|
|
723
|
-
return
|
|
750
|
+
return _context9.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
724
751
|
case 5:
|
|
725
752
|
case "end":
|
|
726
|
-
return
|
|
753
|
+
return _context9.stop();
|
|
727
754
|
}
|
|
728
|
-
},
|
|
755
|
+
}, _callee9, this);
|
|
729
756
|
}));
|
|
730
|
-
function getForeignAssetsByIdBalance(
|
|
757
|
+
function getForeignAssetsByIdBalance(_x14, _x15) {
|
|
731
758
|
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
732
759
|
}
|
|
733
760
|
return getForeignAssetsByIdBalance;
|
|
@@ -735,25 +762,25 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
735
762
|
}, {
|
|
736
763
|
key: "getBalanceForeignBifrost",
|
|
737
764
|
value: function () {
|
|
738
|
-
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
765
|
+
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address, asset) {
|
|
739
766
|
var currencySelection, response, accountData;
|
|
740
|
-
return _regeneratorRuntime().wrap(function
|
|
741
|
-
while (1) switch (
|
|
767
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
768
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
742
769
|
case 0:
|
|
743
770
|
currencySelection = sdkCore.getNode('BifrostPolkadot').getCurrencySelection(asset);
|
|
744
|
-
|
|
771
|
+
_context10.next = 3;
|
|
745
772
|
return this.api.query.tokens.accounts(address, currencySelection);
|
|
746
773
|
case 3:
|
|
747
|
-
response =
|
|
774
|
+
response = _context10.sent;
|
|
748
775
|
accountData = response ? response : null;
|
|
749
|
-
return
|
|
776
|
+
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
750
777
|
case 6:
|
|
751
778
|
case "end":
|
|
752
|
-
return
|
|
779
|
+
return _context10.stop();
|
|
753
780
|
}
|
|
754
|
-
},
|
|
781
|
+
}, _callee10, this);
|
|
755
782
|
}));
|
|
756
|
-
function getBalanceForeignBifrost(
|
|
783
|
+
function getBalanceForeignBifrost(_x16, _x17) {
|
|
757
784
|
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
758
785
|
}
|
|
759
786
|
return getBalanceForeignBifrost;
|
|
@@ -761,26 +788,26 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
761
788
|
}, {
|
|
762
789
|
key: "getBalanceNativeAcala",
|
|
763
790
|
value: function () {
|
|
764
|
-
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
791
|
+
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(address, symbol) {
|
|
765
792
|
var response, accountData;
|
|
766
|
-
return _regeneratorRuntime().wrap(function
|
|
767
|
-
while (1) switch (
|
|
793
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
794
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
768
795
|
case 0:
|
|
769
|
-
|
|
796
|
+
_context11.next = 2;
|
|
770
797
|
return this.api.query.tokens.accounts(address, {
|
|
771
798
|
Token: symbol
|
|
772
799
|
});
|
|
773
800
|
case 2:
|
|
774
|
-
response =
|
|
801
|
+
response = _context11.sent;
|
|
775
802
|
accountData = response ? response : null;
|
|
776
|
-
return
|
|
803
|
+
return _context11.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
777
804
|
case 5:
|
|
778
805
|
case "end":
|
|
779
|
-
return
|
|
806
|
+
return _context11.stop();
|
|
780
807
|
}
|
|
781
|
-
},
|
|
808
|
+
}, _callee11, this);
|
|
782
809
|
}));
|
|
783
|
-
function getBalanceNativeAcala(
|
|
810
|
+
function getBalanceNativeAcala(_x18, _x19) {
|
|
784
811
|
return _getBalanceNativeAcala.apply(this, arguments);
|
|
785
812
|
}
|
|
786
813
|
return getBalanceNativeAcala;
|
|
@@ -788,19 +815,19 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
788
815
|
}, {
|
|
789
816
|
key: "getBalanceForeignXTokens",
|
|
790
817
|
value: function () {
|
|
791
|
-
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
818
|
+
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(node, address, asset) {
|
|
792
819
|
var pallet, response, entry, accountData;
|
|
793
|
-
return _regeneratorRuntime().wrap(function
|
|
794
|
-
while (1) switch (
|
|
820
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
821
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
795
822
|
case 0:
|
|
796
823
|
pallet = 'tokens';
|
|
797
824
|
if (node === 'Centrifuge' || node === 'Altair') {
|
|
798
825
|
pallet = 'ormlTokens';
|
|
799
826
|
}
|
|
800
|
-
|
|
827
|
+
_context12.next = 4;
|
|
801
828
|
return this.api.query[pallet].accounts.entries(address);
|
|
802
829
|
case 4:
|
|
803
|
-
response =
|
|
830
|
+
response = _context12.sent;
|
|
804
831
|
entry = response.find(function (_ref2) {
|
|
805
832
|
var _asset$symbol, _asset$assetId, _assetItem$toHuman, _asset$symbol2, _assetItem$toHuman2, _asset$assetId2;
|
|
806
833
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
@@ -812,14 +839,14 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
812
839
|
return assetSymbol === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || sdkCore.isForeignAsset(asset) && assetSymbol === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || Object.values((_assetItem$toHuman = assetItem.toHuman()) !== null && _assetItem$toHuman !== void 0 ? _assetItem$toHuman : {}).toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || sdkCore.isForeignAsset(asset) && Object.values((_assetItem$toHuman2 = assetItem.toHuman()) !== null && _assetItem$toHuman2 !== void 0 ? _assetItem$toHuman2 : {}).toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
|
|
813
840
|
});
|
|
814
841
|
accountData = entry ? entry[1] : null;
|
|
815
|
-
return
|
|
842
|
+
return _context12.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
816
843
|
case 8:
|
|
817
844
|
case "end":
|
|
818
|
-
return
|
|
845
|
+
return _context12.stop();
|
|
819
846
|
}
|
|
820
|
-
},
|
|
847
|
+
}, _callee12, this);
|
|
821
848
|
}));
|
|
822
|
-
function getBalanceForeignXTokens(
|
|
849
|
+
function getBalanceForeignXTokens(_x20, _x21, _x22) {
|
|
823
850
|
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
824
851
|
}
|
|
825
852
|
return getBalanceForeignXTokens;
|
|
@@ -827,24 +854,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
827
854
|
}, {
|
|
828
855
|
key: "getBalanceForeignAssetsAccount",
|
|
829
856
|
value: function () {
|
|
830
|
-
var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
857
|
+
var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(address, assetId) {
|
|
831
858
|
var response, obj;
|
|
832
|
-
return _regeneratorRuntime().wrap(function
|
|
833
|
-
while (1) switch (
|
|
859
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
860
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
834
861
|
case 0:
|
|
835
|
-
|
|
862
|
+
_context13.next = 2;
|
|
836
863
|
return this.api.query.assets.account(assetId, address);
|
|
837
864
|
case 2:
|
|
838
|
-
response =
|
|
865
|
+
response = _context13.sent;
|
|
839
866
|
obj = response.toJSON();
|
|
840
|
-
return
|
|
867
|
+
return _context13.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
841
868
|
case 5:
|
|
842
869
|
case "end":
|
|
843
|
-
return
|
|
870
|
+
return _context13.stop();
|
|
844
871
|
}
|
|
845
|
-
},
|
|
872
|
+
}, _callee13, this);
|
|
846
873
|
}));
|
|
847
|
-
function getBalanceForeignAssetsAccount(
|
|
874
|
+
function getBalanceForeignAssetsAccount(_x23, _x24) {
|
|
848
875
|
return _getBalanceForeignAssetsAccount.apply(this, arguments);
|
|
849
876
|
}
|
|
850
877
|
return getBalanceForeignAssetsAccount;
|
|
@@ -852,30 +879,30 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
852
879
|
}, {
|
|
853
880
|
key: "getFromRpc",
|
|
854
881
|
value: function () {
|
|
855
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
882
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(module, method, key) {
|
|
856
883
|
var rpcModule, response;
|
|
857
|
-
return _regeneratorRuntime().wrap(function
|
|
858
|
-
while (1) switch (
|
|
884
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
885
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
859
886
|
case 0:
|
|
860
887
|
rpcModule = this.api.rpc[module];
|
|
861
888
|
if (!(!rpcModule || !rpcModule[method])) {
|
|
862
|
-
|
|
889
|
+
_context14.next = 3;
|
|
863
890
|
break;
|
|
864
891
|
}
|
|
865
892
|
throw new Error("RPC method ".concat(module, ".").concat(method, " not available"));
|
|
866
893
|
case 3:
|
|
867
|
-
|
|
894
|
+
_context14.next = 5;
|
|
868
895
|
return rpcModule[method](key);
|
|
869
896
|
case 5:
|
|
870
|
-
response =
|
|
871
|
-
return
|
|
897
|
+
response = _context14.sent;
|
|
898
|
+
return _context14.abrupt("return", response.toHex());
|
|
872
899
|
case 7:
|
|
873
900
|
case "end":
|
|
874
|
-
return
|
|
901
|
+
return _context14.stop();
|
|
875
902
|
}
|
|
876
|
-
},
|
|
903
|
+
}, _callee14, this);
|
|
877
904
|
}));
|
|
878
|
-
function getFromRpc(
|
|
905
|
+
function getFromRpc(_x25, _x26, _x27) {
|
|
879
906
|
return _getFromRpc.apply(this, arguments);
|
|
880
907
|
}
|
|
881
908
|
return getFromRpc;
|
|
@@ -893,23 +920,23 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
893
920
|
}, {
|
|
894
921
|
key: "createApiForNode",
|
|
895
922
|
value: function () {
|
|
896
|
-
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
923
|
+
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(node) {
|
|
897
924
|
var api;
|
|
898
|
-
return _regeneratorRuntime().wrap(function
|
|
899
|
-
while (1) switch (
|
|
925
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
926
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
900
927
|
case 0:
|
|
901
928
|
api = new PolkadotJsApi();
|
|
902
|
-
|
|
929
|
+
_context15.next = 3;
|
|
903
930
|
return api.init(node);
|
|
904
931
|
case 3:
|
|
905
|
-
return
|
|
932
|
+
return _context15.abrupt("return", api);
|
|
906
933
|
case 4:
|
|
907
934
|
case "end":
|
|
908
|
-
return
|
|
935
|
+
return _context15.stop();
|
|
909
936
|
}
|
|
910
|
-
},
|
|
937
|
+
}, _callee15);
|
|
911
938
|
}));
|
|
912
|
-
function createApiForNode(
|
|
939
|
+
function createApiForNode(_x28) {
|
|
913
940
|
return _createApiForNode.apply(this, arguments);
|
|
914
941
|
}
|
|
915
942
|
return createApiForNode;
|
|
@@ -917,55 +944,62 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
917
944
|
}, {
|
|
918
945
|
key: "getDryRun",
|
|
919
946
|
value: function () {
|
|
920
|
-
var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
921
|
-
var tx, address, node, supportsDryRunApi, result, isSuccess, moduleError, failureReason, executionFee, fee;
|
|
922
|
-
return _regeneratorRuntime().wrap(function
|
|
923
|
-
while (1) switch (
|
|
947
|
+
var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref4) {
|
|
948
|
+
var tx, address, node, supportsDryRunApi, response, result, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight;
|
|
949
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
950
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
924
951
|
case 0:
|
|
925
952
|
tx = _ref4.tx, address = _ref4.address, node = _ref4.node;
|
|
926
953
|
supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
|
|
927
954
|
if (supportsDryRunApi) {
|
|
928
|
-
|
|
955
|
+
_context16.next = 4;
|
|
929
956
|
break;
|
|
930
957
|
}
|
|
931
958
|
throw new Error("DryRunApi is not available on node ".concat(node));
|
|
932
959
|
case 4:
|
|
933
|
-
|
|
960
|
+
_context16.next = 6;
|
|
934
961
|
return this.api.call.dryRunApi.dryRunCall({
|
|
935
962
|
system: {
|
|
936
963
|
Signed: address
|
|
937
964
|
}
|
|
938
965
|
}, tx);
|
|
939
966
|
case 6:
|
|
940
|
-
|
|
967
|
+
response = _context16.sent;
|
|
968
|
+
result = response.toHuman();
|
|
941
969
|
isSuccess = result.Ok && result.Ok.executionResult.Ok;
|
|
942
970
|
if (isSuccess) {
|
|
943
|
-
|
|
971
|
+
_context16.next = 13;
|
|
944
972
|
break;
|
|
945
973
|
}
|
|
946
974
|
moduleError = result.Ok.executionResult.Err.error.Module;
|
|
947
975
|
failureReason = sdkCore.resolveModuleError(node, moduleError);
|
|
948
|
-
return
|
|
976
|
+
return _context16.abrupt("return", {
|
|
949
977
|
success: false,
|
|
950
978
|
failureReason: failureReason
|
|
951
979
|
});
|
|
952
|
-
case
|
|
953
|
-
|
|
980
|
+
case 13:
|
|
981
|
+
_context16.next = 15;
|
|
954
982
|
return this.calculateTransactionFee(tx, address);
|
|
955
|
-
case
|
|
956
|
-
executionFee =
|
|
983
|
+
case 15:
|
|
984
|
+
executionFee = _context16.sent;
|
|
957
985
|
fee = sdkCore.computeFeeFromDryRunPjs(result, node, executionFee);
|
|
958
|
-
|
|
986
|
+
actualWeight = response.toJSON().ok.executionResult.ok.actualWeight;
|
|
987
|
+
weight = actualWeight ? {
|
|
988
|
+
refTime: BigInt(actualWeight.refTime),
|
|
989
|
+
proofSize: BigInt(actualWeight.proofSize)
|
|
990
|
+
} : undefined;
|
|
991
|
+
return _context16.abrupt("return", {
|
|
959
992
|
success: true,
|
|
960
|
-
fee: fee
|
|
993
|
+
fee: fee,
|
|
994
|
+
weight: weight
|
|
961
995
|
});
|
|
962
|
-
case
|
|
996
|
+
case 20:
|
|
963
997
|
case "end":
|
|
964
|
-
return
|
|
998
|
+
return _context16.stop();
|
|
965
999
|
}
|
|
966
|
-
},
|
|
1000
|
+
}, _callee16, this);
|
|
967
1001
|
}));
|
|
968
|
-
function getDryRun(
|
|
1002
|
+
function getDryRun(_x29) {
|
|
969
1003
|
return _getDryRun.apply(this, arguments);
|
|
970
1004
|
}
|
|
971
1005
|
return getDryRun;
|
|
@@ -983,36 +1017,36 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
983
1017
|
}, {
|
|
984
1018
|
key: "disconnect",
|
|
985
1019
|
value: function () {
|
|
986
|
-
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1020
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
987
1021
|
var force,
|
|
988
|
-
|
|
989
|
-
return _regeneratorRuntime().wrap(function
|
|
990
|
-
while (1) switch (
|
|
1022
|
+
_args17 = arguments;
|
|
1023
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1024
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
991
1025
|
case 0:
|
|
992
|
-
force =
|
|
1026
|
+
force = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : false;
|
|
993
1027
|
if (this.initialized) {
|
|
994
|
-
|
|
1028
|
+
_context17.next = 3;
|
|
995
1029
|
break;
|
|
996
1030
|
}
|
|
997
|
-
return
|
|
1031
|
+
return _context17.abrupt("return", Promise.resolve());
|
|
998
1032
|
case 3:
|
|
999
1033
|
if (!(!force && !this.disconnectAllowed)) {
|
|
1000
|
-
|
|
1034
|
+
_context17.next = 5;
|
|
1001
1035
|
break;
|
|
1002
1036
|
}
|
|
1003
|
-
return
|
|
1037
|
+
return _context17.abrupt("return");
|
|
1004
1038
|
case 5:
|
|
1005
1039
|
if (!(force || typeof this._api === 'string' || this._api === undefined)) {
|
|
1006
|
-
|
|
1040
|
+
_context17.next = 8;
|
|
1007
1041
|
break;
|
|
1008
1042
|
}
|
|
1009
|
-
|
|
1043
|
+
_context17.next = 8;
|
|
1010
1044
|
return this.api.disconnect();
|
|
1011
1045
|
case 8:
|
|
1012
1046
|
case "end":
|
|
1013
|
-
return
|
|
1047
|
+
return _context17.stop();
|
|
1014
1048
|
}
|
|
1015
|
-
},
|
|
1049
|
+
}, _callee17, this);
|
|
1016
1050
|
}));
|
|
1017
1051
|
function disconnect() {
|
|
1018
1052
|
return _disconnect.apply(this, arguments);
|
package/dist/index.mjs
CHANGED
|
@@ -607,25 +607,52 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
607
607
|
return calculateTransactionFee;
|
|
608
608
|
}()
|
|
609
609
|
}, {
|
|
610
|
-
key: "
|
|
610
|
+
key: "quoteAhPrice",
|
|
611
611
|
value: function () {
|
|
612
|
-
var
|
|
613
|
-
var
|
|
612
|
+
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(fromMl, toMl, amountIn) {
|
|
613
|
+
var includeFee,
|
|
614
|
+
quoted,
|
|
615
|
+
_args4 = arguments;
|
|
614
616
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
615
617
|
while (1) switch (_context4.prev = _context4.next) {
|
|
616
618
|
case 0:
|
|
617
|
-
|
|
619
|
+
includeFee = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : true;
|
|
620
|
+
_context4.next = 3;
|
|
621
|
+
return this.api.call.assetConversionApi.quotePriceExactTokensForTokens(fromMl, toMl, amountIn.toString(), includeFee);
|
|
622
|
+
case 3:
|
|
623
|
+
quoted = _context4.sent;
|
|
624
|
+
return _context4.abrupt("return", quoted.toJSON() !== null ? BigInt(quoted.toString()) : undefined);
|
|
625
|
+
case 5:
|
|
626
|
+
case "end":
|
|
627
|
+
return _context4.stop();
|
|
628
|
+
}
|
|
629
|
+
}, _callee4, this);
|
|
630
|
+
}));
|
|
631
|
+
function quoteAhPrice(_x5, _x6, _x7) {
|
|
632
|
+
return _quoteAhPrice.apply(this, arguments);
|
|
633
|
+
}
|
|
634
|
+
return quoteAhPrice;
|
|
635
|
+
}()
|
|
636
|
+
}, {
|
|
637
|
+
key: "getBalanceNative",
|
|
638
|
+
value: function () {
|
|
639
|
+
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(address) {
|
|
640
|
+
var response;
|
|
641
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
642
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
643
|
+
case 0:
|
|
644
|
+
_context5.next = 2;
|
|
618
645
|
return this.api.query.system.account(address);
|
|
619
646
|
case 2:
|
|
620
|
-
response =
|
|
621
|
-
return
|
|
647
|
+
response = _context5.sent;
|
|
648
|
+
return _context5.abrupt("return", response.data.free.toBigInt());
|
|
622
649
|
case 4:
|
|
623
650
|
case "end":
|
|
624
|
-
return
|
|
651
|
+
return _context5.stop();
|
|
625
652
|
}
|
|
626
|
-
},
|
|
653
|
+
}, _callee5, this);
|
|
627
654
|
}));
|
|
628
|
-
function getBalanceNative(
|
|
655
|
+
function getBalanceNative(_x8) {
|
|
629
656
|
return _getBalanceNative.apply(this, arguments);
|
|
630
657
|
}
|
|
631
658
|
return getBalanceNative;
|
|
@@ -633,25 +660,25 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
633
660
|
}, {
|
|
634
661
|
key: "getBalanceForeignPolkadotXcm",
|
|
635
662
|
value: function () {
|
|
636
|
-
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
663
|
+
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address, id) {
|
|
637
664
|
var parsedId, response, obj;
|
|
638
|
-
return _regeneratorRuntime().wrap(function
|
|
639
|
-
while (1) switch (
|
|
665
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
666
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
640
667
|
case 0:
|
|
641
668
|
parsedId = new u32(this.api.registry, id);
|
|
642
|
-
|
|
669
|
+
_context6.next = 3;
|
|
643
670
|
return this.api.query.assets.account(parsedId, address);
|
|
644
671
|
case 3:
|
|
645
|
-
response =
|
|
672
|
+
response = _context6.sent;
|
|
646
673
|
obj = response.toJSON();
|
|
647
|
-
return
|
|
674
|
+
return _context6.abrupt("return", obj.balance ? BigInt(obj.balance) : 0n);
|
|
648
675
|
case 6:
|
|
649
676
|
case "end":
|
|
650
|
-
return
|
|
677
|
+
return _context6.stop();
|
|
651
678
|
}
|
|
652
|
-
},
|
|
679
|
+
}, _callee6, this);
|
|
653
680
|
}));
|
|
654
|
-
function getBalanceForeignPolkadotXcm(
|
|
681
|
+
function getBalanceForeignPolkadotXcm(_x9, _x10) {
|
|
655
682
|
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
656
683
|
}
|
|
657
684
|
return getBalanceForeignPolkadotXcm;
|
|
@@ -659,24 +686,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
659
686
|
}, {
|
|
660
687
|
key: "getMythosForeignBalance",
|
|
661
688
|
value: function () {
|
|
662
|
-
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
689
|
+
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(address) {
|
|
663
690
|
var response, obj;
|
|
664
|
-
return _regeneratorRuntime().wrap(function
|
|
665
|
-
while (1) switch (
|
|
691
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
692
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
666
693
|
case 0:
|
|
667
|
-
|
|
694
|
+
_context7.next = 2;
|
|
668
695
|
return this.api.query.balances.account(address);
|
|
669
696
|
case 2:
|
|
670
|
-
response =
|
|
697
|
+
response = _context7.sent;
|
|
671
698
|
obj = response.toJSON();
|
|
672
|
-
return
|
|
699
|
+
return _context7.abrupt("return", obj.free ? BigInt(obj.free) : 0n);
|
|
673
700
|
case 5:
|
|
674
701
|
case "end":
|
|
675
|
-
return
|
|
702
|
+
return _context7.stop();
|
|
676
703
|
}
|
|
677
|
-
},
|
|
704
|
+
}, _callee7, this);
|
|
678
705
|
}));
|
|
679
|
-
function getMythosForeignBalance(
|
|
706
|
+
function getMythosForeignBalance(_x11) {
|
|
680
707
|
return _getMythosForeignBalance.apply(this, arguments);
|
|
681
708
|
}
|
|
682
709
|
return getMythosForeignBalance;
|
|
@@ -684,24 +711,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
684
711
|
}, {
|
|
685
712
|
key: "getAssetHubForeignBalance",
|
|
686
713
|
value: function () {
|
|
687
|
-
var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
714
|
+
var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(address, multiLocation) {
|
|
688
715
|
var response, obj;
|
|
689
|
-
return _regeneratorRuntime().wrap(function
|
|
690
|
-
while (1) switch (
|
|
716
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
717
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
691
718
|
case 0:
|
|
692
|
-
|
|
719
|
+
_context8.next = 2;
|
|
693
720
|
return this.api.query.foreignAssets.account(multiLocation, address);
|
|
694
721
|
case 2:
|
|
695
|
-
response =
|
|
722
|
+
response = _context8.sent;
|
|
696
723
|
obj = response.toJSON();
|
|
697
|
-
return
|
|
724
|
+
return _context8.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
698
725
|
case 5:
|
|
699
726
|
case "end":
|
|
700
|
-
return
|
|
727
|
+
return _context8.stop();
|
|
701
728
|
}
|
|
702
|
-
},
|
|
729
|
+
}, _callee8, this);
|
|
703
730
|
}));
|
|
704
|
-
function getAssetHubForeignBalance(
|
|
731
|
+
function getAssetHubForeignBalance(_x12, _x13) {
|
|
705
732
|
return _getAssetHubForeignBalance.apply(this, arguments);
|
|
706
733
|
}
|
|
707
734
|
return getAssetHubForeignBalance;
|
|
@@ -709,24 +736,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
709
736
|
}, {
|
|
710
737
|
key: "getForeignAssetsByIdBalance",
|
|
711
738
|
value: function () {
|
|
712
|
-
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
739
|
+
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(address, assetId) {
|
|
713
740
|
var response, obj;
|
|
714
|
-
return _regeneratorRuntime().wrap(function
|
|
715
|
-
while (1) switch (
|
|
741
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
742
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
716
743
|
case 0:
|
|
717
|
-
|
|
744
|
+
_context9.next = 2;
|
|
718
745
|
return this.api.query.foreignAssets.account(assetId, address);
|
|
719
746
|
case 2:
|
|
720
|
-
response =
|
|
747
|
+
response = _context9.sent;
|
|
721
748
|
obj = response.toJSON();
|
|
722
|
-
return
|
|
749
|
+
return _context9.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
723
750
|
case 5:
|
|
724
751
|
case "end":
|
|
725
|
-
return
|
|
752
|
+
return _context9.stop();
|
|
726
753
|
}
|
|
727
|
-
},
|
|
754
|
+
}, _callee9, this);
|
|
728
755
|
}));
|
|
729
|
-
function getForeignAssetsByIdBalance(
|
|
756
|
+
function getForeignAssetsByIdBalance(_x14, _x15) {
|
|
730
757
|
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
731
758
|
}
|
|
732
759
|
return getForeignAssetsByIdBalance;
|
|
@@ -734,25 +761,25 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
734
761
|
}, {
|
|
735
762
|
key: "getBalanceForeignBifrost",
|
|
736
763
|
value: function () {
|
|
737
|
-
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
764
|
+
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address, asset) {
|
|
738
765
|
var currencySelection, response, accountData;
|
|
739
|
-
return _regeneratorRuntime().wrap(function
|
|
740
|
-
while (1) switch (
|
|
766
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
767
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
741
768
|
case 0:
|
|
742
769
|
currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
|
|
743
|
-
|
|
770
|
+
_context10.next = 3;
|
|
744
771
|
return this.api.query.tokens.accounts(address, currencySelection);
|
|
745
772
|
case 3:
|
|
746
|
-
response =
|
|
773
|
+
response = _context10.sent;
|
|
747
774
|
accountData = response ? response : null;
|
|
748
|
-
return
|
|
775
|
+
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
749
776
|
case 6:
|
|
750
777
|
case "end":
|
|
751
|
-
return
|
|
778
|
+
return _context10.stop();
|
|
752
779
|
}
|
|
753
|
-
},
|
|
780
|
+
}, _callee10, this);
|
|
754
781
|
}));
|
|
755
|
-
function getBalanceForeignBifrost(
|
|
782
|
+
function getBalanceForeignBifrost(_x16, _x17) {
|
|
756
783
|
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
757
784
|
}
|
|
758
785
|
return getBalanceForeignBifrost;
|
|
@@ -760,26 +787,26 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
760
787
|
}, {
|
|
761
788
|
key: "getBalanceNativeAcala",
|
|
762
789
|
value: function () {
|
|
763
|
-
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
790
|
+
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(address, symbol) {
|
|
764
791
|
var response, accountData;
|
|
765
|
-
return _regeneratorRuntime().wrap(function
|
|
766
|
-
while (1) switch (
|
|
792
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
793
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
767
794
|
case 0:
|
|
768
|
-
|
|
795
|
+
_context11.next = 2;
|
|
769
796
|
return this.api.query.tokens.accounts(address, {
|
|
770
797
|
Token: symbol
|
|
771
798
|
});
|
|
772
799
|
case 2:
|
|
773
|
-
response =
|
|
800
|
+
response = _context11.sent;
|
|
774
801
|
accountData = response ? response : null;
|
|
775
|
-
return
|
|
802
|
+
return _context11.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
776
803
|
case 5:
|
|
777
804
|
case "end":
|
|
778
|
-
return
|
|
805
|
+
return _context11.stop();
|
|
779
806
|
}
|
|
780
|
-
},
|
|
807
|
+
}, _callee11, this);
|
|
781
808
|
}));
|
|
782
|
-
function getBalanceNativeAcala(
|
|
809
|
+
function getBalanceNativeAcala(_x18, _x19) {
|
|
783
810
|
return _getBalanceNativeAcala.apply(this, arguments);
|
|
784
811
|
}
|
|
785
812
|
return getBalanceNativeAcala;
|
|
@@ -787,19 +814,19 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
787
814
|
}, {
|
|
788
815
|
key: "getBalanceForeignXTokens",
|
|
789
816
|
value: function () {
|
|
790
|
-
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
817
|
+
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(node, address, asset) {
|
|
791
818
|
var pallet, response, entry, accountData;
|
|
792
|
-
return _regeneratorRuntime().wrap(function
|
|
793
|
-
while (1) switch (
|
|
819
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
820
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
794
821
|
case 0:
|
|
795
822
|
pallet = 'tokens';
|
|
796
823
|
if (node === 'Centrifuge' || node === 'Altair') {
|
|
797
824
|
pallet = 'ormlTokens';
|
|
798
825
|
}
|
|
799
|
-
|
|
826
|
+
_context12.next = 4;
|
|
800
827
|
return this.api.query[pallet].accounts.entries(address);
|
|
801
828
|
case 4:
|
|
802
|
-
response =
|
|
829
|
+
response = _context12.sent;
|
|
803
830
|
entry = response.find(function (_ref2) {
|
|
804
831
|
var _asset$symbol, _asset$assetId, _assetItem$toHuman, _asset$symbol2, _assetItem$toHuman2, _asset$assetId2;
|
|
805
832
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
@@ -811,14 +838,14 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
811
838
|
return assetSymbol === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || isForeignAsset(asset) && assetSymbol === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || Object.values((_assetItem$toHuman = assetItem.toHuman()) !== null && _assetItem$toHuman !== void 0 ? _assetItem$toHuman : {}).toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || isForeignAsset(asset) && Object.values((_assetItem$toHuman2 = assetItem.toHuman()) !== null && _assetItem$toHuman2 !== void 0 ? _assetItem$toHuman2 : {}).toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
|
|
812
839
|
});
|
|
813
840
|
accountData = entry ? entry[1] : null;
|
|
814
|
-
return
|
|
841
|
+
return _context12.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
815
842
|
case 8:
|
|
816
843
|
case "end":
|
|
817
|
-
return
|
|
844
|
+
return _context12.stop();
|
|
818
845
|
}
|
|
819
|
-
},
|
|
846
|
+
}, _callee12, this);
|
|
820
847
|
}));
|
|
821
|
-
function getBalanceForeignXTokens(
|
|
848
|
+
function getBalanceForeignXTokens(_x20, _x21, _x22) {
|
|
822
849
|
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
823
850
|
}
|
|
824
851
|
return getBalanceForeignXTokens;
|
|
@@ -826,24 +853,24 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
826
853
|
}, {
|
|
827
854
|
key: "getBalanceForeignAssetsAccount",
|
|
828
855
|
value: function () {
|
|
829
|
-
var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
856
|
+
var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(address, assetId) {
|
|
830
857
|
var response, obj;
|
|
831
|
-
return _regeneratorRuntime().wrap(function
|
|
832
|
-
while (1) switch (
|
|
858
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
859
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
833
860
|
case 0:
|
|
834
|
-
|
|
861
|
+
_context13.next = 2;
|
|
835
862
|
return this.api.query.assets.account(assetId, address);
|
|
836
863
|
case 2:
|
|
837
|
-
response =
|
|
864
|
+
response = _context13.sent;
|
|
838
865
|
obj = response.toJSON();
|
|
839
|
-
return
|
|
866
|
+
return _context13.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
840
867
|
case 5:
|
|
841
868
|
case "end":
|
|
842
|
-
return
|
|
869
|
+
return _context13.stop();
|
|
843
870
|
}
|
|
844
|
-
},
|
|
871
|
+
}, _callee13, this);
|
|
845
872
|
}));
|
|
846
|
-
function getBalanceForeignAssetsAccount(
|
|
873
|
+
function getBalanceForeignAssetsAccount(_x23, _x24) {
|
|
847
874
|
return _getBalanceForeignAssetsAccount.apply(this, arguments);
|
|
848
875
|
}
|
|
849
876
|
return getBalanceForeignAssetsAccount;
|
|
@@ -851,30 +878,30 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
851
878
|
}, {
|
|
852
879
|
key: "getFromRpc",
|
|
853
880
|
value: function () {
|
|
854
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
881
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(module, method, key) {
|
|
855
882
|
var rpcModule, response;
|
|
856
|
-
return _regeneratorRuntime().wrap(function
|
|
857
|
-
while (1) switch (
|
|
883
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
884
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
858
885
|
case 0:
|
|
859
886
|
rpcModule = this.api.rpc[module];
|
|
860
887
|
if (!(!rpcModule || !rpcModule[method])) {
|
|
861
|
-
|
|
888
|
+
_context14.next = 3;
|
|
862
889
|
break;
|
|
863
890
|
}
|
|
864
891
|
throw new Error("RPC method ".concat(module, ".").concat(method, " not available"));
|
|
865
892
|
case 3:
|
|
866
|
-
|
|
893
|
+
_context14.next = 5;
|
|
867
894
|
return rpcModule[method](key);
|
|
868
895
|
case 5:
|
|
869
|
-
response =
|
|
870
|
-
return
|
|
896
|
+
response = _context14.sent;
|
|
897
|
+
return _context14.abrupt("return", response.toHex());
|
|
871
898
|
case 7:
|
|
872
899
|
case "end":
|
|
873
|
-
return
|
|
900
|
+
return _context14.stop();
|
|
874
901
|
}
|
|
875
|
-
},
|
|
902
|
+
}, _callee14, this);
|
|
876
903
|
}));
|
|
877
|
-
function getFromRpc(
|
|
904
|
+
function getFromRpc(_x25, _x26, _x27) {
|
|
878
905
|
return _getFromRpc.apply(this, arguments);
|
|
879
906
|
}
|
|
880
907
|
return getFromRpc;
|
|
@@ -892,23 +919,23 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
892
919
|
}, {
|
|
893
920
|
key: "createApiForNode",
|
|
894
921
|
value: function () {
|
|
895
|
-
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
922
|
+
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(node) {
|
|
896
923
|
var api;
|
|
897
|
-
return _regeneratorRuntime().wrap(function
|
|
898
|
-
while (1) switch (
|
|
924
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
925
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
899
926
|
case 0:
|
|
900
927
|
api = new PolkadotJsApi();
|
|
901
|
-
|
|
928
|
+
_context15.next = 3;
|
|
902
929
|
return api.init(node);
|
|
903
930
|
case 3:
|
|
904
|
-
return
|
|
931
|
+
return _context15.abrupt("return", api);
|
|
905
932
|
case 4:
|
|
906
933
|
case "end":
|
|
907
|
-
return
|
|
934
|
+
return _context15.stop();
|
|
908
935
|
}
|
|
909
|
-
},
|
|
936
|
+
}, _callee15);
|
|
910
937
|
}));
|
|
911
|
-
function createApiForNode(
|
|
938
|
+
function createApiForNode(_x28) {
|
|
912
939
|
return _createApiForNode.apply(this, arguments);
|
|
913
940
|
}
|
|
914
941
|
return createApiForNode;
|
|
@@ -916,55 +943,62 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
916
943
|
}, {
|
|
917
944
|
key: "getDryRun",
|
|
918
945
|
value: function () {
|
|
919
|
-
var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
920
|
-
var tx, address, node, supportsDryRunApi, result, isSuccess, moduleError, failureReason, executionFee, fee;
|
|
921
|
-
return _regeneratorRuntime().wrap(function
|
|
922
|
-
while (1) switch (
|
|
946
|
+
var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref4) {
|
|
947
|
+
var tx, address, node, supportsDryRunApi, response, result, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight;
|
|
948
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
949
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
923
950
|
case 0:
|
|
924
951
|
tx = _ref4.tx, address = _ref4.address, node = _ref4.node;
|
|
925
952
|
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
926
953
|
if (supportsDryRunApi) {
|
|
927
|
-
|
|
954
|
+
_context16.next = 4;
|
|
928
955
|
break;
|
|
929
956
|
}
|
|
930
957
|
throw new Error("DryRunApi is not available on node ".concat(node));
|
|
931
958
|
case 4:
|
|
932
|
-
|
|
959
|
+
_context16.next = 6;
|
|
933
960
|
return this.api.call.dryRunApi.dryRunCall({
|
|
934
961
|
system: {
|
|
935
962
|
Signed: address
|
|
936
963
|
}
|
|
937
964
|
}, tx);
|
|
938
965
|
case 6:
|
|
939
|
-
|
|
966
|
+
response = _context16.sent;
|
|
967
|
+
result = response.toHuman();
|
|
940
968
|
isSuccess = result.Ok && result.Ok.executionResult.Ok;
|
|
941
969
|
if (isSuccess) {
|
|
942
|
-
|
|
970
|
+
_context16.next = 13;
|
|
943
971
|
break;
|
|
944
972
|
}
|
|
945
973
|
moduleError = result.Ok.executionResult.Err.error.Module;
|
|
946
974
|
failureReason = resolveModuleError(node, moduleError);
|
|
947
|
-
return
|
|
975
|
+
return _context16.abrupt("return", {
|
|
948
976
|
success: false,
|
|
949
977
|
failureReason: failureReason
|
|
950
978
|
});
|
|
951
|
-
case
|
|
952
|
-
|
|
979
|
+
case 13:
|
|
980
|
+
_context16.next = 15;
|
|
953
981
|
return this.calculateTransactionFee(tx, address);
|
|
954
|
-
case
|
|
955
|
-
executionFee =
|
|
982
|
+
case 15:
|
|
983
|
+
executionFee = _context16.sent;
|
|
956
984
|
fee = computeFeeFromDryRunPjs(result, node, executionFee);
|
|
957
|
-
|
|
985
|
+
actualWeight = response.toJSON().ok.executionResult.ok.actualWeight;
|
|
986
|
+
weight = actualWeight ? {
|
|
987
|
+
refTime: BigInt(actualWeight.refTime),
|
|
988
|
+
proofSize: BigInt(actualWeight.proofSize)
|
|
989
|
+
} : undefined;
|
|
990
|
+
return _context16.abrupt("return", {
|
|
958
991
|
success: true,
|
|
959
|
-
fee: fee
|
|
992
|
+
fee: fee,
|
|
993
|
+
weight: weight
|
|
960
994
|
});
|
|
961
|
-
case
|
|
995
|
+
case 20:
|
|
962
996
|
case "end":
|
|
963
|
-
return
|
|
997
|
+
return _context16.stop();
|
|
964
998
|
}
|
|
965
|
-
},
|
|
999
|
+
}, _callee16, this);
|
|
966
1000
|
}));
|
|
967
|
-
function getDryRun(
|
|
1001
|
+
function getDryRun(_x29) {
|
|
968
1002
|
return _getDryRun.apply(this, arguments);
|
|
969
1003
|
}
|
|
970
1004
|
return getDryRun;
|
|
@@ -982,36 +1016,36 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
982
1016
|
}, {
|
|
983
1017
|
key: "disconnect",
|
|
984
1018
|
value: function () {
|
|
985
|
-
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1019
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
986
1020
|
var force,
|
|
987
|
-
|
|
988
|
-
return _regeneratorRuntime().wrap(function
|
|
989
|
-
while (1) switch (
|
|
1021
|
+
_args17 = arguments;
|
|
1022
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1023
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
990
1024
|
case 0:
|
|
991
|
-
force =
|
|
1025
|
+
force = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : false;
|
|
992
1026
|
if (this.initialized) {
|
|
993
|
-
|
|
1027
|
+
_context17.next = 3;
|
|
994
1028
|
break;
|
|
995
1029
|
}
|
|
996
|
-
return
|
|
1030
|
+
return _context17.abrupt("return", Promise.resolve());
|
|
997
1031
|
case 3:
|
|
998
1032
|
if (!(!force && !this.disconnectAllowed)) {
|
|
999
|
-
|
|
1033
|
+
_context17.next = 5;
|
|
1000
1034
|
break;
|
|
1001
1035
|
}
|
|
1002
|
-
return
|
|
1036
|
+
return _context17.abrupt("return");
|
|
1003
1037
|
case 5:
|
|
1004
1038
|
if (!(force || typeof this._api === 'string' || this._api === undefined)) {
|
|
1005
|
-
|
|
1039
|
+
_context17.next = 8;
|
|
1006
1040
|
break;
|
|
1007
1041
|
}
|
|
1008
|
-
|
|
1042
|
+
_context17.next = 8;
|
|
1009
1043
|
return this.api.disconnect();
|
|
1010
1044
|
case 8:
|
|
1011
1045
|
case "end":
|
|
1012
|
-
return
|
|
1046
|
+
return _context17.stop();
|
|
1013
1047
|
}
|
|
1014
|
-
},
|
|
1048
|
+
}, _callee17, this);
|
|
1015
1049
|
}));
|
|
1016
1050
|
function disconnect() {
|
|
1017
1051
|
return _disconnect.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.7.1",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@snowbridge/contract-types": "0.1.32",
|
|
28
28
|
"ethers": "^6.13.5",
|
|
29
29
|
"viem": "^2.23.5",
|
|
30
|
-
"@paraspell/sdk-core": "8.
|
|
30
|
+
"@paraspell/sdk-core": "8.7.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@polkadot/api": ">= 15.0 < 16",
|