@paraspell/sdk 8.0.0 → 8.0.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/dist/index.cjs +251 -157
- package/dist/index.d.ts +28 -7
- package/dist/index.mjs +252 -158
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -12,6 +12,31 @@ function _arrayLikeToArray(r, a) {
|
|
|
12
12
|
function _arrayWithHoles(r) {
|
|
13
13
|
if (Array.isArray(r)) return r;
|
|
14
14
|
}
|
|
15
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
16
|
+
try {
|
|
17
|
+
var i = n[a](c),
|
|
18
|
+
u = i.value;
|
|
19
|
+
} catch (n) {
|
|
20
|
+
return void e(n);
|
|
21
|
+
}
|
|
22
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
23
|
+
}
|
|
24
|
+
function _asyncToGenerator(n) {
|
|
25
|
+
return function () {
|
|
26
|
+
var t = this,
|
|
27
|
+
e = arguments;
|
|
28
|
+
return new Promise(function (r, o) {
|
|
29
|
+
var a = n.apply(t, e);
|
|
30
|
+
function _next(n) {
|
|
31
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
32
|
+
}
|
|
33
|
+
function _throw(n) {
|
|
34
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
35
|
+
}
|
|
36
|
+
_next(void 0);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
15
40
|
function _classCallCheck(a, n) {
|
|
16
41
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
17
42
|
}
|
|
@@ -74,6 +99,14 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
74
99
|
}
|
|
75
100
|
};
|
|
76
101
|
}
|
|
102
|
+
function _defineProperty(e, r, t) {
|
|
103
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
104
|
+
value: t,
|
|
105
|
+
enumerable: !0,
|
|
106
|
+
configurable: !0,
|
|
107
|
+
writable: !0
|
|
108
|
+
}) : e[r] = t, e;
|
|
109
|
+
}
|
|
77
110
|
function _iterableToArrayLimit(r, l) {
|
|
78
111
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
79
112
|
if (null != t) {
|
|
@@ -101,6 +134,27 @@ function _iterableToArrayLimit(r, l) {
|
|
|
101
134
|
function _nonIterableRest() {
|
|
102
135
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
103
136
|
}
|
|
137
|
+
function ownKeys(e, r) {
|
|
138
|
+
var t = Object.keys(e);
|
|
139
|
+
if (Object.getOwnPropertySymbols) {
|
|
140
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
141
|
+
r && (o = o.filter(function (r) {
|
|
142
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
143
|
+
})), t.push.apply(t, o);
|
|
144
|
+
}
|
|
145
|
+
return t;
|
|
146
|
+
}
|
|
147
|
+
function _objectSpread2(e) {
|
|
148
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
149
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
150
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
151
|
+
_defineProperty(e, r, t[r]);
|
|
152
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
153
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return e;
|
|
157
|
+
}
|
|
104
158
|
function _regeneratorRuntime() {
|
|
105
159
|
_regeneratorRuntime = function () {
|
|
106
160
|
return e;
|
|
@@ -436,38 +490,6 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
436
490
|
}
|
|
437
491
|
}
|
|
438
492
|
|
|
439
|
-
/******************************************************************************
|
|
440
|
-
Copyright (c) Microsoft Corporation.
|
|
441
|
-
|
|
442
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
443
|
-
purpose with or without fee is hereby granted.
|
|
444
|
-
|
|
445
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
446
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
447
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
448
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
449
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
450
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
451
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
452
|
-
***************************************************************************** */
|
|
453
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
457
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
458
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
459
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
460
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
461
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
462
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
467
|
-
var e = new Error(message);
|
|
468
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
469
|
-
};
|
|
470
|
-
|
|
471
493
|
var checkAndConvertToNumberOrBigInt = function checkAndConvertToNumberOrBigInt(input) {
|
|
472
494
|
if (!/^-?\d+$/.test(input)) {
|
|
473
495
|
throw new Error('Invalid integer string');
|
|
@@ -630,9 +652,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
630
652
|
}
|
|
631
653
|
}, {
|
|
632
654
|
key: "init",
|
|
633
|
-
value: function
|
|
634
|
-
|
|
635
|
-
var
|
|
655
|
+
value: function () {
|
|
656
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(node) {
|
|
657
|
+
var _this$_api;
|
|
636
658
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
637
659
|
while (1) switch (_context.prev = _context.next) {
|
|
638
660
|
case 0:
|
|
@@ -659,11 +681,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
659
681
|
_context.next = 18;
|
|
660
682
|
break;
|
|
661
683
|
case 10:
|
|
662
|
-
if (!((
|
|
684
|
+
if (!((_this$_api = this._api) !== null && _this$_api !== void 0)) {
|
|
663
685
|
_context.next = 14;
|
|
664
686
|
break;
|
|
665
687
|
}
|
|
666
|
-
_context.t0 =
|
|
688
|
+
_context.t0 = _this$_api;
|
|
667
689
|
_context.next = 17;
|
|
668
690
|
break;
|
|
669
691
|
case 14:
|
|
@@ -681,11 +703,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
681
703
|
}
|
|
682
704
|
}, _callee, this);
|
|
683
705
|
}));
|
|
684
|
-
|
|
706
|
+
function init(_x) {
|
|
707
|
+
return _init.apply(this, arguments);
|
|
708
|
+
}
|
|
709
|
+
return init;
|
|
710
|
+
}()
|
|
685
711
|
}, {
|
|
686
712
|
key: "createApiInstance",
|
|
687
|
-
value: function
|
|
688
|
-
|
|
713
|
+
value: function () {
|
|
714
|
+
var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(wsUrl) {
|
|
689
715
|
var isNodeJs, getWsProvider, provider;
|
|
690
716
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
691
717
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -715,7 +741,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
715
741
|
}
|
|
716
742
|
}, _callee2);
|
|
717
743
|
}));
|
|
718
|
-
|
|
744
|
+
function createApiInstance(_x2) {
|
|
745
|
+
return _createApiInstance.apply(this, arguments);
|
|
746
|
+
}
|
|
747
|
+
return createApiInstance;
|
|
748
|
+
}()
|
|
719
749
|
}, {
|
|
720
750
|
key: "createAccountId",
|
|
721
751
|
value: function createAccountId(address) {
|
|
@@ -739,8 +769,8 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
739
769
|
}
|
|
740
770
|
}, {
|
|
741
771
|
key: "calculateTransactionFee",
|
|
742
|
-
value: function
|
|
743
|
-
|
|
772
|
+
value: function () {
|
|
773
|
+
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tx, address) {
|
|
744
774
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
745
775
|
while (1) switch (_context3.prev = _context3.next) {
|
|
746
776
|
case 0:
|
|
@@ -751,11 +781,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
751
781
|
}
|
|
752
782
|
}, _callee3);
|
|
753
783
|
}));
|
|
754
|
-
|
|
784
|
+
function calculateTransactionFee(_x3, _x4) {
|
|
785
|
+
return _calculateTransactionFee.apply(this, arguments);
|
|
786
|
+
}
|
|
787
|
+
return calculateTransactionFee;
|
|
788
|
+
}()
|
|
755
789
|
}, {
|
|
756
790
|
key: "getBalanceNative",
|
|
757
|
-
value: function
|
|
758
|
-
|
|
791
|
+
value: function () {
|
|
792
|
+
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(address) {
|
|
759
793
|
var res;
|
|
760
794
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
761
795
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -771,11 +805,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
771
805
|
}
|
|
772
806
|
}, _callee4, this);
|
|
773
807
|
}));
|
|
774
|
-
|
|
808
|
+
function getBalanceNative(_x5) {
|
|
809
|
+
return _getBalanceNative.apply(this, arguments);
|
|
810
|
+
}
|
|
811
|
+
return getBalanceNative;
|
|
812
|
+
}()
|
|
775
813
|
}, {
|
|
776
814
|
key: "getBalanceForeignPolkadotXcm",
|
|
777
|
-
value: function
|
|
778
|
-
|
|
815
|
+
value: function () {
|
|
816
|
+
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(address, id) {
|
|
779
817
|
var res;
|
|
780
818
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
781
819
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -784,18 +822,22 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
784
822
|
return this.api.getUnsafeApi().query.Assets.Account.getValue(id, address);
|
|
785
823
|
case 2:
|
|
786
824
|
res = _context5.sent;
|
|
787
|
-
return _context5.abrupt("return", res && res.balance ? BigInt(res.balance) :
|
|
825
|
+
return _context5.abrupt("return", res && res.balance ? BigInt(res.balance) : 0n);
|
|
788
826
|
case 4:
|
|
789
827
|
case "end":
|
|
790
828
|
return _context5.stop();
|
|
791
829
|
}
|
|
792
830
|
}, _callee5, this);
|
|
793
831
|
}));
|
|
794
|
-
|
|
832
|
+
function getBalanceForeignPolkadotXcm(_x6, _x7) {
|
|
833
|
+
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
834
|
+
}
|
|
835
|
+
return getBalanceForeignPolkadotXcm;
|
|
836
|
+
}()
|
|
795
837
|
}, {
|
|
796
838
|
key: "getMythosForeignBalance",
|
|
797
|
-
value: function
|
|
798
|
-
|
|
839
|
+
value: function () {
|
|
840
|
+
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address) {
|
|
799
841
|
var res;
|
|
800
842
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
801
843
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -804,18 +846,22 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
804
846
|
return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
|
|
805
847
|
case 2:
|
|
806
848
|
res = _context6.sent;
|
|
807
|
-
return _context6.abrupt("return", res && res.free ? BigInt(res.free) :
|
|
849
|
+
return _context6.abrupt("return", res && res.free ? BigInt(res.free) : 0n);
|
|
808
850
|
case 4:
|
|
809
851
|
case "end":
|
|
810
852
|
return _context6.stop();
|
|
811
853
|
}
|
|
812
854
|
}, _callee6, this);
|
|
813
855
|
}));
|
|
814
|
-
|
|
856
|
+
function getMythosForeignBalance(_x8) {
|
|
857
|
+
return _getMythosForeignBalance.apply(this, arguments);
|
|
858
|
+
}
|
|
859
|
+
return getMythosForeignBalance;
|
|
860
|
+
}()
|
|
815
861
|
}, {
|
|
816
862
|
key: "getAssetHubForeignBalance",
|
|
817
|
-
value: function
|
|
818
|
-
|
|
863
|
+
value: function () {
|
|
864
|
+
var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(address, multiLocation) {
|
|
819
865
|
var transformedMultiLocation, res;
|
|
820
866
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
821
867
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -832,11 +878,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
832
878
|
}
|
|
833
879
|
}, _callee7, this);
|
|
834
880
|
}));
|
|
835
|
-
|
|
881
|
+
function getAssetHubForeignBalance(_x9, _x10) {
|
|
882
|
+
return _getAssetHubForeignBalance.apply(this, arguments);
|
|
883
|
+
}
|
|
884
|
+
return getAssetHubForeignBalance;
|
|
885
|
+
}()
|
|
836
886
|
}, {
|
|
837
887
|
key: "getForeignAssetsByIdBalance",
|
|
838
|
-
value: function
|
|
839
|
-
|
|
888
|
+
value: function () {
|
|
889
|
+
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(address, assetId) {
|
|
840
890
|
var res;
|
|
841
891
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
842
892
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -852,11 +902,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
852
902
|
}
|
|
853
903
|
}, _callee8, this);
|
|
854
904
|
}));
|
|
855
|
-
|
|
905
|
+
function getForeignAssetsByIdBalance(_x11, _x12) {
|
|
906
|
+
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
907
|
+
}
|
|
908
|
+
return getForeignAssetsByIdBalance;
|
|
909
|
+
}()
|
|
856
910
|
}, {
|
|
857
911
|
key: "getBalanceForeignBifrost",
|
|
858
|
-
value: function
|
|
859
|
-
|
|
912
|
+
value: function () {
|
|
913
|
+
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(address, asset) {
|
|
860
914
|
var currencySelection, transformedParameters, response, accountData;
|
|
861
915
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
862
916
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -868,18 +922,22 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
868
922
|
case 4:
|
|
869
923
|
response = _context9.sent;
|
|
870
924
|
accountData = response ? response : null;
|
|
871
|
-
return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) :
|
|
925
|
+
return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
872
926
|
case 7:
|
|
873
927
|
case "end":
|
|
874
928
|
return _context9.stop();
|
|
875
929
|
}
|
|
876
930
|
}, _callee9, this);
|
|
877
931
|
}));
|
|
878
|
-
|
|
932
|
+
function getBalanceForeignBifrost(_x13, _x14) {
|
|
933
|
+
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
934
|
+
}
|
|
935
|
+
return getBalanceForeignBifrost;
|
|
936
|
+
}()
|
|
879
937
|
}, {
|
|
880
938
|
key: "getBalanceNativeAcala",
|
|
881
|
-
value: function
|
|
882
|
-
|
|
939
|
+
value: function () {
|
|
940
|
+
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address, symbol) {
|
|
883
941
|
var transformedParameters, response, accountData;
|
|
884
942
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
885
943
|
while (1) switch (_context10.prev = _context10.next) {
|
|
@@ -892,18 +950,22 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
892
950
|
case 3:
|
|
893
951
|
response = _context10.sent;
|
|
894
952
|
accountData = response ? response : null;
|
|
895
|
-
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) :
|
|
953
|
+
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
896
954
|
case 6:
|
|
897
955
|
case "end":
|
|
898
956
|
return _context10.stop();
|
|
899
957
|
}
|
|
900
958
|
}, _callee10, this);
|
|
901
959
|
}));
|
|
902
|
-
|
|
960
|
+
function getBalanceNativeAcala(_x15, _x16) {
|
|
961
|
+
return _getBalanceNativeAcala.apply(this, arguments);
|
|
962
|
+
}
|
|
963
|
+
return getBalanceNativeAcala;
|
|
964
|
+
}()
|
|
903
965
|
}, {
|
|
904
966
|
key: "getBalanceForeignXTokens",
|
|
905
|
-
value: function
|
|
906
|
-
|
|
967
|
+
value: function () {
|
|
968
|
+
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(node, address, asset) {
|
|
907
969
|
var pallet, response, entry;
|
|
908
970
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
909
971
|
while (1) switch (_context11.prev = _context11.next) {
|
|
@@ -917,25 +979,29 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
917
979
|
case 4:
|
|
918
980
|
response = _context11.sent;
|
|
919
981
|
entry = response.find(function (_ref2) {
|
|
982
|
+
var _asset$symbol, _asset$assetId, _asset$symbol2, _asset$assetId2;
|
|
920
983
|
var keyArgs = _ref2.keyArgs;
|
|
921
|
-
var _a, _b, _c, _d;
|
|
922
984
|
var _keyArgs = _slicedToArray(keyArgs, 2);
|
|
923
985
|
_keyArgs[0];
|
|
924
986
|
var assetItem = _keyArgs[1];
|
|
925
|
-
return assetItem.toString().toLowerCase() === ((
|
|
987
|
+
return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || sdkCore.isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && sdkCore.isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
|
|
926
988
|
});
|
|
927
|
-
return _context11.abrupt("return",
|
|
989
|
+
return _context11.abrupt("return", entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
|
|
928
990
|
case 7:
|
|
929
991
|
case "end":
|
|
930
992
|
return _context11.stop();
|
|
931
993
|
}
|
|
932
994
|
}, _callee11, this);
|
|
933
995
|
}));
|
|
934
|
-
|
|
996
|
+
function getBalanceForeignXTokens(_x17, _x18, _x19) {
|
|
997
|
+
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
998
|
+
}
|
|
999
|
+
return getBalanceForeignXTokens;
|
|
1000
|
+
}()
|
|
935
1001
|
}, {
|
|
936
1002
|
key: "getBalanceForeignAssetsAccount",
|
|
937
|
-
value: function
|
|
938
|
-
|
|
1003
|
+
value: function () {
|
|
1004
|
+
var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(address, assetId) {
|
|
939
1005
|
var response;
|
|
940
1006
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
941
1007
|
while (1) switch (_context12.prev = _context12.next) {
|
|
@@ -951,11 +1017,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
951
1017
|
}
|
|
952
1018
|
}, _callee12, this);
|
|
953
1019
|
}));
|
|
954
|
-
|
|
1020
|
+
function getBalanceForeignAssetsAccount(_x20, _x21) {
|
|
1021
|
+
return _getBalanceForeignAssetsAccount.apply(this, arguments);
|
|
1022
|
+
}
|
|
1023
|
+
return getBalanceForeignAssetsAccount;
|
|
1024
|
+
}()
|
|
955
1025
|
}, {
|
|
956
1026
|
key: "getFromStorage",
|
|
957
|
-
value: function
|
|
958
|
-
|
|
1027
|
+
value: function () {
|
|
1028
|
+
var _getFromStorage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(key) {
|
|
959
1029
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
960
1030
|
while (1) switch (_context13.prev = _context13.next) {
|
|
961
1031
|
case 0:
|
|
@@ -966,7 +1036,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
966
1036
|
}
|
|
967
1037
|
}, _callee13, this);
|
|
968
1038
|
}));
|
|
969
|
-
|
|
1039
|
+
function getFromStorage(_x22) {
|
|
1040
|
+
return _getFromStorage.apply(this, arguments);
|
|
1041
|
+
}
|
|
1042
|
+
return getFromStorage;
|
|
1043
|
+
}()
|
|
970
1044
|
}, {
|
|
971
1045
|
key: "clone",
|
|
972
1046
|
value: function clone() {
|
|
@@ -974,8 +1048,8 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
974
1048
|
}
|
|
975
1049
|
}, {
|
|
976
1050
|
key: "createApiForNode",
|
|
977
|
-
value: function
|
|
978
|
-
|
|
1051
|
+
value: function () {
|
|
1052
|
+
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(node) {
|
|
979
1053
|
var api;
|
|
980
1054
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
981
1055
|
while (1) switch (_context14.prev = _context14.next) {
|
|
@@ -991,65 +1065,68 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
991
1065
|
}
|
|
992
1066
|
}, _callee14);
|
|
993
1067
|
}));
|
|
994
|
-
|
|
1068
|
+
function createApiForNode(_x23) {
|
|
1069
|
+
return _createApiForNode.apply(this, arguments);
|
|
1070
|
+
}
|
|
1071
|
+
return createApiForNode;
|
|
1072
|
+
}()
|
|
995
1073
|
}, {
|
|
996
1074
|
key: "getDryRun",
|
|
997
|
-
value: function
|
|
998
|
-
|
|
999
|
-
var
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
type: 'system',
|
|
1018
|
-
value: {
|
|
1019
|
-
type: 'Signed',
|
|
1020
|
-
value: address
|
|
1021
|
-
}
|
|
1022
|
-
}, tx.decodedCall);
|
|
1023
|
-
case 5:
|
|
1024
|
-
result = _context15.sent;
|
|
1025
|
-
isSuccess = result.success && result.value.execution_result.success;
|
|
1026
|
-
if (isSuccess) {
|
|
1027
|
-
_context15.next = 10;
|
|
1028
|
-
break;
|
|
1075
|
+
value: function () {
|
|
1076
|
+
var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref3) {
|
|
1077
|
+
var tx, address, node, supportsDryRunApi, result, isSuccess, failureReason, executionFee, fee;
|
|
1078
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1079
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1080
|
+
case 0:
|
|
1081
|
+
tx = _ref3.tx, address = _ref3.address, node = _ref3.node;
|
|
1082
|
+
supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
|
|
1083
|
+
if (supportsDryRunApi) {
|
|
1084
|
+
_context15.next = 4;
|
|
1085
|
+
break;
|
|
1086
|
+
}
|
|
1087
|
+
throw new Error("DryRunApi is not available on node ".concat(node));
|
|
1088
|
+
case 4:
|
|
1089
|
+
_context15.next = 6;
|
|
1090
|
+
return this.api.getUnsafeApi().apis.DryRunApi.dry_run_call({
|
|
1091
|
+
type: 'system',
|
|
1092
|
+
value: {
|
|
1093
|
+
type: 'Signed',
|
|
1094
|
+
value: address
|
|
1029
1095
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1096
|
+
}, tx.decodedCall);
|
|
1097
|
+
case 6:
|
|
1098
|
+
result = _context15.sent;
|
|
1099
|
+
isSuccess = result.success && result.value.execution_result.success;
|
|
1100
|
+
if (isSuccess) {
|
|
1101
|
+
_context15.next = 11;
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
failureReason = result.value.execution_result.value.error.value.value.type;
|
|
1105
|
+
return _context15.abrupt("return", Promise.resolve({
|
|
1106
|
+
success: false,
|
|
1107
|
+
failureReason: failureReason
|
|
1108
|
+
}));
|
|
1109
|
+
case 11:
|
|
1110
|
+
_context15.next = 13;
|
|
1111
|
+
return this.calculateTransactionFee(tx, address);
|
|
1112
|
+
case 13:
|
|
1113
|
+
executionFee = _context15.sent;
|
|
1114
|
+
fee = sdkCore.computeFeeFromDryRun(result, node, executionFee);
|
|
1115
|
+
return _context15.abrupt("return", Promise.resolve({
|
|
1116
|
+
success: true,
|
|
1117
|
+
fee: fee
|
|
1118
|
+
}));
|
|
1119
|
+
case 16:
|
|
1120
|
+
case "end":
|
|
1121
|
+
return _context15.stop();
|
|
1122
|
+
}
|
|
1123
|
+
}, _callee15, this);
|
|
1124
|
+
}));
|
|
1125
|
+
function getDryRun(_x24) {
|
|
1126
|
+
return _getDryRun.apply(this, arguments);
|
|
1127
|
+
}
|
|
1128
|
+
return getDryRun;
|
|
1129
|
+
}()
|
|
1053
1130
|
}, {
|
|
1054
1131
|
key: "setDisconnectAllowed",
|
|
1055
1132
|
value: function setDisconnectAllowed(allowed) {
|
|
@@ -1078,15 +1155,15 @@ var createApiInstanceForNode = function createApiInstanceForNode(node) {
|
|
|
1078
1155
|
return sdkCore.createApiInstanceForNode(pjsApi, node);
|
|
1079
1156
|
};
|
|
1080
1157
|
var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
1081
|
-
return function (
|
|
1082
|
-
|
|
1158
|
+
return /*#__PURE__*/function () {
|
|
1159
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
1083
1160
|
var pjsApi, optionsWithApi;
|
|
1084
1161
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1085
1162
|
while (1) switch (_context.prev = _context.next) {
|
|
1086
1163
|
case 0:
|
|
1087
1164
|
pjsApi = new PapiApi();
|
|
1088
1165
|
pjsApi.setApi(options.api);
|
|
1089
|
-
optionsWithApi =
|
|
1166
|
+
optionsWithApi = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1090
1167
|
api: pjsApi
|
|
1091
1168
|
});
|
|
1092
1169
|
return _context.abrupt("return", apiCall(optionsWithApi));
|
|
@@ -1096,7 +1173,10 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
|
1096
1173
|
}
|
|
1097
1174
|
}, _callee);
|
|
1098
1175
|
}));
|
|
1099
|
-
|
|
1176
|
+
return function (_x) {
|
|
1177
|
+
return _ref.apply(this, arguments);
|
|
1178
|
+
};
|
|
1179
|
+
}();
|
|
1100
1180
|
};
|
|
1101
1181
|
|
|
1102
1182
|
/**
|
|
@@ -1104,16 +1184,7 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
|
1104
1184
|
* @param options - The transfer options.
|
|
1105
1185
|
* @returns An extrinsic to be signed and sent.
|
|
1106
1186
|
*/
|
|
1107
|
-
var send =
|
|
1108
|
-
var papiApi = new PapiApi();
|
|
1109
|
-
papiApi.setApi(options.api);
|
|
1110
|
-
var destPapiApi = new PapiApi();
|
|
1111
|
-
destPapiApi.setApi(options.destApiForKeepAlive);
|
|
1112
|
-
return sdkCore.send(Object.assign(Object.assign({}, options), {
|
|
1113
|
-
api: papiApi,
|
|
1114
|
-
destApiForKeepAlive: destPapiApi
|
|
1115
|
-
}));
|
|
1116
|
-
};
|
|
1187
|
+
var send = createPapiApiCall(sdkCore.send);
|
|
1117
1188
|
var getDryRun = createPapiApiCall(sdkCore.getDryRun);
|
|
1118
1189
|
|
|
1119
1190
|
var transfer = /*#__PURE__*/Object.freeze({
|
|
@@ -1159,15 +1230,34 @@ var getTransferableAmount = createPapiApiCall(sdkCore.getTransferableAmount);
|
|
|
1159
1230
|
|
|
1160
1231
|
var assets = /*#__PURE__*/Object.freeze({
|
|
1161
1232
|
__proto__: null,
|
|
1233
|
+
Foreign: sdkCore.Foreign,
|
|
1234
|
+
ForeignAbstract: sdkCore.ForeignAbstract,
|
|
1235
|
+
Native: sdkCore.Native,
|
|
1236
|
+
Override: sdkCore.Override,
|
|
1162
1237
|
claimAssets: claimAssets,
|
|
1238
|
+
getAllAssetsSymbols: sdkCore.getAllAssetsSymbols,
|
|
1163
1239
|
getAssetBalance: getAssetBalance,
|
|
1240
|
+
getAssetBySymbolOrId: sdkCore.getAssetBySymbolOrId,
|
|
1241
|
+
getAssetDecimals: sdkCore.getAssetDecimals,
|
|
1242
|
+
getAssetId: sdkCore.getAssetId,
|
|
1243
|
+
getAssets: sdkCore.getAssets,
|
|
1244
|
+
getAssetsObject: sdkCore.getAssetsObject,
|
|
1164
1245
|
getBalanceForeign: getBalanceForeign,
|
|
1165
1246
|
getBalanceNative: getBalanceNative,
|
|
1247
|
+
getExistentialDeposit: sdkCore.getExistentialDeposit,
|
|
1166
1248
|
getMaxForeignTransferableAmount: getMaxForeignTransferableAmount,
|
|
1167
1249
|
getMaxNativeTransferableAmount: getMaxNativeTransferableAmount,
|
|
1250
|
+
getNativeAssetSymbol: sdkCore.getNativeAssetSymbol,
|
|
1251
|
+
getNativeAssets: sdkCore.getNativeAssets,
|
|
1168
1252
|
getOriginFeeDetails: getOriginFeeDetails,
|
|
1253
|
+
getOtherAssets: sdkCore.getOtherAssets,
|
|
1254
|
+
getRelayChainSymbol: sdkCore.getRelayChainSymbol,
|
|
1255
|
+
getSupportedAssets: sdkCore.getSupportedAssets,
|
|
1256
|
+
getTNode: sdkCore.getTNode,
|
|
1169
1257
|
getTransferInfo: getTransferInfo,
|
|
1170
|
-
getTransferableAmount: getTransferableAmount
|
|
1258
|
+
getTransferableAmount: getTransferableAmount,
|
|
1259
|
+
hasSupportForAsset: sdkCore.hasSupportForAsset,
|
|
1260
|
+
isNodeEvm: sdkCore.isNodeEvm
|
|
1171
1261
|
});
|
|
1172
1262
|
|
|
1173
1263
|
/**
|
|
@@ -1240,8 +1330,8 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1240
1330
|
*/
|
|
1241
1331
|
}, {
|
|
1242
1332
|
key: "build",
|
|
1243
|
-
value: function
|
|
1244
|
-
|
|
1333
|
+
value: (function () {
|
|
1334
|
+
var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1245
1335
|
var requiredParams, _i, _requiredParams, param;
|
|
1246
1336
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1247
1337
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -1274,7 +1364,11 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1274
1364
|
}
|
|
1275
1365
|
}, _callee, this);
|
|
1276
1366
|
}));
|
|
1277
|
-
|
|
1367
|
+
function build() {
|
|
1368
|
+
return _build.apply(this, arguments);
|
|
1369
|
+
}
|
|
1370
|
+
return build;
|
|
1371
|
+
}())
|
|
1278
1372
|
}]);
|
|
1279
1373
|
}();
|
|
1280
1374
|
/**
|