@paraspell/sdk 10.10.10 → 10.11.0
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 +33 -4
- package/dist/index.cjs +255 -240
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +256 -241
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidParameterError, BatchMode, getNodeProviders, createApiInstanceForNode as createApiInstanceForNode$1,
|
|
1
|
+
import { InvalidParameterError, isConfig, BatchMode, getNodeProviders, MissingChainApiError, NodeNotSupportedError, createApiInstanceForNode as createApiInstanceForNode$1, Parents, Version, getNode, isForeignAsset, computeFeeFromDryRun, findAsset, Native, getNativeAssetSymbol, hasXcmPaymentApiSupport, getAssetsObject, localizeLocation, isRelayChain, InvalidCurrencyError, padFeeBy, isAssetEqual, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Override, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { blake2b } from '@noble/hashes/blake2';
|
|
4
4
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
@@ -547,7 +547,7 @@ function createClientCache(maxSize, onEviction) {
|
|
|
547
547
|
// Call rpc.properties to keep the connection alive
|
|
548
548
|
void _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
549
549
|
return _regenerator().w(function (_context) {
|
|
550
|
-
while (1) switch (_context.n) {
|
|
550
|
+
while (1) switch (_context.p = _context.n) {
|
|
551
551
|
case 0:
|
|
552
552
|
_context.p = 0;
|
|
553
553
|
_context.n = 1;
|
|
@@ -784,21 +784,17 @@ var isHex = function isHex(str) {
|
|
|
784
784
|
return typeof str === 'string' && /^0x[0-9a-fA-F]+$/.test(str);
|
|
785
785
|
};
|
|
786
786
|
var PapiApi = /*#__PURE__*/function () {
|
|
787
|
-
function PapiApi() {
|
|
787
|
+
function PapiApi(config) {
|
|
788
788
|
_classCallCheck(this, PapiApi);
|
|
789
789
|
this._ttlMs = DEFAULT_TTL_MS;
|
|
790
790
|
this.initialized = false;
|
|
791
791
|
this.disconnectAllowed = true;
|
|
792
|
+
this._config = config;
|
|
792
793
|
}
|
|
793
794
|
return _createClass(PapiApi, [{
|
|
794
|
-
key: "
|
|
795
|
-
value: function
|
|
796
|
-
this.
|
|
797
|
-
}
|
|
798
|
-
}, {
|
|
799
|
-
key: "getApiOrUrl",
|
|
800
|
-
value: function getApiOrUrl() {
|
|
801
|
-
return this._api;
|
|
795
|
+
key: "getConfig",
|
|
796
|
+
value: function getConfig() {
|
|
797
|
+
return this._config;
|
|
802
798
|
}
|
|
803
799
|
}, {
|
|
804
800
|
key: "getApi",
|
|
@@ -808,57 +804,41 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
808
804
|
}, {
|
|
809
805
|
key: "init",
|
|
810
806
|
value: function () {
|
|
811
|
-
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(
|
|
807
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(chain) {
|
|
812
808
|
var clientTtlMs,
|
|
813
|
-
|
|
814
|
-
_args3 = arguments
|
|
815
|
-
_t3;
|
|
809
|
+
apiConfig,
|
|
810
|
+
_args3 = arguments;
|
|
816
811
|
return _regenerator().w(function (_context3) {
|
|
817
812
|
while (1) switch (_context3.n) {
|
|
818
813
|
case 0:
|
|
819
814
|
clientTtlMs = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : DEFAULT_TTL_MS;
|
|
820
|
-
if (!(this.initialized ||
|
|
815
|
+
if (!(this.initialized || chain === 'Ethereum')) {
|
|
821
816
|
_context3.n = 1;
|
|
822
817
|
break;
|
|
823
818
|
}
|
|
824
819
|
return _context3.a(2);
|
|
825
820
|
case 1:
|
|
826
|
-
if (!unsupportedNodes.includes(
|
|
821
|
+
if (!unsupportedNodes.includes(chain)) {
|
|
827
822
|
_context3.n = 2;
|
|
828
823
|
break;
|
|
829
824
|
}
|
|
830
|
-
throw new NodeNotSupportedError("The node ".concat(
|
|
825
|
+
throw new NodeNotSupportedError("The node ".concat(chain, " is not yet supported by the Polkadot API."));
|
|
831
826
|
case 2:
|
|
832
827
|
this._ttlMs = clientTtlMs;
|
|
833
|
-
|
|
834
|
-
|
|
828
|
+
this._node = chain;
|
|
829
|
+
apiConfig = this.getApiConfigForChain(chain); // For development mode, api for each used chain must be provided
|
|
830
|
+
if (!(isConfig(this._config) && this._config.development && !apiConfig)) {
|
|
831
|
+
_context3.n = 3;
|
|
835
832
|
break;
|
|
836
833
|
}
|
|
837
|
-
|
|
838
|
-
return this.createApiInstance(this._api);
|
|
834
|
+
throw new MissingChainApiError(chain);
|
|
839
835
|
case 3:
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
break;
|
|
836
|
+
_context3.n = 4;
|
|
837
|
+
return this.resolveApi(apiConfig, chain);
|
|
843
838
|
case 4:
|
|
844
|
-
|
|
845
|
-
_context3.n = 5;
|
|
846
|
-
break;
|
|
847
|
-
}
|
|
848
|
-
_t3 = _this$_api;
|
|
849
|
-
_context3.n = 7;
|
|
850
|
-
break;
|
|
851
|
-
case 5:
|
|
852
|
-
_context3.n = 6;
|
|
853
|
-
return createApiInstanceForNode$1(this, node);
|
|
854
|
-
case 6:
|
|
855
|
-
_t3 = _context3.v;
|
|
856
|
-
case 7:
|
|
857
|
-
this.api = _t3;
|
|
858
|
-
case 8:
|
|
859
|
-
this._node = node;
|
|
839
|
+
this.api = _context3.v;
|
|
860
840
|
this.initialized = true;
|
|
861
|
-
case
|
|
841
|
+
case 5:
|
|
862
842
|
return _context3.a(2);
|
|
863
843
|
}
|
|
864
844
|
}, _callee3, this);
|
|
@@ -869,17 +849,54 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
869
849
|
return init;
|
|
870
850
|
}()
|
|
871
851
|
}, {
|
|
872
|
-
key: "
|
|
852
|
+
key: "getApiConfigForChain",
|
|
853
|
+
value: function getApiConfigForChain(chain) {
|
|
854
|
+
if (isConfig(this._config)) {
|
|
855
|
+
var _this$_config$apiOver;
|
|
856
|
+
return (_this$_config$apiOver = this._config.apiOverrides) === null || _this$_config$apiOver === void 0 ? void 0 : _this$_config$apiOver[chain];
|
|
857
|
+
}
|
|
858
|
+
return this._config;
|
|
859
|
+
}
|
|
860
|
+
}, {
|
|
861
|
+
key: "resolveApi",
|
|
873
862
|
value: function () {
|
|
874
|
-
var
|
|
863
|
+
var _resolveApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(apiConfig, chain) {
|
|
875
864
|
return _regenerator().w(function (_context4) {
|
|
876
865
|
while (1) switch (_context4.n) {
|
|
877
866
|
case 0:
|
|
878
|
-
|
|
867
|
+
if (apiConfig) {
|
|
868
|
+
_context4.n = 1;
|
|
869
|
+
break;
|
|
870
|
+
}
|
|
871
|
+
return _context4.a(2, createApiInstanceForNode$1(this, chain));
|
|
872
|
+
case 1:
|
|
873
|
+
if (!(typeof apiConfig === 'string' || apiConfig instanceof Array)) {
|
|
874
|
+
_context4.n = 2;
|
|
875
|
+
break;
|
|
876
|
+
}
|
|
877
|
+
return _context4.a(2, this.createApiInstance(apiConfig));
|
|
878
|
+
case 2:
|
|
879
|
+
return _context4.a(2, apiConfig);
|
|
879
880
|
}
|
|
880
881
|
}, _callee4, this);
|
|
881
882
|
}));
|
|
882
|
-
function
|
|
883
|
+
function resolveApi(_x5, _x6) {
|
|
884
|
+
return _resolveApi.apply(this, arguments);
|
|
885
|
+
}
|
|
886
|
+
return resolveApi;
|
|
887
|
+
}()
|
|
888
|
+
}, {
|
|
889
|
+
key: "createApiInstance",
|
|
890
|
+
value: function () {
|
|
891
|
+
var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(wsUrl) {
|
|
892
|
+
return _regenerator().w(function (_context5) {
|
|
893
|
+
while (1) switch (_context5.n) {
|
|
894
|
+
case 0:
|
|
895
|
+
return _context5.a(2, leasePolkadotClient(wsUrl, this._ttlMs));
|
|
896
|
+
}
|
|
897
|
+
}, _callee5, this);
|
|
898
|
+
}));
|
|
899
|
+
function createApiInstance(_x7) {
|
|
883
900
|
return _createApiInstance.apply(this, arguments);
|
|
884
901
|
}
|
|
885
902
|
return createApiInstance;
|
|
@@ -923,10 +940,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
923
940
|
}, {
|
|
924
941
|
key: "objectToHex",
|
|
925
942
|
value: function () {
|
|
926
|
-
var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
943
|
+
var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(obj) {
|
|
927
944
|
var transformedObj, tx, removeFirst5Bytes, encodedData;
|
|
928
|
-
return _regenerator().w(function (
|
|
929
|
-
while (1) switch (
|
|
945
|
+
return _regenerator().w(function (_context6) {
|
|
946
|
+
while (1) switch (_context6.n) {
|
|
930
947
|
case 0:
|
|
931
948
|
transformedObj = _transform(obj);
|
|
932
949
|
tx = this.api.getUnsafeApi().tx.PolkadotXcm.send({
|
|
@@ -944,15 +961,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
944
961
|
removeFirst5Bytes = function removeFirst5Bytes(hexString) {
|
|
945
962
|
return '0x' + hexString.slice(12);
|
|
946
963
|
};
|
|
947
|
-
|
|
964
|
+
_context6.n = 1;
|
|
948
965
|
return tx.getEncodedData();
|
|
949
966
|
case 1:
|
|
950
|
-
encodedData =
|
|
951
|
-
return
|
|
967
|
+
encodedData = _context6.v;
|
|
968
|
+
return _context6.a(2, removeFirst5Bytes(encodedData.asHex()));
|
|
952
969
|
}
|
|
953
|
-
},
|
|
970
|
+
}, _callee6, this);
|
|
954
971
|
}));
|
|
955
|
-
function objectToHex(
|
|
972
|
+
function objectToHex(_x8) {
|
|
956
973
|
return _objectToHex.apply(this, arguments);
|
|
957
974
|
}
|
|
958
975
|
return objectToHex;
|
|
@@ -982,15 +999,15 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
982
999
|
}, {
|
|
983
1000
|
key: "calculateTransactionFee",
|
|
984
1001
|
value: function () {
|
|
985
|
-
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
986
|
-
return _regenerator().w(function (
|
|
987
|
-
while (1) switch (
|
|
1002
|
+
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(tx, address) {
|
|
1003
|
+
return _regenerator().w(function (_context7) {
|
|
1004
|
+
while (1) switch (_context7.n) {
|
|
988
1005
|
case 0:
|
|
989
|
-
return
|
|
1006
|
+
return _context7.a(2, tx.getEstimatedFees(address));
|
|
990
1007
|
}
|
|
991
|
-
},
|
|
1008
|
+
}, _callee7);
|
|
992
1009
|
}));
|
|
993
|
-
function calculateTransactionFee(
|
|
1010
|
+
function calculateTransactionFee(_x9, _x0) {
|
|
994
1011
|
return _calculateTransactionFee.apply(this, arguments);
|
|
995
1012
|
}
|
|
996
1013
|
return calculateTransactionFee;
|
|
@@ -998,27 +1015,27 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
998
1015
|
}, {
|
|
999
1016
|
key: "quoteAhPrice",
|
|
1000
1017
|
value: function () {
|
|
1001
|
-
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1018
|
+
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(fromMl, toMl, amountIn) {
|
|
1002
1019
|
var includeFee,
|
|
1003
1020
|
transformedFromMl,
|
|
1004
1021
|
transformedToMl,
|
|
1005
1022
|
response,
|
|
1006
|
-
|
|
1007
|
-
return _regenerator().w(function (
|
|
1008
|
-
while (1) switch (
|
|
1023
|
+
_args8 = arguments;
|
|
1024
|
+
return _regenerator().w(function (_context8) {
|
|
1025
|
+
while (1) switch (_context8.n) {
|
|
1009
1026
|
case 0:
|
|
1010
|
-
includeFee =
|
|
1027
|
+
includeFee = _args8.length > 3 && _args8[3] !== undefined ? _args8[3] : true;
|
|
1011
1028
|
transformedFromMl = _transform(fromMl);
|
|
1012
1029
|
transformedToMl = _transform(toMl);
|
|
1013
|
-
|
|
1030
|
+
_context8.n = 1;
|
|
1014
1031
|
return this.api.getUnsafeApi().apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(transformedFromMl, transformedToMl, amountIn, includeFee);
|
|
1015
1032
|
case 1:
|
|
1016
|
-
response =
|
|
1017
|
-
return
|
|
1033
|
+
response = _context8.v;
|
|
1034
|
+
return _context8.a(2, response ? BigInt(response) : undefined);
|
|
1018
1035
|
}
|
|
1019
|
-
},
|
|
1036
|
+
}, _callee8, this);
|
|
1020
1037
|
}));
|
|
1021
|
-
function quoteAhPrice(
|
|
1038
|
+
function quoteAhPrice(_x1, _x10, _x11) {
|
|
1022
1039
|
return _quoteAhPrice.apply(this, arguments);
|
|
1023
1040
|
}
|
|
1024
1041
|
return quoteAhPrice;
|
|
@@ -1026,20 +1043,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1026
1043
|
}, {
|
|
1027
1044
|
key: "getBalanceNative",
|
|
1028
1045
|
value: function () {
|
|
1029
|
-
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1046
|
+
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address) {
|
|
1030
1047
|
var res;
|
|
1031
|
-
return _regenerator().w(function (
|
|
1032
|
-
while (1) switch (
|
|
1048
|
+
return _regenerator().w(function (_context9) {
|
|
1049
|
+
while (1) switch (_context9.n) {
|
|
1033
1050
|
case 0:
|
|
1034
|
-
|
|
1051
|
+
_context9.n = 1;
|
|
1035
1052
|
return this.api.getUnsafeApi().query.System.Account.getValue(address);
|
|
1036
1053
|
case 1:
|
|
1037
|
-
res =
|
|
1038
|
-
return
|
|
1054
|
+
res = _context9.v;
|
|
1055
|
+
return _context9.a(2, res.data.free);
|
|
1039
1056
|
}
|
|
1040
|
-
},
|
|
1057
|
+
}, _callee9, this);
|
|
1041
1058
|
}));
|
|
1042
|
-
function getBalanceNative(
|
|
1059
|
+
function getBalanceNative(_x12) {
|
|
1043
1060
|
return _getBalanceNative.apply(this, arguments);
|
|
1044
1061
|
}
|
|
1045
1062
|
return getBalanceNative;
|
|
@@ -1047,20 +1064,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1047
1064
|
}, {
|
|
1048
1065
|
key: "getBalanceForeignPolkadotXcm",
|
|
1049
1066
|
value: function () {
|
|
1050
|
-
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1067
|
+
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(address, id) {
|
|
1051
1068
|
var res;
|
|
1052
|
-
return _regenerator().w(function (
|
|
1053
|
-
while (1) switch (
|
|
1069
|
+
return _regenerator().w(function (_context0) {
|
|
1070
|
+
while (1) switch (_context0.n) {
|
|
1054
1071
|
case 0:
|
|
1055
|
-
|
|
1072
|
+
_context0.n = 1;
|
|
1056
1073
|
return this.api.getUnsafeApi().query.Assets.Account.getValue(id, address);
|
|
1057
1074
|
case 1:
|
|
1058
|
-
res =
|
|
1059
|
-
return
|
|
1075
|
+
res = _context0.v;
|
|
1076
|
+
return _context0.a(2, res && res.balance ? BigInt(res.balance) : 0n);
|
|
1060
1077
|
}
|
|
1061
|
-
},
|
|
1078
|
+
}, _callee0, this);
|
|
1062
1079
|
}));
|
|
1063
|
-
function getBalanceForeignPolkadotXcm(
|
|
1080
|
+
function getBalanceForeignPolkadotXcm(_x13, _x14) {
|
|
1064
1081
|
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
1065
1082
|
}
|
|
1066
1083
|
return getBalanceForeignPolkadotXcm;
|
|
@@ -1068,20 +1085,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1068
1085
|
}, {
|
|
1069
1086
|
key: "getMythosForeignBalance",
|
|
1070
1087
|
value: function () {
|
|
1071
|
-
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1088
|
+
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(address) {
|
|
1072
1089
|
var res;
|
|
1073
|
-
return _regenerator().w(function (
|
|
1074
|
-
while (1) switch (
|
|
1090
|
+
return _regenerator().w(function (_context1) {
|
|
1091
|
+
while (1) switch (_context1.n) {
|
|
1075
1092
|
case 0:
|
|
1076
|
-
|
|
1093
|
+
_context1.n = 1;
|
|
1077
1094
|
return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
|
|
1078
1095
|
case 1:
|
|
1079
|
-
res =
|
|
1080
|
-
return
|
|
1096
|
+
res = _context1.v;
|
|
1097
|
+
return _context1.a(2, res && res.free ? BigInt(res.free) : 0n);
|
|
1081
1098
|
}
|
|
1082
|
-
},
|
|
1099
|
+
}, _callee1, this);
|
|
1083
1100
|
}));
|
|
1084
|
-
function getMythosForeignBalance(
|
|
1101
|
+
function getMythosForeignBalance(_x15) {
|
|
1085
1102
|
return _getMythosForeignBalance.apply(this, arguments);
|
|
1086
1103
|
}
|
|
1087
1104
|
return getMythosForeignBalance;
|
|
@@ -1089,21 +1106,21 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1089
1106
|
}, {
|
|
1090
1107
|
key: "getBalanceForeignAssetsPallet",
|
|
1091
1108
|
value: function () {
|
|
1092
|
-
var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1109
|
+
var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(address, multiLocation) {
|
|
1093
1110
|
var transformedMultiLocation, res;
|
|
1094
|
-
return _regenerator().w(function (
|
|
1095
|
-
while (1) switch (
|
|
1111
|
+
return _regenerator().w(function (_context10) {
|
|
1112
|
+
while (1) switch (_context10.n) {
|
|
1096
1113
|
case 0:
|
|
1097
1114
|
transformedMultiLocation = _transform(multiLocation);
|
|
1098
|
-
|
|
1115
|
+
_context10.n = 1;
|
|
1099
1116
|
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedMultiLocation, address);
|
|
1100
1117
|
case 1:
|
|
1101
|
-
res =
|
|
1102
|
-
return
|
|
1118
|
+
res = _context10.v;
|
|
1119
|
+
return _context10.a(2, BigInt(res === undefined ? 0 : res.balance));
|
|
1103
1120
|
}
|
|
1104
|
-
},
|
|
1121
|
+
}, _callee10, this);
|
|
1105
1122
|
}));
|
|
1106
|
-
function getBalanceForeignAssetsPallet(
|
|
1123
|
+
function getBalanceForeignAssetsPallet(_x16, _x17) {
|
|
1107
1124
|
return _getBalanceForeignAssetsPallet.apply(this, arguments);
|
|
1108
1125
|
}
|
|
1109
1126
|
return getBalanceForeignAssetsPallet;
|
|
@@ -1111,20 +1128,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1111
1128
|
}, {
|
|
1112
1129
|
key: "getForeignAssetsByIdBalance",
|
|
1113
1130
|
value: function () {
|
|
1114
|
-
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1131
|
+
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(address, assetId) {
|
|
1115
1132
|
var res;
|
|
1116
|
-
return _regenerator().w(function (
|
|
1117
|
-
while (1) switch (
|
|
1133
|
+
return _regenerator().w(function (_context11) {
|
|
1134
|
+
while (1) switch (_context11.n) {
|
|
1118
1135
|
case 0:
|
|
1119
|
-
|
|
1136
|
+
_context11.n = 1;
|
|
1120
1137
|
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(assetId, address);
|
|
1121
1138
|
case 1:
|
|
1122
|
-
res =
|
|
1123
|
-
return
|
|
1139
|
+
res = _context11.v;
|
|
1140
|
+
return _context11.a(2, BigInt(res === undefined ? 0 : res.balance));
|
|
1124
1141
|
}
|
|
1125
|
-
},
|
|
1142
|
+
}, _callee11, this);
|
|
1126
1143
|
}));
|
|
1127
|
-
function getForeignAssetsByIdBalance(
|
|
1144
|
+
function getForeignAssetsByIdBalance(_x18, _x19) {
|
|
1128
1145
|
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
1129
1146
|
}
|
|
1130
1147
|
return getForeignAssetsByIdBalance;
|
|
@@ -1132,23 +1149,23 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1132
1149
|
}, {
|
|
1133
1150
|
key: "getBalanceForeignBifrost",
|
|
1134
1151
|
value: function () {
|
|
1135
|
-
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1152
|
+
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(address, asset) {
|
|
1136
1153
|
var currencySelection, transformedParameters, response, accountData;
|
|
1137
|
-
return _regenerator().w(function (
|
|
1138
|
-
while (1) switch (
|
|
1154
|
+
return _regenerator().w(function (_context12) {
|
|
1155
|
+
while (1) switch (_context12.n) {
|
|
1139
1156
|
case 0:
|
|
1140
1157
|
currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
|
|
1141
1158
|
transformedParameters = _transform(currencySelection);
|
|
1142
|
-
|
|
1159
|
+
_context12.n = 1;
|
|
1143
1160
|
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
1144
1161
|
case 1:
|
|
1145
|
-
response =
|
|
1162
|
+
response = _context12.v;
|
|
1146
1163
|
accountData = response ? response : null;
|
|
1147
|
-
return
|
|
1164
|
+
return _context12.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
1148
1165
|
}
|
|
1149
|
-
},
|
|
1166
|
+
}, _callee12, this);
|
|
1150
1167
|
}));
|
|
1151
|
-
function getBalanceForeignBifrost(
|
|
1168
|
+
function getBalanceForeignBifrost(_x20, _x21) {
|
|
1152
1169
|
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
1153
1170
|
}
|
|
1154
1171
|
return getBalanceForeignBifrost;
|
|
@@ -1156,24 +1173,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1156
1173
|
}, {
|
|
1157
1174
|
key: "getBalanceNativeAcala",
|
|
1158
1175
|
value: function () {
|
|
1159
|
-
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1176
|
+
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(address, symbol) {
|
|
1160
1177
|
var transformedParameters, response, accountData;
|
|
1161
|
-
return _regenerator().w(function (
|
|
1162
|
-
while (1) switch (
|
|
1178
|
+
return _regenerator().w(function (_context13) {
|
|
1179
|
+
while (1) switch (_context13.n) {
|
|
1163
1180
|
case 0:
|
|
1164
1181
|
transformedParameters = _transform({
|
|
1165
1182
|
Token: symbol
|
|
1166
1183
|
});
|
|
1167
|
-
|
|
1184
|
+
_context13.n = 1;
|
|
1168
1185
|
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
1169
1186
|
case 1:
|
|
1170
|
-
response =
|
|
1187
|
+
response = _context13.v;
|
|
1171
1188
|
accountData = response ? response : null;
|
|
1172
|
-
return
|
|
1189
|
+
return _context13.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
1173
1190
|
}
|
|
1174
|
-
},
|
|
1191
|
+
}, _callee13, this);
|
|
1175
1192
|
}));
|
|
1176
|
-
function getBalanceNativeAcala(
|
|
1193
|
+
function getBalanceNativeAcala(_x22, _x23) {
|
|
1177
1194
|
return _getBalanceNativeAcala.apply(this, arguments);
|
|
1178
1195
|
}
|
|
1179
1196
|
return getBalanceNativeAcala;
|
|
@@ -1181,19 +1198,19 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1181
1198
|
}, {
|
|
1182
1199
|
key: "getBalanceForeignXTokens",
|
|
1183
1200
|
value: function () {
|
|
1184
|
-
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1201
|
+
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(node, address, asset) {
|
|
1185
1202
|
var pallet, response, entry;
|
|
1186
|
-
return _regenerator().w(function (
|
|
1187
|
-
while (1) switch (
|
|
1203
|
+
return _regenerator().w(function (_context14) {
|
|
1204
|
+
while (1) switch (_context14.n) {
|
|
1188
1205
|
case 0:
|
|
1189
1206
|
pallet = 'Tokens';
|
|
1190
1207
|
if (node === 'Centrifuge' || node === 'Altair') {
|
|
1191
1208
|
pallet = 'OrmlTokens';
|
|
1192
1209
|
}
|
|
1193
|
-
|
|
1210
|
+
_context14.n = 1;
|
|
1194
1211
|
return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
|
|
1195
1212
|
case 1:
|
|
1196
|
-
response =
|
|
1213
|
+
response = _context14.v;
|
|
1197
1214
|
entry = response.find(function (_ref5) {
|
|
1198
1215
|
var _asset$symbol, _asset$assetId, _asset$symbol2, _asset$assetId2;
|
|
1199
1216
|
var keyArgs = _ref5.keyArgs;
|
|
@@ -1202,11 +1219,11 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1202
1219
|
var assetItem = _keyArgs[1];
|
|
1203
1220
|
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());
|
|
1204
1221
|
});
|
|
1205
|
-
return
|
|
1222
|
+
return _context14.a(2, entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
|
|
1206
1223
|
}
|
|
1207
|
-
},
|
|
1224
|
+
}, _callee14, this);
|
|
1208
1225
|
}));
|
|
1209
|
-
function getBalanceForeignXTokens(
|
|
1226
|
+
function getBalanceForeignXTokens(_x24, _x25, _x26) {
|
|
1210
1227
|
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
1211
1228
|
}
|
|
1212
1229
|
return getBalanceForeignXTokens;
|
|
@@ -1214,20 +1231,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1214
1231
|
}, {
|
|
1215
1232
|
key: "getBalanceAssetsPallet",
|
|
1216
1233
|
value: function () {
|
|
1217
|
-
var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1234
|
+
var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(address, assetId) {
|
|
1218
1235
|
var response;
|
|
1219
|
-
return _regenerator().w(function (
|
|
1220
|
-
while (1) switch (
|
|
1236
|
+
return _regenerator().w(function (_context15) {
|
|
1237
|
+
while (1) switch (_context15.n) {
|
|
1221
1238
|
case 0:
|
|
1222
|
-
|
|
1239
|
+
_context15.n = 1;
|
|
1223
1240
|
return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
|
|
1224
1241
|
case 1:
|
|
1225
|
-
response =
|
|
1226
|
-
return
|
|
1242
|
+
response = _context15.v;
|
|
1243
|
+
return _context15.a(2, BigInt(response === undefined ? 0 : response.balance));
|
|
1227
1244
|
}
|
|
1228
|
-
},
|
|
1245
|
+
}, _callee15, this);
|
|
1229
1246
|
}));
|
|
1230
|
-
function getBalanceAssetsPallet(
|
|
1247
|
+
function getBalanceAssetsPallet(_x27, _x28) {
|
|
1231
1248
|
return _getBalanceAssetsPallet.apply(this, arguments);
|
|
1232
1249
|
}
|
|
1233
1250
|
return getBalanceAssetsPallet;
|
|
@@ -1235,21 +1252,21 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1235
1252
|
}, {
|
|
1236
1253
|
key: "getFromRpc",
|
|
1237
1254
|
value: function () {
|
|
1238
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1255
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(module, method, key) {
|
|
1239
1256
|
var toSS58, value;
|
|
1240
|
-
return _regenerator().w(function (
|
|
1241
|
-
while (1) switch (
|
|
1257
|
+
return _regenerator().w(function (_context16) {
|
|
1258
|
+
while (1) switch (_context16.n) {
|
|
1242
1259
|
case 0:
|
|
1243
1260
|
toSS58 = AccountId().dec;
|
|
1244
|
-
|
|
1261
|
+
_context16.n = 1;
|
|
1245
1262
|
return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !isAddress(key) ? toSS58(key) : key]);
|
|
1246
1263
|
case 1:
|
|
1247
|
-
value =
|
|
1248
|
-
return
|
|
1264
|
+
value = _context16.v;
|
|
1265
|
+
return _context16.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
|
|
1249
1266
|
}
|
|
1250
|
-
},
|
|
1267
|
+
}, _callee16, this);
|
|
1251
1268
|
}));
|
|
1252
|
-
function getFromRpc(
|
|
1269
|
+
function getFromRpc(_x29, _x30, _x31) {
|
|
1253
1270
|
return _getFromRpc.apply(this, arguments);
|
|
1254
1271
|
}
|
|
1255
1272
|
return getFromRpc;
|
|
@@ -1257,25 +1274,25 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1257
1274
|
}, {
|
|
1258
1275
|
key: "clone",
|
|
1259
1276
|
value: function clone() {
|
|
1260
|
-
return new PapiApi();
|
|
1277
|
+
return new PapiApi(isConfig(this._config) ? this._config : undefined);
|
|
1261
1278
|
}
|
|
1262
1279
|
}, {
|
|
1263
1280
|
key: "createApiForNode",
|
|
1264
1281
|
value: function () {
|
|
1265
|
-
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1282
|
+
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(node) {
|
|
1266
1283
|
var api;
|
|
1267
|
-
return _regenerator().w(function (
|
|
1268
|
-
while (1) switch (
|
|
1284
|
+
return _regenerator().w(function (_context17) {
|
|
1285
|
+
while (1) switch (_context17.n) {
|
|
1269
1286
|
case 0:
|
|
1270
1287
|
api = new PapiApi();
|
|
1271
|
-
|
|
1288
|
+
_context17.n = 1;
|
|
1272
1289
|
return api.init(node);
|
|
1273
1290
|
case 1:
|
|
1274
|
-
return
|
|
1291
|
+
return _context17.a(2, api);
|
|
1275
1292
|
}
|
|
1276
|
-
},
|
|
1293
|
+
}, _callee17);
|
|
1277
1294
|
}));
|
|
1278
|
-
function createApiForNode(
|
|
1295
|
+
function createApiForNode(_x32) {
|
|
1279
1296
|
return _createApiForNode.apply(this, arguments);
|
|
1280
1297
|
}
|
|
1281
1298
|
return createApiForNode;
|
|
@@ -1283,16 +1300,16 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1283
1300
|
}, {
|
|
1284
1301
|
key: "getDryRunCall",
|
|
1285
1302
|
value: function () {
|
|
1286
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1303
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref6) {
|
|
1287
1304
|
var _this = this;
|
|
1288
1305
|
var tx, address, node, feeAsset, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasMultiLocation, xcmFee, fee;
|
|
1289
|
-
return _regenerator().w(function (
|
|
1290
|
-
while (1) switch (
|
|
1306
|
+
return _regenerator().w(function (_context19) {
|
|
1307
|
+
while (1) switch (_context19.n) {
|
|
1291
1308
|
case 0:
|
|
1292
1309
|
tx = _ref6.tx, address = _ref6.address, node = _ref6.node, feeAsset = _ref6.feeAsset;
|
|
1293
1310
|
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
1294
1311
|
if (supportsDryRunApi) {
|
|
1295
|
-
|
|
1312
|
+
_context19.n = 1;
|
|
1296
1313
|
break;
|
|
1297
1314
|
}
|
|
1298
1315
|
throw new NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
|
|
@@ -1306,21 +1323,21 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1306
1323
|
}
|
|
1307
1324
|
};
|
|
1308
1325
|
performDryRunCall = /*#__PURE__*/function () {
|
|
1309
|
-
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1326
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(includeVersion) {
|
|
1310
1327
|
var _this$api$getUnsafeAp;
|
|
1311
1328
|
var callArgs;
|
|
1312
|
-
return _regenerator().w(function (
|
|
1313
|
-
while (1) switch (
|
|
1329
|
+
return _regenerator().w(function (_context18) {
|
|
1330
|
+
while (1) switch (_context18.n) {
|
|
1314
1331
|
case 0:
|
|
1315
1332
|
callArgs = [basePayload, tx.decodedCall];
|
|
1316
1333
|
if (includeVersion) {
|
|
1317
1334
|
callArgs.push(DEFAULT_XCM_VERSION);
|
|
1318
1335
|
}
|
|
1319
|
-
return
|
|
1336
|
+
return _context18.a(2, (_this$api$getUnsafeAp = _this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, callArgs));
|
|
1320
1337
|
}
|
|
1321
|
-
},
|
|
1338
|
+
}, _callee18);
|
|
1322
1339
|
}));
|
|
1323
|
-
return function performDryRunCall(
|
|
1340
|
+
return function performDryRunCall(_x34) {
|
|
1324
1341
|
return _ref7.apply(this, arguments);
|
|
1325
1342
|
};
|
|
1326
1343
|
}();
|
|
@@ -1343,25 +1360,25 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1343
1360
|
return JSON.stringify((_ref8 = (_result$value4 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value4 !== void 0 ? _result$value4 : result) !== null && _ref8 !== void 0 ? _ref8 : 'Unknown error structure');
|
|
1344
1361
|
};
|
|
1345
1362
|
failureOutputReason = '';
|
|
1346
|
-
|
|
1363
|
+
_context19.n = 2;
|
|
1347
1364
|
return performDryRunCall(false);
|
|
1348
1365
|
case 2:
|
|
1349
|
-
result =
|
|
1366
|
+
result = _context19.v;
|
|
1350
1367
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1351
1368
|
if (isSuccess) {
|
|
1352
|
-
|
|
1369
|
+
_context19.n = 4;
|
|
1353
1370
|
break;
|
|
1354
1371
|
}
|
|
1355
1372
|
initialFailureReason = extractFailureReasonFromResult(result);
|
|
1356
1373
|
failureOutputReason = initialFailureReason;
|
|
1357
1374
|
if (!(initialFailureReason === 'VersionedConversionFailed')) {
|
|
1358
|
-
|
|
1375
|
+
_context19.n = 4;
|
|
1359
1376
|
break;
|
|
1360
1377
|
}
|
|
1361
|
-
|
|
1378
|
+
_context19.n = 3;
|
|
1362
1379
|
return performDryRunCall(true);
|
|
1363
1380
|
case 3:
|
|
1364
|
-
result =
|
|
1381
|
+
result = _context19.v;
|
|
1365
1382
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1366
1383
|
if (!isSuccess) {
|
|
1367
1384
|
failureOutputReason = extractFailureReasonFromResult(result);
|
|
@@ -1370,10 +1387,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1370
1387
|
}
|
|
1371
1388
|
case 4:
|
|
1372
1389
|
if (isSuccess) {
|
|
1373
|
-
|
|
1390
|
+
_context19.n = 5;
|
|
1374
1391
|
break;
|
|
1375
1392
|
}
|
|
1376
|
-
return
|
|
1393
|
+
return _context19.a(2, Promise.resolve({
|
|
1377
1394
|
success: false,
|
|
1378
1395
|
failureReason: failureOutputReason
|
|
1379
1396
|
}));
|
|
@@ -1385,27 +1402,27 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1385
1402
|
} : undefined;
|
|
1386
1403
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1387
1404
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
|
|
1388
|
-
|
|
1405
|
+
_context19.n = 6;
|
|
1389
1406
|
return this.calculateTransactionFee(tx, address);
|
|
1390
1407
|
case 6:
|
|
1391
|
-
executionFee =
|
|
1408
|
+
executionFee = _context19.v;
|
|
1392
1409
|
nativeAsset = findAsset(node, {
|
|
1393
1410
|
symbol: Native(getNativeAssetSymbol(node))
|
|
1394
1411
|
}, null);
|
|
1395
1412
|
hasMultiLocation = feeAsset ? Boolean(feeAsset.multiLocation) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.multiLocation);
|
|
1396
1413
|
if (!(hasXcmPaymentApiSupport(node) && result.value.local_xcm && hasMultiLocation && nativeAsset && node !== 'AssetHubPolkadot' && node !== 'Kusama')) {
|
|
1397
|
-
|
|
1414
|
+
_context19.n = 8;
|
|
1398
1415
|
break;
|
|
1399
1416
|
}
|
|
1400
|
-
|
|
1417
|
+
_context19.n = 7;
|
|
1401
1418
|
return this.getXcmPaymentApiFee(node, result.value.local_xcm, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
|
|
1402
1419
|
case 7:
|
|
1403
|
-
xcmFee =
|
|
1420
|
+
xcmFee = _context19.v;
|
|
1404
1421
|
if (!(typeof xcmFee === 'bigint')) {
|
|
1405
|
-
|
|
1422
|
+
_context19.n = 8;
|
|
1406
1423
|
break;
|
|
1407
1424
|
}
|
|
1408
|
-
return
|
|
1425
|
+
return _context19.a(2, Promise.resolve({
|
|
1409
1426
|
success: true,
|
|
1410
1427
|
fee: xcmFee,
|
|
1411
1428
|
weight: weight,
|
|
@@ -1414,7 +1431,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1414
1431
|
}));
|
|
1415
1432
|
case 8:
|
|
1416
1433
|
fee = computeFeeFromDryRun(result, node, executionFee, !!feeAsset);
|
|
1417
|
-
return
|
|
1434
|
+
return _context19.a(2, Promise.resolve({
|
|
1418
1435
|
success: true,
|
|
1419
1436
|
fee: fee,
|
|
1420
1437
|
weight: weight,
|
|
@@ -1422,9 +1439,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1422
1439
|
destParaId: destParaId
|
|
1423
1440
|
}));
|
|
1424
1441
|
}
|
|
1425
|
-
},
|
|
1442
|
+
}, _callee19, this);
|
|
1426
1443
|
}));
|
|
1427
|
-
function getDryRunCall(
|
|
1444
|
+
function getDryRunCall(_x33) {
|
|
1428
1445
|
return _getDryRunCall.apply(this, arguments);
|
|
1429
1446
|
}
|
|
1430
1447
|
return getDryRunCall;
|
|
@@ -1432,24 +1449,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1432
1449
|
}, {
|
|
1433
1450
|
key: "getXcmWeight",
|
|
1434
1451
|
value: function () {
|
|
1435
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1452
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(xcm) {
|
|
1436
1453
|
var weightResult, _weightResult$value, ref_time, proof_size;
|
|
1437
|
-
return _regenerator().w(function (
|
|
1438
|
-
while (1) switch (
|
|
1454
|
+
return _regenerator().w(function (_context20) {
|
|
1455
|
+
while (1) switch (_context20.n) {
|
|
1439
1456
|
case 0:
|
|
1440
|
-
|
|
1457
|
+
_context20.n = 1;
|
|
1441
1458
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
|
|
1442
1459
|
case 1:
|
|
1443
|
-
weightResult =
|
|
1460
|
+
weightResult = _context20.v;
|
|
1444
1461
|
_weightResult$value = weightResult.value, ref_time = _weightResult$value.ref_time, proof_size = _weightResult$value.proof_size;
|
|
1445
|
-
return
|
|
1462
|
+
return _context20.a(2, {
|
|
1446
1463
|
refTime: ref_time,
|
|
1447
1464
|
proofSize: proof_size
|
|
1448
1465
|
});
|
|
1449
1466
|
}
|
|
1450
|
-
},
|
|
1467
|
+
}, _callee20, this);
|
|
1451
1468
|
}));
|
|
1452
|
-
function getXcmWeight(
|
|
1469
|
+
function getXcmWeight(_x35) {
|
|
1453
1470
|
return _getXcmWeight.apply(this, arguments);
|
|
1454
1471
|
}
|
|
1455
1472
|
return getXcmWeight;
|
|
@@ -1457,35 +1474,35 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1457
1474
|
}, {
|
|
1458
1475
|
key: "getXcmPaymentApiFee",
|
|
1459
1476
|
value: function () {
|
|
1460
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1477
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(node, xcm, asset) {
|
|
1461
1478
|
var weight, transformedLocation, transformedPapiLocation, feeResult;
|
|
1462
|
-
return _regenerator().w(function (
|
|
1463
|
-
while (1) switch (
|
|
1479
|
+
return _regenerator().w(function (_context21) {
|
|
1480
|
+
while (1) switch (_context21.n) {
|
|
1464
1481
|
case 0:
|
|
1465
|
-
|
|
1482
|
+
_context21.n = 1;
|
|
1466
1483
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(xcm);
|
|
1467
1484
|
case 1:
|
|
1468
|
-
weight =
|
|
1485
|
+
weight = _context21.v;
|
|
1469
1486
|
if (asset !== null && asset !== void 0 && asset.multiLocation) {
|
|
1470
|
-
|
|
1487
|
+
_context21.n = 2;
|
|
1471
1488
|
break;
|
|
1472
1489
|
}
|
|
1473
1490
|
throw new InvalidCurrencyError('This asset does not have a multiLocation defined. Cannot determine destination fee.');
|
|
1474
1491
|
case 2:
|
|
1475
1492
|
transformedLocation = node === 'AssetHubPolkadot' || node === 'AssetHubKusama' || isRelayChain(node) ? localizeLocation(node, asset.multiLocation) : asset.multiLocation;
|
|
1476
1493
|
transformedPapiLocation = _transform(transformedLocation);
|
|
1477
|
-
|
|
1494
|
+
_context21.n = 3;
|
|
1478
1495
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight.value, {
|
|
1479
1496
|
type: Version.V4,
|
|
1480
1497
|
value: transformedPapiLocation
|
|
1481
1498
|
});
|
|
1482
1499
|
case 3:
|
|
1483
|
-
feeResult =
|
|
1484
|
-
return
|
|
1500
|
+
feeResult = _context21.v;
|
|
1501
|
+
return _context21.a(2, feeResult.value);
|
|
1485
1502
|
}
|
|
1486
|
-
},
|
|
1503
|
+
}, _callee21, this);
|
|
1487
1504
|
}));
|
|
1488
|
-
function getXcmPaymentApiFee(
|
|
1505
|
+
function getXcmPaymentApiFee(_x36, _x37, _x38) {
|
|
1489
1506
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1490
1507
|
}
|
|
1491
1508
|
return getXcmPaymentApiFee;
|
|
@@ -1493,32 +1510,32 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1493
1510
|
}, {
|
|
1494
1511
|
key: "getDryRunXcm",
|
|
1495
1512
|
value: function () {
|
|
1496
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1513
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(_ref9) {
|
|
1497
1514
|
var _ref0, _processAssetsDeposit, _ref1, _ref10, _ref11, _ref12, _ref13;
|
|
1498
1515
|
var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
|
|
1499
|
-
return _regenerator().w(function (
|
|
1500
|
-
while (1) switch (
|
|
1516
|
+
return _regenerator().w(function (_context22) {
|
|
1517
|
+
while (1) switch (_context22.n) {
|
|
1501
1518
|
case 0:
|
|
1502
1519
|
originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
|
|
1503
1520
|
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
1504
1521
|
if (supportsDryRunApi) {
|
|
1505
|
-
|
|
1522
|
+
_context22.n = 1;
|
|
1506
1523
|
break;
|
|
1507
1524
|
}
|
|
1508
1525
|
throw new NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
|
|
1509
1526
|
case 1:
|
|
1510
1527
|
transformedOriginLocation = _transform(originLocation);
|
|
1511
|
-
|
|
1528
|
+
_context22.n = 2;
|
|
1512
1529
|
return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
|
|
1513
1530
|
case 2:
|
|
1514
|
-
result =
|
|
1531
|
+
result = _context22.v;
|
|
1515
1532
|
isSuccess = result.success && result.value.execution_result.type === 'Complete';
|
|
1516
1533
|
if (isSuccess) {
|
|
1517
|
-
|
|
1534
|
+
_context22.n = 3;
|
|
1518
1535
|
break;
|
|
1519
1536
|
}
|
|
1520
1537
|
failureReason = result.value.execution_result.value.error.type;
|
|
1521
|
-
return
|
|
1538
|
+
return _context22.a(2, Promise.resolve({
|
|
1522
1539
|
success: false,
|
|
1523
1540
|
failureReason: failureReason
|
|
1524
1541
|
}));
|
|
@@ -1531,18 +1548,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1531
1548
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1532
1549
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
|
|
1533
1550
|
if (!(hasXcmPaymentApiSupport(node) && asset && node !== 'AssetHubPolkadot' && node !== 'Polkadot')) {
|
|
1534
|
-
|
|
1551
|
+
_context22.n = 5;
|
|
1535
1552
|
break;
|
|
1536
1553
|
}
|
|
1537
|
-
|
|
1554
|
+
_context22.n = 4;
|
|
1538
1555
|
return this.getXcmPaymentApiFee(node, xcm, asset);
|
|
1539
1556
|
case 4:
|
|
1540
|
-
_fee =
|
|
1557
|
+
_fee = _context22.v;
|
|
1541
1558
|
if (!(typeof _fee === 'bigint')) {
|
|
1542
|
-
|
|
1559
|
+
_context22.n = 5;
|
|
1543
1560
|
break;
|
|
1544
1561
|
}
|
|
1545
|
-
return
|
|
1562
|
+
return _context22.a(2, {
|
|
1546
1563
|
success: true,
|
|
1547
1564
|
fee: _fee,
|
|
1548
1565
|
weight: weight,
|
|
@@ -1590,10 +1607,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1590
1607
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1591
1608
|
});
|
|
1592
1609
|
if (feeEvent) {
|
|
1593
|
-
|
|
1610
|
+
_context22.n = 6;
|
|
1594
1611
|
break;
|
|
1595
1612
|
}
|
|
1596
|
-
return
|
|
1613
|
+
return _context22.a(2, Promise.resolve({
|
|
1597
1614
|
success: false,
|
|
1598
1615
|
failureReason: 'Cannot determine destination fee. No fee event found'
|
|
1599
1616
|
}));
|
|
@@ -1603,7 +1620,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1603
1620
|
fee = amount - originFee - feeEvent.value.value.amount;
|
|
1604
1621
|
}
|
|
1605
1622
|
processedFee = (isRelayChain(node) || node.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padFeeBy(fee, 30) : fee;
|
|
1606
|
-
return
|
|
1623
|
+
return _context22.a(2, Promise.resolve({
|
|
1607
1624
|
success: true,
|
|
1608
1625
|
fee: processedFee,
|
|
1609
1626
|
weight: weight,
|
|
@@ -1611,9 +1628,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1611
1628
|
destParaId: destParaId
|
|
1612
1629
|
}));
|
|
1613
1630
|
}
|
|
1614
|
-
},
|
|
1631
|
+
}, _callee22, this);
|
|
1615
1632
|
}));
|
|
1616
|
-
function getDryRunXcm(
|
|
1633
|
+
function getDryRunXcm(_x39) {
|
|
1617
1634
|
return _getDryRunXcm.apply(this, arguments);
|
|
1618
1635
|
}
|
|
1619
1636
|
return getDryRunXcm;
|
|
@@ -1621,18 +1638,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1621
1638
|
}, {
|
|
1622
1639
|
key: "getBridgeStatus",
|
|
1623
1640
|
value: function () {
|
|
1624
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1641
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23() {
|
|
1625
1642
|
var outboundOperatingMode;
|
|
1626
|
-
return _regenerator().w(function (
|
|
1627
|
-
while (1) switch (
|
|
1643
|
+
return _regenerator().w(function (_context23) {
|
|
1644
|
+
while (1) switch (_context23.n) {
|
|
1628
1645
|
case 0:
|
|
1629
|
-
|
|
1646
|
+
_context23.n = 1;
|
|
1630
1647
|
return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
|
|
1631
1648
|
case 1:
|
|
1632
|
-
outboundOperatingMode =
|
|
1633
|
-
return
|
|
1649
|
+
outboundOperatingMode = _context23.v;
|
|
1650
|
+
return _context23.a(2, outboundOperatingMode.type);
|
|
1634
1651
|
}
|
|
1635
|
-
},
|
|
1652
|
+
}, _callee23, this);
|
|
1636
1653
|
}));
|
|
1637
1654
|
function getBridgeStatus() {
|
|
1638
1655
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1652,19 +1669,21 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1652
1669
|
}, {
|
|
1653
1670
|
key: "disconnect",
|
|
1654
1671
|
value: function disconnect() {
|
|
1672
|
+
var _this$_config$apiOver2;
|
|
1655
1673
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1656
1674
|
if (!this.initialized) return Promise.resolve();
|
|
1657
1675
|
if (!force && !this.disconnectAllowed) return Promise.resolve();
|
|
1676
|
+
var api = isConfig(this._config) ? (_this$_config$apiOver2 = this._config.apiOverrides) === null || _this$_config$apiOver2 === void 0 ? void 0 : _this$_config$apiOver2[this._node] : this._config;
|
|
1658
1677
|
// Own client provided, destroy only if force true
|
|
1659
|
-
if (force && _typeof(
|
|
1678
|
+
if (force && _typeof(api) === 'object') {
|
|
1660
1679
|
this.api.destroy();
|
|
1661
1680
|
}
|
|
1662
1681
|
// Client created automatically
|
|
1663
|
-
if (typeof
|
|
1682
|
+
if (typeof api === 'string' || Array.isArray(api) || api === undefined) {
|
|
1664
1683
|
if (force) {
|
|
1665
1684
|
this.api.destroy();
|
|
1666
1685
|
} else {
|
|
1667
|
-
var key =
|
|
1686
|
+
var key = api === undefined ? getNodeProviders(this._node) : api;
|
|
1668
1687
|
releasePolkadotClient(key);
|
|
1669
1688
|
}
|
|
1670
1689
|
}
|
|
@@ -1684,8 +1703,7 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
|
|
|
1684
1703
|
return _regenerator().w(function (_context) {
|
|
1685
1704
|
while (1) switch (_context.n) {
|
|
1686
1705
|
case 0:
|
|
1687
|
-
papiApi = new PapiApi();
|
|
1688
|
-
papiApi.setApi(options.api);
|
|
1706
|
+
papiApi = new PapiApi(options.api);
|
|
1689
1707
|
optionsWithApi = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1690
1708
|
api: papiApi
|
|
1691
1709
|
});
|
|
@@ -1896,8 +1914,7 @@ var EvmBuilder$1 = function EvmBuilder(api) {
|
|
|
1896
1914
|
* @returns A new Builder instance.
|
|
1897
1915
|
*/
|
|
1898
1916
|
var Builder = function Builder(api) {
|
|
1899
|
-
var papiApi = new PapiApi();
|
|
1900
|
-
papiApi.setApi(api);
|
|
1917
|
+
var papiApi = new PapiApi(api);
|
|
1901
1918
|
return Builder$1(papiApi);
|
|
1902
1919
|
};
|
|
1903
1920
|
var EvmBuilder = function EvmBuilder() {
|
|
@@ -1919,8 +1936,7 @@ var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
|
1919
1936
|
return _regenerator().w(function (_context) {
|
|
1920
1937
|
while (1) switch (_context.n) {
|
|
1921
1938
|
case 0:
|
|
1922
|
-
papiApi = new PapiApi();
|
|
1923
|
-
papiApi.setApi(ahApi);
|
|
1939
|
+
papiApi = new PapiApi(ahApi);
|
|
1924
1940
|
_context.n = 1;
|
|
1925
1941
|
return papiApi.init('AssetHubPolkadot');
|
|
1926
1942
|
case 1:
|
|
@@ -1941,8 +1957,7 @@ var getBridgeStatus = /*#__PURE__*/function () {
|
|
|
1941
1957
|
return _regenerator().w(function (_context2) {
|
|
1942
1958
|
while (1) switch (_context2.n) {
|
|
1943
1959
|
case 0:
|
|
1944
|
-
papiApi = new PapiApi();
|
|
1945
|
-
papiApi.setApi(ahApi);
|
|
1960
|
+
papiApi = new PapiApi(ahApi);
|
|
1946
1961
|
return _context2.a(2, getBridgeStatus$1(papiApi));
|
|
1947
1962
|
}
|
|
1948
1963
|
}, _callee2);
|