@paraspell/sdk-dedot 13.0.0-rc.1 → 13.0.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 +196 -66
- package/dist/index.d.ts +9 -10
- package/dist/index.mjs +231 -277
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEvmPrivateKeyHex, getNativeAssetSymbol, getOtherAssets, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner,
|
|
1
|
+
import { getEvmPrivateKeyHex, getNativeAssetSymbol, getOtherAssets, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner, PolkadotApi, resolveChainApi, DEFAULT_TTL_MS, isExternalChain, UnsupportedOperationError, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, isAssetXcEqual, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, replaceBigInt, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { stringPascalCase, isEvmAddress, decodeAddress, isHex, u8aToHex, hexToU8a, stringToU8a, blake2AsHex } from 'dedot/utils';
|
|
4
4
|
import { Keyring } from '@polkadot/keyring';
|
|
@@ -768,41 +768,27 @@ var extractDryRunXcmFailureReason = function extractDryRunXcmFailureReason(resul
|
|
|
768
768
|
}
|
|
769
769
|
return JSON.stringify((_ref6 = (_result$value2 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value2 !== void 0 ? _result$value2 : result) !== null && _ref6 !== void 0 ? _ref6 : "Unknown error structure", replaceBigInt);
|
|
770
770
|
};
|
|
771
|
-
var DedotApi = /*#__PURE__*/function () {
|
|
772
|
-
function DedotApi(
|
|
771
|
+
var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
772
|
+
function DedotApi() {
|
|
773
|
+
var _this;
|
|
773
774
|
_classCallCheck(this, DedotApi);
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
this._config = config;
|
|
775
|
+
_this = _callSuper(this, DedotApi, arguments);
|
|
776
|
+
_this.type = "DEDOT";
|
|
777
|
+
return _this;
|
|
778
778
|
}
|
|
779
|
+
_inherits(DedotApi, _PolkadotApi);
|
|
779
780
|
return _createClass(DedotApi, [{
|
|
780
|
-
key: "getType",
|
|
781
|
-
value: function getType() {
|
|
782
|
-
return "DEDOT";
|
|
783
|
-
}
|
|
784
|
-
}, {
|
|
785
|
-
key: "getConfig",
|
|
786
|
-
value: function getConfig() {
|
|
787
|
-
return this._config;
|
|
788
|
-
}
|
|
789
|
-
}, {
|
|
790
|
-
key: "getApi",
|
|
791
|
-
value: function getApi() {
|
|
792
|
-
return this.api;
|
|
793
|
-
}
|
|
794
|
-
}, {
|
|
795
781
|
key: "init",
|
|
796
782
|
value: function () {
|
|
797
783
|
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(chain) {
|
|
798
|
-
var
|
|
784
|
+
var _this2 = this;
|
|
799
785
|
var clientTtlMs,
|
|
800
786
|
_args = arguments;
|
|
801
787
|
return _regenerator().w(function (_context3) {
|
|
802
788
|
while (1) switch (_context3.n) {
|
|
803
789
|
case 0:
|
|
804
790
|
clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
|
|
805
|
-
if (!(this.
|
|
791
|
+
if (!(this._chain !== undefined || isExternalChain(chain))) {
|
|
806
792
|
_context3.n = 1;
|
|
807
793
|
break;
|
|
808
794
|
}
|
|
@@ -812,11 +798,10 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
812
798
|
this._chain = chain;
|
|
813
799
|
_context3.n = 2;
|
|
814
800
|
return resolveChainApi(this._config, chain, function (wsUrl, c) {
|
|
815
|
-
return
|
|
801
|
+
return _this2.createApiInstance(wsUrl, c);
|
|
816
802
|
});
|
|
817
803
|
case 2:
|
|
818
|
-
this.
|
|
819
|
-
this.initialized = true;
|
|
804
|
+
this._api = _context3.v;
|
|
820
805
|
case 3:
|
|
821
806
|
return _context3.a(2);
|
|
822
807
|
}
|
|
@@ -875,23 +860,13 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
875
860
|
}
|
|
876
861
|
}, {
|
|
877
862
|
key: "queryState",
|
|
878
|
-
value: function () {
|
|
879
|
-
var
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
_this$convertToDedotC2 = this.convertToDedotCall(serialized), module = _this$convertToDedotC2.module, method = _this$convertToDedotC2.method;
|
|
886
|
-
return _context4.a(2, this.api.query[module][method](params.length > 1 ? params.map(_transform) : params[0]));
|
|
887
|
-
}
|
|
888
|
-
}, _callee4, this);
|
|
889
|
-
}));
|
|
890
|
-
function queryState(_x4) {
|
|
891
|
-
return _queryState.apply(this, arguments);
|
|
892
|
-
}
|
|
893
|
-
return queryState;
|
|
894
|
-
}()
|
|
863
|
+
value: function queryState(serialized) {
|
|
864
|
+
var params = serialized.params;
|
|
865
|
+
var _this$convertToDedotC2 = this.convertToDedotCall(serialized),
|
|
866
|
+
module = _this$convertToDedotC2.module,
|
|
867
|
+
method = _this$convertToDedotC2.method;
|
|
868
|
+
return this.api.query[module][method](params.length > 1 ? params.map(_transform) : params[0]);
|
|
869
|
+
}
|
|
895
870
|
}, {
|
|
896
871
|
key: "queryRuntimeApi",
|
|
897
872
|
value: function queryRuntimeApi(serialized) {
|
|
@@ -944,15 +919,15 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
944
919
|
}, {
|
|
945
920
|
key: "getPaymentInfo",
|
|
946
921
|
value: function () {
|
|
947
|
-
var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
948
|
-
return _regenerator().w(function (
|
|
949
|
-
while (1) switch (
|
|
922
|
+
var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(tx, address) {
|
|
923
|
+
return _regenerator().w(function (_context4) {
|
|
924
|
+
while (1) switch (_context4.n) {
|
|
950
925
|
case 0:
|
|
951
|
-
return
|
|
926
|
+
return _context4.a(2, tx.paymentInfo(address));
|
|
952
927
|
}
|
|
953
|
-
},
|
|
928
|
+
}, _callee4);
|
|
954
929
|
}));
|
|
955
|
-
function getPaymentInfo(
|
|
930
|
+
function getPaymentInfo(_x4, _x5) {
|
|
956
931
|
return _getPaymentInfo.apply(this, arguments);
|
|
957
932
|
}
|
|
958
933
|
return getPaymentInfo;
|
|
@@ -960,23 +935,23 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
960
935
|
}, {
|
|
961
936
|
key: "quoteAhPrice",
|
|
962
937
|
value: function () {
|
|
963
|
-
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
938
|
+
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(fromMl, toMl, amountIn) {
|
|
964
939
|
var includeFee,
|
|
965
940
|
quoted,
|
|
966
|
-
|
|
967
|
-
return _regenerator().w(function (
|
|
968
|
-
while (1) switch (
|
|
941
|
+
_args3 = arguments;
|
|
942
|
+
return _regenerator().w(function (_context5) {
|
|
943
|
+
while (1) switch (_context5.n) {
|
|
969
944
|
case 0:
|
|
970
|
-
includeFee =
|
|
971
|
-
|
|
945
|
+
includeFee = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : true;
|
|
946
|
+
_context5.n = 1;
|
|
972
947
|
return this.api.call.assetConversionApi.quotePriceExactTokensForTokens(fromMl, toMl, amountIn, includeFee);
|
|
973
948
|
case 1:
|
|
974
|
-
quoted =
|
|
975
|
-
return
|
|
949
|
+
quoted = _context5.v;
|
|
950
|
+
return _context5.a(2, quoted !== undefined && quoted !== null ? BigInt(quoted) : undefined);
|
|
976
951
|
}
|
|
977
|
-
},
|
|
952
|
+
}, _callee5, this);
|
|
978
953
|
}));
|
|
979
|
-
function quoteAhPrice(_x7, _x8
|
|
954
|
+
function quoteAhPrice(_x6, _x7, _x8) {
|
|
980
955
|
return _quoteAhPrice.apply(this, arguments);
|
|
981
956
|
}
|
|
982
957
|
return quoteAhPrice;
|
|
@@ -1014,26 +989,26 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1014
989
|
}, {
|
|
1015
990
|
key: "getFromRpc",
|
|
1016
991
|
value: function () {
|
|
1017
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
992
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(module, method, key) {
|
|
1018
993
|
var rpcModule;
|
|
1019
|
-
return _regenerator().w(function (
|
|
1020
|
-
while (1) switch (
|
|
994
|
+
return _regenerator().w(function (_context6) {
|
|
995
|
+
while (1) switch (_context6.n) {
|
|
1021
996
|
case 0:
|
|
1022
997
|
rpcModule = this.api.rpc["".concat(module, "_").concat(method)];
|
|
1023
998
|
if (!(!rpcModule || !rpcModule(key))) {
|
|
1024
|
-
|
|
999
|
+
_context6.n = 1;
|
|
1025
1000
|
break;
|
|
1026
1001
|
}
|
|
1027
1002
|
throw new UnsupportedOperationError("RPC method ".concat(module, ".").concat(method, " not available"));
|
|
1028
1003
|
case 1:
|
|
1029
|
-
|
|
1004
|
+
_context6.n = 2;
|
|
1030
1005
|
return rpcModule(key);
|
|
1031
1006
|
case 2:
|
|
1032
|
-
return
|
|
1007
|
+
return _context6.a(2, _context6.v);
|
|
1033
1008
|
}
|
|
1034
|
-
},
|
|
1009
|
+
}, _callee6, this);
|
|
1035
1010
|
}));
|
|
1036
|
-
function getFromRpc(_x0, _x1
|
|
1011
|
+
function getFromRpc(_x9, _x0, _x1) {
|
|
1037
1012
|
return _getFromRpc.apply(this, arguments);
|
|
1038
1013
|
}
|
|
1039
1014
|
return getFromRpc;
|
|
@@ -1051,20 +1026,20 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1051
1026
|
}, {
|
|
1052
1027
|
key: "createApiForChain",
|
|
1053
1028
|
value: function () {
|
|
1054
|
-
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1029
|
+
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(chain) {
|
|
1055
1030
|
var api;
|
|
1056
|
-
return _regenerator().w(function (
|
|
1057
|
-
while (1) switch (
|
|
1031
|
+
return _regenerator().w(function (_context7) {
|
|
1032
|
+
while (1) switch (_context7.n) {
|
|
1058
1033
|
case 0:
|
|
1059
1034
|
api = new DedotApi(isConfig(this._config) ? this._config : undefined);
|
|
1060
|
-
|
|
1035
|
+
_context7.n = 1;
|
|
1061
1036
|
return api.init(chain);
|
|
1062
1037
|
case 1:
|
|
1063
|
-
return
|
|
1038
|
+
return _context7.a(2, api);
|
|
1064
1039
|
}
|
|
1065
|
-
},
|
|
1040
|
+
}, _callee7, this);
|
|
1066
1041
|
}));
|
|
1067
|
-
function createApiForChain(
|
|
1042
|
+
function createApiForChain(_x10) {
|
|
1068
1043
|
return _createApiForChain.apply(this, arguments);
|
|
1069
1044
|
}
|
|
1070
1045
|
return createApiForChain;
|
|
@@ -1079,44 +1054,44 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1079
1054
|
}, {
|
|
1080
1055
|
key: "resolveFeeAsset",
|
|
1081
1056
|
value: function () {
|
|
1082
|
-
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1057
|
+
var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(options) {
|
|
1083
1058
|
var chain, address, assetId;
|
|
1084
|
-
return _regenerator().w(function (
|
|
1085
|
-
while (1) switch (
|
|
1059
|
+
return _regenerator().w(function (_context8) {
|
|
1060
|
+
while (1) switch (_context8.n) {
|
|
1086
1061
|
case 0:
|
|
1087
1062
|
chain = options.chain, address = options.address;
|
|
1088
1063
|
if (chain.startsWith("Hydration")) {
|
|
1089
|
-
|
|
1064
|
+
_context8.n = 1;
|
|
1090
1065
|
break;
|
|
1091
1066
|
}
|
|
1092
|
-
return
|
|
1067
|
+
return _context8.a(2, {
|
|
1093
1068
|
isCustomAsset: false,
|
|
1094
1069
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1095
1070
|
});
|
|
1096
1071
|
case 1:
|
|
1097
|
-
|
|
1072
|
+
_context8.n = 2;
|
|
1098
1073
|
return this.api.query.multiTransactionPayment.accountCurrencyMap(address);
|
|
1099
1074
|
case 2:
|
|
1100
|
-
assetId =
|
|
1075
|
+
assetId = _context8.v;
|
|
1101
1076
|
if (!(assetId === null || assetId === undefined)) {
|
|
1102
|
-
|
|
1077
|
+
_context8.n = 3;
|
|
1103
1078
|
break;
|
|
1104
1079
|
}
|
|
1105
|
-
return
|
|
1080
|
+
return _context8.a(2, {
|
|
1106
1081
|
isCustomAsset: false,
|
|
1107
1082
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1108
1083
|
});
|
|
1109
1084
|
case 3:
|
|
1110
|
-
return
|
|
1085
|
+
return _context8.a(2, {
|
|
1111
1086
|
isCustomAsset: true,
|
|
1112
1087
|
asset: findAssetInfoOrThrow(chain, {
|
|
1113
1088
|
id: assetId
|
|
1114
1089
|
})
|
|
1115
1090
|
});
|
|
1116
1091
|
}
|
|
1117
|
-
},
|
|
1092
|
+
}, _callee8, this);
|
|
1118
1093
|
}));
|
|
1119
|
-
function resolveFeeAsset(
|
|
1094
|
+
function resolveFeeAsset(_x11) {
|
|
1120
1095
|
return _resolveFeeAsset.apply(this, arguments);
|
|
1121
1096
|
}
|
|
1122
1097
|
return resolveFeeAsset;
|
|
@@ -1124,19 +1099,19 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1124
1099
|
}, {
|
|
1125
1100
|
key: "getDryRunCall",
|
|
1126
1101
|
value: function () {
|
|
1127
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1128
|
-
var
|
|
1102
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(options) {
|
|
1103
|
+
var _this3 = this,
|
|
1129
1104
|
_result,
|
|
1130
1105
|
_resValue$executionRe,
|
|
1131
1106
|
_execRes$actualWeight;
|
|
1132
1107
|
var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, _getAssetsObject, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, findFailingEventInResult, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, resValue, execRes, forwardedXcms, actualWeight, weight, destParaId, localXcm, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
|
|
1133
|
-
return _regenerator().w(function (
|
|
1134
|
-
while (1) switch (
|
|
1108
|
+
return _regenerator().w(function (_context9) {
|
|
1109
|
+
while (1) switch (_context9.p = _context9.n) {
|
|
1135
1110
|
case 0:
|
|
1136
1111
|
tx = options.tx, address = options.address, feeAsset = options.feeAsset, chain = options.chain, destination = options.destination, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
|
|
1137
1112
|
_getAssetsObject = getAssetsObject(chain), supportsDryRunApi = _getAssetsObject.supportsDryRunApi;
|
|
1138
1113
|
if (supportsDryRunApi) {
|
|
1139
|
-
|
|
1114
|
+
_context9.n = 1;
|
|
1140
1115
|
break;
|
|
1141
1116
|
}
|
|
1142
1117
|
throw new RuntimeApiUnavailableError(chain, "DryRunApi");
|
|
@@ -1151,41 +1126,30 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1151
1126
|
}
|
|
1152
1127
|
};
|
|
1153
1128
|
if (!useRootOrigin) {
|
|
1154
|
-
|
|
1129
|
+
_context9.n = 3;
|
|
1155
1130
|
break;
|
|
1156
1131
|
}
|
|
1157
|
-
|
|
1132
|
+
_context9.n = 2;
|
|
1158
1133
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1159
1134
|
api: this
|
|
1160
1135
|
}), bypassOptions);
|
|
1161
1136
|
case 2:
|
|
1162
|
-
_t =
|
|
1163
|
-
|
|
1137
|
+
_t = _context9.v;
|
|
1138
|
+
_context9.n = 4;
|
|
1164
1139
|
break;
|
|
1165
1140
|
case 3:
|
|
1166
1141
|
_t = tx;
|
|
1167
1142
|
case 4:
|
|
1168
1143
|
resolvedTx = _t;
|
|
1169
|
-
|
|
1144
|
+
_context9.n = 5;
|
|
1170
1145
|
return this.resolveFeeAsset(options);
|
|
1171
1146
|
case 5:
|
|
1172
|
-
resolvedFeeAsset =
|
|
1173
|
-
performDryRunCall =
|
|
1174
|
-
var
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
while (1) switch (_context0.n) {
|
|
1179
|
-
case 0:
|
|
1180
|
-
versionNum = Number(version.charAt(1));
|
|
1181
|
-
return _context0.a(2, (_this2$api$call$dryRu = _this2.api.call.dryRunApi).dryRunCall.apply(_this2$api$call$dryRu, [basePayload, resolvedTx.call].concat(_toConsumableArray(includeVersion ? [versionNum] : []))));
|
|
1182
|
-
}
|
|
1183
|
-
}, _callee0);
|
|
1184
|
-
}));
|
|
1185
|
-
return function performDryRunCall(_x14) {
|
|
1186
|
-
return _ref1.apply(this, arguments);
|
|
1187
|
-
};
|
|
1188
|
-
}();
|
|
1147
|
+
resolvedFeeAsset = _context9.v;
|
|
1148
|
+
performDryRunCall = function performDryRunCall(includeVersion) {
|
|
1149
|
+
var _this3$api$call$dryRu;
|
|
1150
|
+
var versionNum = Number(version.charAt(1));
|
|
1151
|
+
return (_this3$api$call$dryRu = _this3.api.call.dryRunApi).dryRunCall.apply(_this3$api$call$dryRu, [basePayload, resolvedTx.call].concat(_toConsumableArray(includeVersion ? [versionNum] : [])));
|
|
1152
|
+
};
|
|
1189
1153
|
findFailingEventInResult = function findFailingEventInResult(res) {
|
|
1190
1154
|
var _res$value;
|
|
1191
1155
|
return res === null || res === void 0 || (_res$value = res.value) === null || _res$value === void 0 || (_res$value = _res$value.emittedEvents) === null || _res$value === void 0 ? void 0 : _res$value.find(function (event) {
|
|
@@ -1252,11 +1216,11 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1252
1216
|
failureReason: ""
|
|
1253
1217
|
};
|
|
1254
1218
|
shouldRetryWithVersion = false;
|
|
1255
|
-
|
|
1256
|
-
|
|
1219
|
+
_context9.p = 6;
|
|
1220
|
+
_context9.n = 7;
|
|
1257
1221
|
return performDryRunCall(false);
|
|
1258
1222
|
case 7:
|
|
1259
|
-
result =
|
|
1223
|
+
result = _context9.v;
|
|
1260
1224
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1261
1225
|
if (!isSuccess) {
|
|
1262
1226
|
failureErr = extractFailureReasonFromResult(result);
|
|
@@ -1264,49 +1228,49 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1264
1228
|
shouldRetryWithVersion = true;
|
|
1265
1229
|
}
|
|
1266
1230
|
}
|
|
1267
|
-
|
|
1231
|
+
_context9.n = 10;
|
|
1268
1232
|
break;
|
|
1269
1233
|
case 8:
|
|
1270
|
-
|
|
1271
|
-
_t2 =
|
|
1234
|
+
_context9.p = 8;
|
|
1235
|
+
_t2 = _context9.v;
|
|
1272
1236
|
msg = _t2 instanceof Error ? _t2.message : String(_t2);
|
|
1273
1237
|
if (!msg.includes("Expected 3 parameters")) {
|
|
1274
|
-
|
|
1238
|
+
_context9.n = 9;
|
|
1275
1239
|
break;
|
|
1276
1240
|
}
|
|
1277
1241
|
shouldRetryWithVersion = true;
|
|
1278
|
-
|
|
1242
|
+
_context9.n = 10;
|
|
1279
1243
|
break;
|
|
1280
1244
|
case 9:
|
|
1281
|
-
return
|
|
1245
|
+
return _context9.a(2, {
|
|
1282
1246
|
success: false,
|
|
1283
1247
|
failureReason: msg,
|
|
1284
1248
|
asset: resolvedFeeAsset.asset
|
|
1285
1249
|
});
|
|
1286
1250
|
case 10:
|
|
1287
1251
|
if (!shouldRetryWithVersion) {
|
|
1288
|
-
|
|
1252
|
+
_context9.n = 14;
|
|
1289
1253
|
break;
|
|
1290
1254
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1255
|
+
_context9.p = 11;
|
|
1256
|
+
_context9.n = 12;
|
|
1293
1257
|
return performDryRunCall(true);
|
|
1294
1258
|
case 12:
|
|
1295
|
-
result =
|
|
1259
|
+
result = _context9.v;
|
|
1296
1260
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1297
1261
|
if (!isSuccess) {
|
|
1298
1262
|
failureErr = extractFailureReasonFromResult(result);
|
|
1299
1263
|
}
|
|
1300
|
-
|
|
1264
|
+
_context9.n = 14;
|
|
1301
1265
|
break;
|
|
1302
1266
|
case 13:
|
|
1303
|
-
|
|
1304
|
-
_t3 =
|
|
1267
|
+
_context9.p = 13;
|
|
1268
|
+
_t3 = _context9.v;
|
|
1305
1269
|
_msg = _t3 instanceof Error ? _t3.message : String(_t3);
|
|
1306
1270
|
failureErr = failureErr || {
|
|
1307
1271
|
failureReason: _msg
|
|
1308
1272
|
};
|
|
1309
|
-
return
|
|
1273
|
+
return _context9.a(2, {
|
|
1310
1274
|
success: false,
|
|
1311
1275
|
failureReason: failureErr.failureReason,
|
|
1312
1276
|
failureSubReason: failureErr.failureSubReason,
|
|
@@ -1314,10 +1278,10 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1314
1278
|
});
|
|
1315
1279
|
case 14:
|
|
1316
1280
|
if (isSuccess) {
|
|
1317
|
-
|
|
1281
|
+
_context9.n = 15;
|
|
1318
1282
|
break;
|
|
1319
1283
|
}
|
|
1320
|
-
return
|
|
1284
|
+
return _context9.a(2, {
|
|
1321
1285
|
success: false,
|
|
1322
1286
|
failureReason: failureErr.failureReason || "Unknown error",
|
|
1323
1287
|
failureSubReason: failureErr.failureSubReason,
|
|
@@ -1333,32 +1297,32 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1333
1297
|
localXcm = resValue === null || resValue === void 0 ? void 0 : resValue.localXcm;
|
|
1334
1298
|
USE_XCM_PAYMENT_API_CHAINS = ["Astar"];
|
|
1335
1299
|
if (!(hasXcmPaymentApiSupport(chain) && localXcm && (feeAsset || USE_XCM_PAYMENT_API_CHAINS.includes(chain) || chain.startsWith("AssetHub") && destination === "Ethereum") || resolvedFeeAsset.isCustomAsset)) {
|
|
1336
|
-
|
|
1300
|
+
_context9.n = 21;
|
|
1337
1301
|
break;
|
|
1338
1302
|
}
|
|
1339
1303
|
if (localXcm) {
|
|
1340
|
-
|
|
1304
|
+
_context9.n = 17;
|
|
1341
1305
|
break;
|
|
1342
1306
|
}
|
|
1343
|
-
|
|
1307
|
+
_context9.n = 16;
|
|
1344
1308
|
return this.getPaymentInfo(tx, address);
|
|
1345
1309
|
case 16:
|
|
1346
|
-
_t4 =
|
|
1347
|
-
|
|
1310
|
+
_t4 = _context9.v.weight;
|
|
1311
|
+
_context9.n = 18;
|
|
1348
1312
|
break;
|
|
1349
1313
|
case 17:
|
|
1350
1314
|
_t4 = undefined;
|
|
1351
1315
|
case 18:
|
|
1352
1316
|
overriddenWeight = _t4;
|
|
1353
|
-
|
|
1317
|
+
_context9.n = 19;
|
|
1354
1318
|
return this.getXcmPaymentApiFee(chain, localXcm, forwardedXcms, resolvedFeeAsset.asset, version, false, overriddenWeight);
|
|
1355
1319
|
case 19:
|
|
1356
|
-
xcmFee =
|
|
1320
|
+
xcmFee = _context9.v;
|
|
1357
1321
|
if (!(typeof xcmFee === "bigint")) {
|
|
1358
|
-
|
|
1322
|
+
_context9.n = 20;
|
|
1359
1323
|
break;
|
|
1360
1324
|
}
|
|
1361
|
-
return
|
|
1325
|
+
return _context9.a(2, {
|
|
1362
1326
|
success: true,
|
|
1363
1327
|
fee: xcmFee,
|
|
1364
1328
|
asset: resolvedFeeAsset.asset,
|
|
@@ -1372,13 +1336,13 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1372
1336
|
asset: this.resolveDefaultFeeAsset(options)
|
|
1373
1337
|
};
|
|
1374
1338
|
case 21:
|
|
1375
|
-
|
|
1339
|
+
_context9.n = 22;
|
|
1376
1340
|
return this.getPaymentInfo(tx, address);
|
|
1377
1341
|
case 22:
|
|
1378
|
-
_yield$this$getPaymen =
|
|
1342
|
+
_yield$this$getPaymen = _context9.v;
|
|
1379
1343
|
executionFee = _yield$this$getPaymen.partialFee;
|
|
1380
1344
|
fee = computeOriginFee(result, chain, executionFee);
|
|
1381
|
-
return
|
|
1345
|
+
return _context9.a(2, {
|
|
1382
1346
|
success: true,
|
|
1383
1347
|
fee: fee,
|
|
1384
1348
|
asset: resolvedFeeAsset.asset,
|
|
@@ -1387,9 +1351,9 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1387
1351
|
destParaId: destParaId
|
|
1388
1352
|
});
|
|
1389
1353
|
}
|
|
1390
|
-
},
|
|
1354
|
+
}, _callee9, this, [[11, 13], [6, 8]]);
|
|
1391
1355
|
}));
|
|
1392
|
-
function getDryRunCall(
|
|
1356
|
+
function getDryRunCall(_x12) {
|
|
1393
1357
|
return _getDryRunCall.apply(this, arguments);
|
|
1394
1358
|
}
|
|
1395
1359
|
return getDryRunCall;
|
|
@@ -1397,8 +1361,8 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1397
1361
|
}, {
|
|
1398
1362
|
key: "getXcmPaymentApiFee",
|
|
1399
1363
|
value: function () {
|
|
1400
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1401
|
-
var
|
|
1364
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(chain, localXcm, forwardedXcm, asset, version) {
|
|
1365
|
+
var _this4 = this,
|
|
1402
1366
|
_execFeeRes$value;
|
|
1403
1367
|
var transformXcm,
|
|
1404
1368
|
overridenWeight,
|
|
@@ -1411,77 +1375,77 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1411
1375
|
execFee,
|
|
1412
1376
|
bridgeHubExecFee,
|
|
1413
1377
|
deliveryFee,
|
|
1414
|
-
|
|
1378
|
+
_args9 = arguments,
|
|
1415
1379
|
_t5;
|
|
1416
|
-
return _regenerator().w(function (
|
|
1417
|
-
while (1) switch (
|
|
1380
|
+
return _regenerator().w(function (_context1) {
|
|
1381
|
+
while (1) switch (_context1.n) {
|
|
1418
1382
|
case 0:
|
|
1419
|
-
transformXcm =
|
|
1420
|
-
overridenWeight =
|
|
1383
|
+
transformXcm = _args9.length > 5 && _args9[5] !== undefined ? _args9[5] : false;
|
|
1384
|
+
overridenWeight = _args9.length > 6 ? _args9[6] : undefined;
|
|
1421
1385
|
transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
|
|
1422
1386
|
queryWeight = /*#__PURE__*/function () {
|
|
1423
|
-
var
|
|
1387
|
+
var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
1424
1388
|
var weightRes;
|
|
1425
|
-
return _regenerator().w(function (
|
|
1426
|
-
while (1) switch (
|
|
1389
|
+
return _regenerator().w(function (_context0) {
|
|
1390
|
+
while (1) switch (_context0.n) {
|
|
1427
1391
|
case 0:
|
|
1428
|
-
|
|
1429
|
-
return
|
|
1392
|
+
_context0.n = 1;
|
|
1393
|
+
return _this4.api.call.xcmPaymentApi.queryXcmWeight(transformedXcm);
|
|
1430
1394
|
case 1:
|
|
1431
|
-
weightRes =
|
|
1432
|
-
return
|
|
1395
|
+
weightRes = _context0.v;
|
|
1396
|
+
return _context0.a(2, weightRes.value);
|
|
1433
1397
|
}
|
|
1434
|
-
},
|
|
1398
|
+
}, _callee0);
|
|
1435
1399
|
}));
|
|
1436
1400
|
return function queryWeight() {
|
|
1437
|
-
return
|
|
1401
|
+
return _ref1.apply(this, arguments);
|
|
1438
1402
|
};
|
|
1439
1403
|
}();
|
|
1440
1404
|
if (!overridenWeight) {
|
|
1441
|
-
|
|
1405
|
+
_context1.n = 1;
|
|
1442
1406
|
break;
|
|
1443
1407
|
}
|
|
1444
1408
|
_t5 = overridenWeight;
|
|
1445
|
-
|
|
1409
|
+
_context1.n = 3;
|
|
1446
1410
|
break;
|
|
1447
1411
|
case 1:
|
|
1448
|
-
|
|
1412
|
+
_context1.n = 2;
|
|
1449
1413
|
return queryWeight();
|
|
1450
1414
|
case 2:
|
|
1451
|
-
_t5 =
|
|
1415
|
+
_t5 = _context1.v;
|
|
1452
1416
|
case 3:
|
|
1453
1417
|
weight = _t5;
|
|
1454
1418
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
1455
1419
|
transformedAssetLoc = _transform(assetLocalizedLoc);
|
|
1456
|
-
|
|
1420
|
+
_context1.n = 4;
|
|
1457
1421
|
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, {
|
|
1458
1422
|
type: version,
|
|
1459
1423
|
value: transformedAssetLoc
|
|
1460
1424
|
});
|
|
1461
1425
|
case 4:
|
|
1462
|
-
execFeeRes =
|
|
1426
|
+
execFeeRes = _context1.v;
|
|
1463
1427
|
execFee = typeof (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.value) === "bigint" ? execFeeRes.value : 0n;
|
|
1464
1428
|
if (!(chain.startsWith("BridgeHub") && (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.success) === false && (execFeeRes === null || execFeeRes === void 0 || (_execFeeRes$value = execFeeRes.value) === null || _execFeeRes$value === void 0 ? void 0 : _execFeeRes$value.type) === "AssetNotFound")) {
|
|
1465
|
-
|
|
1429
|
+
_context1.n = 6;
|
|
1466
1430
|
break;
|
|
1467
1431
|
}
|
|
1468
|
-
|
|
1432
|
+
_context1.n = 5;
|
|
1469
1433
|
return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
|
|
1470
1434
|
case 5:
|
|
1471
|
-
bridgeHubExecFee =
|
|
1435
|
+
bridgeHubExecFee = _context1.v;
|
|
1472
1436
|
if (typeof bridgeHubExecFee === "bigint") {
|
|
1473
1437
|
execFee = bridgeHubExecFee;
|
|
1474
1438
|
}
|
|
1475
1439
|
case 6:
|
|
1476
|
-
|
|
1440
|
+
_context1.n = 7;
|
|
1477
1441
|
return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
|
|
1478
1442
|
case 7:
|
|
1479
|
-
deliveryFee =
|
|
1480
|
-
return
|
|
1443
|
+
deliveryFee = _context1.v;
|
|
1444
|
+
return _context1.a(2, execFee + deliveryFee);
|
|
1481
1445
|
}
|
|
1482
|
-
},
|
|
1446
|
+
}, _callee1, this);
|
|
1483
1447
|
}));
|
|
1484
|
-
function getXcmPaymentApiFee(
|
|
1448
|
+
function getXcmPaymentApiFee(_x13, _x14, _x15, _x16, _x17) {
|
|
1485
1449
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1486
1450
|
}
|
|
1487
1451
|
return getXcmPaymentApiFee;
|
|
@@ -1489,40 +1453,40 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1489
1453
|
}, {
|
|
1490
1454
|
key: "getDeliveryFee",
|
|
1491
1455
|
value: function () {
|
|
1492
|
-
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1456
|
+
var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
|
|
1493
1457
|
var _deliveryFeeRes, _assets$0$fun$value, _assets$;
|
|
1494
1458
|
var usedThirdParam, deliveryFeeRes, baseArgs, _this$api$call$xcmPay, message, _this$api$call$xcmPay2, versionedAssetLoc, assets, deliveryFeeResolved, nativeAsset, res, _t6;
|
|
1495
|
-
return _regenerator().w(function (
|
|
1496
|
-
while (1) switch (
|
|
1459
|
+
return _regenerator().w(function (_context10) {
|
|
1460
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
1497
1461
|
case 0:
|
|
1498
1462
|
usedThirdParam = false;
|
|
1499
1463
|
if (!(forwardedXcm.length > 0)) {
|
|
1500
|
-
|
|
1464
|
+
_context10.n = 6;
|
|
1501
1465
|
break;
|
|
1502
1466
|
}
|
|
1503
1467
|
baseArgs = [forwardedXcm[0], forwardedXcm[1][0]];
|
|
1504
|
-
|
|
1505
|
-
|
|
1468
|
+
_context10.p = 1;
|
|
1469
|
+
_context10.n = 2;
|
|
1506
1470
|
return (_this$api$call$xcmPay = this.api.call.xcmPaymentApi).queryDeliveryFees.apply(_this$api$call$xcmPay, baseArgs);
|
|
1507
1471
|
case 2:
|
|
1508
|
-
deliveryFeeRes =
|
|
1509
|
-
|
|
1472
|
+
deliveryFeeRes = _context10.v;
|
|
1473
|
+
_context10.n = 6;
|
|
1510
1474
|
break;
|
|
1511
1475
|
case 3:
|
|
1512
|
-
|
|
1513
|
-
_t6 =
|
|
1476
|
+
_context10.p = 3;
|
|
1477
|
+
_t6 = _context10.v;
|
|
1514
1478
|
message = _t6 instanceof Error ? _t6.message : String(_t6);
|
|
1515
1479
|
if (!message.includes("Expected 3 parameters")) {
|
|
1516
|
-
|
|
1480
|
+
_context10.n = 5;
|
|
1517
1481
|
break;
|
|
1518
1482
|
}
|
|
1519
1483
|
usedThirdParam = true;
|
|
1520
1484
|
versionedAssetLoc = addXcmVersionHeader(assetLocalizedLoc, version);
|
|
1521
|
-
|
|
1485
|
+
_context10.n = 4;
|
|
1522
1486
|
return (_this$api$call$xcmPay2 = this.api.call.xcmPaymentApi).queryDeliveryFees.apply(_this$api$call$xcmPay2, baseArgs.concat([versionedAssetLoc]));
|
|
1523
1487
|
case 4:
|
|
1524
|
-
deliveryFeeRes =
|
|
1525
|
-
|
|
1488
|
+
deliveryFeeRes = _context10.v;
|
|
1489
|
+
_context10.n = 6;
|
|
1526
1490
|
break;
|
|
1527
1491
|
case 5:
|
|
1528
1492
|
throw _t6;
|
|
@@ -1531,25 +1495,25 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1531
1495
|
deliveryFeeResolved = deliveryFeeRes && (assets === null || assets === void 0 ? void 0 : assets.length) > 0 ? (_assets$0$fun$value = (_assets$ = assets[0]) === null || _assets$ === void 0 || (_assets$ = _assets$.fun) === null || _assets$ === void 0 ? void 0 : _assets$.value) !== null && _assets$0$fun$value !== void 0 ? _assets$0$fun$value : 0n : 0n;
|
|
1532
1496
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1533
1497
|
if (!(isAssetXcEqual(asset, nativeAsset) || usedThirdParam)) {
|
|
1534
|
-
|
|
1498
|
+
_context10.n = 7;
|
|
1535
1499
|
break;
|
|
1536
1500
|
}
|
|
1537
|
-
return
|
|
1501
|
+
return _context10.a(2, deliveryFeeResolved);
|
|
1538
1502
|
case 7:
|
|
1539
|
-
|
|
1540
|
-
|
|
1503
|
+
_context10.p = 7;
|
|
1504
|
+
_context10.n = 8;
|
|
1541
1505
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
1542
1506
|
case 8:
|
|
1543
|
-
res =
|
|
1544
|
-
return
|
|
1507
|
+
res = _context10.v;
|
|
1508
|
+
return _context10.a(2, res !== null && res !== void 0 ? res : 0n);
|
|
1545
1509
|
case 9:
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
return
|
|
1510
|
+
_context10.p = 9;
|
|
1511
|
+
_context10.v;
|
|
1512
|
+
return _context10.a(2, 0n);
|
|
1549
1513
|
}
|
|
1550
|
-
},
|
|
1514
|
+
}, _callee10, this, [[7, 9], [1, 3]]);
|
|
1551
1515
|
}));
|
|
1552
|
-
function getDeliveryFee(
|
|
1516
|
+
function getDeliveryFee(_x18, _x19, _x20, _x21, _x22) {
|
|
1553
1517
|
return _getDeliveryFee.apply(this, arguments);
|
|
1554
1518
|
}
|
|
1555
1519
|
return getDeliveryFee;
|
|
@@ -1557,44 +1521,44 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1557
1521
|
}, {
|
|
1558
1522
|
key: "getBridgeHubFallbackExecFee",
|
|
1559
1523
|
value: function () {
|
|
1560
|
-
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1524
|
+
var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, weightValue, asset, version) {
|
|
1561
1525
|
var fallbackExecFeeRes, fallbackOk, fallbackExecFee, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
|
|
1562
|
-
return _regenerator().w(function (
|
|
1563
|
-
while (1) switch (
|
|
1526
|
+
return _regenerator().w(function (_context11) {
|
|
1527
|
+
while (1) switch (_context11.n) {
|
|
1564
1528
|
case 0:
|
|
1565
|
-
|
|
1529
|
+
_context11.n = 1;
|
|
1566
1530
|
return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weightValue, addXcmVersionHeader(RELAY_LOCATION, version));
|
|
1567
1531
|
case 1:
|
|
1568
|
-
fallbackExecFeeRes =
|
|
1532
|
+
fallbackExecFeeRes = _context11.v;
|
|
1569
1533
|
fallbackOk = fallbackExecFeeRes === null || fallbackExecFeeRes === void 0 ? void 0 : fallbackExecFeeRes.value;
|
|
1570
1534
|
fallbackExecFee = typeof fallbackOk === "bigint" ? fallbackOk : typeof fallbackOk === "string" || typeof fallbackOk === "number" ? BigInt(fallbackOk) : undefined;
|
|
1571
1535
|
if (!(fallbackExecFee === undefined)) {
|
|
1572
|
-
|
|
1536
|
+
_context11.n = 2;
|
|
1573
1537
|
break;
|
|
1574
1538
|
}
|
|
1575
|
-
return
|
|
1539
|
+
return _context11.a(2, undefined);
|
|
1576
1540
|
case 2:
|
|
1577
1541
|
ahApi = this.clone();
|
|
1578
1542
|
assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
|
|
1579
|
-
|
|
1543
|
+
_context11.n = 3;
|
|
1580
1544
|
return ahApi.init(assetHubChain);
|
|
1581
1545
|
case 3:
|
|
1582
1546
|
ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
|
|
1583
|
-
|
|
1547
|
+
_context11.n = 4;
|
|
1584
1548
|
return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFee, false);
|
|
1585
1549
|
case 4:
|
|
1586
|
-
convertedExecFee =
|
|
1550
|
+
convertedExecFee = _context11.v;
|
|
1587
1551
|
if (!(typeof convertedExecFee === "bigint")) {
|
|
1588
|
-
|
|
1552
|
+
_context11.n = 5;
|
|
1589
1553
|
break;
|
|
1590
1554
|
}
|
|
1591
|
-
return
|
|
1555
|
+
return _context11.a(2, convertedExecFee);
|
|
1592
1556
|
case 5:
|
|
1593
|
-
return
|
|
1557
|
+
return _context11.a(2, undefined);
|
|
1594
1558
|
}
|
|
1595
|
-
},
|
|
1559
|
+
}, _callee11, this);
|
|
1596
1560
|
}));
|
|
1597
|
-
function getBridgeHubFallbackExecFee(
|
|
1561
|
+
function getBridgeHubFallbackExecFee(_x23, _x24, _x25, _x26) {
|
|
1598
1562
|
return _getBridgeHubFallbackExecFee.apply(this, arguments);
|
|
1599
1563
|
}
|
|
1600
1564
|
return getBridgeHubFallbackExecFee;
|
|
@@ -1602,25 +1566,25 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1602
1566
|
}, {
|
|
1603
1567
|
key: "getXcmWeight",
|
|
1604
1568
|
value: function () {
|
|
1605
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1569
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(xcm) {
|
|
1606
1570
|
var _okValue$refTime, _okValue$proofSize;
|
|
1607
1571
|
var result, okValue;
|
|
1608
|
-
return _regenerator().w(function (
|
|
1609
|
-
while (1) switch (
|
|
1572
|
+
return _regenerator().w(function (_context12) {
|
|
1573
|
+
while (1) switch (_context12.n) {
|
|
1610
1574
|
case 0:
|
|
1611
|
-
|
|
1575
|
+
_context12.n = 1;
|
|
1612
1576
|
return this.api.call.xcmPaymentApi.queryXcmWeight(!xcm.type ? _transform(xcm) : xcm);
|
|
1613
1577
|
case 1:
|
|
1614
|
-
result =
|
|
1578
|
+
result = _context12.v;
|
|
1615
1579
|
okValue = result === null || result === void 0 ? void 0 : result.value;
|
|
1616
|
-
return
|
|
1580
|
+
return _context12.a(2, {
|
|
1617
1581
|
refTime: BigInt((_okValue$refTime = okValue === null || okValue === void 0 ? void 0 : okValue.refTime) !== null && _okValue$refTime !== void 0 ? _okValue$refTime : 0),
|
|
1618
1582
|
proofSize: BigInt((_okValue$proofSize = okValue === null || okValue === void 0 ? void 0 : okValue.proofSize) !== null && _okValue$proofSize !== void 0 ? _okValue$proofSize : 0)
|
|
1619
1583
|
});
|
|
1620
1584
|
}
|
|
1621
|
-
},
|
|
1585
|
+
}, _callee12, this);
|
|
1622
1586
|
}));
|
|
1623
|
-
function getXcmWeight(
|
|
1587
|
+
function getXcmWeight(_x27) {
|
|
1624
1588
|
return _getXcmWeight.apply(this, arguments);
|
|
1625
1589
|
}
|
|
1626
1590
|
return getXcmWeight;
|
|
@@ -1628,32 +1592,32 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1628
1592
|
}, {
|
|
1629
1593
|
key: "getDryRunXcm",
|
|
1630
1594
|
value: function () {
|
|
1631
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1595
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(_ref10) {
|
|
1632
1596
|
var _result$value5;
|
|
1633
1597
|
var originLocation, xcm, asset, chain, version, _getAssetsObject2, supportsDryRunApi, transformedOriginLocation, result, executionResult, isSuccess, actualWeight, weight, forwardedXcms, destParaId, fee;
|
|
1634
|
-
return _regenerator().w(function (
|
|
1635
|
-
while (1) switch (
|
|
1598
|
+
return _regenerator().w(function (_context13) {
|
|
1599
|
+
while (1) switch (_context13.n) {
|
|
1636
1600
|
case 0:
|
|
1637
|
-
originLocation =
|
|
1601
|
+
originLocation = _ref10.originLocation, xcm = _ref10.xcm, asset = _ref10.asset, chain = _ref10.chain, version = _ref10.version;
|
|
1638
1602
|
_getAssetsObject2 = getAssetsObject(chain), supportsDryRunApi = _getAssetsObject2.supportsDryRunApi;
|
|
1639
1603
|
if (supportsDryRunApi) {
|
|
1640
|
-
|
|
1604
|
+
_context13.n = 1;
|
|
1641
1605
|
break;
|
|
1642
1606
|
}
|
|
1643
1607
|
throw new RuntimeApiUnavailableError(chain, "DryRunApi");
|
|
1644
1608
|
case 1:
|
|
1645
1609
|
transformedOriginLocation = _transform(originLocation);
|
|
1646
|
-
|
|
1610
|
+
_context13.n = 2;
|
|
1647
1611
|
return this.api.call.dryRunApi.dryRunXcm(transformedOriginLocation, xcm);
|
|
1648
1612
|
case 2:
|
|
1649
|
-
result =
|
|
1613
|
+
result = _context13.v;
|
|
1650
1614
|
executionResult = result === null || result === void 0 || (_result$value5 = result.value) === null || _result$value5 === void 0 ? void 0 : _result$value5.executionResult;
|
|
1651
1615
|
isSuccess = result.isOk && executionResult.type === "Complete";
|
|
1652
1616
|
if (isSuccess) {
|
|
1653
|
-
|
|
1617
|
+
_context13.n = 3;
|
|
1654
1618
|
break;
|
|
1655
1619
|
}
|
|
1656
|
-
return
|
|
1620
|
+
return _context13.a(2, {
|
|
1657
1621
|
success: false,
|
|
1658
1622
|
failureReason: extractDryRunXcmFailureReason(result),
|
|
1659
1623
|
asset: asset
|
|
@@ -1664,24 +1628,24 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1664
1628
|
forwardedXcms = result.value.forwardedXcms.length > 0 ? result.value.forwardedXcms[0] : [];
|
|
1665
1629
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === "Here" ? 0 : forwardedXcms[0].value.interior.value[0].value;
|
|
1666
1630
|
if (!hasXcmPaymentApiSupport(chain)) {
|
|
1667
|
-
|
|
1631
|
+
_context13.n = 6;
|
|
1668
1632
|
break;
|
|
1669
1633
|
}
|
|
1670
|
-
|
|
1634
|
+
_context13.n = 4;
|
|
1671
1635
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset, version);
|
|
1672
1636
|
case 4:
|
|
1673
|
-
fee =
|
|
1637
|
+
fee = _context13.v;
|
|
1674
1638
|
if (!(typeof fee !== "bigint")) {
|
|
1675
|
-
|
|
1639
|
+
_context13.n = 5;
|
|
1676
1640
|
break;
|
|
1677
1641
|
}
|
|
1678
|
-
return
|
|
1642
|
+
return _context13.a(2, {
|
|
1679
1643
|
success: false,
|
|
1680
1644
|
failureReason: "Failed to retrieve fee from XcmPaymentApi",
|
|
1681
1645
|
asset: asset
|
|
1682
1646
|
});
|
|
1683
1647
|
case 5:
|
|
1684
|
-
return
|
|
1648
|
+
return _context13.a(2, {
|
|
1685
1649
|
success: true,
|
|
1686
1650
|
fee: fee,
|
|
1687
1651
|
asset: asset,
|
|
@@ -1690,15 +1654,15 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1690
1654
|
destParaId: destParaId
|
|
1691
1655
|
});
|
|
1692
1656
|
case 6:
|
|
1693
|
-
return
|
|
1657
|
+
return _context13.a(2, {
|
|
1694
1658
|
success: false,
|
|
1695
1659
|
failureReason: "Cannot determine destination fee. XcmPaymentApi is not supported by this chain",
|
|
1696
1660
|
asset: asset
|
|
1697
1661
|
});
|
|
1698
1662
|
}
|
|
1699
|
-
},
|
|
1663
|
+
}, _callee13, this);
|
|
1700
1664
|
}));
|
|
1701
|
-
function getDryRunXcm(
|
|
1665
|
+
function getDryRunXcm(_x28) {
|
|
1702
1666
|
return _getDryRunXcm.apply(this, arguments);
|
|
1703
1667
|
}
|
|
1704
1668
|
return getDryRunXcm;
|
|
@@ -1706,40 +1670,30 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1706
1670
|
}, {
|
|
1707
1671
|
key: "getBridgeStatus",
|
|
1708
1672
|
value: function () {
|
|
1709
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1673
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
1710
1674
|
var outboundOperatingMode;
|
|
1711
|
-
return _regenerator().w(function (
|
|
1712
|
-
while (1) switch (
|
|
1675
|
+
return _regenerator().w(function (_context14) {
|
|
1676
|
+
while (1) switch (_context14.n) {
|
|
1713
1677
|
case 0:
|
|
1714
|
-
|
|
1678
|
+
_context14.n = 1;
|
|
1715
1679
|
return this.api.query.ethereumOutboundQueue.operatingMode();
|
|
1716
1680
|
case 1:
|
|
1717
|
-
outboundOperatingMode =
|
|
1718
|
-
return
|
|
1681
|
+
outboundOperatingMode = _context14.v;
|
|
1682
|
+
return _context14.a(2, outboundOperatingMode);
|
|
1719
1683
|
}
|
|
1720
|
-
},
|
|
1684
|
+
}, _callee14, this);
|
|
1721
1685
|
}));
|
|
1722
1686
|
function getBridgeStatus() {
|
|
1723
1687
|
return _getBridgeStatus.apply(this, arguments);
|
|
1724
1688
|
}
|
|
1725
1689
|
return getBridgeStatus;
|
|
1726
1690
|
}()
|
|
1727
|
-
}, {
|
|
1728
|
-
key: "setDisconnectAllowed",
|
|
1729
|
-
value: function setDisconnectAllowed(allowed) {
|
|
1730
|
-
this.disconnectAllowed = allowed;
|
|
1731
|
-
}
|
|
1732
|
-
}, {
|
|
1733
|
-
key: "getDisconnectAllowed",
|
|
1734
|
-
value: function getDisconnectAllowed() {
|
|
1735
|
-
return this.disconnectAllowed;
|
|
1736
|
-
}
|
|
1737
1691
|
}, {
|
|
1738
1692
|
key: "disconnect",
|
|
1739
1693
|
value: function disconnect() {
|
|
1740
1694
|
var _this$_config$apiOver;
|
|
1741
1695
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1742
|
-
if (!this.
|
|
1696
|
+
if (!this._chain) return Promise.resolve();
|
|
1743
1697
|
if (!force && !this.disconnectAllowed) return Promise.resolve();
|
|
1744
1698
|
var api = isConfig(this._config) ? (_this$_config$apiOver = this._config.apiOverrides) === null || _this$_config$apiOver === void 0 ? void 0 : _this$_config$apiOver[this._chain] : this._config;
|
|
1745
1699
|
// Own client provided, destroy only if force true
|
|
@@ -1778,20 +1732,20 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1778
1732
|
}, {
|
|
1779
1733
|
key: "signAndSubmit",
|
|
1780
1734
|
value: function () {
|
|
1781
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1735
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(tx, sender) {
|
|
1782
1736
|
var account;
|
|
1783
|
-
return _regenerator().w(function (
|
|
1784
|
-
while (1) switch (
|
|
1737
|
+
return _regenerator().w(function (_context15) {
|
|
1738
|
+
while (1) switch (_context15.n) {
|
|
1785
1739
|
case 0:
|
|
1786
1740
|
account = isSenderSigner(sender) ? sender : createKeyringPair(sender);
|
|
1787
|
-
|
|
1741
|
+
_context15.n = 1;
|
|
1788
1742
|
return tx.signAndSend(account);
|
|
1789
1743
|
case 1:
|
|
1790
|
-
return
|
|
1744
|
+
return _context15.a(2, _context15.v);
|
|
1791
1745
|
}
|
|
1792
|
-
},
|
|
1746
|
+
}, _callee15);
|
|
1793
1747
|
}));
|
|
1794
|
-
function signAndSubmit(
|
|
1748
|
+
function signAndSubmit(_x29, _x30) {
|
|
1795
1749
|
return _signAndSubmit.apply(this, arguments);
|
|
1796
1750
|
}
|
|
1797
1751
|
return signAndSubmit;
|
|
@@ -1799,27 +1753,27 @@ var DedotApi = /*#__PURE__*/function () {
|
|
|
1799
1753
|
}, {
|
|
1800
1754
|
key: "signAndSubmitFinalized",
|
|
1801
1755
|
value: function () {
|
|
1802
|
-
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1756
|
+
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(tx, sender) {
|
|
1803
1757
|
var account, result;
|
|
1804
|
-
return _regenerator().w(function (
|
|
1805
|
-
while (1) switch (
|
|
1758
|
+
return _regenerator().w(function (_context16) {
|
|
1759
|
+
while (1) switch (_context16.n) {
|
|
1806
1760
|
case 0:
|
|
1807
1761
|
account = isSenderSigner(sender) ? sender : createKeyringPair(sender);
|
|
1808
|
-
|
|
1762
|
+
_context16.n = 1;
|
|
1809
1763
|
return tx.signAndSend(account).untilFinalized();
|
|
1810
1764
|
case 1:
|
|
1811
|
-
result =
|
|
1812
|
-
return
|
|
1765
|
+
result = _context16.v;
|
|
1766
|
+
return _context16.a(2, result.txHash);
|
|
1813
1767
|
}
|
|
1814
|
-
},
|
|
1768
|
+
}, _callee16);
|
|
1815
1769
|
}));
|
|
1816
|
-
function signAndSubmitFinalized(
|
|
1770
|
+
function signAndSubmitFinalized(_x31, _x32) {
|
|
1817
1771
|
return _signAndSubmitFinalized.apply(this, arguments);
|
|
1818
1772
|
}
|
|
1819
1773
|
return signAndSubmitFinalized;
|
|
1820
1774
|
}()
|
|
1821
1775
|
}]);
|
|
1822
|
-
}();
|
|
1776
|
+
}(PolkadotApi);
|
|
1823
1777
|
|
|
1824
1778
|
var createChainClient = function createChainClient(chain, builderOptions) {
|
|
1825
1779
|
var dedotApi = new DedotApi(builderOptions);
|