@paraspell/sdk-core 14.5.2 → 14.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +37 -30
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2.js';
2
- import { isChainEvm, getAssetsObject, InvalidCurrencyError, isAssetEqual, isSymbolMatch, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, STABLECOIN_IDS, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, extractAssetLocation, normalizeSymbol, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositImpl, normalizeCustomAssets } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, InvalidCurrencyError, isAssetEqual, isSymbolMatch, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, STABLECOIN_IDS, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, extractAssetLocation, normalizeSymbol, findNativeAssetInfoOrThrow, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositImpl, normalizeCustomAssets } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, isHex, createPublicClient, http, formatUnits as formatUnits$1, parseUnits as parseUnits$1, stringToHex, numberToBytes } from 'viem';
@@ -3598,13 +3598,11 @@ var padFee = function padFee(raw, origin, dest, side) {
3598
3598
  var sysParaDest = isSystemPara(dest);
3599
3599
  var relayToPara = relayOrigin && !relayDest;
3600
3600
  var sysParaToPara = sysParaOrigin && !sysParaDest;
3601
- var paraToPara = !relayOrigin && !sysParaOrigin;
3602
3601
  if (sysParaToPara) return raw * 40n;
3603
3602
  if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
3604
- if (paraToPara && side == 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
3603
+ if (side === 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
3605
3604
  return 150000000000000000n;
3606
3605
  }
3607
- if (paraToPara) return mul(raw, 130n, 100n);
3608
3606
  // apply default 30% padding
3609
3607
  return mul(raw, 130n, 100n);
3610
3608
  };
@@ -5314,7 +5312,7 @@ var getEthErc20Balance = /*#__PURE__*/function () {
5314
5312
 
5315
5313
  var isSufficientOrigin = /*#__PURE__*/function () {
5316
5314
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, sender, feeNative, asset, feeAsset) {
5317
- var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
5315
+ var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, remainingAsset, isSufficientAsset;
5318
5316
  return _regenerator().w(function (_context) {
5319
5317
  while (1) switch (_context.n) {
5320
5318
  case 0:
@@ -5355,8 +5353,8 @@ var isSufficientOrigin = /*#__PURE__*/function () {
5355
5353
  });
5356
5354
  case 4:
5357
5355
  balanceAsset = _context.v;
5358
- edAsset = BigInt(asset.existentialDeposit);
5359
- isSufficientAsset = balanceAsset - edAsset > 0n;
5356
+ remainingAsset = balanceAsset - asset.amount;
5357
+ isSufficientAsset = remainingAsset === 0n || remainingAsset >= BigInt(asset.existentialDeposit);
5360
5358
  return _context.a(2, isSufficientNative && isSufficientAsset);
5361
5359
  case 5:
5362
5360
  return _context.a(2, balanceNative - edNative - feeNative - asset.amount > 0n);
@@ -7854,7 +7852,8 @@ var buildHopInfo = /*#__PURE__*/function () {
7854
7852
  var _excluded$1 = ["amount"];
7855
7853
  var buildOriginInfo = /*#__PURE__*/function () {
7856
7854
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
7857
- var api, origin, sender, assets, amount, originFee, originFeeAsset, isOriginFeeAsset, buildSelectedCurrency, selectedCurrency, originBalanceFee, originBalanceFeeAfter;
7855
+ var _transferredFeeAsset$;
7856
+ var api, origin, sender, assets, amount, originFee, originFeeAsset, isOriginFeeAsset, buildSelectedCurrency, selectedCurrency, originBalanceFee, transferredFeeAsset, originBalanceFeeAfter, ed, isNativeFeeAsset, remaining;
7858
7857
  return _regenerator().w(function (_context2) {
7859
7858
  while (1) switch (_context2.n) {
7860
7859
  case 0:
@@ -7902,11 +7901,17 @@ var buildOriginInfo = /*#__PURE__*/function () {
7902
7901
  });
7903
7902
  case 2:
7904
7903
  originBalanceFee = _context2.v;
7905
- originBalanceFeeAfter = isOriginFeeAsset ? originBalanceFee - amount : originBalanceFee - originFee;
7904
+ transferredFeeAsset = isOriginFeeAsset ? undefined : assets.find(function (asset) {
7905
+ return isAssetEqual(asset, originFeeAsset);
7906
+ });
7907
+ originBalanceFeeAfter = isOriginFeeAsset ? originBalanceFee - amount : originBalanceFee - originFee - ((_transferredFeeAsset$ = transferredFeeAsset === null || transferredFeeAsset === void 0 ? void 0 : transferredFeeAsset.amount) !== null && _transferredFeeAsset$ !== void 0 ? _transferredFeeAsset$ : 0n);
7908
+ ed = BigInt(originFeeAsset.existentialDeposit);
7909
+ isNativeFeeAsset = isAssetEqual(originFeeAsset, api.findNativeAssetInfoOrThrow(origin));
7910
+ remaining = originBalanceFeeAfter + (isNativeFeeAsset ? ed : 0n);
7906
7911
  return _context2.a(2, {
7907
7912
  selectedCurrency: selectedCurrency,
7908
7913
  xcmFee: {
7909
- sufficient: originBalanceFee >= originFee,
7914
+ sufficient: transferredFeeAsset ? remaining === 0n || remaining >= ed : originBalanceFee >= originFee,
7910
7915
  fee: originFee,
7911
7916
  balance: originBalanceFee,
7912
7917
  balanceAfter: originBalanceFeeAfter,
@@ -8220,33 +8225,35 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
8220
8225
  return createTx(amounts);
8221
8226
  case 5:
8222
8227
  tx = _context3.v;
8223
- _context3.n = 10;
8228
+ _context3.n = 11;
8224
8229
  break;
8225
8230
  case 6:
8226
8231
  _context3.p = 6;
8227
8232
  _t = _context3.v;
8228
- if (!(_t instanceof AmountTooLowError)) {
8229
- _context3.n = 10;
8233
+ if (_t instanceof AmountTooLowError) {
8234
+ _context3.n = 7;
8230
8235
  break;
8231
8236
  }
8237
+ throw _t;
8238
+ case 7:
8232
8239
  amounts = amounts.map(function (amount) {
8233
8240
  return padValueBy(amount, FEE_PADDING);
8234
8241
  });
8235
- _context3.p = 7;
8236
- _context3.n = 8;
8242
+ _context3.p = 8;
8243
+ _context3.n = 9;
8237
8244
  return createTx(amounts);
8238
- case 8:
8245
+ case 9:
8239
8246
  tx = _context3.v;
8240
- _context3.n = 10;
8247
+ _context3.n = 11;
8241
8248
  break;
8242
- case 9:
8243
- _context3.p = 9;
8249
+ case 10:
8250
+ _context3.p = 10;
8244
8251
  _context3.v;
8245
8252
  return _context3.a(2, toResult(amounts.map(function () {
8246
8253
  return 0n;
8247
8254
  })));
8248
- case 10:
8249
- _context3.n = 11;
8255
+ case 11:
8256
+ _context3.n = 12;
8250
8257
  return dryRunInternal({
8251
8258
  api: api,
8252
8259
  tx: tx,
@@ -8257,19 +8264,19 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
8257
8264
  currency: buildMinCurrency(amounts),
8258
8265
  feeAsset: feeAsset
8259
8266
  });
8260
- case 11:
8267
+ case 12:
8261
8268
  dryRunResult = _context3.v;
8262
8269
  if (dryRunResult.success) {
8263
- _context3.n = 12;
8270
+ _context3.n = 13;
8264
8271
  break;
8265
8272
  }
8266
8273
  return _context3.a(2, toResult(amounts.map(function () {
8267
8274
  return 0n;
8268
8275
  })));
8269
- case 12:
8276
+ case 13:
8270
8277
  return _context3.a(2, toResult(amounts));
8271
8278
  }
8272
- }, _callee3, null, [[7, 9], [4, 6]]);
8279
+ }, _callee3, null, [[8, 10], [4, 6]]);
8273
8280
  }));
8274
8281
  return function getMinTransferableAmountInternal(_x) {
8275
8282
  return _ref2.apply(this, arguments);
@@ -9165,7 +9172,7 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
9165
9172
  var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9166
9173
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
9167
9174
  var _destAssets$find;
9168
- var api, buildTx, origin, destination, currency, sender, recipient, feeAsset, version, isSubBridge, resolvedFeeAsset, destApi, resolvedAssets, destAssets, _destAssets, firstAsset, feeElement, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, method, isTypeAndThenMethod, verifyAsset, results;
9175
+ var api, buildTx, origin, destination, currency, sender, recipient, feeAsset, version, isSubBridge, resolvedFeeAsset, destApi, resolvedAssets, destAssets, _destAssets, firstAsset, feeElement, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, method, subtractsHopFees, verifyAsset, results;
9169
9176
  return _regenerator().w(function (_context2) {
9170
9177
  while (1) switch (_context2.n) {
9171
9178
  case 0:
@@ -9271,7 +9278,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9271
9278
  case 9:
9272
9279
  tx = _context2.v;
9273
9280
  method = api.getMethod(tx);
9274
- isTypeAndThenMethod = method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen';
9281
+ subtractsHopFees = method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen' || method === 'execute';
9275
9282
  verifyAsset = /*#__PURE__*/function () {
9276
9283
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref4) {
9277
9284
  var destAsset, amount, paysDestFee, ed, balance, feeToSubtract;
@@ -9289,7 +9296,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
9289
9296
  });
9290
9297
  case 1:
9291
9298
  balance = _context.v;
9292
- feeToSubtract = isTypeAndThenMethod ? calculateTotalXcmFee(destAsset, xcmFeeResult) : paysDestFee ? destFee : 0n;
9299
+ feeToSubtract = subtractsHopFees ? calculateTotalXcmFee(destAsset, xcmFeeResult) : paysDestFee && isAssetEqual(destFeeAsset, destAsset) ? destFee : 0n;
9293
9300
  return _context.a(2, amount - feeToSubtract > (balance < ed ? ed : 0));
9294
9301
  }
9295
9302
  }, _callee);
@@ -10126,8 +10133,8 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(options, origin, mess
10126
10133
 
10127
10134
  var isMultiHopSwap = function isMultiHopSwap(exchangeChain, assetFrom, assetTo) {
10128
10135
  var isAssetHub = exchangeChain.includes('AssetHub');
10129
- var nativeSymbol = getNativeAssetSymbol(exchangeChain);
10130
- return isAssetHub && assetFrom.symbol !== nativeSymbol && assetTo.symbol !== nativeSymbol;
10136
+ var nativeAsset = findNativeAssetInfoOrThrow(exchangeChain);
10137
+ return isAssetHub && !isAssetEqual(assetFrom, nativeAsset) && !isAssetEqual(assetTo, nativeAsset);
10131
10138
  };
10132
10139
 
10133
10140
  var createExchangeInstructions = /*#__PURE__*/function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "14.5.2",
3
+ "version": "14.5.3",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,9 +23,9 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@noble/hashes": "^2.4.0",
26
- "@paraspell/assets": "14.5.2",
27
- "@paraspell/pallets": "14.5.2",
28
- "@paraspell/sdk-common": "14.5.2",
26
+ "@paraspell/assets": "14.5.3",
27
+ "@paraspell/pallets": "14.5.3",
28
+ "@paraspell/sdk-common": "14.5.3",
29
29
  "@scure/base": "^2.4.0",
30
30
  "viem": "^2.57.13"
31
31
  },