@paraspell/assets 12.7.0 → 12.8.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
@@ -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",
@@ -4593,6 +4593,29 @@ var Hydration = {
4593
4593
  },
4594
4594
  isFeeAsset: true
4595
4595
  },
4596
+ {
4597
+ assetId: "1043",
4598
+ symbol: "aPRIME",
4599
+ decimals: 6,
4600
+ existentialDeposit: "9901",
4601
+ location: {
4602
+ parents: 1,
4603
+ interior: {
4604
+ X2: [
4605
+ {
4606
+ Parachain: 2034
4607
+ },
4608
+ {
4609
+ AccountKey20: {
4610
+ network: null,
4611
+ key: "0x4c892a298a9c6b4ced988b3d6e9cf93333aadcf7"
4612
+ }
4613
+ }
4614
+ ]
4615
+ }
4616
+ },
4617
+ isFeeAsset: true
4618
+ },
4596
4619
  {
4597
4620
  assetId: "9",
4598
4621
  symbol: "ASTR",
@@ -19397,6 +19420,14 @@ function _createClass(e, r, t) {
19397
19420
  writable: false
19398
19421
  }), e;
19399
19422
  }
19423
+ function _defineProperty(e, r, t) {
19424
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
19425
+ value: t,
19426
+ enumerable: true,
19427
+ configurable: true,
19428
+ writable: true
19429
+ }) : e[r] = t, e;
19430
+ }
19400
19431
  function _getPrototypeOf(t) {
19401
19432
  return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
19402
19433
  return t.__proto__ || Object.getPrototypeOf(t);
@@ -19468,6 +19499,20 @@ function _setPrototypeOf(t, e) {
19468
19499
  function _toConsumableArray(r) {
19469
19500
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
19470
19501
  }
19502
+ function _toPrimitive(t, r) {
19503
+ if ("object" != typeof t || !t) return t;
19504
+ var e = t[Symbol.toPrimitive];
19505
+ if (void 0 !== e) {
19506
+ var i = e.call(t, r);
19507
+ if ("object" != typeof i) return i;
19508
+ throw new TypeError("@@toPrimitive must return a primitive value.");
19509
+ }
19510
+ return ("string" === r ? String : Number)(t);
19511
+ }
19512
+ function _toPropertyKey(t) {
19513
+ var i = _toPrimitive(t, "string");
19514
+ return "symbol" == typeof i ? i : i + "";
19515
+ }
19471
19516
  function _typeof(o) {
19472
19517
  "@babel/helpers - typeof";
19473
19518
 
@@ -19902,6 +19947,20 @@ var isStableCoinAsset = function isStableCoinAsset(asset, assetId) {
19902
19947
  return isStablecoinLocation(asset.location, assetId);
19903
19948
  };
19904
19949
 
19950
+ var isSystemAsset = function isSystemAsset(asset) {
19951
+ return deepEqual(asset.location, {
19952
+ parents: Parents.ONE,
19953
+ interior: {
19954
+ Here: null
19955
+ }
19956
+ }) || isBridgedSystemAsset(asset, RELAYCHAINS);
19957
+ };
19958
+ var isBridgedSystemAsset = function isBridgedSystemAsset(asset, relayChains) {
19959
+ return asset.location.parents === Parents.TWO && relayChains.some(function (relayChain) {
19960
+ return deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), _defineProperty({}, relayChain.toLowerCase(), null));
19961
+ });
19962
+ };
19963
+
19905
19964
  var findAssetInfoOrThrow = function findAssetInfoOrThrow(chain, currency, destination) {
19906
19965
  var asset = findAssetInfo(chain, currency, destination);
19907
19966
  if (!asset) {
@@ -19923,29 +19982,37 @@ var findStablecoinAssets = function findStablecoinAssets(chain) {
19923
19982
  });
19924
19983
  };
19925
19984
 
19985
+ var findAssetInfoOnSubBridgeDest = function findAssetInfoOnSubBridgeDest(destination, resolvedOriginAsset) {
19986
+ var nativeMatch = findAssetInfo(destination, {
19987
+ symbol: Native(resolvedOriginAsset.symbol)
19988
+ }, null);
19989
+ if (nativeMatch) return nativeMatch;
19990
+ var isStablecoin = isStableCoinAsset(resolvedOriginAsset);
19991
+ if (isStablecoin) {
19992
+ var stablecoins = findStablecoinAssets(destination);
19993
+ var match = stablecoins.find(function (asset) {
19994
+ return asset.symbol === resolvedOriginAsset.symbol;
19995
+ });
19996
+ if (match) return match;
19997
+ }
19998
+ var foreignMatch = findAssetInfo(destination, {
19999
+ symbol: Foreign(resolvedOriginAsset.symbol)
20000
+ }, null);
20001
+ if (foreignMatch) return foreignMatch;
20002
+ return null;
20003
+ };
19926
20004
  var findAssetInfoOnDest = function findAssetInfoOnDest(origin, destination, currency, originAsset) {
19927
- var isBridge = isSubstrateBridge(origin, destination);
20005
+ var isSubBridge = isSubstrateBridge(origin, destination);
20006
+ var isSb = isSnowbridge(origin, destination);
19928
20007
  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)
20008
+ if (isSubBridge) {
20009
+ return findAssetInfoOnSubBridgeDest(destination, resolvedOriginAsset);
20010
+ }
20011
+ if (isSb && isSystemAsset(resolvedOriginAsset)) {
20012
+ var match = findAssetInfo(destination, {
20013
+ symbol: resolvedOriginAsset.symbol
19946
20014
  }, null);
19947
- if (foreignMatch) return foreignMatch;
19948
- return null;
20015
+ if (match) return match;
19949
20016
  }
19950
20017
  return findAssetInfo(destination, {
19951
20018
  location: resolvedOriginAsset.location
@@ -20205,19 +20272,29 @@ var isAssetXcEqual = function isAssetXcEqual(asset1, asset2) {
20205
20272
  var getSupportedAssets = function getSupportedAssets(origin, destination) {
20206
20273
  var originAssets = getAssets(origin);
20207
20274
  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
20275
  var supportedAssets = originAssets.filter(function (asset) {
20217
20276
  return destinationAssets.some(function (a) {
20218
20277
  return isAssetXcEqual(a, asset);
20219
20278
  });
20220
20279
  });
20280
+ var isSubBridge = isSubstrateBridge(origin, destination);
20281
+ var isSb = isSnowbridge(origin, destination);
20282
+ if (isSubBridge || isSb) {
20283
+ var systemAssets = originAssets.filter(function (asset) {
20284
+ return isSystemAsset(asset);
20285
+ });
20286
+ if (isSubBridge) {
20287
+ var nativeSymbols = [origin, destination].map(getNativeAssetSymbol);
20288
+ var filteredSystemAssets = systemAssets.filter(function (_ref) {
20289
+ var symbol = _ref.symbol;
20290
+ return nativeSymbols.includes(symbol);
20291
+ });
20292
+ var stablecoinAssets = findStablecoinAssets(origin);
20293
+ return [].concat(_toConsumableArray(filteredSystemAssets), _toConsumableArray(stablecoinAssets));
20294
+ } else {
20295
+ return [].concat(_toConsumableArray(systemAssets), _toConsumableArray(supportedAssets));
20296
+ }
20297
+ }
20221
20298
  return supportedAssets;
20222
20299
  };
20223
20300
 
@@ -20246,4 +20323,4 @@ var getSupportedDestinations = function getSupportedDestinations(origin, currenc
20246
20323
  });
20247
20324
  };
20248
20325
 
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 };
20326
+ 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.7.0",
3
+ "version": "12.8.0",
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.7.0"
26
+ "@paraspell/sdk-common": "12.8.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@babel/plugin-syntax-import-attributes": "^7.28.6",