@paraspell/assets 12.6.3 → 12.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TLocation, TChain, Version } from '@paraspell/sdk-common';
1
+ import { TLocation, TChain, TRelaychain, Version } from '@paraspell/sdk-common';
2
2
 
3
3
  type TAsset<T = bigint> = TAssetV3<T> | TAssetV4<T>;
4
4
  interface TAssetV3<T = bigint> {
@@ -193,6 +193,9 @@ declare const isStableCoinAsset: (asset: TAssetInfo, assetId?: number) => boolea
193
193
 
194
194
  declare const isSymbolMatch: (symbolA: string, symbolB: string) => boolean;
195
195
 
196
+ declare const isSystemAsset: (asset: TAssetInfo) => boolean;
197
+ declare const isBridgedSystemAsset: (asset: TAssetInfo, relayChains: readonly TRelaychain[]) => boolean;
198
+
196
199
  /**
197
200
  * Converts a location to a specific XCM version
198
201
  *
@@ -278,5 +281,5 @@ declare const extractAssetLocation: <T = bigint>(asset: TAsset<T>) => TLocation;
278
281
 
279
282
  declare const getAssetLocation: (chain: TChain, currency: TCurrencyInput) => TLocation | null;
280
283
 
281
- export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoOnDest, findAssetInfoOrThrow, findAssetOnDestOrThrow, findBestMatches, findNativeAssetInfo, findNativeAssetInfoOrThrow, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsObject, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getSupportedDestinations, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isAssetXcEqual, isChainEvm, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isTAsset, normalizeLocation, normalizeSymbol };
284
+ export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoOnDest, findAssetInfoOrThrow, findAssetOnDestOrThrow, findBestMatches, findNativeAssetInfo, findNativeAssetInfoOrThrow, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsObject, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getSupportedDestinations, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeLocation, normalizeSymbol };
282
285
  export type { TAmount, TAsset, TAssetInfo, TAssetInfoWithId, TAssetJsonMap, TAssetV3, TAssetV4, TAssetWithFee, TChainAssetsInfo, TCurrency, TCurrencyCore, TCurrencyInput, TCurrencyInputWithAmount, TCurrencySymbol, TCurrencySymbolValue, TLocationValue, TLocationValueWithOverride, TOverrideLocationSpecifier, TSymbolSpecifier, WithAmount, WithComplexAmount };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Version, deepEqual, isExternalChain, getJunctionValue, hasJunction, replaceBigInt, isSubstrateBridge, CHAINS } from '@paraspell/sdk-common';
1
+ import { Version, deepEqual, isExternalChain, getJunctionValue, hasJunction, Parents, RELAYCHAINS, replaceBigInt, isSubstrateBridge, isSnowbridge, CHAINS } from '@paraspell/sdk-common';
2
2
 
3
3
  var Polkadot = {
4
4
  relaychainSymbol: "DOT",
@@ -19397,6 +19397,14 @@ function _createClass(e, r, t) {
19397
19397
  writable: false
19398
19398
  }), e;
19399
19399
  }
19400
+ function _defineProperty(e, r, t) {
19401
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
19402
+ value: t,
19403
+ enumerable: true,
19404
+ configurable: true,
19405
+ writable: true
19406
+ }) : e[r] = t, e;
19407
+ }
19400
19408
  function _getPrototypeOf(t) {
19401
19409
  return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
19402
19410
  return t.__proto__ || Object.getPrototypeOf(t);
@@ -19468,6 +19476,20 @@ function _setPrototypeOf(t, e) {
19468
19476
  function _toConsumableArray(r) {
19469
19477
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
19470
19478
  }
19479
+ function _toPrimitive(t, r) {
19480
+ if ("object" != typeof t || !t) return t;
19481
+ var e = t[Symbol.toPrimitive];
19482
+ if (void 0 !== e) {
19483
+ var i = e.call(t, r);
19484
+ if ("object" != typeof i) return i;
19485
+ throw new TypeError("@@toPrimitive must return a primitive value.");
19486
+ }
19487
+ return ("string" === r ? String : Number)(t);
19488
+ }
19489
+ function _toPropertyKey(t) {
19490
+ var i = _toPrimitive(t, "string");
19491
+ return "symbol" == typeof i ? i : i + "";
19492
+ }
19471
19493
  function _typeof(o) {
19472
19494
  "@babel/helpers - typeof";
19473
19495
 
@@ -19902,6 +19924,20 @@ var isStableCoinAsset = function isStableCoinAsset(asset, assetId) {
19902
19924
  return isStablecoinLocation(asset.location, assetId);
19903
19925
  };
19904
19926
 
19927
+ var isSystemAsset = function isSystemAsset(asset) {
19928
+ return deepEqual(asset.location, {
19929
+ parents: Parents.ONE,
19930
+ interior: {
19931
+ Here: null
19932
+ }
19933
+ }) || isBridgedSystemAsset(asset, RELAYCHAINS);
19934
+ };
19935
+ var isBridgedSystemAsset = function isBridgedSystemAsset(asset, relayChains) {
19936
+ return asset.location.parents === Parents.TWO && relayChains.some(function (relayChain) {
19937
+ return deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), _defineProperty({}, relayChain.toLowerCase(), null));
19938
+ });
19939
+ };
19940
+
19905
19941
  var findAssetInfoOrThrow = function findAssetInfoOrThrow(chain, currency, destination) {
19906
19942
  var asset = findAssetInfo(chain, currency, destination);
19907
19943
  if (!asset) {
@@ -19923,29 +19959,37 @@ var findStablecoinAssets = function findStablecoinAssets(chain) {
19923
19959
  });
19924
19960
  };
19925
19961
 
19962
+ var findAssetInfoOnSubBridgeDest = function findAssetInfoOnSubBridgeDest(destination, resolvedOriginAsset) {
19963
+ var nativeMatch = findAssetInfo(destination, {
19964
+ symbol: Native(resolvedOriginAsset.symbol)
19965
+ }, null);
19966
+ if (nativeMatch) return nativeMatch;
19967
+ var isStablecoin = isStableCoinAsset(resolvedOriginAsset);
19968
+ if (isStablecoin) {
19969
+ var stablecoins = findStablecoinAssets(destination);
19970
+ var match = stablecoins.find(function (asset) {
19971
+ return asset.symbol === resolvedOriginAsset.symbol;
19972
+ });
19973
+ if (match) return match;
19974
+ }
19975
+ var foreignMatch = findAssetInfo(destination, {
19976
+ symbol: Foreign(resolvedOriginAsset.symbol)
19977
+ }, null);
19978
+ if (foreignMatch) return foreignMatch;
19979
+ return null;
19980
+ };
19926
19981
  var findAssetInfoOnDest = function findAssetInfoOnDest(origin, destination, currency, originAsset) {
19927
- var isBridge = isSubstrateBridge(origin, destination);
19982
+ var isSubBridge = isSubstrateBridge(origin, destination);
19983
+ var isSb = isSnowbridge(origin, destination);
19928
19984
  var resolvedOriginAsset = originAsset !== null && originAsset !== void 0 ? originAsset : findAssetInfoOrThrow(origin, currency, destination);
19929
- if (isBridge) {
19930
- // Try native first
19931
- var nativeMatch = findAssetInfo(destination, {
19932
- symbol: Native(resolvedOriginAsset.symbol)
19933
- }, null);
19934
- if (nativeMatch) return nativeMatch;
19935
- var isStablecoin = isStableCoinAsset(resolvedOriginAsset);
19936
- if (isStablecoin) {
19937
- var stablecoins = findStablecoinAssets(destination);
19938
- var match = stablecoins.find(function (asset) {
19939
- return asset.symbol === resolvedOriginAsset.symbol;
19940
- });
19941
- if (match) return match;
19942
- }
19943
- // Then try foreign
19944
- var foreignMatch = findAssetInfo(destination, {
19945
- symbol: Foreign(resolvedOriginAsset.symbol)
19985
+ if (isSubBridge) {
19986
+ return findAssetInfoOnSubBridgeDest(destination, resolvedOriginAsset);
19987
+ }
19988
+ if (isSb && isSystemAsset(resolvedOriginAsset)) {
19989
+ var match = findAssetInfo(destination, {
19990
+ symbol: resolvedOriginAsset.symbol
19946
19991
  }, null);
19947
- if (foreignMatch) return foreignMatch;
19948
- return null;
19992
+ if (match) return match;
19949
19993
  }
19950
19994
  return findAssetInfo(destination, {
19951
19995
  location: resolvedOriginAsset.location
@@ -20205,19 +20249,29 @@ var isAssetXcEqual = function isAssetXcEqual(asset1, asset2) {
20205
20249
  var getSupportedAssets = function getSupportedAssets(origin, destination) {
20206
20250
  var originAssets = getAssets(origin);
20207
20251
  var destinationAssets = getAssets(destination);
20208
- var isSubBridge = isSubstrateBridge(origin, destination);
20209
- if (isSubBridge) {
20210
- var systemAssets = originAssets.filter(function (asset) {
20211
- return ['DOT', 'KSM'].includes(asset.symbol);
20212
- });
20213
- var stablecoinAssets = findStablecoinAssets(origin);
20214
- return [].concat(_toConsumableArray(systemAssets), _toConsumableArray(stablecoinAssets));
20215
- }
20216
20252
  var supportedAssets = originAssets.filter(function (asset) {
20217
20253
  return destinationAssets.some(function (a) {
20218
20254
  return isAssetXcEqual(a, asset);
20219
20255
  });
20220
20256
  });
20257
+ var isSubBridge = isSubstrateBridge(origin, destination);
20258
+ var isSb = isSnowbridge(origin, destination);
20259
+ if (isSubBridge || isSb) {
20260
+ var systemAssets = originAssets.filter(function (asset) {
20261
+ return isSystemAsset(asset);
20262
+ });
20263
+ if (isSubBridge) {
20264
+ var nativeSymbols = [origin, destination].map(getNativeAssetSymbol);
20265
+ var filteredSystemAssets = systemAssets.filter(function (_ref) {
20266
+ var symbol = _ref.symbol;
20267
+ return nativeSymbols.includes(symbol);
20268
+ });
20269
+ var stablecoinAssets = findStablecoinAssets(origin);
20270
+ return [].concat(_toConsumableArray(filteredSystemAssets), _toConsumableArray(stablecoinAssets));
20271
+ } else {
20272
+ return [].concat(_toConsumableArray(systemAssets), _toConsumableArray(supportedAssets));
20273
+ }
20274
+ }
20221
20275
  return supportedAssets;
20222
20276
  };
20223
20277
 
@@ -20246,4 +20300,4 @@ var getSupportedDestinations = function getSupportedDestinations(origin, currenc
20246
20300
  });
20247
20301
  };
20248
20302
 
20249
- export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoOnDest, findAssetInfoOrThrow, findAssetOnDestOrThrow, findBestMatches, findNativeAssetInfo, findNativeAssetInfoOrThrow, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsObject, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getSupportedDestinations, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isAssetXcEqual, isChainEvm, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isTAsset, normalizeLocation, normalizeSymbol };
20303
+ export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoOnDest, findAssetInfoOrThrow, findAssetOnDestOrThrow, findBestMatches, findNativeAssetInfo, findNativeAssetInfoOrThrow, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsObject, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getSupportedDestinations, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeLocation, normalizeSymbol };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/assets",
3
- "version": "12.6.3",
3
+ "version": "12.7.1",
4
4
  "description": "Assets for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@paraspell/sdk-common": "12.6.3"
26
+ "@paraspell/sdk-common": "12.7.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@babel/plugin-syntax-import-attributes": "^7.28.6",