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