@paraspell/sdk-core 10.5.0 → 10.5.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
@@ -3841,28 +3841,30 @@ var padFeeBy = function padFeeBy(amount, percent) {
3841
3841
  return mul(amount, BigInt(100 + percent), 100n);
3842
3842
  };
3843
3843
 
3844
+ var determineAddress = function determineAddress(chain, address, senderAddress) {
3845
+ if (assets.isNodeEvm(chain)) {
3846
+ return viem.isAddress(address) ? address : senderAddress;
3847
+ }
3848
+ return viem.isAddress(address) ? senderAddress : address;
3849
+ };
3844
3850
  var getReverseTxFee = /*#__PURE__*/function () {
3845
3851
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
3846
- var api, origin, destination, senderAddress, address, currency, tx, rawFee;
3852
+ var api, origin, destination, senderAddress, address, currency, toAddress, fromAddress, tx, rawFee;
3847
3853
  return _regenerator().w(function (_context) {
3848
3854
  while (1) switch (_context.n) {
3849
3855
  case 0:
3850
3856
  api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency;
3851
- if (!('multiasset' in currency)) {
3852
- _context.n = 1;
3853
- break;
3854
- }
3855
- throw new assets.InvalidCurrencyError('Multi-assets are not yet supported for XCM fee calculation.');
3856
- case 1:
3857
- _context.n = 2;
3858
- return Builder(api).from(destination).to(origin).address(senderAddress).senderAddress(address).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
3857
+ toAddress = determineAddress(origin, address, senderAddress);
3858
+ fromAddress = determineAddress(destination, address, senderAddress);
3859
+ _context.n = 1;
3860
+ return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
3859
3861
  amount: currency.amount
3860
3862
  })).build();
3861
- case 2:
3863
+ case 1:
3862
3864
  tx = _context.v;
3863
- _context.n = 3;
3864
- return api.calculateTransactionFee(tx, address);
3865
- case 3:
3865
+ _context.n = 2;
3866
+ return api.calculateTransactionFee(tx, fromAddress);
3867
+ case 2:
3866
3868
  rawFee = _context.v;
3867
3869
  return _context.a(2, padFee(rawFee, origin, destination, 'destination'));
3868
3870
  }
@@ -4557,8 +4559,8 @@ var verifyEdOnDestination = /*#__PURE__*/function () {
4557
4559
  }();
4558
4560
 
4559
4561
  var isSufficientOrigin = /*#__PURE__*/function () {
4560
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, node, senderAddress, fee, feeAsset) {
4561
- var existentialDeposit, nativeBalance;
4562
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, senderAddress, feeNative, currency, asset, feeAsset) {
4563
+ var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
4562
4564
  return _regenerator().w(function (_context) {
4563
4565
  while (1) switch (_context.n) {
4564
4566
  case 0:
@@ -4568,30 +4570,57 @@ var isSufficientOrigin = /*#__PURE__*/function () {
4568
4570
  }
4569
4571
  return _context.a(2, undefined);
4570
4572
  case 1:
4571
- existentialDeposit = assets.getExistentialDepositOrThrow(node);
4573
+ edNative = assets.getExistentialDepositOrThrow(origin);
4572
4574
  _context.n = 2;
4573
4575
  return getBalanceNativeInternal({
4574
4576
  api: api,
4575
- node: node,
4577
+ node: origin,
4576
4578
  address: senderAddress
4577
4579
  });
4578
4580
  case 2:
4579
- nativeBalance = _context.v;
4580
- return _context.a(2, nativeBalance - existentialDeposit - fee > 0n);
4581
+ balanceNative = _context.v;
4582
+ isNativeAssetToOrigin = assets.isSymbolMatch(asset.symbol, assets.getNativeAssetSymbol(origin));
4583
+ isNativeAssetToDest = assets.isSymbolMatch(asset.symbol, assets.getNativeAssetSymbol(destination));
4584
+ if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
4585
+ _context.n = 3;
4586
+ break;
4587
+ }
4588
+ return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
4589
+ case 3:
4590
+ if (isNativeAssetToOrigin) {
4591
+ _context.n = 5;
4592
+ break;
4593
+ }
4594
+ isSufficientNative = balanceNative - edNative - feeNative > 0n;
4595
+ _context.n = 4;
4596
+ return getAssetBalance({
4597
+ api: api,
4598
+ node: origin,
4599
+ address: senderAddress,
4600
+ currency: currency
4601
+ });
4602
+ case 4:
4603
+ balanceAsset = _context.v;
4604
+ edAsset = assets.getExistentialDepositOrThrow(origin, currency);
4605
+ isSufficientAsset = balanceAsset - edAsset > 0n;
4606
+ return _context.a(2, isSufficientNative && isSufficientAsset);
4607
+ case 5:
4608
+ return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
4581
4609
  }
4582
4610
  }, _callee);
4583
4611
  }));
4584
- return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5) {
4612
+ return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
4585
4613
  return _ref.apply(this, arguments);
4586
4614
  };
4587
4615
  }();
4588
4616
  var isSufficientDestination = /*#__PURE__*/function () {
4589
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset) {
4590
- var existentialDeposit, nativeBalance;
4617
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset, feeNative) {
4618
+ var isNativeAsset, existentialDeposit, nativeBalance;
4591
4619
  return _regenerator().w(function (_context2) {
4592
4620
  while (1) switch (_context2.n) {
4593
4621
  case 0:
4594
- if (!(assets.normalizeSymbol(asset.symbol) !== assets.normalizeSymbol(assets.getNativeAssetSymbol(destination)))) {
4622
+ isNativeAsset = assets.isSymbolMatch(asset.symbol, assets.getNativeAssetSymbol(destination));
4623
+ if (isNativeAsset) {
4595
4624
  _context2.n = 1;
4596
4625
  break;
4597
4626
  }
@@ -4606,11 +4635,11 @@ var isSufficientDestination = /*#__PURE__*/function () {
4606
4635
  });
4607
4636
  case 2:
4608
4637
  nativeBalance = _context2.v;
4609
- return _context2.a(2, nativeBalance + amount - existentialDeposit > 0n);
4638
+ return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
4610
4639
  }
4611
4640
  }, _callee2);
4612
4641
  }));
4613
- return function isSufficientDestination(_x6, _x7, _x8, _x9, _x0) {
4642
+ return function isSufficientDestination(_x9, _x0, _x1, _x10, _x11, _x12) {
4614
4643
  return _ref2.apply(this, arguments);
4615
4644
  };
4616
4645
  }();
@@ -4628,7 +4657,7 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
4628
4657
  };
4629
4658
  var getDestXcmFee = /*#__PURE__*/function () {
4630
4659
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
4631
- var api, origin, hopNode, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, sufficient, dryRunResult, _sufficient, fee, newForwardedXcms, destParaId, _t2, _t3, _t4, _t5, _t6;
4660
+ var api, origin, hopNode, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, _sufficient, fee, newForwardedXcms, destParaId;
4632
4661
  return _regenerator().w(function (_context2) {
4633
4662
  while (1) switch (_context2.n) {
4634
4663
  case 0:
@@ -4698,18 +4727,17 @@ var getDestXcmFee = /*#__PURE__*/function () {
4698
4727
  break;
4699
4728
  }
4700
4729
  _context2.n = 1;
4701
- return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset);
4730
+ return calcPaymentInfoFee();
4702
4731
  case 1:
4703
- sufficient = _context2.v;
4732
+ _fee = _context2.v;
4704
4733
  _context2.n = 2;
4705
- return calcPaymentInfoFee();
4734
+ return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee);
4706
4735
  case 2:
4707
- _t2 = _context2.v;
4708
- _t3 = sufficient;
4736
+ sufficient = _context2.v;
4709
4737
  return _context2.a(2, {
4710
- fee: _t2,
4738
+ fee: _fee,
4711
4739
  feeType: 'paymentInfo',
4712
- sufficient: _t3
4740
+ sufficient: sufficient
4713
4741
  });
4714
4742
  case 3:
4715
4743
  _context2.n = 4;
@@ -4738,20 +4766,18 @@ var getDestXcmFee = /*#__PURE__*/function () {
4738
4766
  });
4739
4767
  case 5:
4740
4768
  _context2.n = 6;
4741
- return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset);
4769
+ return calcPaymentInfoFee();
4742
4770
  case 6:
4743
- _sufficient = _context2.v;
4771
+ _fee2 = _context2.v;
4744
4772
  _context2.n = 7;
4745
- return calcPaymentInfoFee();
4773
+ return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee2);
4746
4774
  case 7:
4747
- _t4 = _context2.v;
4748
- _t5 = dryRunResult.failureReason;
4749
- _t6 = _sufficient;
4775
+ _sufficient = _context2.v;
4750
4776
  return _context2.a(2, {
4751
- fee: _t4,
4777
+ fee: _fee2,
4752
4778
  feeType: 'paymentInfo',
4753
- dryRunError: _t5,
4754
- sufficient: _t6
4779
+ dryRunError: dryRunResult.failureReason,
4780
+ sufficient: _sufficient
4755
4781
  });
4756
4782
  case 8:
4757
4783
  fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
@@ -4792,13 +4818,14 @@ var dryRunInternal = /*#__PURE__*/function () {
4792
4818
  case 0:
4793
4819
  origin = options.origin, destination = options.destination, currency = options.currency, api = options.api, tx = options.tx, senderAddress = options.senderAddress, feeAsset = options.feeAsset;
4794
4820
  resolvedFeeAsset = feeAsset && origin === 'AssetHubPolkadot' ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4795
- asset = 'multiasset' in currency ? null : assets.findAssetForNodeOrThrow(origin, currency, destination);
4821
+ asset = assets.findAssetForNodeOrThrow(origin, currency, destination);
4796
4822
  _context.n = 1;
4797
4823
  return api.getDryRunCall({
4798
4824
  tx: tx,
4799
4825
  node: origin,
4800
4826
  address: senderAddress,
4801
- isFeeAsset: !!resolvedFeeAsset
4827
+ asset: asset,
4828
+ feeAsset: resolvedFeeAsset
4802
4829
  });
4803
4830
  case 1:
4804
4831
  originDryRun = _context.v;
@@ -5011,11 +5038,12 @@ var dryRunOrigin = /*#__PURE__*/function () {
5011
5038
 
5012
5039
  var getOriginXcmFee = /*#__PURE__*/function () {
5013
5040
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
5014
- var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, resolvedFeeAsset, nativeAssetSymbol, rawFee, paddedFee, sufficient, dryRunResult, _rawFee, _paddedFee, _sufficient, fee, forwardedXcms, destParaId, weight, currencySymbol;
5041
+ var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, asset, resolvedFeeAsset, nativeAssetSymbol, rawFee, paddedFee, sufficient, dryRunResult, _rawFee, _paddedFee, _sufficient, fee, forwardedXcms, destParaId, weight, currencySymbol;
5015
5042
  return _regenerator().w(function (_context) {
5016
5043
  while (1) switch (_context.n) {
5017
5044
  case 0:
5018
5045
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, disableFallback = _ref.disableFallback, feeAsset = _ref.feeAsset, currency = _ref.currency;
5046
+ asset = assets.findAssetForNodeOrThrow(origin, currency, destination);
5019
5047
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
5020
5048
  _context.n = 1;
5021
5049
  return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
@@ -5031,7 +5059,7 @@ var getOriginXcmFee = /*#__PURE__*/function () {
5031
5059
  rawFee = _context.v;
5032
5060
  paddedFee = padFee(rawFee, origin, destination, 'origin');
5033
5061
  _context.n = 3;
5034
- return isSufficientOrigin(api, origin, senderAddress, paddedFee, resolvedFeeAsset);
5062
+ return isSufficientOrigin(api, origin, destination, senderAddress, paddedFee, currency, asset, resolvedFeeAsset);
5035
5063
  case 3:
5036
5064
  sufficient = _context.v;
5037
5065
  return _context.a(2, {
@@ -5046,7 +5074,8 @@ var getOriginXcmFee = /*#__PURE__*/function () {
5046
5074
  tx: tx,
5047
5075
  node: origin,
5048
5076
  address: senderAddress,
5049
- isFeeAsset: !!resolvedFeeAsset
5077
+ asset: asset,
5078
+ feeAsset: resolvedFeeAsset
5050
5079
  });
5051
5080
  case 5:
5052
5081
  dryRunResult = _context.v;
@@ -5068,7 +5097,7 @@ var getOriginXcmFee = /*#__PURE__*/function () {
5068
5097
  _rawFee = _context.v;
5069
5098
  _paddedFee = padFee(_rawFee, origin, destination, 'origin');
5070
5099
  _context.n = 8;
5071
- return isSufficientOrigin(api, origin, senderAddress, _paddedFee, resolvedFeeAsset);
5100
+ return isSufficientOrigin(api, origin, destination, senderAddress, _paddedFee, currency, asset, resolvedFeeAsset);
5072
5101
  case 8:
5073
5102
  _sufficient = _context.v;
5074
5103
  return _context.a(2, {
@@ -5255,11 +5284,12 @@ var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled
5255
5284
 
5256
5285
  var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
5257
5286
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
5258
- var api, tx, origin, destination, currency, senderAddress, feeAsset, rawOriginFee, originFee, resolvedFeeAsset, sufficient;
5287
+ var api, tx, origin, destination, currency, senderAddress, feeAsset, originAsset, rawOriginFee, originFee, resolvedFeeAsset, sufficient;
5259
5288
  return _regenerator().w(function (_context) {
5260
5289
  while (1) switch (_context.n) {
5261
5290
  case 0:
5262
5291
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, currency = _ref.currency, senderAddress = _ref.senderAddress, feeAsset = _ref.feeAsset;
5292
+ originAsset = assets.findAssetForNodeOrThrow(origin, currency, destination);
5263
5293
  _context.n = 1;
5264
5294
  return api.calculateTransactionFee(tx, senderAddress);
5265
5295
  case 1:
@@ -5267,7 +5297,7 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
5267
5297
  originFee = padFee(rawOriginFee, origin, destination, 'origin');
5268
5298
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
5269
5299
  _context.n = 2;
5270
- return isSufficientOrigin(api, origin, senderAddress, originFee, resolvedFeeAsset);
5300
+ return isSufficientOrigin(api, origin, destination, senderAddress, originFee, currency, originAsset, resolvedFeeAsset);
5271
5301
  case 2:
5272
5302
  sufficient = _context.v;
5273
5303
  return _context.a(2, {
@@ -5624,11 +5654,11 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
5624
5654
  }
5625
5655
  _ref2 = origin === 'AssetHubPolkadot' ? [BRIDGE_FEE_DOT, BRIDGE_FEE_KSM] : [BRIDGE_FEE_KSM, BRIDGE_FEE_DOT], _ref3 = _slicedToArray(_ref2, 2), fixedOriginFee = _ref3[0], fixedDestinationFee = _ref3[1];
5626
5656
  _context.n = 3;
5627
- return isSufficientOrigin(api, origin, senderAddress, fixedOriginFee, resolvedFeeAsset);
5657
+ return isSufficientOrigin(api, origin, destination, senderAddress, fixedOriginFee, currency, originAsset, resolvedFeeAsset);
5628
5658
  case 3:
5629
5659
  originSufficient = _context.v;
5630
5660
  _context.n = 4;
5631
- return isSufficientDestination(destApi, destination, address, BigInt(currency.amount), originAsset);
5661
+ return isSufficientDestination(destApi, destination, address, BigInt(currency.amount), originAsset, fixedDestinationFee);
5632
5662
  case 4:
5633
5663
  _destinationSufficient = _context.v;
5634
5664
  return _context.a(2, {
@@ -5671,7 +5701,7 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
5671
5701
  case 9:
5672
5702
  destinationFee = _t;
5673
5703
  _context.n = 10;
5674
- return isSufficientDestination(destApi, destination, address, BigInt(currency.amount), originAsset);
5704
+ return isSufficientDestination(destApi, destination, address, BigInt(currency.amount), originAsset, destinationFee);
5675
5705
  case 10:
5676
5706
  destinationSufficient = _context.v;
5677
5707
  destFeeDetails = {
@@ -7275,7 +7305,8 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7275
7305
  node: this.node,
7276
7306
  tx: api.callTxMethod(call),
7277
7307
  address: senderAddress,
7278
- isFeeAsset: !!feeAsset
7308
+ asset: asset,
7309
+ feeAsset: feeAsset
7279
7310
  });
7280
7311
  case 2:
7281
7312
  dryRunResult = _context3.v;
package/dist/index.d.ts CHANGED
@@ -354,7 +354,7 @@ type TGetTransferableAmountOptionsBase<TRes> = {
354
354
  /**
355
355
  * The currency to query.
356
356
  */
357
- currency: TCurrencyCore;
357
+ currency: WithAmount<TCurrencyCore>;
358
358
  /**
359
359
  * The transaction to calculate the fee for
360
360
  */
@@ -539,7 +539,8 @@ type TDryRunCallBaseOptions<TRes> = {
539
539
  * The address to dry-run with
540
540
  */
541
541
  address: string;
542
- isFeeAsset: boolean;
542
+ asset: TAsset;
543
+ feeAsset?: TAsset;
543
544
  };
544
545
  type TDryRunCallOptions<TApi, TRes> = WithApi<TDryRunCallBaseOptions<TRes>, TApi, TRes>;
545
546
  type TDryRunXcmBaseOptions = {
@@ -854,7 +855,7 @@ type TGetOriginXcmFeeBaseOptions<TRes> = {
854
855
  origin: TNodeDotKsmWithRelayChains;
855
856
  destination: TNodeWithRelayChains;
856
857
  senderAddress: string;
857
- currency: TCurrencyInput;
858
+ currency: WithAmount<TCurrencyCore>;
858
859
  feeAsset?: TCurrencyInput;
859
860
  disableFallback: boolean;
860
861
  };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2';
2
- import { isNodeEvm, getAssetsObject, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, InvalidCurrencyError, findAssetForNodeOrThrow, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, findAsset, isTMultiAsset, getExistentialDeposit, getExistentialDepositOrThrow, isAssetEqual, findAssetOnDestOrThrow, normalizeSymbol, hasDryRunSupport, hasSupportForAsset, extractMultiAssetLoc, isSymbolSpecifier, normalizeMultiLocation, getAssetId } from '@paraspell/assets';
2
+ import { isNodeEvm, getAssetsObject, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, InvalidCurrencyError, findAssetForNodeOrThrow, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, findAsset, isTMultiAsset, getExistentialDeposit, getExistentialDepositOrThrow, isAssetEqual, findAssetOnDestOrThrow, normalizeSymbol, isSymbolMatch, hasDryRunSupport, hasSupportForAsset, extractMultiAssetLoc, isSymbolSpecifier, normalizeMultiLocation, getAssetId } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, createPublicClient, http, getContract } from 'viem';
@@ -3842,28 +3842,30 @@ var padFeeBy = function padFeeBy(amount, percent) {
3842
3842
  return mul(amount, BigInt(100 + percent), 100n);
3843
3843
  };
3844
3844
 
3845
+ var determineAddress = function determineAddress(chain, address, senderAddress) {
3846
+ if (isNodeEvm(chain)) {
3847
+ return isAddress(address) ? address : senderAddress;
3848
+ }
3849
+ return isAddress(address) ? senderAddress : address;
3850
+ };
3845
3851
  var getReverseTxFee = /*#__PURE__*/function () {
3846
3852
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
3847
- var api, origin, destination, senderAddress, address, currency, tx, rawFee;
3853
+ var api, origin, destination, senderAddress, address, currency, toAddress, fromAddress, tx, rawFee;
3848
3854
  return _regenerator().w(function (_context) {
3849
3855
  while (1) switch (_context.n) {
3850
3856
  case 0:
3851
3857
  api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency;
3852
- if (!('multiasset' in currency)) {
3853
- _context.n = 1;
3854
- break;
3855
- }
3856
- throw new InvalidCurrencyError('Multi-assets are not yet supported for XCM fee calculation.');
3857
- case 1:
3858
- _context.n = 2;
3859
- return Builder(api).from(destination).to(origin).address(senderAddress).senderAddress(address).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
3858
+ toAddress = determineAddress(origin, address, senderAddress);
3859
+ fromAddress = determineAddress(destination, address, senderAddress);
3860
+ _context.n = 1;
3861
+ return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(_objectSpread2(_objectSpread2({}, currencyInput), {}, {
3860
3862
  amount: currency.amount
3861
3863
  })).build();
3862
- case 2:
3864
+ case 1:
3863
3865
  tx = _context.v;
3864
- _context.n = 3;
3865
- return api.calculateTransactionFee(tx, address);
3866
- case 3:
3866
+ _context.n = 2;
3867
+ return api.calculateTransactionFee(tx, fromAddress);
3868
+ case 2:
3867
3869
  rawFee = _context.v;
3868
3870
  return _context.a(2, padFee(rawFee, origin, destination, 'destination'));
3869
3871
  }
@@ -4558,8 +4560,8 @@ var verifyEdOnDestination = /*#__PURE__*/function () {
4558
4560
  }();
4559
4561
 
4560
4562
  var isSufficientOrigin = /*#__PURE__*/function () {
4561
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, node, senderAddress, fee, feeAsset) {
4562
- var existentialDeposit, nativeBalance;
4563
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, senderAddress, feeNative, currency, asset, feeAsset) {
4564
+ var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
4563
4565
  return _regenerator().w(function (_context) {
4564
4566
  while (1) switch (_context.n) {
4565
4567
  case 0:
@@ -4569,30 +4571,57 @@ var isSufficientOrigin = /*#__PURE__*/function () {
4569
4571
  }
4570
4572
  return _context.a(2, undefined);
4571
4573
  case 1:
4572
- existentialDeposit = getExistentialDepositOrThrow(node);
4574
+ edNative = getExistentialDepositOrThrow(origin);
4573
4575
  _context.n = 2;
4574
4576
  return getBalanceNativeInternal({
4575
4577
  api: api,
4576
- node: node,
4578
+ node: origin,
4577
4579
  address: senderAddress
4578
4580
  });
4579
4581
  case 2:
4580
- nativeBalance = _context.v;
4581
- return _context.a(2, nativeBalance - existentialDeposit - fee > 0n);
4582
+ balanceNative = _context.v;
4583
+ isNativeAssetToOrigin = isSymbolMatch(asset.symbol, getNativeAssetSymbol(origin));
4584
+ isNativeAssetToDest = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
4585
+ if (!(isNativeAssetToOrigin && isNativeAssetToDest)) {
4586
+ _context.n = 3;
4587
+ break;
4588
+ }
4589
+ return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
4590
+ case 3:
4591
+ if (isNativeAssetToOrigin) {
4592
+ _context.n = 5;
4593
+ break;
4594
+ }
4595
+ isSufficientNative = balanceNative - edNative - feeNative > 0n;
4596
+ _context.n = 4;
4597
+ return getAssetBalance({
4598
+ api: api,
4599
+ node: origin,
4600
+ address: senderAddress,
4601
+ currency: currency
4602
+ });
4603
+ case 4:
4604
+ balanceAsset = _context.v;
4605
+ edAsset = getExistentialDepositOrThrow(origin, currency);
4606
+ isSufficientAsset = balanceAsset - edAsset > 0n;
4607
+ return _context.a(2, isSufficientNative && isSufficientAsset);
4608
+ case 5:
4609
+ return _context.a(2, balanceNative - edNative - feeNative - BigInt(currency.amount) > 0n);
4582
4610
  }
4583
4611
  }, _callee);
4584
4612
  }));
4585
- return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5) {
4613
+ return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
4586
4614
  return _ref.apply(this, arguments);
4587
4615
  };
4588
4616
  }();
4589
4617
  var isSufficientDestination = /*#__PURE__*/function () {
4590
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset) {
4591
- var existentialDeposit, nativeBalance;
4618
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, destination, address, amount, asset, feeNative) {
4619
+ var isNativeAsset, existentialDeposit, nativeBalance;
4592
4620
  return _regenerator().w(function (_context2) {
4593
4621
  while (1) switch (_context2.n) {
4594
4622
  case 0:
4595
- if (!(normalizeSymbol(asset.symbol) !== normalizeSymbol(getNativeAssetSymbol(destination)))) {
4623
+ isNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbol(destination));
4624
+ if (isNativeAsset) {
4596
4625
  _context2.n = 1;
4597
4626
  break;
4598
4627
  }
@@ -4607,11 +4636,11 @@ var isSufficientDestination = /*#__PURE__*/function () {
4607
4636
  });
4608
4637
  case 2:
4609
4638
  nativeBalance = _context2.v;
4610
- return _context2.a(2, nativeBalance + amount - existentialDeposit > 0n);
4639
+ return _context2.a(2, nativeBalance + amount - existentialDeposit - feeNative > 0n);
4611
4640
  }
4612
4641
  }, _callee2);
4613
4642
  }));
4614
- return function isSufficientDestination(_x6, _x7, _x8, _x9, _x0) {
4643
+ return function isSufficientDestination(_x9, _x0, _x1, _x10, _x11, _x12) {
4615
4644
  return _ref2.apply(this, arguments);
4616
4645
  };
4617
4646
  }();
@@ -4629,7 +4658,7 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
4629
4658
  };
4630
4659
  var getDestXcmFee = /*#__PURE__*/function () {
4631
4660
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
4632
- var api, origin, hopNode, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, sufficient, dryRunResult, _sufficient, fee, newForwardedXcms, destParaId, _t2, _t3, _t4, _t5, _t6;
4661
+ var api, origin, hopNode, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, _sufficient, fee, newForwardedXcms, destParaId;
4633
4662
  return _regenerator().w(function (_context2) {
4634
4663
  while (1) switch (_context2.n) {
4635
4664
  case 0:
@@ -4699,18 +4728,17 @@ var getDestXcmFee = /*#__PURE__*/function () {
4699
4728
  break;
4700
4729
  }
4701
4730
  _context2.n = 1;
4702
- return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset);
4731
+ return calcPaymentInfoFee();
4703
4732
  case 1:
4704
- sufficient = _context2.v;
4733
+ _fee = _context2.v;
4705
4734
  _context2.n = 2;
4706
- return calcPaymentInfoFee();
4735
+ return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee);
4707
4736
  case 2:
4708
- _t2 = _context2.v;
4709
- _t3 = sufficient;
4737
+ sufficient = _context2.v;
4710
4738
  return _context2.a(2, {
4711
- fee: _t2,
4739
+ fee: _fee,
4712
4740
  feeType: 'paymentInfo',
4713
- sufficient: _t3
4741
+ sufficient: sufficient
4714
4742
  });
4715
4743
  case 3:
4716
4744
  _context2.n = 4;
@@ -4739,20 +4767,18 @@ var getDestXcmFee = /*#__PURE__*/function () {
4739
4767
  });
4740
4768
  case 5:
4741
4769
  _context2.n = 6;
4742
- return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset);
4770
+ return calcPaymentInfoFee();
4743
4771
  case 6:
4744
- _sufficient = _context2.v;
4772
+ _fee2 = _context2.v;
4745
4773
  _context2.n = 7;
4746
- return calcPaymentInfoFee();
4774
+ return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee2);
4747
4775
  case 7:
4748
- _t4 = _context2.v;
4749
- _t5 = dryRunResult.failureReason;
4750
- _t6 = _sufficient;
4776
+ _sufficient = _context2.v;
4751
4777
  return _context2.a(2, {
4752
- fee: _t4,
4778
+ fee: _fee2,
4753
4779
  feeType: 'paymentInfo',
4754
- dryRunError: _t5,
4755
- sufficient: _t6
4780
+ dryRunError: dryRunResult.failureReason,
4781
+ sufficient: _sufficient
4756
4782
  });
4757
4783
  case 8:
4758
4784
  fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
@@ -4793,13 +4819,14 @@ var dryRunInternal = /*#__PURE__*/function () {
4793
4819
  case 0:
4794
4820
  origin = options.origin, destination = options.destination, currency = options.currency, api = options.api, tx = options.tx, senderAddress = options.senderAddress, feeAsset = options.feeAsset;
4795
4821
  resolvedFeeAsset = feeAsset && origin === 'AssetHubPolkadot' ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4796
- asset = 'multiasset' in currency ? null : findAssetForNodeOrThrow(origin, currency, destination);
4822
+ asset = findAssetForNodeOrThrow(origin, currency, destination);
4797
4823
  _context.n = 1;
4798
4824
  return api.getDryRunCall({
4799
4825
  tx: tx,
4800
4826
  node: origin,
4801
4827
  address: senderAddress,
4802
- isFeeAsset: !!resolvedFeeAsset
4828
+ asset: asset,
4829
+ feeAsset: resolvedFeeAsset
4803
4830
  });
4804
4831
  case 1:
4805
4832
  originDryRun = _context.v;
@@ -5012,11 +5039,12 @@ var dryRunOrigin = /*#__PURE__*/function () {
5012
5039
 
5013
5040
  var getOriginXcmFee = /*#__PURE__*/function () {
5014
5041
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
5015
- var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, resolvedFeeAsset, nativeAssetSymbol, rawFee, paddedFee, sufficient, dryRunResult, _rawFee, _paddedFee, _sufficient, fee, forwardedXcms, destParaId, weight, currencySymbol;
5042
+ var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, asset, resolvedFeeAsset, nativeAssetSymbol, rawFee, paddedFee, sufficient, dryRunResult, _rawFee, _paddedFee, _sufficient, fee, forwardedXcms, destParaId, weight, currencySymbol;
5016
5043
  return _regenerator().w(function (_context) {
5017
5044
  while (1) switch (_context.n) {
5018
5045
  case 0:
5019
5046
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, disableFallback = _ref.disableFallback, feeAsset = _ref.feeAsset, currency = _ref.currency;
5047
+ asset = findAssetForNodeOrThrow(origin, currency, destination);
5020
5048
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
5021
5049
  _context.n = 1;
5022
5050
  return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
@@ -5032,7 +5060,7 @@ var getOriginXcmFee = /*#__PURE__*/function () {
5032
5060
  rawFee = _context.v;
5033
5061
  paddedFee = padFee(rawFee, origin, destination, 'origin');
5034
5062
  _context.n = 3;
5035
- return isSufficientOrigin(api, origin, senderAddress, paddedFee, resolvedFeeAsset);
5063
+ return isSufficientOrigin(api, origin, destination, senderAddress, paddedFee, currency, asset, resolvedFeeAsset);
5036
5064
  case 3:
5037
5065
  sufficient = _context.v;
5038
5066
  return _context.a(2, {
@@ -5047,7 +5075,8 @@ var getOriginXcmFee = /*#__PURE__*/function () {
5047
5075
  tx: tx,
5048
5076
  node: origin,
5049
5077
  address: senderAddress,
5050
- isFeeAsset: !!resolvedFeeAsset
5078
+ asset: asset,
5079
+ feeAsset: resolvedFeeAsset
5051
5080
  });
5052
5081
  case 5:
5053
5082
  dryRunResult = _context.v;
@@ -5069,7 +5098,7 @@ var getOriginXcmFee = /*#__PURE__*/function () {
5069
5098
  _rawFee = _context.v;
5070
5099
  _paddedFee = padFee(_rawFee, origin, destination, 'origin');
5071
5100
  _context.n = 8;
5072
- return isSufficientOrigin(api, origin, senderAddress, _paddedFee, resolvedFeeAsset);
5101
+ return isSufficientOrigin(api, origin, destination, senderAddress, _paddedFee, currency, asset, resolvedFeeAsset);
5073
5102
  case 8:
5074
5103
  _sufficient = _context.v;
5075
5104
  return _context.a(2, {
@@ -5256,11 +5285,12 @@ var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled
5256
5285
 
5257
5286
  var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
5258
5287
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
5259
- var api, tx, origin, destination, currency, senderAddress, feeAsset, rawOriginFee, originFee, resolvedFeeAsset, sufficient;
5288
+ var api, tx, origin, destination, currency, senderAddress, feeAsset, originAsset, rawOriginFee, originFee, resolvedFeeAsset, sufficient;
5260
5289
  return _regenerator().w(function (_context) {
5261
5290
  while (1) switch (_context.n) {
5262
5291
  case 0:
5263
5292
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, currency = _ref.currency, senderAddress = _ref.senderAddress, feeAsset = _ref.feeAsset;
5293
+ originAsset = findAssetForNodeOrThrow(origin, currency, destination);
5264
5294
  _context.n = 1;
5265
5295
  return api.calculateTransactionFee(tx, senderAddress);
5266
5296
  case 1:
@@ -5268,7 +5298,7 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
5268
5298
  originFee = padFee(rawOriginFee, origin, destination, 'origin');
5269
5299
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
5270
5300
  _context.n = 2;
5271
- return isSufficientOrigin(api, origin, senderAddress, originFee, resolvedFeeAsset);
5301
+ return isSufficientOrigin(api, origin, destination, senderAddress, originFee, currency, originAsset, resolvedFeeAsset);
5272
5302
  case 2:
5273
5303
  sufficient = _context.v;
5274
5304
  return _context.a(2, {
@@ -5625,11 +5655,11 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
5625
5655
  }
5626
5656
  _ref2 = origin === 'AssetHubPolkadot' ? [BRIDGE_FEE_DOT, BRIDGE_FEE_KSM] : [BRIDGE_FEE_KSM, BRIDGE_FEE_DOT], _ref3 = _slicedToArray(_ref2, 2), fixedOriginFee = _ref3[0], fixedDestinationFee = _ref3[1];
5627
5657
  _context.n = 3;
5628
- return isSufficientOrigin(api, origin, senderAddress, fixedOriginFee, resolvedFeeAsset);
5658
+ return isSufficientOrigin(api, origin, destination, senderAddress, fixedOriginFee, currency, originAsset, resolvedFeeAsset);
5629
5659
  case 3:
5630
5660
  originSufficient = _context.v;
5631
5661
  _context.n = 4;
5632
- return isSufficientDestination(destApi, destination, address, BigInt(currency.amount), originAsset);
5662
+ return isSufficientDestination(destApi, destination, address, BigInt(currency.amount), originAsset, fixedDestinationFee);
5633
5663
  case 4:
5634
5664
  _destinationSufficient = _context.v;
5635
5665
  return _context.a(2, {
@@ -5672,7 +5702,7 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
5672
5702
  case 9:
5673
5703
  destinationFee = _t;
5674
5704
  _context.n = 10;
5675
- return isSufficientDestination(destApi, destination, address, BigInt(currency.amount), originAsset);
5705
+ return isSufficientDestination(destApi, destination, address, BigInt(currency.amount), originAsset, destinationFee);
5676
5706
  case 10:
5677
5707
  destinationSufficient = _context.v;
5678
5708
  destFeeDetails = {
@@ -7276,7 +7306,8 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7276
7306
  node: this.node,
7277
7307
  tx: api.callTxMethod(call),
7278
7308
  address: senderAddress,
7279
- isFeeAsset: !!feeAsset
7309
+ asset: asset,
7310
+ feeAsset: feeAsset
7280
7311
  });
7281
7312
  case 2:
7282
7313
  dryRunResult = _context3.v;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "10.5.0",
3
+ "version": "10.5.2",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,9 +26,9 @@
26
26
  "@noble/hashes": "^1.8.0",
27
27
  "@scure/base": "^1.2.6",
28
28
  "viem": "^2.30.5",
29
- "@paraspell/assets": "10.5.0",
30
- "@paraspell/sdk-common": "10.5.0",
31
- "@paraspell/pallets": "10.5.0"
29
+ "@paraspell/assets": "10.5.2",
30
+ "@paraspell/pallets": "10.5.2",
31
+ "@paraspell/sdk-common": "10.5.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",