@paraspell/sdk-core 10.1.0 → 10.1.2

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 CHANGED
@@ -609,7 +609,7 @@ var DryRunFailedError = /*#__PURE__*/function (_Error) {
609
609
  _classCallCheck(this, DryRunFailedError);
610
610
  var message = "Dry run failed: ".concat(reason);
611
611
  if (dryRunType) {
612
- message = "Dry run ".concat(dryRunType, " failed: ").concat(reason);
612
+ message = "Dry run on ".concat(dryRunType, " failed: ").concat(reason);
613
613
  }
614
614
  _this = _callSuper(this, DryRunFailedError, [message]);
615
615
  _this.name = 'DryRunFailedError';
@@ -2778,6 +2778,10 @@ var getNode = function getNode(node) {
2778
2778
  return nodeMap[node];
2779
2779
  };
2780
2780
 
2781
+ var replaceBigInt = function replaceBigInt(_key, value) {
2782
+ return typeof value === 'bigint' ? value.toString() : value;
2783
+ };
2784
+
2781
2785
  var resolveParaId = function resolveParaId(paraId, destination) {
2782
2786
  if (sdkCommon.isTMultiLocation(destination) || sdkCommon.isRelayChain(destination) || destination === 'Ethereum') {
2783
2787
  return undefined;
@@ -4084,11 +4088,11 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
4084
4088
  };
4085
4089
  var getDestXcmFee = /*#__PURE__*/function () {
4086
4090
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
4087
- var api, origin, destination, currency, forwardedXcms, asset, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
4091
+ var api, origin, hopNode, destination, currency, forwardedXcms, asset, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
4088
4092
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4089
4093
  while (1) switch (_context2.prev = _context2.next) {
4090
4094
  case 0:
4091
- api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
4095
+ api = options.api, origin = options.origin, hopNode = options.prevNode, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
4092
4096
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4093
4097
  calcPaymentInfoFee = /*#__PURE__*/function () {
4094
4098
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -4107,7 +4111,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
4107
4111
  _context.next = 5;
4108
4112
  break;
4109
4113
  }
4110
- throw new assets.InvalidCurrencyError("Currency ".concat(JSON.stringify(currency), " not found in ").concat(origin));
4114
+ throw new assets.InvalidCurrencyError("Currency ".concat(JSON.stringify(currency, replaceBigInt), " not found in ").concat(origin));
4111
4115
  case 5:
4112
4116
  if (!originAsset.multiLocation) {
4113
4117
  _context.next = 19;
@@ -4173,7 +4177,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
4173
4177
  case 8:
4174
4178
  _context2.next = 10;
4175
4179
  return api.getDryRunXcm({
4176
- originLocation: addXcmVersionHeader(createOriginLocation(origin, destination), exports.Version.V4),
4180
+ originLocation: addXcmVersionHeader(createOriginLocation(hopNode, destination), exports.Version.V4),
4177
4181
  xcm: forwardedXcms[1][0],
4178
4182
  node: destination,
4179
4183
  origin: origin,
@@ -4553,7 +4557,7 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
4553
4557
 
4554
4558
  var getXcmFee = /*#__PURE__*/function () {
4555
4559
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4556
- var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
4560
+ var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, _destApi, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
4557
4561
  return _regeneratorRuntime().wrap(function _callee$(_context) {
4558
4562
  while (1) switch (_context.prev = _context.next) {
4559
4563
  case 0:
@@ -4602,6 +4606,7 @@ var getXcmFee = /*#__PURE__*/function () {
4602
4606
  forwardedXcms: undefined,
4603
4607
  // force paymentInfo
4604
4608
  origin: origin,
4609
+ prevNode: origin,
4605
4610
  destination: destination,
4606
4611
  currency: currency,
4607
4612
  address: address,
@@ -4650,7 +4655,7 @@ var getXcmFee = /*#__PURE__*/function () {
4650
4655
  destinationFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
4651
4656
  case 38:
4652
4657
  if (!(Array.isArray(forwardedXcms) && forwardedXcms.length > 0 && forwardedXcms[1].length > 0 && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
4653
- _context.next = 70;
4658
+ _context.next = 74;
4654
4659
  break;
4655
4660
  }
4656
4661
  nextChain = getTNode(nextParaId, determineRelayChain(origin) === 'Polkadot' ? 'polkadot' : 'kusama');
@@ -4669,7 +4674,8 @@ var getXcmFee = /*#__PURE__*/function () {
4669
4674
  return getDestXcmFee({
4670
4675
  api: hopApi,
4671
4676
  forwardedXcms: forwardedXcms,
4672
- origin: currentOrigin,
4677
+ origin: origin,
4678
+ prevNode: currentOrigin,
4673
4679
  destination: nextChain,
4674
4680
  currency: currency,
4675
4681
  address: address,
@@ -4682,7 +4688,7 @@ var getXcmFee = /*#__PURE__*/function () {
4682
4688
  case 48:
4683
4689
  hopResult = _context.sent;
4684
4690
  if (!hopResult.dryRunError) {
4685
- _context.next = 60;
4691
+ _context.next = 64;
4686
4692
  break;
4687
4693
  }
4688
4694
  failingRecord = {
@@ -4703,14 +4709,23 @@ var getXcmFee = /*#__PURE__*/function () {
4703
4709
  }
4704
4710
  // We failed before the true destination, use fallback via paymentInfo.
4705
4711
  if (hopIsDestination) {
4706
- _context.next = 59;
4712
+ _context.next = 63;
4707
4713
  break;
4708
4714
  }
4709
- _context.next = 56;
4715
+ _destApi = api.clone();
4716
+ if (!(destination !== 'Ethereum')) {
4717
+ _context.next = 58;
4718
+ break;
4719
+ }
4720
+ _context.next = 58;
4721
+ return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
4722
+ case 58:
4723
+ _context.next = 60;
4710
4724
  return getDestXcmFee({
4711
- api: hopApi,
4725
+ api: _destApi,
4712
4726
  forwardedXcms: undefined,
4713
- origin: nextChain,
4727
+ origin: origin,
4728
+ prevNode: currentOrigin,
4714
4729
  destination: destination,
4715
4730
  currency: currency,
4716
4731
  address: address,
@@ -4719,13 +4734,13 @@ var getXcmFee = /*#__PURE__*/function () {
4719
4734
  senderAddress: senderAddress,
4720
4735
  disableFallback: disableFallback
4721
4736
  });
4722
- case 56:
4737
+ case 60:
4723
4738
  destFallback = _context.sent;
4724
4739
  destinationFee = destFallback.fee;
4725
4740
  destinationFeeType = destFallback.feeType;
4726
- case 59:
4727
- return _context.abrupt("break", 70);
4728
- case 60:
4741
+ case 63:
4742
+ return _context.abrupt("break", 74);
4743
+ case 64:
4729
4744
  if (nextChain === destination || sdkCommon.isRelayChain(nextChain) && !sdkCommon.isRelayChain(destination)) {
4730
4745
  destinationFee = hopResult.fee;
4731
4746
  destinationFeeType = hopResult.feeType;
@@ -4745,35 +4760,35 @@ var getXcmFee = /*#__PURE__*/function () {
4745
4760
  forwardedXcms = hopResult.forwardedXcms;
4746
4761
  nextParaId = hopResult.destParaId;
4747
4762
  currentOrigin = nextChain;
4748
- case 64:
4749
- _context.prev = 64;
4750
- _context.next = 67;
4751
- return hopApi.disconnect();
4752
- case 67:
4753
- return _context.finish(64);
4754
4763
  case 68:
4764
+ _context.prev = 68;
4765
+ _context.next = 71;
4766
+ return hopApi.disconnect();
4767
+ case 71:
4768
+ return _context.finish(68);
4769
+ case 72:
4755
4770
  _context.next = 38;
4756
4771
  break;
4757
- case 70:
4772
+ case 74:
4758
4773
  processedBridgeHubData = intermediateFees.bridgeHub;
4759
4774
  if (!(intermediateFees.bridgeHub && !intermediateFees.bridgeHub.dryRunError && destination === 'Ethereum')) {
4760
- _context.next = 81;
4775
+ _context.next = 85;
4761
4776
  break;
4762
4777
  }
4763
4778
  ahApi = api.clone();
4764
- _context.next = 75;
4779
+ _context.next = 79;
4765
4780
  return ahApi.init(assetHubNode, DRY_RUN_CLIENT_TIMEOUT_MS);
4766
- case 75:
4767
- _context.next = 77;
4781
+ case 79:
4782
+ _context.next = 81;
4768
4783
  return getParaEthTransferFees(ahApi);
4769
- case 77:
4784
+ case 81:
4770
4785
  _yield$getParaEthTran = _context.sent;
4771
4786
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
4772
4787
  bridgeFee = _yield$getParaEthTran2[0];
4773
4788
  processedBridgeHubData = _objectSpread2(_objectSpread2({}, intermediateFees.bridgeHub), {}, {
4774
4789
  fee: intermediateFees.bridgeHub.fee + bridgeFee
4775
4790
  });
4776
- case 81:
4791
+ case 85:
4777
4792
  intermediateFees.bridgeHub = processedBridgeHubData;
4778
4793
  return _context.abrupt("return", _objectSpread2(_objectSpread2({
4779
4794
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
@@ -4796,11 +4811,11 @@ var getXcmFee = /*#__PURE__*/function () {
4796
4811
  dryRunError: destinationDryRunError
4797
4812
  })
4798
4813
  }));
4799
- case 83:
4814
+ case 87:
4800
4815
  case "end":
4801
4816
  return _context.stop();
4802
4817
  }
4803
- }, _callee, null, [[16,, 25, 30], [43,, 64, 68]]);
4818
+ }, _callee, null, [[16,, 25, 30], [43,, 68, 72]]);
4804
4819
  }));
4805
4820
  return function getXcmFee(_x) {
4806
4821
  return _ref2.apply(this, arguments);
@@ -4874,6 +4889,7 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
4874
4889
  case 18:
4875
4890
  _context.next = 20;
4876
4891
  return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4892
+ api: destApi,
4877
4893
  destination: destination
4878
4894
  }), currencyInput);
4879
4895
  case 20:
@@ -6072,7 +6088,7 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
6072
6088
  },
6073
6089
  weight_limit: {
6074
6090
  Limited: {
6075
- ref_time: 100n,
6091
+ ref_time: 150n,
6076
6092
  proof_size: 0n
6077
6093
  }
6078
6094
  }
@@ -6093,7 +6109,7 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
6093
6109
  fees: {
6094
6110
  id: asset.multiLocation,
6095
6111
  fun: {
6096
- Fungible: amountWithoutFee
6112
+ Fungible: amountWithoutFee - executionFee
6097
6113
  }
6098
6114
  },
6099
6115
  weight_limit: 'Unlimited'
@@ -6443,11 +6459,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6443
6459
  key: "handleExecuteTransfer",
6444
6460
  value: function () {
6445
6461
  var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(input) {
6446
- var api, senderAddress, asset, decimals, multiplier, base, scaledMultiplier, MIN_FEE, maxU64, dummyTx, dryRunResult, feeDotShifted, toMl, feeConverted, feeConvertedPadded;
6462
+ var api, senderAddress, asset, feeAsset, decimals, multiplier, base, scaledMultiplier, MIN_FEE, maxU64, dummyTx, dryRunResult, paddedFee;
6447
6463
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
6448
6464
  while (1) switch (_context3.prev = _context3.next) {
6449
6465
  case 0:
6450
- api = input.api, senderAddress = input.senderAddress, asset = input.asset;
6466
+ api = input.api, senderAddress = input.senderAddress, asset = input.asset, feeAsset = input.feeAsset;
6451
6467
  if (senderAddress) {
6452
6468
  _context3.next = 3;
6453
6469
  break;
@@ -6470,7 +6486,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6470
6486
  node: this.node,
6471
6487
  tx: dummyTx,
6472
6488
  address: senderAddress,
6473
- isFeeAsset: false
6489
+ isFeeAsset: !!feeAsset
6474
6490
  });
6475
6491
  case 13:
6476
6492
  dryRunResult = _context3.sent;
@@ -6478,35 +6494,17 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6478
6494
  _context3.next = 16;
6479
6495
  break;
6480
6496
  }
6481
- throw new DryRunFailedError("Dry run failed: ".concat(dryRunResult.failureReason));
6497
+ throw new DryRunFailedError(dryRunResult.failureReason);
6482
6498
  case 16:
6483
6499
  if (dryRunResult.weight) {
6484
6500
  _context3.next = 18;
6485
6501
  break;
6486
6502
  }
6487
- throw new DryRunFailedError('Dry run failed: weight not found');
6503
+ throw new DryRunFailedError('weight not found');
6488
6504
  case 18:
6489
- feeDotShifted = dryRunResult.fee / 10n;
6490
- toMl = transformMultiLocation(asset.multiLocation);
6491
- _context3.next = 22;
6492
- return api.quoteAhPrice(DOT_MULTILOCATION, toMl, feeDotShifted);
6493
- case 22:
6494
- feeConverted = _context3.sent;
6495
- if (feeConverted) {
6496
- _context3.next = 25;
6497
- break;
6498
- }
6499
- throw new InvalidParameterError("Pool DOT -> ".concat(asset.symbol, " not found."));
6500
- case 25:
6501
- if (!(BigInt(asset.amount) - feeConverted < 0)) {
6502
- _context3.next = 27;
6503
- break;
6504
- }
6505
- throw new InvalidParameterError("Insufficient balance. Fee: ".concat(feeConverted, ", Amount: ").concat(asset.amount));
6506
- case 27:
6507
- feeConvertedPadded = feeConverted * 3n / 2n; // increases fee by 50%
6508
- return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, feeConvertedPadded));
6509
- case 29:
6505
+ paddedFee = dryRunResult.fee * 120n / 100n;
6506
+ return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, paddedFee));
6507
+ case 20:
6510
6508
  case "end":
6511
6509
  return _context3.stop();
6512
6510
  }
@@ -8993,7 +8991,7 @@ function _getEthErc20Balance() {
8993
8991
 
8994
8992
  var buildDestInfo = /*#__PURE__*/function () {
8995
8993
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
8996
- var api, origin, destination, address, currency, originFee, destAsset, isFeeAssetAh, destFeeDetail, assetHubFee, bridgeFee, destApi, destCurrency, edDest, edDestBn, destBalance, destAmount, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isAssetHubToAssetHubRoute, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
8994
+ var api, origin, destination, address, currency, originFee, destAsset, isFeeAssetAh, destFeeDetail, assetHubFee, bridgeFee, destApi, destCurrency, edDest, edDestBn, destBalance, destAmount, effectiveAmountForBalance, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isAssetHubToAssetHubRoute, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
8997
8995
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8998
8996
  while (1) switch (_context.prev = _context.next) {
8999
8997
  case 0:
@@ -9042,9 +9040,13 @@ var buildDestInfo = /*#__PURE__*/function () {
9042
9040
  case 19:
9043
9041
  destBalance = _context.t0;
9044
9042
  destAmount = isFeeAssetAh ? BigInt(currency.amount) - originFee : BigInt(currency.amount);
9045
- destBalanceSufficient = destAmount - destFeeDetail.fee > (destBalance < edDestBn ? edDestBn : 0);
9043
+ effectiveAmountForBalance = destAmount;
9044
+ if (destination === 'Ethereum' && assetHubFee !== undefined) {
9045
+ effectiveAmountForBalance -= assetHubFee;
9046
+ }
9047
+ destBalanceSufficient = effectiveAmountForBalance - destFeeDetail.fee > (destBalance < edDestBn ? edDestBn : 0);
9046
9048
  destBalanceSufficientResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceSufficient;
9047
- destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) + destAmount;
9049
+ destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) + effectiveAmountForBalance;
9048
9050
  destbalanceAfterResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceAfter;
9049
9051
  isAssetHubToAssetHubRoute = origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot' || origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama';
9050
9052
  if (isAssetHubToAssetHubRoute) {
@@ -9069,44 +9071,41 @@ var buildDestInfo = /*#__PURE__*/function () {
9069
9071
  receivedAmount = destbalanceAfterResult - destBalance;
9070
9072
  }
9071
9073
  }
9072
- if (destination === 'Ethereum' && assetHubFee && !(receivedAmount instanceof UnableToComputeError)) {
9073
- receivedAmount -= assetHubFee;
9074
- }
9075
9074
  isDestFeeInNativeCurrency = destFeeDetail.currency === assets.getNativeAssetSymbol(destination);
9076
9075
  if (!isDestFeeInNativeCurrency) {
9077
- _context.next = 43;
9076
+ _context.next = 44;
9078
9077
  break;
9079
9078
  }
9080
9079
  if (!(destination === 'Ethereum')) {
9081
- _context.next = 36;
9080
+ _context.next = 37;
9082
9081
  break;
9083
9082
  }
9084
- _context.next = 33;
9083
+ _context.next = 34;
9085
9084
  return getEthErc20Balance({
9086
9085
  symbol: assets.getNativeAssetSymbol(destination)
9087
9086
  }, address);
9088
- case 33:
9087
+ case 34:
9089
9088
  _context.t1 = _context.sent;
9090
- _context.next = 39;
9089
+ _context.next = 40;
9091
9090
  break;
9092
- case 36:
9093
- _context.next = 38;
9091
+ case 37:
9092
+ _context.next = 39;
9094
9093
  return getBalanceNativeInternal({
9095
9094
  address: address,
9096
9095
  node: destination,
9097
9096
  api: destApi
9098
9097
  });
9099
- case 38:
9100
- _context.t1 = _context.sent;
9101
9098
  case 39:
9099
+ _context.t1 = _context.sent;
9100
+ case 40:
9102
9101
  destRecipientNativeBalance = _context.t1;
9103
9102
  destXcmFeeBalance = destRecipientNativeBalance;
9104
- _context.next = 44;
9103
+ _context.next = 45;
9105
9104
  break;
9106
- case 43:
9107
- destXcmFeeBalance = destBalance;
9108
9105
  case 44:
9109
- destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeDetail.currency === destAsset.symbol ? BigInt(currency.amount) : 0n);
9106
+ destXcmFeeBalance = destBalance;
9107
+ case 45:
9108
+ destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeDetail.currency === destAsset.symbol ? effectiveAmountForBalance : 0n);
9110
9109
  return _context.abrupt("return", {
9111
9110
  receivedCurrency: {
9112
9111
  sufficient: destBalanceSufficientResult,
@@ -9123,7 +9122,7 @@ var buildDestInfo = /*#__PURE__*/function () {
9123
9122
  currencySymbol: destFeeDetail.currency
9124
9123
  }
9125
9124
  });
9126
- case 46:
9125
+ case 47:
9127
9126
  case "end":
9128
9127
  return _context.stop();
9129
9128
  }
@@ -9420,7 +9419,7 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
9420
9419
  };
9421
9420
  var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9422
9421
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
9423
- var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, xcmFeeResult, dryRunError, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, totalFee, method, feeToSubtract;
9422
+ var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, totalFee, method, feeToSubtract;
9424
9423
  return _regeneratorRuntime().wrap(function _callee$(_context) {
9425
9424
  while (1) switch (_context.prev = _context.next) {
9426
9425
  case 0:
@@ -9485,7 +9484,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9485
9484
  });
9486
9485
  case 22:
9487
9486
  xcmFeeResult = _context.sent;
9488
- dryRunError = xcmFeeResult.origin.dryRunError, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
9487
+ dryRunError = xcmFeeResult.origin.dryRunError, assetHubFeeResult = xcmFeeResult.assetHub, bridgeHubFeeResult = xcmFeeResult.bridgeHub, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
9489
9488
  if (!(destFee === undefined)) {
9490
9489
  _context.next = 26;
9491
9490
  break;
@@ -9498,18 +9497,25 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9498
9497
  }
9499
9498
  throw new DryRunFailedError(dryRunError, 'origin');
9500
9499
  case 28:
9500
+ hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
9501
+ if (!hopDryRunError) {
9502
+ _context.next = 31;
9503
+ break;
9504
+ }
9505
+ throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
9506
+ case 31:
9501
9507
  if (!destDryRunError) {
9502
- _context.next = 30;
9508
+ _context.next = 33;
9503
9509
  break;
9504
9510
  }
9505
9511
  throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
9506
- case 30:
9512
+ case 33:
9507
9513
  if (!(assets.normalizeSymbol(asset.symbol) !== assets.normalizeSymbol(destFeeCurrency))) {
9508
- _context.next = 32;
9514
+ _context.next = 35;
9509
9515
  break;
9510
9516
  }
9511
9517
  throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
9512
- case 32:
9518
+ case 35:
9513
9519
  totalFee = calculateTotalXcmFee(xcmFeeResult);
9514
9520
  method = api.getMethod(tx);
9515
9521
  if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
@@ -9518,7 +9524,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9518
9524
  feeToSubtract = destFee;
9519
9525
  }
9520
9526
  return _context.abrupt("return", BigInt(currency.amount) - feeToSubtract > (balance < edBN ? edBN : 0));
9521
- case 36:
9527
+ case 39:
9522
9528
  case "end":
9523
9529
  return _context.stop();
9524
9530
  }
@@ -10358,6 +10364,7 @@ exports.getXcmFee = getXcmFee;
10358
10364
  exports.getXcmFeeEstimate = getXcmFeeEstimate;
10359
10365
  exports.isEthersContract = isEthersContract;
10360
10366
  exports.isEthersSigner = isEthersSigner;
10367
+ exports.replaceBigInt = replaceBigInt;
10361
10368
  exports.resolveModuleError = resolveModuleError;
10362
10369
  exports.resolveParaId = resolveParaId;
10363
10370
  exports.reverseTransformMultiLocation = reverseTransformMultiLocation;
package/dist/index.d.ts CHANGED
@@ -673,7 +673,7 @@ declare class DryRunFailedError extends Error {
673
673
  * @param reason - The reason why the dry run failed.
674
674
  * @param dryRunType - Optional. Specifies if the error is related to the 'origin' or 'destination' dry run.
675
675
  */
676
- constructor(reason: string, dryRunType?: 'origin' | 'destination');
676
+ constructor(reason: string, dryRunType?: 'origin' | 'destination' | 'assetHub' | 'bridgeHub');
677
677
  }
678
678
 
679
679
  /**
@@ -869,6 +869,7 @@ type TGetOriginXcmFeeBaseOptions<TRes> = {
869
869
  };
870
870
  type TGetOriginXcmFeeOptions<TApi, TRes> = WithApi<TGetOriginXcmFeeBaseOptions<TRes>, TApi, TRes>;
871
871
  type TGetFeeForDestNodeBaseOptions = {
872
+ prevNode: TNodeDotKsmWithRelayChains;
872
873
  origin: TNodeDotKsmWithRelayChains;
873
874
  destination: TNodeWithRelayChains;
874
875
  senderAddress: string;
@@ -881,7 +882,7 @@ type TGetFeeForDestNodeBaseOptions = {
881
882
  disableFallback: boolean;
882
883
  };
883
884
  type TGetFeeForDestNodeOptions<TApi, TRes> = WithApi<TGetFeeForDestNodeBaseOptions, TApi, TRes>;
884
- type TGetReverseTxFeeOptions<TApi, TRes> = Omit<TGetFeeForDestNodeOptions<TApi, TRes>, 'destination' | 'disableFallback' | 'forwardedXcms' | 'asset' | 'originFee'> & {
885
+ type TGetReverseTxFeeOptions<TApi, TRes> = Omit<TGetFeeForDestNodeOptions<TApi, TRes>, 'destination' | 'disableFallback' | 'forwardedXcms' | 'asset' | 'originFee' | 'prevNode'> & {
885
886
  destination: TNodeDotKsmWithRelayChains;
886
887
  };
887
888
  type THubKey = 'assetHub' | 'bridgeHub';
@@ -1869,6 +1870,8 @@ declare const reverseTransformMultiLocation: (multiLocation: TMultiLocation) =>
1869
1870
  */
1870
1871
  declare const transformMultiLocation: (multiLocation: TMultiLocation) => TMultiLocation;
1871
1872
 
1873
+ declare const replaceBigInt: (_key: string, value: unknown) => unknown;
1874
+
1872
1875
  declare const resolveParaId: (paraId: number | undefined, destination: TDestination) => number | undefined;
1873
1876
 
1874
1877
  declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, isDestination?: boolean) => void;
@@ -1881,5 +1884,5 @@ declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, i
1881
1884
  */
1882
1885
  declare const determineRelayChain: (node: TNodeWithRelayChains) => TRelaychain;
1883
1886
 
1884
- export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
1887
+ export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, replaceBigInt, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
1885
1888
  export type { IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimOptions, TAssetClaimOptionsBase, TBalanceResponse, TBatchOptions, TBifrostToken, TBridgeStatus, TCreateBeneficiaryOptions, TDestWeight, TDestination, TDryRunBaseOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunNodeFailure, TDryRunNodeResult, TDryRunNodeResultInternal, TDryRunNodeSuccess, TDryRunOptions, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEdJsonMap, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmNodeFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestNodeBaseOptions, TGetFeeForDestNodeOptions, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeOptions, TGetXcmFeeResult, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodeConfig, TNodeConfigMap, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmSection, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TRelaychain, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TTransferInfo, TTransferLocalOptions, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TVersionClaimAssets, TWeight, TXTokensCurrencySelection, TXTokensSection, TXTokensTransferOptions, TXTransferSection, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeDetail, TXcmForeignAsset, TXcmPalletSection, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
package/dist/index.mjs CHANGED
@@ -610,7 +610,7 @@ var DryRunFailedError = /*#__PURE__*/function (_Error) {
610
610
  _classCallCheck(this, DryRunFailedError);
611
611
  var message = "Dry run failed: ".concat(reason);
612
612
  if (dryRunType) {
613
- message = "Dry run ".concat(dryRunType, " failed: ").concat(reason);
613
+ message = "Dry run on ".concat(dryRunType, " failed: ").concat(reason);
614
614
  }
615
615
  _this = _callSuper(this, DryRunFailedError, [message]);
616
616
  _this.name = 'DryRunFailedError';
@@ -2779,6 +2779,10 @@ var getNode = function getNode(node) {
2779
2779
  return nodeMap[node];
2780
2780
  };
2781
2781
 
2782
+ var replaceBigInt = function replaceBigInt(_key, value) {
2783
+ return typeof value === 'bigint' ? value.toString() : value;
2784
+ };
2785
+
2782
2786
  var resolveParaId = function resolveParaId(paraId, destination) {
2783
2787
  if (isTMultiLocation(destination) || isRelayChain(destination) || destination === 'Ethereum') {
2784
2788
  return undefined;
@@ -4085,11 +4089,11 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
4085
4089
  };
4086
4090
  var getDestXcmFee = /*#__PURE__*/function () {
4087
4091
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
4088
- var api, origin, destination, currency, forwardedXcms, asset, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
4092
+ var api, origin, hopNode, destination, currency, forwardedXcms, asset, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
4089
4093
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4090
4094
  while (1) switch (_context2.prev = _context2.next) {
4091
4095
  case 0:
4092
- api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
4096
+ api = options.api, origin = options.origin, hopNode = options.prevNode, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
4093
4097
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4094
4098
  calcPaymentInfoFee = /*#__PURE__*/function () {
4095
4099
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -4108,7 +4112,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
4108
4112
  _context.next = 5;
4109
4113
  break;
4110
4114
  }
4111
- throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(currency), " not found in ").concat(origin));
4115
+ throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(currency, replaceBigInt), " not found in ").concat(origin));
4112
4116
  case 5:
4113
4117
  if (!originAsset.multiLocation) {
4114
4118
  _context.next = 19;
@@ -4174,7 +4178,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
4174
4178
  case 8:
4175
4179
  _context2.next = 10;
4176
4180
  return api.getDryRunXcm({
4177
- originLocation: addXcmVersionHeader(createOriginLocation(origin, destination), Version.V4),
4181
+ originLocation: addXcmVersionHeader(createOriginLocation(hopNode, destination), Version.V4),
4178
4182
  xcm: forwardedXcms[1][0],
4179
4183
  node: destination,
4180
4184
  origin: origin,
@@ -4554,7 +4558,7 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
4554
4558
 
4555
4559
  var getXcmFee = /*#__PURE__*/function () {
4556
4560
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4557
- var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
4561
+ var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, _destApi, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
4558
4562
  return _regeneratorRuntime().wrap(function _callee$(_context) {
4559
4563
  while (1) switch (_context.prev = _context.next) {
4560
4564
  case 0:
@@ -4603,6 +4607,7 @@ var getXcmFee = /*#__PURE__*/function () {
4603
4607
  forwardedXcms: undefined,
4604
4608
  // force paymentInfo
4605
4609
  origin: origin,
4610
+ prevNode: origin,
4606
4611
  destination: destination,
4607
4612
  currency: currency,
4608
4613
  address: address,
@@ -4651,7 +4656,7 @@ var getXcmFee = /*#__PURE__*/function () {
4651
4656
  destinationFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
4652
4657
  case 38:
4653
4658
  if (!(Array.isArray(forwardedXcms) && forwardedXcms.length > 0 && forwardedXcms[1].length > 0 && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
4654
- _context.next = 70;
4659
+ _context.next = 74;
4655
4660
  break;
4656
4661
  }
4657
4662
  nextChain = getTNode(nextParaId, determineRelayChain(origin) === 'Polkadot' ? 'polkadot' : 'kusama');
@@ -4670,7 +4675,8 @@ var getXcmFee = /*#__PURE__*/function () {
4670
4675
  return getDestXcmFee({
4671
4676
  api: hopApi,
4672
4677
  forwardedXcms: forwardedXcms,
4673
- origin: currentOrigin,
4678
+ origin: origin,
4679
+ prevNode: currentOrigin,
4674
4680
  destination: nextChain,
4675
4681
  currency: currency,
4676
4682
  address: address,
@@ -4683,7 +4689,7 @@ var getXcmFee = /*#__PURE__*/function () {
4683
4689
  case 48:
4684
4690
  hopResult = _context.sent;
4685
4691
  if (!hopResult.dryRunError) {
4686
- _context.next = 60;
4692
+ _context.next = 64;
4687
4693
  break;
4688
4694
  }
4689
4695
  failingRecord = {
@@ -4704,14 +4710,23 @@ var getXcmFee = /*#__PURE__*/function () {
4704
4710
  }
4705
4711
  // We failed before the true destination, use fallback via paymentInfo.
4706
4712
  if (hopIsDestination) {
4707
- _context.next = 59;
4713
+ _context.next = 63;
4708
4714
  break;
4709
4715
  }
4710
- _context.next = 56;
4716
+ _destApi = api.clone();
4717
+ if (!(destination !== 'Ethereum')) {
4718
+ _context.next = 58;
4719
+ break;
4720
+ }
4721
+ _context.next = 58;
4722
+ return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
4723
+ case 58:
4724
+ _context.next = 60;
4711
4725
  return getDestXcmFee({
4712
- api: hopApi,
4726
+ api: _destApi,
4713
4727
  forwardedXcms: undefined,
4714
- origin: nextChain,
4728
+ origin: origin,
4729
+ prevNode: currentOrigin,
4715
4730
  destination: destination,
4716
4731
  currency: currency,
4717
4732
  address: address,
@@ -4720,13 +4735,13 @@ var getXcmFee = /*#__PURE__*/function () {
4720
4735
  senderAddress: senderAddress,
4721
4736
  disableFallback: disableFallback
4722
4737
  });
4723
- case 56:
4738
+ case 60:
4724
4739
  destFallback = _context.sent;
4725
4740
  destinationFee = destFallback.fee;
4726
4741
  destinationFeeType = destFallback.feeType;
4727
- case 59:
4728
- return _context.abrupt("break", 70);
4729
- case 60:
4742
+ case 63:
4743
+ return _context.abrupt("break", 74);
4744
+ case 64:
4730
4745
  if (nextChain === destination || isRelayChain(nextChain) && !isRelayChain(destination)) {
4731
4746
  destinationFee = hopResult.fee;
4732
4747
  destinationFeeType = hopResult.feeType;
@@ -4746,35 +4761,35 @@ var getXcmFee = /*#__PURE__*/function () {
4746
4761
  forwardedXcms = hopResult.forwardedXcms;
4747
4762
  nextParaId = hopResult.destParaId;
4748
4763
  currentOrigin = nextChain;
4749
- case 64:
4750
- _context.prev = 64;
4751
- _context.next = 67;
4752
- return hopApi.disconnect();
4753
- case 67:
4754
- return _context.finish(64);
4755
4764
  case 68:
4765
+ _context.prev = 68;
4766
+ _context.next = 71;
4767
+ return hopApi.disconnect();
4768
+ case 71:
4769
+ return _context.finish(68);
4770
+ case 72:
4756
4771
  _context.next = 38;
4757
4772
  break;
4758
- case 70:
4773
+ case 74:
4759
4774
  processedBridgeHubData = intermediateFees.bridgeHub;
4760
4775
  if (!(intermediateFees.bridgeHub && !intermediateFees.bridgeHub.dryRunError && destination === 'Ethereum')) {
4761
- _context.next = 81;
4776
+ _context.next = 85;
4762
4777
  break;
4763
4778
  }
4764
4779
  ahApi = api.clone();
4765
- _context.next = 75;
4780
+ _context.next = 79;
4766
4781
  return ahApi.init(assetHubNode, DRY_RUN_CLIENT_TIMEOUT_MS);
4767
- case 75:
4768
- _context.next = 77;
4782
+ case 79:
4783
+ _context.next = 81;
4769
4784
  return getParaEthTransferFees(ahApi);
4770
- case 77:
4785
+ case 81:
4771
4786
  _yield$getParaEthTran = _context.sent;
4772
4787
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
4773
4788
  bridgeFee = _yield$getParaEthTran2[0];
4774
4789
  processedBridgeHubData = _objectSpread2(_objectSpread2({}, intermediateFees.bridgeHub), {}, {
4775
4790
  fee: intermediateFees.bridgeHub.fee + bridgeFee
4776
4791
  });
4777
- case 81:
4792
+ case 85:
4778
4793
  intermediateFees.bridgeHub = processedBridgeHubData;
4779
4794
  return _context.abrupt("return", _objectSpread2(_objectSpread2({
4780
4795
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
@@ -4797,11 +4812,11 @@ var getXcmFee = /*#__PURE__*/function () {
4797
4812
  dryRunError: destinationDryRunError
4798
4813
  })
4799
4814
  }));
4800
- case 83:
4815
+ case 87:
4801
4816
  case "end":
4802
4817
  return _context.stop();
4803
4818
  }
4804
- }, _callee, null, [[16,, 25, 30], [43,, 64, 68]]);
4819
+ }, _callee, null, [[16,, 25, 30], [43,, 68, 72]]);
4805
4820
  }));
4806
4821
  return function getXcmFee(_x) {
4807
4822
  return _ref2.apply(this, arguments);
@@ -4875,6 +4890,7 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
4875
4890
  case 18:
4876
4891
  _context.next = 20;
4877
4892
  return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4893
+ api: destApi,
4878
4894
  destination: destination
4879
4895
  }), currencyInput);
4880
4896
  case 20:
@@ -6073,7 +6089,7 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
6073
6089
  },
6074
6090
  weight_limit: {
6075
6091
  Limited: {
6076
- ref_time: 100n,
6092
+ ref_time: 150n,
6077
6093
  proof_size: 0n
6078
6094
  }
6079
6095
  }
@@ -6094,7 +6110,7 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
6094
6110
  fees: {
6095
6111
  id: asset.multiLocation,
6096
6112
  fun: {
6097
- Fungible: amountWithoutFee
6113
+ Fungible: amountWithoutFee - executionFee
6098
6114
  }
6099
6115
  },
6100
6116
  weight_limit: 'Unlimited'
@@ -6444,11 +6460,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6444
6460
  key: "handleExecuteTransfer",
6445
6461
  value: function () {
6446
6462
  var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(input) {
6447
- var api, senderAddress, asset, decimals, multiplier, base, scaledMultiplier, MIN_FEE, maxU64, dummyTx, dryRunResult, feeDotShifted, toMl, feeConverted, feeConvertedPadded;
6463
+ var api, senderAddress, asset, feeAsset, decimals, multiplier, base, scaledMultiplier, MIN_FEE, maxU64, dummyTx, dryRunResult, paddedFee;
6448
6464
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
6449
6465
  while (1) switch (_context3.prev = _context3.next) {
6450
6466
  case 0:
6451
- api = input.api, senderAddress = input.senderAddress, asset = input.asset;
6467
+ api = input.api, senderAddress = input.senderAddress, asset = input.asset, feeAsset = input.feeAsset;
6452
6468
  if (senderAddress) {
6453
6469
  _context3.next = 3;
6454
6470
  break;
@@ -6471,7 +6487,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6471
6487
  node: this.node,
6472
6488
  tx: dummyTx,
6473
6489
  address: senderAddress,
6474
- isFeeAsset: false
6490
+ isFeeAsset: !!feeAsset
6475
6491
  });
6476
6492
  case 13:
6477
6493
  dryRunResult = _context3.sent;
@@ -6479,35 +6495,17 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6479
6495
  _context3.next = 16;
6480
6496
  break;
6481
6497
  }
6482
- throw new DryRunFailedError("Dry run failed: ".concat(dryRunResult.failureReason));
6498
+ throw new DryRunFailedError(dryRunResult.failureReason);
6483
6499
  case 16:
6484
6500
  if (dryRunResult.weight) {
6485
6501
  _context3.next = 18;
6486
6502
  break;
6487
6503
  }
6488
- throw new DryRunFailedError('Dry run failed: weight not found');
6504
+ throw new DryRunFailedError('weight not found');
6489
6505
  case 18:
6490
- feeDotShifted = dryRunResult.fee / 10n;
6491
- toMl = transformMultiLocation(asset.multiLocation);
6492
- _context3.next = 22;
6493
- return api.quoteAhPrice(DOT_MULTILOCATION, toMl, feeDotShifted);
6494
- case 22:
6495
- feeConverted = _context3.sent;
6496
- if (feeConverted) {
6497
- _context3.next = 25;
6498
- break;
6499
- }
6500
- throw new InvalidParameterError("Pool DOT -> ".concat(asset.symbol, " not found."));
6501
- case 25:
6502
- if (!(BigInt(asset.amount) - feeConverted < 0)) {
6503
- _context3.next = 27;
6504
- break;
6505
- }
6506
- throw new InvalidParameterError("Insufficient balance. Fee: ".concat(feeConverted, ", Amount: ").concat(asset.amount));
6507
- case 27:
6508
- feeConvertedPadded = feeConverted * 3n / 2n; // increases fee by 50%
6509
- return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, feeConvertedPadded));
6510
- case 29:
6506
+ paddedFee = dryRunResult.fee * 120n / 100n;
6507
+ return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, paddedFee));
6508
+ case 20:
6511
6509
  case "end":
6512
6510
  return _context3.stop();
6513
6511
  }
@@ -8994,7 +8992,7 @@ function _getEthErc20Balance() {
8994
8992
 
8995
8993
  var buildDestInfo = /*#__PURE__*/function () {
8996
8994
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
8997
- var api, origin, destination, address, currency, originFee, destAsset, isFeeAssetAh, destFeeDetail, assetHubFee, bridgeFee, destApi, destCurrency, edDest, edDestBn, destBalance, destAmount, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isAssetHubToAssetHubRoute, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
8995
+ var api, origin, destination, address, currency, originFee, destAsset, isFeeAssetAh, destFeeDetail, assetHubFee, bridgeFee, destApi, destCurrency, edDest, edDestBn, destBalance, destAmount, effectiveAmountForBalance, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isAssetHubToAssetHubRoute, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
8998
8996
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8999
8997
  while (1) switch (_context.prev = _context.next) {
9000
8998
  case 0:
@@ -9043,9 +9041,13 @@ var buildDestInfo = /*#__PURE__*/function () {
9043
9041
  case 19:
9044
9042
  destBalance = _context.t0;
9045
9043
  destAmount = isFeeAssetAh ? BigInt(currency.amount) - originFee : BigInt(currency.amount);
9046
- destBalanceSufficient = destAmount - destFeeDetail.fee > (destBalance < edDestBn ? edDestBn : 0);
9044
+ effectiveAmountForBalance = destAmount;
9045
+ if (destination === 'Ethereum' && assetHubFee !== undefined) {
9046
+ effectiveAmountForBalance -= assetHubFee;
9047
+ }
9048
+ destBalanceSufficient = effectiveAmountForBalance - destFeeDetail.fee > (destBalance < edDestBn ? edDestBn : 0);
9047
9049
  destBalanceSufficientResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceSufficient;
9048
- destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) + destAmount;
9050
+ destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) + effectiveAmountForBalance;
9049
9051
  destbalanceAfterResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceAfter;
9050
9052
  isAssetHubToAssetHubRoute = origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot' || origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama';
9051
9053
  if (isAssetHubToAssetHubRoute) {
@@ -9070,44 +9072,41 @@ var buildDestInfo = /*#__PURE__*/function () {
9070
9072
  receivedAmount = destbalanceAfterResult - destBalance;
9071
9073
  }
9072
9074
  }
9073
- if (destination === 'Ethereum' && assetHubFee && !(receivedAmount instanceof UnableToComputeError)) {
9074
- receivedAmount -= assetHubFee;
9075
- }
9076
9075
  isDestFeeInNativeCurrency = destFeeDetail.currency === getNativeAssetSymbol(destination);
9077
9076
  if (!isDestFeeInNativeCurrency) {
9078
- _context.next = 43;
9077
+ _context.next = 44;
9079
9078
  break;
9080
9079
  }
9081
9080
  if (!(destination === 'Ethereum')) {
9082
- _context.next = 36;
9081
+ _context.next = 37;
9083
9082
  break;
9084
9083
  }
9085
- _context.next = 33;
9084
+ _context.next = 34;
9086
9085
  return getEthErc20Balance({
9087
9086
  symbol: getNativeAssetSymbol(destination)
9088
9087
  }, address);
9089
- case 33:
9088
+ case 34:
9090
9089
  _context.t1 = _context.sent;
9091
- _context.next = 39;
9090
+ _context.next = 40;
9092
9091
  break;
9093
- case 36:
9094
- _context.next = 38;
9092
+ case 37:
9093
+ _context.next = 39;
9095
9094
  return getBalanceNativeInternal({
9096
9095
  address: address,
9097
9096
  node: destination,
9098
9097
  api: destApi
9099
9098
  });
9100
- case 38:
9101
- _context.t1 = _context.sent;
9102
9099
  case 39:
9100
+ _context.t1 = _context.sent;
9101
+ case 40:
9103
9102
  destRecipientNativeBalance = _context.t1;
9104
9103
  destXcmFeeBalance = destRecipientNativeBalance;
9105
- _context.next = 44;
9104
+ _context.next = 45;
9106
9105
  break;
9107
- case 43:
9108
- destXcmFeeBalance = destBalance;
9109
9106
  case 44:
9110
- destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeDetail.currency === destAsset.symbol ? BigInt(currency.amount) : 0n);
9107
+ destXcmFeeBalance = destBalance;
9108
+ case 45:
9109
+ destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeDetail.currency === destAsset.symbol ? effectiveAmountForBalance : 0n);
9111
9110
  return _context.abrupt("return", {
9112
9111
  receivedCurrency: {
9113
9112
  sufficient: destBalanceSufficientResult,
@@ -9124,7 +9123,7 @@ var buildDestInfo = /*#__PURE__*/function () {
9124
9123
  currencySymbol: destFeeDetail.currency
9125
9124
  }
9126
9125
  });
9127
- case 46:
9126
+ case 47:
9128
9127
  case "end":
9129
9128
  return _context.stop();
9130
9129
  }
@@ -9421,7 +9420,7 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
9421
9420
  };
9422
9421
  var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9423
9422
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
9424
- var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, xcmFeeResult, dryRunError, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, totalFee, method, feeToSubtract;
9423
+ var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, totalFee, method, feeToSubtract;
9425
9424
  return _regeneratorRuntime().wrap(function _callee$(_context) {
9426
9425
  while (1) switch (_context.prev = _context.next) {
9427
9426
  case 0:
@@ -9486,7 +9485,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9486
9485
  });
9487
9486
  case 22:
9488
9487
  xcmFeeResult = _context.sent;
9489
- dryRunError = xcmFeeResult.origin.dryRunError, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
9488
+ dryRunError = xcmFeeResult.origin.dryRunError, assetHubFeeResult = xcmFeeResult.assetHub, bridgeHubFeeResult = xcmFeeResult.bridgeHub, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
9490
9489
  if (!(destFee === undefined)) {
9491
9490
  _context.next = 26;
9492
9491
  break;
@@ -9499,18 +9498,25 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9499
9498
  }
9500
9499
  throw new DryRunFailedError(dryRunError, 'origin');
9501
9500
  case 28:
9501
+ hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
9502
+ if (!hopDryRunError) {
9503
+ _context.next = 31;
9504
+ break;
9505
+ }
9506
+ throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
9507
+ case 31:
9502
9508
  if (!destDryRunError) {
9503
- _context.next = 30;
9509
+ _context.next = 33;
9504
9510
  break;
9505
9511
  }
9506
9512
  throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
9507
- case 30:
9513
+ case 33:
9508
9514
  if (!(normalizeSymbol(asset.symbol) !== normalizeSymbol(destFeeCurrency))) {
9509
- _context.next = 32;
9515
+ _context.next = 35;
9510
9516
  break;
9511
9517
  }
9512
9518
  throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
9513
- case 32:
9519
+ case 35:
9514
9520
  totalFee = calculateTotalXcmFee(xcmFeeResult);
9515
9521
  method = api.getMethod(tx);
9516
9522
  if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
@@ -9519,7 +9525,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9519
9525
  feeToSubtract = destFee;
9520
9526
  }
9521
9527
  return _context.abrupt("return", BigInt(currency.amount) - feeToSubtract > (balance < edBN ? edBN : 0));
9522
- case 36:
9528
+ case 39:
9523
9529
  case "end":
9524
9530
  return _context.stop();
9525
9531
  }
@@ -10301,4 +10307,4 @@ var Builder = function Builder(api) {
10301
10307
  return new GeneralBuilder(api, new BatchTransactionManager());
10302
10308
  };
10303
10309
 
10304
- export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
10310
+ export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, replaceBigInt, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "10.1.0",
3
+ "version": "10.1.2",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "@scure/base": "^1.2.5",
28
28
  "ethers": "^6.13.7",
29
29
  "viem": "^2.28.1",
30
- "@paraspell/assets": "10.1.0",
31
- "@paraspell/sdk-common": "10.1.0",
32
- "@paraspell/pallets": "10.1.0"
30
+ "@paraspell/pallets": "10.1.2",
31
+ "@paraspell/sdk-common": "10.1.2",
32
+ "@paraspell/assets": "10.1.2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/plugin-syntax-import-attributes": "^7.27.1",