@paraspell/assets 13.6.0 → 13.7.0

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.d.ts CHANGED
@@ -89,6 +89,7 @@ type TCustomCtx = {
89
89
  customChainAssets?: Record<string, TChainAssetsInfo>;
90
90
  };
91
91
 
92
+ declare const getExistentialDepositImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, currency?: TCurrencyCore, ctx?: TCustomCtx) => bigint | null;
92
93
  /**
93
94
  * Retrieves the existential deposit value for a given chain.
94
95
  *
@@ -96,7 +97,8 @@ type TCustomCtx = {
96
97
  * @returns The existential deposit as a bigint if available; otherwise, null.
97
98
  */
98
99
  declare const getExistentialDeposit: (chain: TChain, currency?: TCurrencyCore) => bigint | null;
99
- declare const assertEdDefined: (ed: bigint | null, chain?: TChain, currency?: TCurrencyCore) => asserts ed is bigint;
100
+ declare const assertEdDefined: <TCustomChain extends string = never>(ed: bigint | null, chain?: TChain | TCustomChain, currency?: TCurrencyCore) => asserts ed is bigint;
101
+ declare const getExistentialDepositOrThrowImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, currency?: TCurrencyCore, ctx?: TCustomCtx) => bigint;
100
102
  declare const getExistentialDepositOrThrow: (chain: TChain, currency?: TCurrencyCore) => bigint;
101
103
  declare const getEdFromAssetOrThrow: (asset: TAssetInfo) => bigint;
102
104
 
@@ -328,5 +330,5 @@ declare const extractAssetLocation: <T = bigint>(asset: TAsset<T>) => TLocation;
328
330
 
329
331
  declare const getAssetLocation: (chain: TChain, currency: TCurrencyInput) => TLocation | null;
330
332
 
331
- export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasSupportForAsset, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeCustomAssets, normalizeLocation, normalizeSymbol };
333
+ export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositImpl, getExistentialDepositOrThrow, getExistentialDepositOrThrowImpl, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasSupportForAsset, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeCustomAssets, normalizeLocation, normalizeSymbol };
332
334
  export type { TAmount, TAsset, TAssetInfo, TAssetInfoWithId, TAssetJsonMap, TAssetV3, TAssetV4, TAssetWithFee, TChainAssetsInfo, TCurrency, TCurrencyCore, TCurrencyInput, TCurrencyInputWithAmount, TCurrencySymbol, TCurrencySymbolValue, TCustomAssetInfo, TCustomAssetsMap, TCustomAssetsMapNormalized, TCustomCtx, TLocationValue, TLocationValueWithOverride, TOverrideLocationSpecifier, TSymbolSpecifier, WithAmount, WithComplexAmount };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Version, deepEqual, isChain, isExternalChain, getJunctionValue, hasJunction, Parents, RELAYCHAINS, replaceBigInt, isCustomChain, isSubstrateBridge, isSnowbridge, CHAINS } from '@paraspell/sdk-common';
1
+ import { Version, deepEqual, isChain, isExternalChain, getJunctionValue, hasJunction, Parents, RELAYCHAINS, replaceBigInt, isCustomChain, isSubstrateBridge, isSnowbridge, SUBSTRATE_CHAINS, CHAINS, ETHEREUM_BRIDGE_ORIGINS } from '@paraspell/sdk-common';
2
2
 
3
3
  function _arrayLikeToArray(r, a) {
4
4
  (null == a || a > r.length) && (a = r.length);
@@ -19581,10 +19581,10 @@ var findAssetInfoImpl = function findAssetInfoImpl(chain, currency, destination,
19581
19581
  var nativeAssets = getNativeAssetsImpl(chain, ctx);
19582
19582
  var assets = [].concat(_toConsumableArray(nativeAssets), _toConsumableArray(otherAssets));
19583
19583
  var asset;
19584
- if ('symbol' in currency) {
19585
- asset = findAssetInfoBySymbol(otherAssets, nativeAssets, currency.symbol, destination !== null && destination !== void 0 ? destination : undefined);
19586
- } else if ('location' in currency && !isOverrideLocationSpecifier(currency.location)) {
19584
+ if ('location' in currency && !isOverrideLocationSpecifier(currency.location)) {
19587
19585
  asset = findAssetInfoByLoc(assets, currency.location);
19586
+ } else if ('symbol' in currency) {
19587
+ asset = findAssetInfoBySymbol(otherAssets, nativeAssets, currency.symbol, destination !== null && destination !== void 0 ? destination : undefined);
19588
19588
  } else if ('id' in currency) {
19589
19589
  asset = findAssetInfoById(assets, currency.id);
19590
19590
  }
@@ -19761,37 +19761,43 @@ var findNativeAssetInfoOrThrow = function findNativeAssetInfoOrThrow(chain) {
19761
19761
  var extractEdFromAsset = function extractEdFromAsset(asset) {
19762
19762
  return asset.existentialDeposit ? BigInt(asset.existentialDeposit) : null;
19763
19763
  };
19764
- /**
19765
- * Retrieves the existential deposit value for a given chain.
19766
- *
19767
- * @param chain - The chain for which to get the existential deposit.
19768
- * @returns The existential deposit as a bigint if available; otherwise, null.
19769
- */
19770
- var getExistentialDeposit = function getExistentialDeposit(chain, currency) {
19764
+ var getExistentialDepositImpl = function getExistentialDepositImpl(chain, currency, ctx) {
19771
19765
  var asset;
19772
19766
  if (!currency) {
19773
- var _findAssetInfo;
19774
- var nativeAssetSymbol = getNativeAssetSymbol(chain);
19775
- asset = (_findAssetInfo = findAssetInfo(chain, {
19767
+ var _findAssetInfoImpl;
19768
+ var nativeAssetSymbol = getNativeAssetSymbolImpl(chain, ctx);
19769
+ asset = (_findAssetInfoImpl = findAssetInfoImpl(chain, {
19776
19770
  symbol: Native(nativeAssetSymbol)
19777
- })) !== null && _findAssetInfo !== void 0 ? _findAssetInfo : findAssetInfoOrThrow(chain, {
19771
+ }, undefined, ctx)) !== null && _findAssetInfoImpl !== void 0 ? _findAssetInfoImpl : findAssetInfoOrThrowImpl(chain, {
19778
19772
  symbol: nativeAssetSymbol
19779
- });
19773
+ }, undefined, ctx);
19780
19774
  } else {
19781
- asset = findAssetInfoOrThrow(chain, currency);
19775
+ asset = findAssetInfoOrThrowImpl(chain, currency, undefined, ctx);
19782
19776
  }
19783
19777
  return extractEdFromAsset(asset);
19784
19778
  };
19779
+ /**
19780
+ * Retrieves the existential deposit value for a given chain.
19781
+ *
19782
+ * @param chain - The chain for which to get the existential deposit.
19783
+ * @returns The existential deposit as a bigint if available; otherwise, null.
19784
+ */
19785
+ var getExistentialDeposit = function getExistentialDeposit(chain, currency) {
19786
+ return getExistentialDepositImpl(chain, currency);
19787
+ };
19785
19788
  var assertEdDefined = function assertEdDefined(ed, chain, currency) {
19786
19789
  if (ed === undefined || ed === null) {
19787
19790
  throw new InvalidCurrencyError("Existential deposit not found for currency ".concat(JSON.stringify(currency, replaceBigInt)).concat(chain ? " on chain ".concat(chain, ".") : '.'));
19788
19791
  }
19789
19792
  };
19790
- var getExistentialDepositOrThrow = function getExistentialDepositOrThrow(chain, currency) {
19791
- var ed = getExistentialDeposit(chain, currency);
19793
+ var getExistentialDepositOrThrowImpl = function getExistentialDepositOrThrowImpl(chain, currency, ctx) {
19794
+ var ed = getExistentialDepositImpl(chain, currency, ctx);
19792
19795
  assertEdDefined(ed, chain, currency);
19793
19796
  return ed;
19794
19797
  };
19798
+ var getExistentialDepositOrThrow = function getExistentialDepositOrThrow(chain, currency) {
19799
+ return getExistentialDepositOrThrowImpl(chain, currency);
19800
+ };
19795
19801
  var getEdFromAssetOrThrow = function getEdFromAssetOrThrow(asset) {
19796
19802
  var ed = extractEdFromAsset(asset);
19797
19803
  assertEdDefined(ed, undefined, asset);
@@ -20075,10 +20081,36 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
20075
20081
  return getSupportedAssetsImpl(origin, destination);
20076
20082
  };
20077
20083
 
20084
+ var isDestinationReachable = function isDestinationReachable(origin, destination) {
20085
+ if (isExternalChain(origin) || isExternalChain(destination)) {
20086
+ var substrateSide = isExternalChain(origin) ? destination : origin;
20087
+ if (isExternalChain(substrateSide)) return false;
20088
+ return ETHEREUM_BRIDGE_ORIGINS.includes(substrateSide);
20089
+ }
20090
+ if (isSubstrateBridge(origin, destination)) return true;
20091
+ return getRelayChainSymbol(origin) === getRelayChainSymbol(destination);
20092
+ };
20093
+ var isUnsupportedAssetHubNative = function isUnsupportedAssetHubNative(origin, destination, originAsset, nativeAssets) {
20094
+ if (isExternalChain(origin) || isExternalChain(destination)) return false;
20095
+ var originIsAssetHub = origin.startsWith('AssetHub');
20096
+ var destinationIsAssetHub = destination.startsWith('AssetHub');
20097
+ if (originIsAssetHub === destinationIsAssetHub) return false;
20098
+ if (isSystemAsset(originAsset)) return false;
20099
+ return nativeAssets.some(function (_native) {
20100
+ return isAssetEqual(originAsset, _native);
20101
+ });
20102
+ };
20078
20103
  var getSupportedDestinations = function getSupportedDestinations(origin, currency) {
20079
20104
  findAssetInfoOrThrow(origin, currency);
20105
+ var ecosystem = getRelayChainSymbol(origin);
20106
+ var nativeAssets = SUBSTRATE_CHAINS.filter(function (chain) {
20107
+ return getRelayChainSymbol(chain) === ecosystem;
20108
+ }).map(function (chain) {
20109
+ return findNativeAssetInfoOrThrow(chain);
20110
+ });
20080
20111
  return CHAINS.filter(function (destination) {
20081
20112
  if (destination === origin) return false;
20113
+ if (!isDestinationReachable(origin, destination)) return false;
20082
20114
  // Check if we still can find asset if we specify destination
20083
20115
  var originAsset;
20084
20116
  try {
@@ -20089,6 +20121,10 @@ var getSupportedDestinations = function getSupportedDestinations(origin, currenc
20089
20121
  }
20090
20122
  throw error;
20091
20123
  }
20124
+ if (isUnsupportedAssetHubNative(origin, destination, originAsset, nativeAssets)) return false;
20125
+ if (isSubstrateBridge(origin, destination)) {
20126
+ return isSystemAsset(originAsset) || isStableCoinAsset(originAsset);
20127
+ }
20092
20128
  try {
20093
20129
  return !!findAssetInfoOnDest(origin, destination, currency, originAsset);
20094
20130
  } catch (error) {
@@ -20100,4 +20136,4 @@ var getSupportedDestinations = function getSupportedDestinations(origin, currenc
20100
20136
  });
20101
20137
  };
20102
20138
 
20103
- export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasSupportForAsset, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeCustomAssets, normalizeLocation, normalizeSymbol };
20139
+ export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositImpl, getExistentialDepositOrThrow, getExistentialDepositOrThrowImpl, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasSupportForAsset, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeCustomAssets, normalizeLocation, normalizeSymbol };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/assets",
3
- "version": "13.6.0",
3
+ "version": "13.7.0",
4
4
  "description": "Assets for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@paraspell/sdk-common": "13.6.0"
25
+ "@paraspell/sdk-common": "13.7.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@babel/plugin-syntax-import-attributes": "^7.29.7",