@paraspell/sdk 11.14.4 → 11.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +155 -414
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +156 -415
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidParameterError, isConfig, InvalidAddressError, BatchMode, getChainProviders, MissingChainApiError, Parents, Version,
|
|
1
|
+
import { InvalidParameterError, isConfig, InvalidAddressError, BatchMode, getChainProviders, MissingChainApiError, Parents, Version, computeFeeFromDryRun, findNativeAssetInfoOrThrow, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, ChainNotSupportedError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, padValueBy, isRelayChain, isAssetEqual, createChainClient as createChainClient$1, getBalanceNative as getBalanceNative$1, getBalance, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, transferMoonbeamEvm, validateAddress, transferMoonbeamToEth, Builder as Builder$1, handleSwapExecuteTransfer as handleSwapExecuteTransfer$1, getParaEthTransferFees as getParaEthTransferFees$1, getBridgeStatus as getBridgeStatus$1, getXcmFee as getXcmFee$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1, getOriginXcmFee as getOriginXcmFee$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { blake2b } from '@noble/hashes/blake2';
|
|
4
4
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
@@ -313,7 +313,7 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
var LEGACY_CHAINS = ['Interlay', 'CrustShadow', 'Kintsugi', 'RobonomicsKusama', 'Pendulum'];
|
|
316
|
+
var LEGACY_CHAINS = ['Interlay', 'CrustShadow', 'Kintsugi', 'RobonomicsKusama', 'RobonomicsPolkadot', 'Pendulum'];
|
|
317
317
|
// Cache settings
|
|
318
318
|
var DEFAULT_TTL_MS = 60000; // 1 minute
|
|
319
319
|
var MAX_CLIENTS = 100;
|
|
@@ -402,6 +402,11 @@ var _transform = function transform(obj) {
|
|
|
402
402
|
type: key,
|
|
403
403
|
value: value
|
|
404
404
|
};
|
|
405
|
+
} else if (key === 'Substrate') {
|
|
406
|
+
return {
|
|
407
|
+
type: key,
|
|
408
|
+
value: value
|
|
409
|
+
};
|
|
405
410
|
} else if (key === 'OtherReserve') {
|
|
406
411
|
return {
|
|
407
412
|
type: key,
|
|
@@ -414,11 +419,16 @@ var _transform = function transform(obj) {
|
|
|
414
419
|
type: 'polkadot' in value ? 'Polkadot' : 'Kusama'
|
|
415
420
|
}
|
|
416
421
|
};
|
|
417
|
-
} else if (key === 'PalletInstance'
|
|
422
|
+
} else if (key === 'PalletInstance') {
|
|
418
423
|
return {
|
|
419
424
|
type: key,
|
|
420
425
|
value: value
|
|
421
426
|
};
|
|
427
|
+
} else if (key === 'GeneralIndex') {
|
|
428
|
+
return {
|
|
429
|
+
type: key,
|
|
430
|
+
value: BigInt(value)
|
|
431
|
+
};
|
|
422
432
|
} else if (key === 'Ethereum') {
|
|
423
433
|
return {
|
|
424
434
|
type: key,
|
|
@@ -893,13 +903,31 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
893
903
|
return result.isValid;
|
|
894
904
|
}
|
|
895
905
|
}, {
|
|
896
|
-
key: "
|
|
897
|
-
value: function
|
|
906
|
+
key: "deserializeExtrinsics",
|
|
907
|
+
value: function deserializeExtrinsics(_ref5) {
|
|
898
908
|
var module = _ref5.module,
|
|
899
909
|
method = _ref5.method,
|
|
900
|
-
|
|
901
|
-
var
|
|
902
|
-
return this.api.getUnsafeApi().tx[module][method](
|
|
910
|
+
params = _ref5.params;
|
|
911
|
+
var transformedParams = _transform(params);
|
|
912
|
+
return this.api.getUnsafeApi().tx[module][method](transformedParams);
|
|
913
|
+
}
|
|
914
|
+
}, {
|
|
915
|
+
key: "queryState",
|
|
916
|
+
value: function queryState(_ref6) {
|
|
917
|
+
var _this$api$getUnsafeAp;
|
|
918
|
+
var module = _ref6.module,
|
|
919
|
+
method = _ref6.method,
|
|
920
|
+
params = _ref6.params;
|
|
921
|
+
return (_this$api$getUnsafeAp = this.api.getUnsafeApi().query[module][method]).getValue.apply(_this$api$getUnsafeAp, _toConsumableArray(params.map(_transform)));
|
|
922
|
+
}
|
|
923
|
+
}, {
|
|
924
|
+
key: "queryRuntimeApi",
|
|
925
|
+
value: function queryRuntimeApi(_ref7) {
|
|
926
|
+
var _this$api$getUnsafeAp2;
|
|
927
|
+
var module = _ref7.module,
|
|
928
|
+
method = _ref7.method,
|
|
929
|
+
params = _ref7.params;
|
|
930
|
+
return (_this$api$getUnsafeAp2 = this.api.getUnsafeApi().apis[module])[method].apply(_this$api$getUnsafeAp2, _toConsumableArray(params.map(_transform)));
|
|
903
931
|
}
|
|
904
932
|
}, {
|
|
905
933
|
key: "callBatchMethod",
|
|
@@ -1071,287 +1099,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1071
1099
|
value: function getEvmStorage(contract, slot) {
|
|
1072
1100
|
return this.api.getUnsafeApi().query.EVM.AccountStorages.getKey(FixedSizeBinary.fromHex(contract), FixedSizeBinary.fromHex(slot));
|
|
1073
1101
|
}
|
|
1074
|
-
}, {
|
|
1075
|
-
key: "getBalanceNative",
|
|
1076
|
-
value: function () {
|
|
1077
|
-
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(address) {
|
|
1078
|
-
var res;
|
|
1079
|
-
return _regenerator().w(function (_context7) {
|
|
1080
|
-
while (1) switch (_context7.n) {
|
|
1081
|
-
case 0:
|
|
1082
|
-
_context7.n = 1;
|
|
1083
|
-
return this.api.getUnsafeApi().query.System.Account.getValue(address);
|
|
1084
|
-
case 1:
|
|
1085
|
-
res = _context7.v;
|
|
1086
|
-
return _context7.a(2, res.data.free);
|
|
1087
|
-
}
|
|
1088
|
-
}, _callee7, this);
|
|
1089
|
-
}));
|
|
1090
|
-
function getBalanceNative(_x10) {
|
|
1091
|
-
return _getBalanceNative.apply(this, arguments);
|
|
1092
|
-
}
|
|
1093
|
-
return getBalanceNative;
|
|
1094
|
-
}()
|
|
1095
|
-
}, {
|
|
1096
|
-
key: "getBalanceForeignPolkadotXcm",
|
|
1097
|
-
value: function () {
|
|
1098
|
-
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(chain, address, asset) {
|
|
1099
|
-
var _res, res;
|
|
1100
|
-
return _regenerator().w(function (_context8) {
|
|
1101
|
-
while (1) switch (_context8.n) {
|
|
1102
|
-
case 0:
|
|
1103
|
-
if (!chain.startsWith('Kilt')) {
|
|
1104
|
-
_context8.n = 2;
|
|
1105
|
-
break;
|
|
1106
|
-
}
|
|
1107
|
-
assertHasLocation(asset);
|
|
1108
|
-
_context8.n = 1;
|
|
1109
|
-
return this.api.getUnsafeApi().query.Fungibles.Account.getValue(_transform(asset.location), address);
|
|
1110
|
-
case 1:
|
|
1111
|
-
_res = _context8.v;
|
|
1112
|
-
return _context8.a(2, _res && _res.balance ? BigInt(_res.balance) : 0n);
|
|
1113
|
-
case 2:
|
|
1114
|
-
assertHasId(asset);
|
|
1115
|
-
_context8.n = 3;
|
|
1116
|
-
return this.api.getUnsafeApi().query.Assets.Account.getValue(chain.startsWith('NeuroWeb') ? BigInt(asset.assetId) : asset.assetId, address);
|
|
1117
|
-
case 3:
|
|
1118
|
-
res = _context8.v;
|
|
1119
|
-
return _context8.a(2, res && res.balance ? BigInt(res.balance) : 0n);
|
|
1120
|
-
}
|
|
1121
|
-
}, _callee8, this);
|
|
1122
|
-
}));
|
|
1123
|
-
function getBalanceForeignPolkadotXcm(_x11, _x12, _x13) {
|
|
1124
|
-
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
1125
|
-
}
|
|
1126
|
-
return getBalanceForeignPolkadotXcm;
|
|
1127
|
-
}()
|
|
1128
|
-
}, {
|
|
1129
|
-
key: "getMythosForeignBalance",
|
|
1130
|
-
value: function () {
|
|
1131
|
-
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address) {
|
|
1132
|
-
var res;
|
|
1133
|
-
return _regenerator().w(function (_context9) {
|
|
1134
|
-
while (1) switch (_context9.n) {
|
|
1135
|
-
case 0:
|
|
1136
|
-
_context9.n = 1;
|
|
1137
|
-
return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
|
|
1138
|
-
case 1:
|
|
1139
|
-
res = _context9.v;
|
|
1140
|
-
return _context9.a(2, res && res.free ? BigInt(res.free) : 0n);
|
|
1141
|
-
}
|
|
1142
|
-
}, _callee9, this);
|
|
1143
|
-
}));
|
|
1144
|
-
function getMythosForeignBalance(_x14) {
|
|
1145
|
-
return _getMythosForeignBalance.apply(this, arguments);
|
|
1146
|
-
}
|
|
1147
|
-
return getMythosForeignBalance;
|
|
1148
|
-
}()
|
|
1149
|
-
}, {
|
|
1150
|
-
key: "getBalanceForeignAssetsPallet",
|
|
1151
|
-
value: function () {
|
|
1152
|
-
var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(address, location) {
|
|
1153
|
-
var transformedLocation, res;
|
|
1154
|
-
return _regenerator().w(function (_context0) {
|
|
1155
|
-
while (1) switch (_context0.n) {
|
|
1156
|
-
case 0:
|
|
1157
|
-
transformedLocation = _transform(location);
|
|
1158
|
-
_context0.n = 1;
|
|
1159
|
-
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedLocation, address);
|
|
1160
|
-
case 1:
|
|
1161
|
-
res = _context0.v;
|
|
1162
|
-
return _context0.a(2, BigInt(res === undefined ? 0 : res.balance));
|
|
1163
|
-
}
|
|
1164
|
-
}, _callee0, this);
|
|
1165
|
-
}));
|
|
1166
|
-
function getBalanceForeignAssetsPallet(_x15, _x16) {
|
|
1167
|
-
return _getBalanceForeignAssetsPallet.apply(this, arguments);
|
|
1168
|
-
}
|
|
1169
|
-
return getBalanceForeignAssetsPallet;
|
|
1170
|
-
}()
|
|
1171
|
-
}, {
|
|
1172
|
-
key: "getForeignAssetsByIdBalance",
|
|
1173
|
-
value: function () {
|
|
1174
|
-
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(address, assetId) {
|
|
1175
|
-
var res;
|
|
1176
|
-
return _regenerator().w(function (_context1) {
|
|
1177
|
-
while (1) switch (_context1.n) {
|
|
1178
|
-
case 0:
|
|
1179
|
-
_context1.n = 1;
|
|
1180
|
-
return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(assetId, address);
|
|
1181
|
-
case 1:
|
|
1182
|
-
res = _context1.v;
|
|
1183
|
-
return _context1.a(2, BigInt(res === undefined ? 0 : res.balance));
|
|
1184
|
-
}
|
|
1185
|
-
}, _callee1, this);
|
|
1186
|
-
}));
|
|
1187
|
-
function getForeignAssetsByIdBalance(_x17, _x18) {
|
|
1188
|
-
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
1189
|
-
}
|
|
1190
|
-
return getForeignAssetsByIdBalance;
|
|
1191
|
-
}()
|
|
1192
|
-
}, {
|
|
1193
|
-
key: "getBalanceForeignBifrost",
|
|
1194
|
-
value: function () {
|
|
1195
|
-
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(address, asset) {
|
|
1196
|
-
var currencySelection, transformedParameters, response, accountData;
|
|
1197
|
-
return _regenerator().w(function (_context10) {
|
|
1198
|
-
while (1) switch (_context10.n) {
|
|
1199
|
-
case 0:
|
|
1200
|
-
currencySelection = getChain('BifrostPolkadot').getCurrencySelection(asset);
|
|
1201
|
-
transformedParameters = _transform(currencySelection);
|
|
1202
|
-
_context10.n = 1;
|
|
1203
|
-
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
1204
|
-
case 1:
|
|
1205
|
-
response = _context10.v;
|
|
1206
|
-
accountData = response ? response : null;
|
|
1207
|
-
return _context10.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
1208
|
-
}
|
|
1209
|
-
}, _callee10, this);
|
|
1210
|
-
}));
|
|
1211
|
-
function getBalanceForeignBifrost(_x19, _x20) {
|
|
1212
|
-
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
1213
|
-
}
|
|
1214
|
-
return getBalanceForeignBifrost;
|
|
1215
|
-
}()
|
|
1216
|
-
}, {
|
|
1217
|
-
key: "getBalanceNativeAcala",
|
|
1218
|
-
value: function () {
|
|
1219
|
-
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(address, symbol) {
|
|
1220
|
-
var transformedParameters, response, accountData;
|
|
1221
|
-
return _regenerator().w(function (_context11) {
|
|
1222
|
-
while (1) switch (_context11.n) {
|
|
1223
|
-
case 0:
|
|
1224
|
-
transformedParameters = _transform({
|
|
1225
|
-
Token: symbol
|
|
1226
|
-
});
|
|
1227
|
-
_context11.n = 1;
|
|
1228
|
-
return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
|
|
1229
|
-
case 1:
|
|
1230
|
-
response = _context11.v;
|
|
1231
|
-
accountData = response ? response : null;
|
|
1232
|
-
return _context11.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
1233
|
-
}
|
|
1234
|
-
}, _callee11, this);
|
|
1235
|
-
}));
|
|
1236
|
-
function getBalanceNativeAcala(_x21, _x22) {
|
|
1237
|
-
return _getBalanceNativeAcala.apply(this, arguments);
|
|
1238
|
-
}
|
|
1239
|
-
return getBalanceNativeAcala;
|
|
1240
|
-
}()
|
|
1241
|
-
}, {
|
|
1242
|
-
key: "getBalanceForeignXTokens",
|
|
1243
|
-
value: function () {
|
|
1244
|
-
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, address, asset) {
|
|
1245
|
-
var pallet, _response, unsafeApi, collectionId, balance, _response2, response, entry;
|
|
1246
|
-
return _regenerator().w(function (_context12) {
|
|
1247
|
-
while (1) switch (_context12.n) {
|
|
1248
|
-
case 0:
|
|
1249
|
-
pallet = 'Tokens';
|
|
1250
|
-
if (chain === 'Centrifuge' || chain === 'Altair') {
|
|
1251
|
-
pallet = 'OrmlTokens';
|
|
1252
|
-
}
|
|
1253
|
-
if (!(chain === 'Peaq' || chain === 'Manta' || chain === 'Crust' || chain === 'Ajuna')) {
|
|
1254
|
-
_context12.n = 2;
|
|
1255
|
-
break;
|
|
1256
|
-
}
|
|
1257
|
-
assertHasId(asset);
|
|
1258
|
-
_context12.n = 1;
|
|
1259
|
-
return this.api.getUnsafeApi().query.Assets.Account.getValue(chain === 'Manta' || chain === 'Crust' ? BigInt(asset.assetId) : asset.assetId, address);
|
|
1260
|
-
case 1:
|
|
1261
|
-
_response = _context12.v;
|
|
1262
|
-
return _context12.a(2, _response ? BigInt(_response.free.toString()) : 0n);
|
|
1263
|
-
case 2:
|
|
1264
|
-
if (!(chain === 'Unique')) {
|
|
1265
|
-
_context12.n = 5;
|
|
1266
|
-
break;
|
|
1267
|
-
}
|
|
1268
|
-
assertHasLocation(asset);
|
|
1269
|
-
assertHasId(asset);
|
|
1270
|
-
unsafeApi = this.api.getUnsafeApi();
|
|
1271
|
-
_context12.n = 3;
|
|
1272
|
-
return unsafeApi.query.ForeignAssets.ForeignAssetToCollection.getValue(_transform(asset.location));
|
|
1273
|
-
case 3:
|
|
1274
|
-
collectionId = _context12.v;
|
|
1275
|
-
_context12.n = 4;
|
|
1276
|
-
return unsafeApi.apis.UniqueApi.balance(collectionId, {
|
|
1277
|
-
type: 'Substrate',
|
|
1278
|
-
value: address
|
|
1279
|
-
}, asset.assetId);
|
|
1280
|
-
case 4:
|
|
1281
|
-
balance = _context12.v;
|
|
1282
|
-
return _context12.a(2, balance.success ? BigInt(balance.value) : 0n);
|
|
1283
|
-
case 5:
|
|
1284
|
-
if (!(chain === 'Hydration')) {
|
|
1285
|
-
_context12.n = 7;
|
|
1286
|
-
break;
|
|
1287
|
-
}
|
|
1288
|
-
assertHasId(asset);
|
|
1289
|
-
_context12.n = 6;
|
|
1290
|
-
return this.api.getUnsafeApi().apis.CurrenciesApi.account(asset.assetId, address);
|
|
1291
|
-
case 6:
|
|
1292
|
-
_response2 = _context12.v;
|
|
1293
|
-
return _context12.a(2, _response2 ? BigInt(_response2.free.toString()) : 0n);
|
|
1294
|
-
case 7:
|
|
1295
|
-
_context12.n = 8;
|
|
1296
|
-
return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
|
|
1297
|
-
case 8:
|
|
1298
|
-
response = _context12.v;
|
|
1299
|
-
entry = response.find(function (_ref6) {
|
|
1300
|
-
var _asset$symbol, _asset$assetId, _asset$symbol2, _asset$symbol3, _asset$assetId2;
|
|
1301
|
-
var keyArgs = _ref6.keyArgs;
|
|
1302
|
-
var _keyArgs = _slicedToArray(keyArgs, 2);
|
|
1303
|
-
_keyArgs[0];
|
|
1304
|
-
var assetItem = _keyArgs[1];
|
|
1305
|
-
return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.type && assetItem.value.type.toString().toLowerCase() === ((_asset$symbol3 = asset.symbol) === null || _asset$symbol3 === void 0 ? void 0 : _asset$symbol3.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
|
|
1306
|
-
});
|
|
1307
|
-
return _context12.a(2, entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
|
|
1308
|
-
}
|
|
1309
|
-
}, _callee12, this);
|
|
1310
|
-
}));
|
|
1311
|
-
function getBalanceForeignXTokens(_x23, _x24, _x25) {
|
|
1312
|
-
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
1313
|
-
}
|
|
1314
|
-
return getBalanceForeignXTokens;
|
|
1315
|
-
}()
|
|
1316
|
-
}, {
|
|
1317
|
-
key: "getBalanceAssetsPallet",
|
|
1318
|
-
value: function () {
|
|
1319
|
-
var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(address, assetId) {
|
|
1320
|
-
var response;
|
|
1321
|
-
return _regenerator().w(function (_context13) {
|
|
1322
|
-
while (1) switch (_context13.n) {
|
|
1323
|
-
case 0:
|
|
1324
|
-
_context13.n = 1;
|
|
1325
|
-
return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
|
|
1326
|
-
case 1:
|
|
1327
|
-
response = _context13.v;
|
|
1328
|
-
return _context13.a(2, BigInt(response === undefined ? 0 : response.balance));
|
|
1329
|
-
}
|
|
1330
|
-
}, _callee13, this);
|
|
1331
|
-
}));
|
|
1332
|
-
function getBalanceAssetsPallet(_x26, _x27) {
|
|
1333
|
-
return _getBalanceAssetsPallet.apply(this, arguments);
|
|
1334
|
-
}
|
|
1335
|
-
return getBalanceAssetsPallet;
|
|
1336
|
-
}()
|
|
1337
1102
|
}, {
|
|
1338
1103
|
key: "getFromRpc",
|
|
1339
1104
|
value: function () {
|
|
1340
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1105
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(module, method, key) {
|
|
1341
1106
|
var toSS58, value;
|
|
1342
|
-
return _regenerator().w(function (
|
|
1343
|
-
while (1) switch (
|
|
1107
|
+
return _regenerator().w(function (_context7) {
|
|
1108
|
+
while (1) switch (_context7.n) {
|
|
1344
1109
|
case 0:
|
|
1345
1110
|
toSS58 = AccountId().dec;
|
|
1346
|
-
|
|
1111
|
+
_context7.n = 1;
|
|
1347
1112
|
return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !isAddress(key) ? toSS58(key) : key]);
|
|
1348
1113
|
case 1:
|
|
1349
|
-
value =
|
|
1350
|
-
return
|
|
1114
|
+
value = _context7.v;
|
|
1115
|
+
return _context7.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
|
|
1351
1116
|
}
|
|
1352
|
-
},
|
|
1117
|
+
}, _callee7, this);
|
|
1353
1118
|
}));
|
|
1354
|
-
function getFromRpc(
|
|
1119
|
+
function getFromRpc(_x10, _x11, _x12) {
|
|
1355
1120
|
return _getFromRpc.apply(this, arguments);
|
|
1356
1121
|
}
|
|
1357
1122
|
return getFromRpc;
|
|
@@ -1364,20 +1129,20 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1364
1129
|
}, {
|
|
1365
1130
|
key: "createApiForChain",
|
|
1366
1131
|
value: function () {
|
|
1367
|
-
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1132
|
+
var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(chain) {
|
|
1368
1133
|
var api;
|
|
1369
|
-
return _regenerator().w(function (
|
|
1370
|
-
while (1) switch (
|
|
1134
|
+
return _regenerator().w(function (_context8) {
|
|
1135
|
+
while (1) switch (_context8.n) {
|
|
1371
1136
|
case 0:
|
|
1372
1137
|
api = new PapiApi();
|
|
1373
|
-
|
|
1138
|
+
_context8.n = 1;
|
|
1374
1139
|
return api.init(chain);
|
|
1375
1140
|
case 1:
|
|
1376
|
-
return
|
|
1141
|
+
return _context8.a(2, api);
|
|
1377
1142
|
}
|
|
1378
|
-
},
|
|
1143
|
+
}, _callee8);
|
|
1379
1144
|
}));
|
|
1380
|
-
function createApiForChain(
|
|
1145
|
+
function createApiForChain(_x13) {
|
|
1381
1146
|
return _createApiForChain.apply(this, arguments);
|
|
1382
1147
|
}
|
|
1383
1148
|
return createApiForChain;
|
|
@@ -1385,16 +1150,16 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1385
1150
|
}, {
|
|
1386
1151
|
key: "getDryRunCall",
|
|
1387
1152
|
value: function () {
|
|
1388
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1153
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
|
|
1389
1154
|
var _this = this;
|
|
1390
1155
|
var tx, chain, destination, address, feeAsset, bypassOptions, _options$useRootOrigi, useRootOrigin, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, usedAsset, usedSymbol, actualWeight, weight, forwardedXcms, destParaId, nativeAsset, hasLocation, xcmFee, executionFee, fee, _t2;
|
|
1391
|
-
return _regenerator().w(function (
|
|
1392
|
-
while (1) switch (
|
|
1156
|
+
return _regenerator().w(function (_context0) {
|
|
1157
|
+
while (1) switch (_context0.n) {
|
|
1393
1158
|
case 0:
|
|
1394
1159
|
tx = options.tx, chain = options.chain, destination = options.destination, address = options.address, feeAsset = options.feeAsset, bypassOptions = options.bypassOptions, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
1395
1160
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1396
1161
|
if (supportsDryRunApi) {
|
|
1397
|
-
|
|
1162
|
+
_context0.n = 1;
|
|
1398
1163
|
break;
|
|
1399
1164
|
}
|
|
1400
1165
|
throw new ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
@@ -1410,38 +1175,38 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1410
1175
|
}
|
|
1411
1176
|
};
|
|
1412
1177
|
if (!useRootOrigin) {
|
|
1413
|
-
|
|
1178
|
+
_context0.n = 3;
|
|
1414
1179
|
break;
|
|
1415
1180
|
}
|
|
1416
|
-
|
|
1181
|
+
_context0.n = 2;
|
|
1417
1182
|
return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1418
1183
|
api: this
|
|
1419
1184
|
}), bypassOptions);
|
|
1420
1185
|
case 2:
|
|
1421
|
-
_t2 =
|
|
1422
|
-
|
|
1186
|
+
_t2 = _context0.v;
|
|
1187
|
+
_context0.n = 4;
|
|
1423
1188
|
break;
|
|
1424
1189
|
case 3:
|
|
1425
1190
|
_t2 = tx;
|
|
1426
1191
|
case 4:
|
|
1427
1192
|
resolvedTx = _t2;
|
|
1428
1193
|
performDryRunCall = /*#__PURE__*/function () {
|
|
1429
|
-
var
|
|
1430
|
-
var _this$api$
|
|
1194
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(includeVersion) {
|
|
1195
|
+
var _this$api$getUnsafeAp3;
|
|
1431
1196
|
var callArgs;
|
|
1432
|
-
return _regenerator().w(function (
|
|
1433
|
-
while (1) switch (
|
|
1197
|
+
return _regenerator().w(function (_context9) {
|
|
1198
|
+
while (1) switch (_context9.n) {
|
|
1434
1199
|
case 0:
|
|
1435
1200
|
callArgs = [basePayload, resolvedTx.decodedCall];
|
|
1436
1201
|
if (includeVersion) {
|
|
1437
1202
|
callArgs.push(DEFAULT_XCM_VERSION);
|
|
1438
1203
|
}
|
|
1439
|
-
return
|
|
1204
|
+
return _context9.a(2, (_this$api$getUnsafeAp3 = _this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp3, callArgs));
|
|
1440
1205
|
}
|
|
1441
|
-
},
|
|
1206
|
+
}, _callee9);
|
|
1442
1207
|
}));
|
|
1443
|
-
return function performDryRunCall(
|
|
1444
|
-
return
|
|
1208
|
+
return function performDryRunCall(_x15) {
|
|
1209
|
+
return _ref8.apply(this, arguments);
|
|
1445
1210
|
};
|
|
1446
1211
|
}();
|
|
1447
1212
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(result) {
|
|
@@ -1470,7 +1235,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1470
1235
|
return result;
|
|
1471
1236
|
};
|
|
1472
1237
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(result) {
|
|
1473
|
-
var _obj$value,
|
|
1238
|
+
var _obj$value, _ref9, _result$value6;
|
|
1474
1239
|
var obj = findFailureObjectFromResult(result);
|
|
1475
1240
|
if (obj !== null && obj !== void 0 && obj.type && obj !== null && obj !== void 0 && (_obj$value = obj.value) !== null && _obj$value !== void 0 && (_obj$value = _obj$value.error) !== null && _obj$value !== void 0 && _obj$value.type) {
|
|
1476
1241
|
return {
|
|
@@ -1484,31 +1249,31 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1484
1249
|
};
|
|
1485
1250
|
}
|
|
1486
1251
|
return {
|
|
1487
|
-
failureReason: JSON.stringify((
|
|
1252
|
+
failureReason: JSON.stringify((_ref9 = (_result$value6 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value6 !== void 0 ? _result$value6 : result) !== null && _ref9 !== void 0 ? _ref9 : 'Unknown error structure', replaceBigInt)
|
|
1488
1253
|
};
|
|
1489
1254
|
};
|
|
1490
1255
|
failureOutputReason = {
|
|
1491
1256
|
failureReason: ''
|
|
1492
1257
|
};
|
|
1493
|
-
|
|
1258
|
+
_context0.n = 5;
|
|
1494
1259
|
return performDryRunCall(false);
|
|
1495
1260
|
case 5:
|
|
1496
|
-
result =
|
|
1261
|
+
result = _context0.v;
|
|
1497
1262
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1498
1263
|
if (isSuccess) {
|
|
1499
|
-
|
|
1264
|
+
_context0.n = 7;
|
|
1500
1265
|
break;
|
|
1501
1266
|
}
|
|
1502
1267
|
initialFailureReason = extractFailureReasonFromResult(result);
|
|
1503
1268
|
failureOutputReason = initialFailureReason;
|
|
1504
1269
|
if (!(initialFailureReason.failureReason === 'VersionedConversionFailed')) {
|
|
1505
|
-
|
|
1270
|
+
_context0.n = 7;
|
|
1506
1271
|
break;
|
|
1507
1272
|
}
|
|
1508
|
-
|
|
1273
|
+
_context0.n = 6;
|
|
1509
1274
|
return performDryRunCall(true);
|
|
1510
1275
|
case 6:
|
|
1511
|
-
result =
|
|
1276
|
+
result = _context0.v;
|
|
1512
1277
|
isSuccess = getExecutionSuccessFromResult(result);
|
|
1513
1278
|
if (!isSuccess) {
|
|
1514
1279
|
failureOutputReason = extractFailureReasonFromResult(result);
|
|
@@ -1522,10 +1287,10 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1522
1287
|
usedAsset = feeAsset !== null && feeAsset !== void 0 ? feeAsset : findNativeAssetInfoOrThrow(chain);
|
|
1523
1288
|
usedSymbol = usedAsset.symbol;
|
|
1524
1289
|
if (isSuccess) {
|
|
1525
|
-
|
|
1290
|
+
_context0.n = 8;
|
|
1526
1291
|
break;
|
|
1527
1292
|
}
|
|
1528
|
-
return
|
|
1293
|
+
return _context0.a(2, Promise.resolve({
|
|
1529
1294
|
success: false,
|
|
1530
1295
|
failureReason: failureOutputReason.failureReason,
|
|
1531
1296
|
failureSubReason: failureOutputReason.failureSubReason,
|
|
@@ -1543,18 +1308,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1543
1308
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1544
1309
|
hasLocation = feeAsset ? Boolean(feeAsset.location) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.location);
|
|
1545
1310
|
if (!(hasXcmPaymentApiSupport(chain) && result.value.local_xcm && hasLocation && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum'))) {
|
|
1546
|
-
|
|
1311
|
+
_context0.n = 10;
|
|
1547
1312
|
break;
|
|
1548
1313
|
}
|
|
1549
|
-
|
|
1314
|
+
_context0.n = 9;
|
|
1550
1315
|
return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
|
|
1551
1316
|
case 9:
|
|
1552
|
-
xcmFee =
|
|
1317
|
+
xcmFee = _context0.v;
|
|
1553
1318
|
if (!(typeof xcmFee === 'bigint')) {
|
|
1554
|
-
|
|
1319
|
+
_context0.n = 10;
|
|
1555
1320
|
break;
|
|
1556
1321
|
}
|
|
1557
|
-
return
|
|
1322
|
+
return _context0.a(2, Promise.resolve({
|
|
1558
1323
|
success: true,
|
|
1559
1324
|
fee: xcmFee,
|
|
1560
1325
|
currency: usedSymbol,
|
|
@@ -1564,12 +1329,12 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1564
1329
|
destParaId: destParaId
|
|
1565
1330
|
}));
|
|
1566
1331
|
case 10:
|
|
1567
|
-
|
|
1332
|
+
_context0.n = 11;
|
|
1568
1333
|
return this.calculateTransactionFee(tx, address);
|
|
1569
1334
|
case 11:
|
|
1570
|
-
executionFee =
|
|
1335
|
+
executionFee = _context0.v;
|
|
1571
1336
|
fee = computeFeeFromDryRun(result, chain, executionFee, !!feeAsset);
|
|
1572
|
-
return
|
|
1337
|
+
return _context0.a(2, Promise.resolve({
|
|
1573
1338
|
success: true,
|
|
1574
1339
|
fee: fee,
|
|
1575
1340
|
currency: usedSymbol,
|
|
@@ -1579,9 +1344,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1579
1344
|
destParaId: destParaId
|
|
1580
1345
|
}));
|
|
1581
1346
|
}
|
|
1582
|
-
},
|
|
1347
|
+
}, _callee0, this);
|
|
1583
1348
|
}));
|
|
1584
|
-
function getDryRunCall(
|
|
1349
|
+
function getDryRunCall(_x14) {
|
|
1585
1350
|
return _getDryRunCall.apply(this, arguments);
|
|
1586
1351
|
}
|
|
1587
1352
|
return getDryRunCall;
|
|
@@ -1589,24 +1354,24 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1589
1354
|
}, {
|
|
1590
1355
|
key: "getXcmWeight",
|
|
1591
1356
|
value: function () {
|
|
1592
|
-
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1357
|
+
var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(xcm) {
|
|
1593
1358
|
var weightResult, _weightResult$value, ref_time, proof_size;
|
|
1594
|
-
return _regenerator().w(function (
|
|
1595
|
-
while (1) switch (
|
|
1359
|
+
return _regenerator().w(function (_context1) {
|
|
1360
|
+
while (1) switch (_context1.n) {
|
|
1596
1361
|
case 0:
|
|
1597
|
-
|
|
1362
|
+
_context1.n = 1;
|
|
1598
1363
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
|
|
1599
1364
|
case 1:
|
|
1600
|
-
weightResult =
|
|
1365
|
+
weightResult = _context1.v;
|
|
1601
1366
|
_weightResult$value = weightResult.value, ref_time = _weightResult$value.ref_time, proof_size = _weightResult$value.proof_size;
|
|
1602
|
-
return
|
|
1367
|
+
return _context1.a(2, {
|
|
1603
1368
|
refTime: ref_time,
|
|
1604
1369
|
proofSize: proof_size
|
|
1605
1370
|
});
|
|
1606
1371
|
}
|
|
1607
|
-
},
|
|
1372
|
+
}, _callee1, this);
|
|
1608
1373
|
}));
|
|
1609
|
-
function getXcmWeight(
|
|
1374
|
+
function getXcmWeight(_x16) {
|
|
1610
1375
|
return _getXcmWeight.apply(this, arguments);
|
|
1611
1376
|
}
|
|
1612
1377
|
return getXcmWeight;
|
|
@@ -1614,7 +1379,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1614
1379
|
}, {
|
|
1615
1380
|
key: "getXcmPaymentApiFee",
|
|
1616
1381
|
value: function () {
|
|
1617
|
-
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1382
|
+
var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, localXcm, forwardedXcm, asset) {
|
|
1618
1383
|
var _deliveryFeeRes$value, _deliveryFeeRes$value2;
|
|
1619
1384
|
var transformXcm,
|
|
1620
1385
|
transformedXcm,
|
|
@@ -1627,37 +1392,37 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1627
1392
|
nativeAsset,
|
|
1628
1393
|
deliveryFee,
|
|
1629
1394
|
res,
|
|
1630
|
-
|
|
1395
|
+
_args10 = arguments,
|
|
1631
1396
|
_t3,
|
|
1632
1397
|
_t4;
|
|
1633
|
-
return _regenerator().w(function (
|
|
1634
|
-
while (1) switch (
|
|
1398
|
+
return _regenerator().w(function (_context10) {
|
|
1399
|
+
while (1) switch (_context10.p = _context10.n) {
|
|
1635
1400
|
case 0:
|
|
1636
|
-
transformXcm =
|
|
1401
|
+
transformXcm = _args10.length > 4 && _args10[4] !== undefined ? _args10[4] : false;
|
|
1637
1402
|
transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
|
|
1638
|
-
|
|
1403
|
+
_context10.n = 1;
|
|
1639
1404
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
|
|
1640
1405
|
case 1:
|
|
1641
|
-
weight =
|
|
1406
|
+
weight = _context10.v;
|
|
1642
1407
|
assertHasLocation(asset);
|
|
1643
1408
|
assetLocalizedLoc = localizeLocation(chain, asset.location);
|
|
1644
1409
|
transformedAssetLoc = _transform(assetLocalizedLoc);
|
|
1645
|
-
|
|
1410
|
+
_context10.n = 2;
|
|
1646
1411
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight.value, {
|
|
1647
1412
|
type: Version.V4,
|
|
1648
1413
|
value: transformedAssetLoc
|
|
1649
1414
|
});
|
|
1650
1415
|
case 2:
|
|
1651
|
-
execFeeRes =
|
|
1416
|
+
execFeeRes = _context10.v;
|
|
1652
1417
|
if (!(forwardedXcm.length > 0)) {
|
|
1653
|
-
|
|
1418
|
+
_context10.n = 4;
|
|
1654
1419
|
break;
|
|
1655
1420
|
}
|
|
1656
|
-
|
|
1421
|
+
_context10.n = 3;
|
|
1657
1422
|
return this.api.getUnsafeApi().apis.XcmPaymentApi.query_delivery_fees(forwardedXcm[0], forwardedXcm[1][0]);
|
|
1658
1423
|
case 3:
|
|
1659
|
-
_t3 =
|
|
1660
|
-
|
|
1424
|
+
_t3 = _context10.v;
|
|
1425
|
+
_context10.n = 5;
|
|
1661
1426
|
break;
|
|
1662
1427
|
case 4:
|
|
1663
1428
|
_t3 = undefined;
|
|
@@ -1666,36 +1431,36 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1666
1431
|
deliveryFeeResolved = (deliveryFeeRes === null || deliveryFeeRes === void 0 || (_deliveryFeeRes$value = deliveryFeeRes.value) === null || _deliveryFeeRes$value === void 0 ? void 0 : _deliveryFeeRes$value.value.length) > 0 ? deliveryFeeRes === null || deliveryFeeRes === void 0 || (_deliveryFeeRes$value2 = deliveryFeeRes.value) === null || _deliveryFeeRes$value2 === void 0 ? void 0 : _deliveryFeeRes$value2.value[0].fun.value : 0n;
|
|
1667
1432
|
nativeAsset = findNativeAssetInfoOrThrow(chain);
|
|
1668
1433
|
if (!isAssetXcEqual(asset, nativeAsset)) {
|
|
1669
|
-
|
|
1434
|
+
_context10.n = 6;
|
|
1670
1435
|
break;
|
|
1671
1436
|
}
|
|
1672
1437
|
deliveryFee = deliveryFeeResolved;
|
|
1673
|
-
|
|
1438
|
+
_context10.n = 9;
|
|
1674
1439
|
break;
|
|
1675
1440
|
case 6:
|
|
1676
|
-
|
|
1441
|
+
_context10.p = 6;
|
|
1677
1442
|
assertHasLocation(nativeAsset);
|
|
1678
|
-
|
|
1443
|
+
_context10.n = 7;
|
|
1679
1444
|
return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
|
|
1680
1445
|
case 7:
|
|
1681
|
-
res =
|
|
1446
|
+
res = _context10.v;
|
|
1682
1447
|
deliveryFee = res !== null && res !== void 0 ? res : 0n;
|
|
1683
|
-
|
|
1448
|
+
_context10.n = 9;
|
|
1684
1449
|
break;
|
|
1685
1450
|
case 8:
|
|
1686
|
-
|
|
1687
|
-
_t4 =
|
|
1451
|
+
_context10.p = 8;
|
|
1452
|
+
_t4 = _context10.v;
|
|
1688
1453
|
if (_t4 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t4.message)) {
|
|
1689
1454
|
deliveryFee = 0n;
|
|
1690
1455
|
} else {
|
|
1691
1456
|
deliveryFee = 0n;
|
|
1692
1457
|
}
|
|
1693
1458
|
case 9:
|
|
1694
|
-
return
|
|
1459
|
+
return _context10.a(2, execFeeRes.value + deliveryFee);
|
|
1695
1460
|
}
|
|
1696
|
-
},
|
|
1461
|
+
}, _callee10, this, [[6, 8]]);
|
|
1697
1462
|
}));
|
|
1698
|
-
function getXcmPaymentApiFee(
|
|
1463
|
+
function getXcmPaymentApiFee(_x17, _x18, _x19, _x20) {
|
|
1699
1464
|
return _getXcmPaymentApiFee.apply(this, arguments);
|
|
1700
1465
|
}
|
|
1701
1466
|
return getXcmPaymentApiFee;
|
|
@@ -1703,33 +1468,33 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1703
1468
|
}, {
|
|
1704
1469
|
key: "getDryRunXcm",
|
|
1705
1470
|
value: function () {
|
|
1706
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1707
|
-
var
|
|
1471
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(_ref0) {
|
|
1472
|
+
var _ref1, _processAssetsDeposit, _ref10, _ref11, _ref12, _ref13, _ref14;
|
|
1708
1473
|
var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, symbol, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
|
|
1709
|
-
return _regenerator().w(function (
|
|
1710
|
-
while (1) switch (
|
|
1474
|
+
return _regenerator().w(function (_context11) {
|
|
1475
|
+
while (1) switch (_context11.n) {
|
|
1711
1476
|
case 0:
|
|
1712
|
-
originLocation =
|
|
1477
|
+
originLocation = _ref0.originLocation, xcm = _ref0.xcm, chain = _ref0.chain, origin = _ref0.origin, asset = _ref0.asset, feeAsset = _ref0.feeAsset, originFee = _ref0.originFee, amount = _ref0.amount;
|
|
1713
1478
|
supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
|
|
1714
1479
|
if (supportsDryRunApi) {
|
|
1715
|
-
|
|
1480
|
+
_context11.n = 1;
|
|
1716
1481
|
break;
|
|
1717
1482
|
}
|
|
1718
1483
|
throw new ChainNotSupportedError("DryRunApi is not available on chain ".concat(chain));
|
|
1719
1484
|
case 1:
|
|
1720
1485
|
transformedOriginLocation = _transform(originLocation);
|
|
1721
|
-
|
|
1486
|
+
_context11.n = 2;
|
|
1722
1487
|
return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
|
|
1723
1488
|
case 2:
|
|
1724
|
-
result =
|
|
1489
|
+
result = _context11.v;
|
|
1725
1490
|
symbol = asset.symbol;
|
|
1726
1491
|
isSuccess = result.success && result.value.execution_result.type === 'Complete';
|
|
1727
1492
|
if (isSuccess) {
|
|
1728
|
-
|
|
1493
|
+
_context11.n = 3;
|
|
1729
1494
|
break;
|
|
1730
1495
|
}
|
|
1731
1496
|
failureReason = extractDryRunXcmFailureReason(result);
|
|
1732
|
-
return
|
|
1497
|
+
return _context11.a(2, {
|
|
1733
1498
|
success: false,
|
|
1734
1499
|
failureReason: failureReason,
|
|
1735
1500
|
currency: symbol,
|
|
@@ -1744,18 +1509,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1744
1509
|
forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
|
|
1745
1510
|
destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
|
|
1746
1511
|
if (!(hasXcmPaymentApiSupport(chain) && asset)) {
|
|
1747
|
-
|
|
1512
|
+
_context11.n = 5;
|
|
1748
1513
|
break;
|
|
1749
1514
|
}
|
|
1750
|
-
|
|
1515
|
+
_context11.n = 4;
|
|
1751
1516
|
return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
|
|
1752
1517
|
case 4:
|
|
1753
|
-
_fee =
|
|
1518
|
+
_fee = _context11.v;
|
|
1754
1519
|
if (!(typeof _fee === 'bigint')) {
|
|
1755
|
-
|
|
1520
|
+
_context11.n = 5;
|
|
1756
1521
|
break;
|
|
1757
1522
|
}
|
|
1758
|
-
return
|
|
1523
|
+
return _context11.a(2, {
|
|
1759
1524
|
success: true,
|
|
1760
1525
|
fee: _fee,
|
|
1761
1526
|
currency: symbol,
|
|
@@ -1769,13 +1534,13 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1769
1534
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1770
1535
|
palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
|
|
1771
1536
|
isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && asset && isAssetEqual(feeAsset, asset);
|
|
1772
|
-
feeAssetFeeEvent = (
|
|
1537
|
+
feeAssetFeeEvent = (_ref1 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1773
1538
|
return (event.type === 'ForeignAssets' || event.type === 'Assets') && event.value.type === 'Issued';
|
|
1774
|
-
}) : undefined) !== null &&
|
|
1539
|
+
}) : undefined) !== null && _ref1 !== void 0 ? _ref1 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
|
|
1775
1540
|
return event.type === 'Tokens' && event.value.type === 'Deposited';
|
|
1776
1541
|
}) : undefined;
|
|
1777
1542
|
processedAssetsAmount = chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? processAssetsDepositedEvents(emitted, amount, 'Assets', 'Deposited', true) : (_processAssetsDeposit = processAssetsDepositedEvents(emitted, amount, 'Balances', 'Minted', false)) !== null && _processAssetsDeposit !== void 0 ? _processAssetsDeposit : processAssetsDepositedEvents(emitted, amount, 'Balances', 'Issued', false);
|
|
1778
|
-
feeEvent = (
|
|
1543
|
+
feeEvent = (_ref10 = (_ref11 = (_ref12 = (_ref13 = (_ref14 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent :
|
|
1779
1544
|
//
|
|
1780
1545
|
processedAssetsAmount !== undefined ? {
|
|
1781
1546
|
type: 'Assets',
|
|
@@ -1785,30 +1550,30 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1785
1550
|
amount: processedAssetsAmount
|
|
1786
1551
|
}
|
|
1787
1552
|
}
|
|
1788
|
-
} : undefined) !== null &&
|
|
1553
|
+
} : undefined) !== null && _ref14 !== void 0 ? _ref14 :
|
|
1789
1554
|
//
|
|
1790
1555
|
chain === 'Mythos' ? reversedEvents.find(function (event) {
|
|
1791
1556
|
return event.type === 'Balances' && event.value.type === 'Issued';
|
|
1792
|
-
}) : undefined) !== null &&
|
|
1557
|
+
}) : undefined) !== null && _ref13 !== void 0 ? _ref13 :
|
|
1793
1558
|
//
|
|
1794
1559
|
origin === 'Mythos' || chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
|
|
1795
1560
|
return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
|
|
1796
|
-
}) : undefined) !== null &&
|
|
1561
|
+
}) : undefined) !== null && _ref12 !== void 0 ? _ref12 :
|
|
1797
1562
|
// Prefer to Minted event
|
|
1798
1563
|
reversedEvents.find(function (event) {
|
|
1799
1564
|
return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
|
|
1800
|
-
})) !== null &&
|
|
1565
|
+
})) !== null && _ref11 !== void 0 ? _ref11 :
|
|
1801
1566
|
// Fallback an Issued event
|
|
1802
1567
|
reversedEvents.find(function (event) {
|
|
1803
1568
|
return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
|
|
1804
|
-
})) !== null &&
|
|
1569
|
+
})) !== null && _ref10 !== void 0 ? _ref10 : reversedEvents.find(function (event) {
|
|
1805
1570
|
return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
|
|
1806
1571
|
});
|
|
1807
1572
|
if (feeEvent) {
|
|
1808
|
-
|
|
1573
|
+
_context11.n = 6;
|
|
1809
1574
|
break;
|
|
1810
1575
|
}
|
|
1811
|
-
return
|
|
1576
|
+
return _context11.a(2, Promise.resolve({
|
|
1812
1577
|
success: false,
|
|
1813
1578
|
failureReason: 'Cannot determine destination fee. No fee event found',
|
|
1814
1579
|
currency: symbol,
|
|
@@ -1820,7 +1585,7 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1820
1585
|
fee = amount - originFee - feeEvent.value.value.amount;
|
|
1821
1586
|
}
|
|
1822
1587
|
processedFee = (isRelayChain(chain) || chain.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padValueBy(fee, 30) : fee;
|
|
1823
|
-
return
|
|
1588
|
+
return _context11.a(2, Promise.resolve({
|
|
1824
1589
|
success: true,
|
|
1825
1590
|
fee: processedFee,
|
|
1826
1591
|
currency: symbol,
|
|
@@ -1830,9 +1595,9 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1830
1595
|
destParaId: destParaId
|
|
1831
1596
|
}));
|
|
1832
1597
|
}
|
|
1833
|
-
},
|
|
1598
|
+
}, _callee11, this);
|
|
1834
1599
|
}));
|
|
1835
|
-
function getDryRunXcm(
|
|
1600
|
+
function getDryRunXcm(_x21) {
|
|
1836
1601
|
return _getDryRunXcm.apply(this, arguments);
|
|
1837
1602
|
}
|
|
1838
1603
|
return getDryRunXcm;
|
|
@@ -1840,18 +1605,18 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1840
1605
|
}, {
|
|
1841
1606
|
key: "getBridgeStatus",
|
|
1842
1607
|
value: function () {
|
|
1843
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1608
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
1844
1609
|
var outboundOperatingMode;
|
|
1845
|
-
return _regenerator().w(function (
|
|
1846
|
-
while (1) switch (
|
|
1610
|
+
return _regenerator().w(function (_context12) {
|
|
1611
|
+
while (1) switch (_context12.n) {
|
|
1847
1612
|
case 0:
|
|
1848
|
-
|
|
1613
|
+
_context12.n = 1;
|
|
1849
1614
|
return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
|
|
1850
1615
|
case 1:
|
|
1851
|
-
outboundOperatingMode =
|
|
1852
|
-
return
|
|
1616
|
+
outboundOperatingMode = _context12.v;
|
|
1617
|
+
return _context12.a(2, outboundOperatingMode.type);
|
|
1853
1618
|
}
|
|
1854
|
-
},
|
|
1619
|
+
}, _callee12, this);
|
|
1855
1620
|
}));
|
|
1856
1621
|
function getBridgeStatus() {
|
|
1857
1622
|
return _getBridgeStatus.apply(this, arguments);
|
|
@@ -1891,30 +1656,6 @@ var PapiApi = /*#__PURE__*/function () {
|
|
|
1891
1656
|
}
|
|
1892
1657
|
return Promise.resolve();
|
|
1893
1658
|
}
|
|
1894
|
-
}, {
|
|
1895
|
-
key: "convertLocationToAccount",
|
|
1896
|
-
value: function () {
|
|
1897
|
-
var _convertLocationToAccount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(location) {
|
|
1898
|
-
var res;
|
|
1899
|
-
return _regenerator().w(function (_context22) {
|
|
1900
|
-
while (1) switch (_context22.n) {
|
|
1901
|
-
case 0:
|
|
1902
|
-
_context22.n = 1;
|
|
1903
|
-
return this.api.getUnsafeApi().apis.LocationToAccountApi.convert_location({
|
|
1904
|
-
type: Version.V4,
|
|
1905
|
-
value: _transform(location)
|
|
1906
|
-
});
|
|
1907
|
-
case 1:
|
|
1908
|
-
res = _context22.v;
|
|
1909
|
-
return _context22.a(2, res.success ? res.value : undefined);
|
|
1910
|
-
}
|
|
1911
|
-
}, _callee22, this);
|
|
1912
|
-
}));
|
|
1913
|
-
function convertLocationToAccount(_x40) {
|
|
1914
|
-
return _convertLocationToAccount.apply(this, arguments);
|
|
1915
|
-
}
|
|
1916
|
-
return convertLocationToAccount;
|
|
1917
|
-
}()
|
|
1918
1659
|
}]);
|
|
1919
1660
|
}();
|
|
1920
1661
|
|
|
@@ -1960,13 +1701,13 @@ var getBalanceNative = createPapiApiCall(getBalanceNative$1);
|
|
|
1960
1701
|
*
|
|
1961
1702
|
* @returns The balance of the foreign asset as a bigint, or null if not found.
|
|
1962
1703
|
*/
|
|
1963
|
-
var getBalanceForeign = createPapiApiCall(
|
|
1704
|
+
var getBalanceForeign = createPapiApiCall(getBalance);
|
|
1964
1705
|
/**
|
|
1965
1706
|
* Retrieves the asset balance for a given account on a specified chain.
|
|
1966
1707
|
*
|
|
1967
1708
|
* @returns The asset balance as a bigint.
|
|
1968
1709
|
*/
|
|
1969
|
-
var getAssetBalance = createPapiApiCall(
|
|
1710
|
+
var getAssetBalance = createPapiApiCall(getBalance);
|
|
1970
1711
|
/**
|
|
1971
1712
|
* Claims assets from a parachain.
|
|
1972
1713
|
*
|