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