@paraspell/assets 12.0.6 → 12.1.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
@@ -192,6 +192,8 @@ declare const isAssetEqual: (asset1: TAssetInfo, asset2: TAssetInfo) => boolean;
192
192
 
193
193
  declare const isAssetXcEqual: (asset1: TAssetInfo, asset2: TAssetInfo) => boolean;
194
194
 
195
+ declare const isStableCoinAsset: (asset: TAssetInfo, assetId?: number) => boolean;
196
+
195
197
  declare const isSymbolMatch: (symbolA: string, symbolB: string) => boolean;
196
198
 
197
199
  /**
@@ -279,5 +281,5 @@ declare const extractAssetLocation: <T = bigint>(asset: TAsset<T>) => TLocation;
279
281
 
280
282
  declare const getAssetLocation: (chain: TChain, currency: TCurrencyInput) => TLocation | null;
281
283
 
282
- 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, 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, isChainEvm, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isTAsset, normalizeLocation, normalizeSymbol };
283
285
  export type { TAmount, TAsset, TAssetInfo, TAssetInfoWithId, TAssetJsonMap, TAssetV3, TAssetV4, TAssetWithFee, TAssetWithLocation, 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, getJunctionValue, replaceBigInt, isSubstrateBridge, CHAINS } from '@paraspell/sdk-common';
1
+ import { Version, deepEqual, getJunctionValue, hasJunction, replaceBigInt, isSubstrateBridge, CHAINS } from '@paraspell/sdk-common';
2
2
 
3
3
  var Polkadot = {
4
4
  relaychainSymbol: "DOT",
@@ -20962,6 +20962,20 @@ var Override = function Override(location) {
20962
20962
  };
20963
20963
  };
20964
20964
 
20965
+ var STABLECOIN_IDS = [1984, 1337];
20966
+
20967
+ var hasStablecoinIndex = function hasStablecoinIndex(location, assetId) {
20968
+ return assetId !== undefined ? hasJunction(location, 'GeneralIndex', assetId) : STABLECOIN_IDS.some(function (id) {
20969
+ return hasJunction(location, 'GeneralIndex', id);
20970
+ });
20971
+ };
20972
+ var isStablecoinLocation = function isStablecoinLocation(location, assetId) {
20973
+ return !!location && hasJunction(location, 'PalletInstance', 50) && hasStablecoinIndex(location, assetId);
20974
+ };
20975
+ var isStableCoinAsset = function isStableCoinAsset(asset, assetId) {
20976
+ return isStablecoinLocation(asset.location, assetId);
20977
+ };
20978
+
20965
20979
  var findAssetInfoOrThrow = function findAssetInfoOrThrow(chain, currency, destination) {
20966
20980
  var asset = findAssetInfo(chain, currency, destination);
20967
20981
  if (!asset) {
@@ -20970,6 +20984,19 @@ var findAssetInfoOrThrow = function findAssetInfoOrThrow(chain, currency, destin
20970
20984
  return asset;
20971
20985
  };
20972
20986
 
20987
+ var findStablecoinAssets = function findStablecoinAssets(chain) {
20988
+ var assets = getOtherAssets(chain);
20989
+ return STABLECOIN_IDS.map(function (id) {
20990
+ var matches = assets.filter(function (asset) {
20991
+ return isStableCoinAsset(asset, id);
20992
+ });
20993
+ var consensusMatch = matches.find(function (asset) {
20994
+ return asset.location && hasJunction(asset.location, 'GlobalConsensus');
20995
+ });
20996
+ return consensusMatch !== null && consensusMatch !== void 0 ? consensusMatch : matches[0];
20997
+ });
20998
+ };
20999
+
20973
21000
  var findAssetInfoOnDest = function findAssetInfoOnDest(origin, destination, currency, originAsset) {
20974
21001
  var isBridge = isSubstrateBridge(origin, destination);
20975
21002
  var resolvedOriginAsset = originAsset !== null && originAsset !== void 0 ? originAsset : findAssetInfoOrThrow(origin, currency, destination);
@@ -20979,6 +21006,14 @@ var findAssetInfoOnDest = function findAssetInfoOnDest(origin, destination, curr
20979
21006
  symbol: Native(resolvedOriginAsset.symbol)
20980
21007
  }, null);
20981
21008
  if (nativeMatch) return nativeMatch;
21009
+ var isStablecoin = isStableCoinAsset(resolvedOriginAsset);
21010
+ if (isStablecoin) {
21011
+ var stablecoins = findStablecoinAssets(destination);
21012
+ var match = stablecoins.find(function (asset) {
21013
+ return asset.symbol === resolvedOriginAsset.symbol;
21014
+ });
21015
+ if (match) return match;
21016
+ }
20982
21017
  // Then try foreign
20983
21018
  var foreignMatch = findAssetInfo(destination, {
20984
21019
  symbol: Foreign(resolvedOriginAsset.symbol)
@@ -21246,9 +21281,11 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
21246
21281
  var destinationAssets = getAssets(destination);
21247
21282
  var isSubBridge = isSubstrateBridge(origin, destination);
21248
21283
  if (isSubBridge) {
21249
- return originAssets.filter(function (asset) {
21250
- return asset.symbol === 'KSM' || asset.symbol === 'DOT';
21284
+ var systemAssets = originAssets.filter(function (asset) {
21285
+ return ['DOT', 'KSM'].includes(asset.symbol);
21251
21286
  });
21287
+ var stablecoinAssets = findStablecoinAssets(origin);
21288
+ return [].concat(_toConsumableArray(systemAssets), _toConsumableArray(stablecoinAssets));
21252
21289
  }
21253
21290
  var supportedAssets = originAssets.filter(function (asset) {
21254
21291
  return destinationAssets.some(function (a) {
@@ -21293,4 +21330,4 @@ var isAssetEqual = function isAssetEqual(asset1, asset2) {
21293
21330
  return isSymbolMatch(asset1.symbol, asset2.symbol);
21294
21331
  };
21295
21332
 
21296
- 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, isSymbolMatch, isSymbolSpecifier, isTAsset, normalizeLocation, normalizeSymbol };
21333
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/assets",
3
- "version": "12.0.6",
3
+ "version": "12.1.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.0.6"
26
+ "@paraspell/sdk-common": "12.1.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@babel/plugin-syntax-import-attributes": "^7.27.1",