@paraspell/sdk 12.0.6 → 12.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +245 -115
  2. package/package.json +8 -8
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { NumberFormatError, isConfig, InvalidAddressError, BatchMode, findNativeAssetInfoOrThrow, getChainProviders, MissingChainApiError, Parents, Version, findAssetInfoOrThrow, computeFeeFromDryRun, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, padValueBy, isRelayChain, isAssetEqual, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$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';
1
+ import { NumberFormatError, isConfig, InvalidAddressError, BatchMode, findNativeAssetInfoOrThrow, getChainProviders, MissingChainApiError, Parents, Version, findAssetInfoOrThrow, computeFeeFromDryRun, hasXcmPaymentApiSupport, replaceBigInt, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, RELAY_LOCATION, getRelayChainOf, padValueBy, isRelayChain, isAssetEqual, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$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.js';
4
4
  import { bytesToHex } from '@noble/hashes/utils.js';
@@ -313,7 +313,7 @@ function _unsupportedIterableToArray(r, a) {
313
313
  }
314
314
  }
315
315
 
316
- var LEGACY_CHAINS = ['Interlay', 'CrustShadow', 'Kintsugi', 'RobonomicsKusama', 'RobonomicsPolkadot', 'Pendulum'];
316
+ var LEGACY_CHAINS = ['Interlay', 'CrustShadow', 'Kintsugi', 'RobonomicsPolkadot', 'Pendulum'];
317
317
  // Cache settings
318
318
  var DEFAULT_TTL_MS = 60000; // 1 minute
319
319
  var MAX_CLIENTS = 100;
@@ -1202,16 +1202,16 @@ var PapiApi = /*#__PURE__*/function () {
1202
1202
  }, {
1203
1203
  key: "getDryRunCall",
1204
1204
  value: function () {
1205
- var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(options) {
1205
+ var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(options) {
1206
1206
  var _this = this;
1207
- var tx, chain, destination, address, feeAsset, bypassOptions, _options$useRootOrigi, useRootOrigin, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, resolvedFeeAsset, actualWeight, weight, forwardedXcms, destParaId, hasLocation, xcmFee, executionFee, fee, _t2;
1208
- return _regenerator().w(function (_context1) {
1209
- while (1) switch (_context1.n) {
1207
+ var tx, chain, destination, address, feeAsset, bypassOptions, _options$useRootOrigi, useRootOrigin, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, resolvedTx, performDryRunCall, getExecutionSuccessFromResult, findFailureObjectFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, resolvedFeeAsset, actualWeight, weight, forwardedXcms, destParaId, hasLocation, getPaymentInfoWeight, overriddenWeight, xcmFee, executionFee, fee, _t2, _t3;
1208
+ return _regenerator().w(function (_context10) {
1209
+ while (1) switch (_context10.n) {
1210
1210
  case 0:
1211
1211
  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;
1212
1212
  supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
1213
1213
  if (supportsDryRunApi) {
1214
- _context1.n = 1;
1214
+ _context10.n = 1;
1215
1215
  break;
1216
1216
  }
1217
1217
  throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
@@ -1227,16 +1227,16 @@ var PapiApi = /*#__PURE__*/function () {
1227
1227
  }
1228
1228
  };
1229
1229
  if (!useRootOrigin) {
1230
- _context1.n = 3;
1230
+ _context10.n = 3;
1231
1231
  break;
1232
1232
  }
1233
- _context1.n = 2;
1233
+ _context10.n = 2;
1234
1234
  return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
1235
1235
  api: this
1236
1236
  }), bypassOptions);
1237
1237
  case 2:
1238
- _t2 = _context1.v;
1239
- _context1.n = 4;
1238
+ _t2 = _context10.v;
1239
+ _context10.n = 4;
1240
1240
  break;
1241
1241
  case 3:
1242
1242
  _t2 = tx;
@@ -1307,25 +1307,25 @@ var PapiApi = /*#__PURE__*/function () {
1307
1307
  failureOutputReason = {
1308
1308
  failureReason: ''
1309
1309
  };
1310
- _context1.n = 5;
1310
+ _context10.n = 5;
1311
1311
  return performDryRunCall(false);
1312
1312
  case 5:
1313
- result = _context1.v;
1313
+ result = _context10.v;
1314
1314
  isSuccess = getExecutionSuccessFromResult(result);
1315
1315
  if (isSuccess) {
1316
- _context1.n = 7;
1316
+ _context10.n = 7;
1317
1317
  break;
1318
1318
  }
1319
1319
  initialFailureReason = extractFailureReasonFromResult(result);
1320
1320
  failureOutputReason = initialFailureReason;
1321
1321
  if (!(initialFailureReason.failureReason === 'VersionedConversionFailed')) {
1322
- _context1.n = 7;
1322
+ _context10.n = 7;
1323
1323
  break;
1324
1324
  }
1325
- _context1.n = 6;
1325
+ _context10.n = 6;
1326
1326
  return performDryRunCall(true);
1327
1327
  case 6:
1328
- result = _context1.v;
1328
+ result = _context10.v;
1329
1329
  isSuccess = getExecutionSuccessFromResult(result);
1330
1330
  if (!isSuccess) {
1331
1331
  failureOutputReason = extractFailureReasonFromResult(result);
@@ -1336,15 +1336,15 @@ var PapiApi = /*#__PURE__*/function () {
1336
1336
  };
1337
1337
  }
1338
1338
  case 7:
1339
- _context1.n = 8;
1339
+ _context10.n = 8;
1340
1340
  return this.resolveFeeAsset(options);
1341
1341
  case 8:
1342
- resolvedFeeAsset = _context1.v;
1342
+ resolvedFeeAsset = _context10.v;
1343
1343
  if (isSuccess) {
1344
- _context1.n = 9;
1344
+ _context10.n = 9;
1345
1345
  break;
1346
1346
  }
1347
- return _context1.a(2, Promise.resolve({
1347
+ return _context10.a(2, Promise.resolve({
1348
1348
  success: false,
1349
1349
  failureReason: failureOutputReason.failureReason,
1350
1350
  failureSubReason: failureOutputReason.failureSubReason,
@@ -1360,18 +1360,51 @@ var PapiApi = /*#__PURE__*/function () {
1360
1360
  destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1361
1361
  hasLocation = resolvedFeeAsset.asset.location;
1362
1362
  if (!(hasXcmPaymentApiSupport(chain) && result.value.local_xcm && hasLocation && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
1363
- _context1.n = 12;
1363
+ _context10.n = 15;
1364
+ break;
1365
+ }
1366
+ getPaymentInfoWeight = /*#__PURE__*/function () {
1367
+ var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
1368
+ var _yield$tx$getPaymentI, weight;
1369
+ return _regenerator().w(function (_context1) {
1370
+ while (1) switch (_context1.n) {
1371
+ case 0:
1372
+ _context1.n = 1;
1373
+ return tx.getPaymentInfo(address);
1374
+ case 1:
1375
+ _yield$tx$getPaymentI = _context1.v;
1376
+ weight = _yield$tx$getPaymentI.weight;
1377
+ return _context1.a(2, weight);
1378
+ }
1379
+ }, _callee1);
1380
+ }));
1381
+ return function getPaymentInfoWeight() {
1382
+ return _ref1.apply(this, arguments);
1383
+ };
1384
+ }();
1385
+ if (result.value.local_xcm) {
1386
+ _context10.n = 11;
1364
1387
  break;
1365
1388
  }
1366
- _context1.n = 10;
1367
- return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, resolvedFeeAsset.asset);
1389
+ _context10.n = 10;
1390
+ return getPaymentInfoWeight();
1368
1391
  case 10:
1369
- xcmFee = _context1.v;
1392
+ _t3 = _context10.v;
1393
+ _context10.n = 12;
1394
+ break;
1395
+ case 11:
1396
+ _t3 = undefined;
1397
+ case 12:
1398
+ overriddenWeight = _t3;
1399
+ _context10.n = 13;
1400
+ return this.getXcmPaymentApiFee(chain, result.value.local_xcm, forwardedXcms, resolvedFeeAsset.asset, false, overriddenWeight);
1401
+ case 13:
1402
+ xcmFee = _context10.v;
1370
1403
  if (!(typeof xcmFee === 'bigint')) {
1371
- _context1.n = 11;
1404
+ _context10.n = 14;
1372
1405
  break;
1373
1406
  }
1374
- return _context1.a(2, Promise.resolve({
1407
+ return _context10.a(2, Promise.resolve({
1375
1408
  success: true,
1376
1409
  fee: xcmFee,
1377
1410
  asset: resolvedFeeAsset.asset,
@@ -1379,18 +1412,18 @@ var PapiApi = /*#__PURE__*/function () {
1379
1412
  forwardedXcms: forwardedXcms,
1380
1413
  destParaId: destParaId
1381
1414
  }));
1382
- case 11:
1415
+ case 14:
1383
1416
  resolvedFeeAsset = {
1384
1417
  isCustomAsset: false,
1385
1418
  asset: this.resolveDefaultFeeAsset(options)
1386
1419
  };
1387
- case 12:
1388
- _context1.n = 13;
1420
+ case 15:
1421
+ _context10.n = 16;
1389
1422
  return this.calculateTransactionFee(tx, address);
1390
- case 13:
1391
- executionFee = _context1.v;
1423
+ case 16:
1424
+ executionFee = _context10.v;
1392
1425
  fee = computeFeeFromDryRun(result, chain, executionFee, !!feeAsset);
1393
- return _context1.a(2, Promise.resolve({
1426
+ return _context10.a(2, Promise.resolve({
1394
1427
  success: true,
1395
1428
  fee: fee,
1396
1429
  asset: resolvedFeeAsset.asset,
@@ -1399,7 +1432,7 @@ var PapiApi = /*#__PURE__*/function () {
1399
1432
  destParaId: destParaId
1400
1433
  }));
1401
1434
  }
1402
- }, _callee1, this);
1435
+ }, _callee10, this);
1403
1436
  }));
1404
1437
  function getDryRunCall(_x15) {
1405
1438
  return _getDryRunCall.apply(this, arguments);
@@ -1409,22 +1442,22 @@ var PapiApi = /*#__PURE__*/function () {
1409
1442
  }, {
1410
1443
  key: "getXcmWeight",
1411
1444
  value: function () {
1412
- var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(xcm) {
1445
+ var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(xcm) {
1413
1446
  var weightResult, _weightResult$value, ref_time, proof_size;
1414
- return _regenerator().w(function (_context10) {
1415
- while (1) switch (_context10.n) {
1447
+ return _regenerator().w(function (_context11) {
1448
+ while (1) switch (_context11.n) {
1416
1449
  case 0:
1417
- _context10.n = 1;
1450
+ _context11.n = 1;
1418
1451
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
1419
1452
  case 1:
1420
- weightResult = _context10.v;
1453
+ weightResult = _context11.v;
1421
1454
  _weightResult$value = weightResult.value, ref_time = _weightResult$value.ref_time, proof_size = _weightResult$value.proof_size;
1422
- return _context10.a(2, {
1455
+ return _context11.a(2, {
1423
1456
  refTime: ref_time,
1424
1457
  proofSize: proof_size
1425
1458
  });
1426
1459
  }
1427
- }, _callee10, this);
1460
+ }, _callee11, this);
1428
1461
  }));
1429
1462
  function getXcmWeight(_x17) {
1430
1463
  return _getXcmWeight.apply(this, arguments);
@@ -1434,121 +1467,218 @@ var PapiApi = /*#__PURE__*/function () {
1434
1467
  }, {
1435
1468
  key: "getXcmPaymentApiFee",
1436
1469
  value: function () {
1437
- var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, localXcm, forwardedXcm, asset) {
1438
- var _deliveryFeeRes$value, _deliveryFeeRes$value2;
1470
+ var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(chain, localXcm, forwardedXcm, asset) {
1471
+ var _this2 = this,
1472
+ _execFeeRes$value,
1473
+ _deliveryFeeRes$value,
1474
+ _deliveryFeeRes$value2;
1439
1475
  var transformXcm,
1476
+ overridenWeight,
1440
1477
  transformedXcm,
1478
+ queryWeight,
1441
1479
  weight,
1442
1480
  assetLocalizedLoc,
1443
1481
  transformedAssetLoc,
1444
1482
  execFeeRes,
1483
+ execFee,
1484
+ bridgeHubExecFee,
1445
1485
  deliveryFeeRes,
1446
1486
  deliveryFeeResolved,
1447
1487
  nativeAsset,
1448
1488
  deliveryFee,
1449
1489
  res,
1450
- _args11 = arguments,
1451
- _t3,
1452
- _t4;
1453
- return _regenerator().w(function (_context11) {
1454
- while (1) switch (_context11.p = _context11.n) {
1490
+ _args13 = arguments,
1491
+ _t4,
1492
+ _t5,
1493
+ _t6;
1494
+ return _regenerator().w(function (_context13) {
1495
+ while (1) switch (_context13.p = _context13.n) {
1455
1496
  case 0:
1456
- transformXcm = _args11.length > 4 && _args11[4] !== undefined ? _args11[4] : false;
1497
+ transformXcm = _args13.length > 4 && _args13[4] !== undefined ? _args13[4] : false;
1498
+ overridenWeight = _args13.length > 5 ? _args13[5] : undefined;
1457
1499
  transformedXcm = transformXcm ? _transform(localXcm) : localXcm;
1458
- _context11.n = 1;
1459
- return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
1500
+ queryWeight = /*#__PURE__*/function () {
1501
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
1502
+ var weightRes;
1503
+ return _regenerator().w(function (_context12) {
1504
+ while (1) switch (_context12.n) {
1505
+ case 0:
1506
+ _context12.n = 1;
1507
+ return _this2.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(transformedXcm);
1508
+ case 1:
1509
+ weightRes = _context12.v;
1510
+ return _context12.a(2, weightRes.value);
1511
+ }
1512
+ }, _callee12);
1513
+ }));
1514
+ return function queryWeight() {
1515
+ return _ref10.apply(this, arguments);
1516
+ };
1517
+ }();
1518
+ if (!(overridenWeight !== null && overridenWeight !== void 0)) {
1519
+ _context13.n = 1;
1520
+ break;
1521
+ }
1522
+ _t4 = overridenWeight;
1523
+ _context13.n = 3;
1524
+ break;
1460
1525
  case 1:
1461
- weight = _context11.v;
1526
+ _context13.n = 2;
1527
+ return queryWeight();
1528
+ case 2:
1529
+ _t4 = _context13.v;
1530
+ case 3:
1531
+ weight = _t4;
1462
1532
  assertHasLocation(asset);
1463
1533
  assetLocalizedLoc = localizeLocation(chain, asset.location);
1464
1534
  transformedAssetLoc = _transform(assetLocalizedLoc);
1465
- _context11.n = 2;
1466
- return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight.value, {
1535
+ _context13.n = 4;
1536
+ return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight, {
1467
1537
  type: Version.V4,
1468
1538
  value: transformedAssetLoc
1469
1539
  });
1470
- case 2:
1471
- execFeeRes = _context11.v;
1540
+ case 4:
1541
+ execFeeRes = _context13.v;
1542
+ execFee = typeof (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.value) === 'bigint' ? execFeeRes.value : 0n;
1543
+ 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')) {
1544
+ _context13.n = 6;
1545
+ break;
1546
+ }
1547
+ _context13.n = 5;
1548
+ return this.getBridgeHubFallbackExecFee(chain, weight, asset);
1549
+ case 5:
1550
+ bridgeHubExecFee = _context13.v;
1551
+ if (typeof bridgeHubExecFee === 'bigint') {
1552
+ execFee = bridgeHubExecFee;
1553
+ }
1554
+ case 6:
1472
1555
  if (!(forwardedXcm.length > 0)) {
1473
- _context11.n = 4;
1556
+ _context13.n = 8;
1474
1557
  break;
1475
1558
  }
1476
- _context11.n = 3;
1559
+ _context13.n = 7;
1477
1560
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_delivery_fees(forwardedXcm[0], forwardedXcm[1][0]);
1478
- case 3:
1479
- _t3 = _context11.v;
1480
- _context11.n = 5;
1561
+ case 7:
1562
+ _t5 = _context13.v;
1563
+ _context13.n = 9;
1481
1564
  break;
1482
- case 4:
1483
- _t3 = undefined;
1484
- case 5:
1485
- deliveryFeeRes = _t3;
1565
+ case 8:
1566
+ _t5 = undefined;
1567
+ case 9:
1568
+ deliveryFeeRes = _t5;
1486
1569
  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;
1487
1570
  nativeAsset = findNativeAssetInfoOrThrow(chain);
1488
1571
  if (!isAssetXcEqual(asset, nativeAsset)) {
1489
- _context11.n = 6;
1572
+ _context13.n = 10;
1490
1573
  break;
1491
1574
  }
1492
1575
  deliveryFee = deliveryFeeResolved;
1493
- _context11.n = 9;
1576
+ _context13.n = 13;
1494
1577
  break;
1495
- case 6:
1496
- _context11.p = 6;
1578
+ case 10:
1579
+ _context13.p = 10;
1497
1580
  assertHasLocation(nativeAsset);
1498
- _context11.n = 7;
1581
+ _context13.n = 11;
1499
1582
  return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
1500
- case 7:
1501
- res = _context11.v;
1583
+ case 11:
1584
+ res = _context13.v;
1502
1585
  deliveryFee = res !== null && res !== void 0 ? res : 0n;
1503
- _context11.n = 9;
1586
+ _context13.n = 13;
1504
1587
  break;
1505
- case 8:
1506
- _context11.p = 8;
1507
- _t4 = _context11.v;
1508
- if (_t4 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t4.message)) {
1588
+ case 12:
1589
+ _context13.p = 12;
1590
+ _t6 = _context13.v;
1591
+ if (_t6 instanceof Error && /Runtime entry RuntimeCall\(.+\) not found/.test(_t6.message)) {
1509
1592
  deliveryFee = 0n;
1510
1593
  } else {
1511
1594
  deliveryFee = 0n;
1512
1595
  }
1513
- case 9:
1514
- return _context11.a(2, execFeeRes.value + deliveryFee);
1596
+ case 13:
1597
+ return _context13.a(2, execFee + deliveryFee);
1515
1598
  }
1516
- }, _callee11, this, [[6, 8]]);
1599
+ }, _callee13, this, [[10, 12]]);
1517
1600
  }));
1518
1601
  function getXcmPaymentApiFee(_x18, _x19, _x20, _x21) {
1519
1602
  return _getXcmPaymentApiFee.apply(this, arguments);
1520
1603
  }
1521
1604
  return getXcmPaymentApiFee;
1522
1605
  }()
1606
+ }, {
1607
+ key: "getBridgeHubFallbackExecFee",
1608
+ value: function () {
1609
+ var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(chain, weightValue, asset) {
1610
+ var fallbackExecFeeRes, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
1611
+ return _regenerator().w(function (_context14) {
1612
+ while (1) switch (_context14.n) {
1613
+ case 0:
1614
+ _context14.n = 1;
1615
+ return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weightValue, {
1616
+ type: Version.V4,
1617
+ value: _transform(RELAY_LOCATION)
1618
+ });
1619
+ case 1:
1620
+ fallbackExecFeeRes = _context14.v;
1621
+ if (!(typeof (fallbackExecFeeRes === null || fallbackExecFeeRes === void 0 ? void 0 : fallbackExecFeeRes.value) !== 'bigint')) {
1622
+ _context14.n = 2;
1623
+ break;
1624
+ }
1625
+ return _context14.a(2, undefined);
1626
+ case 2:
1627
+ ahApi = this.clone();
1628
+ assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
1629
+ _context14.n = 3;
1630
+ return ahApi.init(assetHubChain);
1631
+ case 3:
1632
+ assertHasLocation(asset);
1633
+ ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
1634
+ _context14.n = 4;
1635
+ return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFeeRes.value, false);
1636
+ case 4:
1637
+ convertedExecFee = _context14.v;
1638
+ if (!(typeof convertedExecFee === 'bigint')) {
1639
+ _context14.n = 5;
1640
+ break;
1641
+ }
1642
+ return _context14.a(2, convertedExecFee);
1643
+ case 5:
1644
+ return _context14.a(2, undefined);
1645
+ }
1646
+ }, _callee14, this);
1647
+ }));
1648
+ function getBridgeHubFallbackExecFee(_x22, _x23, _x24) {
1649
+ return _getBridgeHubFallbackExecFee.apply(this, arguments);
1650
+ }
1651
+ return getBridgeHubFallbackExecFee;
1652
+ }()
1523
1653
  }, {
1524
1654
  key: "getDryRunXcm",
1525
1655
  value: function () {
1526
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(_ref1) {
1527
- var _ref10, _processAssetsDeposit, _ref11, _ref12, _ref13, _ref14, _ref15;
1656
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref11) {
1657
+ var _ref12, _processAssetsDeposit, _ref13, _ref14, _ref15, _ref16, _ref17;
1528
1658
  var originLocation, xcm, chain, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
1529
- return _regenerator().w(function (_context12) {
1530
- while (1) switch (_context12.n) {
1659
+ return _regenerator().w(function (_context15) {
1660
+ while (1) switch (_context15.n) {
1531
1661
  case 0:
1532
- originLocation = _ref1.originLocation, xcm = _ref1.xcm, chain = _ref1.chain, origin = _ref1.origin, asset = _ref1.asset, feeAsset = _ref1.feeAsset, originFee = _ref1.originFee, amount = _ref1.amount;
1662
+ originLocation = _ref11.originLocation, xcm = _ref11.xcm, chain = _ref11.chain, origin = _ref11.origin, asset = _ref11.asset, feeAsset = _ref11.feeAsset, originFee = _ref11.originFee, amount = _ref11.amount;
1533
1663
  supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
1534
1664
  if (supportsDryRunApi) {
1535
- _context12.n = 1;
1665
+ _context15.n = 1;
1536
1666
  break;
1537
1667
  }
1538
1668
  throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
1539
1669
  case 1:
1540
1670
  transformedOriginLocation = _transform(originLocation);
1541
- _context12.n = 2;
1671
+ _context15.n = 2;
1542
1672
  return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
1543
1673
  case 2:
1544
- result = _context12.v;
1674
+ result = _context15.v;
1545
1675
  isSuccess = result.success && result.value.execution_result.type === 'Complete';
1546
1676
  if (isSuccess) {
1547
- _context12.n = 3;
1677
+ _context15.n = 3;
1548
1678
  break;
1549
1679
  }
1550
1680
  failureReason = extractDryRunXcmFailureReason(result);
1551
- return _context12.a(2, {
1681
+ return _context15.a(2, {
1552
1682
  success: false,
1553
1683
  failureReason: failureReason,
1554
1684
  asset: asset
@@ -1562,18 +1692,18 @@ var PapiApi = /*#__PURE__*/function () {
1562
1692
  forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1563
1693
  destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1564
1694
  if (!(hasXcmPaymentApiSupport(chain) && asset)) {
1565
- _context12.n = 5;
1695
+ _context15.n = 5;
1566
1696
  break;
1567
1697
  }
1568
- _context12.n = 4;
1698
+ _context15.n = 4;
1569
1699
  return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset);
1570
1700
  case 4:
1571
- _fee = _context12.v;
1701
+ _fee = _context15.v;
1572
1702
  if (!(typeof _fee === 'bigint')) {
1573
- _context12.n = 5;
1703
+ _context15.n = 5;
1574
1704
  break;
1575
1705
  }
1576
- return _context12.a(2, {
1706
+ return _context15.a(2, {
1577
1707
  success: true,
1578
1708
  fee: _fee,
1579
1709
  asset: asset,
@@ -1586,13 +1716,13 @@ var PapiApi = /*#__PURE__*/function () {
1586
1716
  reversedEvents = _toConsumableArray(emitted).reverse();
1587
1717
  palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
1588
1718
  isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && asset && isAssetEqual(feeAsset, asset);
1589
- feeAssetFeeEvent = (_ref10 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
1719
+ feeAssetFeeEvent = (_ref12 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
1590
1720
  return (event.type === 'ForeignAssets' || event.type === 'Assets') && event.value.type === 'Issued';
1591
- }) : undefined) !== null && _ref10 !== void 0 ? _ref10 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
1721
+ }) : undefined) !== null && _ref12 !== void 0 ? _ref12 : isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
1592
1722
  return event.type === 'Tokens' && event.value.type === 'Deposited';
1593
1723
  }) : undefined;
1594
1724
  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);
1595
- feeEvent = (_ref11 = (_ref12 = (_ref13 = (_ref14 = (_ref15 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent :
1725
+ feeEvent = (_ref13 = (_ref14 = (_ref15 = (_ref16 = (_ref17 = feeAssetFeeEvent !== null && feeAssetFeeEvent !== void 0 ? feeAssetFeeEvent :
1596
1726
  //
1597
1727
  processedAssetsAmount !== undefined ? {
1598
1728
  type: 'Assets',
@@ -1602,30 +1732,30 @@ var PapiApi = /*#__PURE__*/function () {
1602
1732
  amount: processedAssetsAmount
1603
1733
  }
1604
1734
  }
1605
- } : undefined) !== null && _ref15 !== void 0 ? _ref15 :
1735
+ } : undefined) !== null && _ref17 !== void 0 ? _ref17 :
1606
1736
  //
1607
1737
  chain === 'Mythos' ? reversedEvents.find(function (event) {
1608
1738
  return event.type === 'Balances' && event.value.type === 'Issued';
1609
- }) : undefined) !== null && _ref14 !== void 0 ? _ref14 :
1739
+ }) : undefined) !== null && _ref16 !== void 0 ? _ref16 :
1610
1740
  //
1611
1741
  origin === 'Mythos' || chain === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
1612
1742
  return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
1613
- }) : undefined) !== null && _ref13 !== void 0 ? _ref13 :
1743
+ }) : undefined) !== null && _ref15 !== void 0 ? _ref15 :
1614
1744
  // Prefer to Minted event
1615
1745
  reversedEvents.find(function (event) {
1616
1746
  return ['Balances', 'ForeignAssets'].includes(event.type) && event.value.type === 'Minted';
1617
- })) !== null && _ref12 !== void 0 ? _ref12 :
1747
+ })) !== null && _ref14 !== void 0 ? _ref14 :
1618
1748
  // Fallback an Issued event
1619
1749
  reversedEvents.find(function (event) {
1620
1750
  return palletsWithIssued.includes(event.type) && event.value.type === 'Issued';
1621
- })) !== null && _ref11 !== void 0 ? _ref11 : reversedEvents.find(function (event) {
1751
+ })) !== null && _ref13 !== void 0 ? _ref13 : reversedEvents.find(function (event) {
1622
1752
  return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
1623
1753
  });
1624
1754
  if (feeEvent) {
1625
- _context12.n = 6;
1755
+ _context15.n = 6;
1626
1756
  break;
1627
1757
  }
1628
- return _context12.a(2, Promise.resolve({
1758
+ return _context15.a(2, Promise.resolve({
1629
1759
  success: false,
1630
1760
  failureReason: 'Cannot determine destination fee. No fee event found',
1631
1761
  asset: asset
@@ -1636,7 +1766,7 @@ var PapiApi = /*#__PURE__*/function () {
1636
1766
  fee = amount - originFee - feeEvent.value.value.amount;
1637
1767
  }
1638
1768
  processedFee = (isRelayChain(chain) || chain.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? padValueBy(fee, 30) : fee;
1639
- return _context12.a(2, Promise.resolve({
1769
+ return _context15.a(2, Promise.resolve({
1640
1770
  success: true,
1641
1771
  fee: processedFee,
1642
1772
  asset: asset,
@@ -1645,9 +1775,9 @@ var PapiApi = /*#__PURE__*/function () {
1645
1775
  destParaId: destParaId
1646
1776
  }));
1647
1777
  }
1648
- }, _callee12, this);
1778
+ }, _callee15, this);
1649
1779
  }));
1650
- function getDryRunXcm(_x22) {
1780
+ function getDryRunXcm(_x25) {
1651
1781
  return _getDryRunXcm.apply(this, arguments);
1652
1782
  }
1653
1783
  return getDryRunXcm;
@@ -1655,18 +1785,18 @@ var PapiApi = /*#__PURE__*/function () {
1655
1785
  }, {
1656
1786
  key: "getBridgeStatus",
1657
1787
  value: function () {
1658
- var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
1788
+ var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
1659
1789
  var outboundOperatingMode;
1660
- return _regenerator().w(function (_context13) {
1661
- while (1) switch (_context13.n) {
1790
+ return _regenerator().w(function (_context16) {
1791
+ while (1) switch (_context16.n) {
1662
1792
  case 0:
1663
- _context13.n = 1;
1793
+ _context16.n = 1;
1664
1794
  return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
1665
1795
  case 1:
1666
- outboundOperatingMode = _context13.v;
1667
- return _context13.a(2, outboundOperatingMode.type);
1796
+ outboundOperatingMode = _context16.v;
1797
+ return _context16.a(2, outboundOperatingMode.type);
1668
1798
  }
1669
- }, _callee13, this);
1799
+ }, _callee16, this);
1670
1800
  }));
1671
1801
  function getBridgeStatus() {
1672
1802
  return _getBridgeStatus.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "12.0.6",
3
+ "version": "12.1.1",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,28 +25,28 @@
25
25
  "dependencies": {
26
26
  "@noble/hashes": "^2.0.1",
27
27
  "@polkadot-api/legacy-provider": "^0.3.6",
28
- "viem": "^2.40.3",
29
- "@paraspell/sdk-core": "12.0.6"
28
+ "viem": "2.40.3",
29
+ "@paraspell/sdk-core": "12.1.1"
30
30
  },
31
31
  "peerDependencies": {
32
- "polkadot-api": ">= 1.22.0 < 2"
32
+ "polkadot-api": ">= 1.23.1 < 2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/plugin-syntax-import-attributes": "^7.27.1",
36
36
  "@babel/preset-env": "^7.28.5",
37
37
  "@codecov/rollup-plugin": "^1.9.1",
38
38
  "@noble/curves": "^2.0.1",
39
- "@polkadot-labs/hdkd": "^0.0.25",
40
- "@polkadot-labs/hdkd-helpers": "^0.0.26",
39
+ "@polkadot-labs/hdkd": "^0.0.26",
40
+ "@polkadot-labs/hdkd-helpers": "^0.0.27",
41
41
  "@rollup/plugin-babel": "^6.1.0",
42
42
  "@rollup/plugin-json": "^6.1.0",
43
43
  "@rollup/plugin-typescript": "^12.3.0",
44
44
  "@scure/bip32": "^2.0.1",
45
45
  "@scure/bip39": "^2.0.1",
46
- "@vitest/coverage-v8": "^4.0.14",
46
+ "@vitest/coverage-v8": "^4.0.16",
47
47
  "axios": "^1.13.2",
48
48
  "dotenv": "^17.2.3",
49
- "rollup": "^4.53.3",
49
+ "rollup": "^4.54.0",
50
50
  "rollup-plugin-dts": "^6.3.0",
51
51
  "tslib": "^2.8.1"
52
52
  },