@paraspell/assets 10.4.9 → 10.5.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.cjs CHANGED
@@ -12232,16 +12232,23 @@ var findAssetForNodeOrThrow = function findAssetForNodeOrThrow(node, currency, d
12232
12232
  return asset;
12233
12233
  };
12234
12234
 
12235
- var findAssetOnDestOrThrow = function findAssetOnDestOrThrow(origin, destination, currency) {
12235
+ var findAssetOnDest = function findAssetOnDest(origin, destination, currency, originAsset) {
12236
12236
  var isDotKsmBridge = origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot';
12237
- var originAsset = findAssetForNodeOrThrow(origin, currency, destination);
12238
- var assetByMultiLocation = !isDotKsmBridge && originAsset.multiLocation ? findAsset(destination, {
12239
- multilocation: originAsset.multiLocation
12237
+ var resolvedOriginAsset = originAsset !== null && originAsset !== void 0 ? originAsset : findAssetForNodeOrThrow(origin, currency, destination);
12238
+ var assetByMultiLocation = !isDotKsmBridge && resolvedOriginAsset.multiLocation ? findAsset(destination, {
12239
+ multilocation: resolvedOriginAsset.multiLocation
12240
12240
  }, null) : null;
12241
- return assetByMultiLocation !== null && assetByMultiLocation !== void 0 ? assetByMultiLocation : findAssetForNodeOrThrow(destination, {
12242
- symbol: originAsset.symbol
12241
+ return assetByMultiLocation !== null && assetByMultiLocation !== void 0 ? assetByMultiLocation : findAsset(destination, {
12242
+ symbol: resolvedOriginAsset.symbol
12243
12243
  }, null);
12244
12244
  };
12245
+ var findAssetOnDestOrThrow = function findAssetOnDestOrThrow(origin, destination, currency) {
12246
+ var asset = findAssetOnDest(origin, destination, currency);
12247
+ if (!asset) {
12248
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency, sdkCommon.replaceBigInt), " not found on ").concat(destination));
12249
+ }
12250
+ return asset;
12251
+ };
12245
12252
 
12246
12253
  /**
12247
12254
  * Retrieves the existential deposit value for a given node.
@@ -12465,6 +12472,7 @@ var normalizeSymbol = function normalizeSymbol(symbol) {
12465
12472
  var lowerSymbol = symbol.toLowerCase();
12466
12473
  return lowerSymbol.startsWith('xc') ? lowerSymbol.substring(2) : lowerSymbol;
12467
12474
  };
12475
+
12468
12476
  /**
12469
12477
  * Retrieves the list of assets that are supported for transfers between two specified nodes.
12470
12478
  *
@@ -12507,6 +12515,31 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
12507
12515
  return supportedAssets;
12508
12516
  };
12509
12517
 
12518
+ var getSupportedDestinations = function getSupportedDestinations(origin, currency) {
12519
+ findAssetForNodeOrThrow(origin, currency, null);
12520
+ return sdkCommon.NODES_WITH_RELAY_CHAINS.filter(function (destination) {
12521
+ if (destination === origin) return false;
12522
+ // Check if we still can find asset if we specify destination
12523
+ var originAsset;
12524
+ try {
12525
+ originAsset = findAssetForNodeOrThrow(origin, currency, destination);
12526
+ } catch (error) {
12527
+ if (error instanceof InvalidCurrencyError) {
12528
+ return false;
12529
+ }
12530
+ throw error;
12531
+ }
12532
+ try {
12533
+ return !!findAssetOnDest(origin, destination, currency, originAsset);
12534
+ } catch (error) {
12535
+ if (error instanceof DuplicateAssetError) {
12536
+ return true;
12537
+ }
12538
+ throw error;
12539
+ }
12540
+ });
12541
+ };
12542
+
12510
12543
  var isAssetEqual = function isAssetEqual(asset1, asset2) {
12511
12544
  var ml1 = asset1.multiLocation;
12512
12545
  var ml2 = asset2.multiLocation;
@@ -12542,6 +12575,7 @@ exports.findAssetById = findAssetById;
12542
12575
  exports.findAssetByMultiLocation = findAssetByMultiLocation;
12543
12576
  exports.findAssetBySymbol = findAssetBySymbol;
12544
12577
  exports.findAssetForNodeOrThrow = findAssetForNodeOrThrow;
12578
+ exports.findAssetOnDest = findAssetOnDest;
12545
12579
  exports.findAssetOnDestOrThrow = findAssetOnDestOrThrow;
12546
12580
  exports.findBestMatches = findBestMatches;
12547
12581
  exports.getAllAssetsSymbols = getAllAssetsSymbols;
@@ -12558,6 +12592,7 @@ exports.getNativeAssets = getNativeAssets;
12558
12592
  exports.getOtherAssets = getOtherAssets;
12559
12593
  exports.getRelayChainSymbol = getRelayChainSymbol;
12560
12594
  exports.getSupportedAssets = getSupportedAssets;
12595
+ exports.getSupportedDestinations = getSupportedDestinations;
12561
12596
  exports.hasDryRunSupport = hasDryRunSupport;
12562
12597
  exports.hasSupportForAsset = hasSupportForAsset;
12563
12598
  exports.hasXcmPaymentApiSupport = hasXcmPaymentApiSupport;
package/dist/index.d.ts CHANGED
@@ -185,13 +185,6 @@ declare const Override: (multiLocation: TMultiLocation) => TOverrideMultiLocatio
185
185
 
186
186
  declare const filterEthCompatibleAssets: (assets: TForeignAsset[]) => TForeignAsset[];
187
187
 
188
- /**
189
- * Normalizes an asset symbol by stripping the 'xc' prefix (if present) and converting it to lowercase.
190
- *
191
- * @param symbol - The symbol to normalize.
192
- * @returns The normalized symbol.
193
- */
194
- declare const normalizeSymbol: (symbol: string | undefined) => string;
195
188
  /**
196
189
  * Retrieves the list of assets that are supported for transfers between two specified nodes.
197
190
  *
@@ -201,6 +194,8 @@ declare const normalizeSymbol: (symbol: string | undefined) => string;
201
194
  */
202
195
  declare const getSupportedAssets: (origin: TNodeWithRelayChains, destination: TNodeWithRelayChains) => TAsset[];
203
196
 
197
+ declare const getSupportedDestinations: (origin: TNodeWithRelayChains, currency: TCurrencyCore) => TNodeWithRelayChains[];
198
+
204
199
  declare const isAssetEqual: (asset1: TAsset, asset2: TAsset) => boolean;
205
200
 
206
201
  /**
@@ -214,6 +209,14 @@ declare const isAssetEqual: (asset1: TAsset, asset2: TAsset) => boolean;
214
209
  */
215
210
  declare const normalizeMultiLocation: (multiLocation: TMultiLocation, version?: Version) => TMultiLocation;
216
211
 
212
+ /**
213
+ * Normalizes an asset symbol by stripping the 'xc' prefix (if present) and converting it to lowercase.
214
+ *
215
+ * @param symbol - The symbol to normalize.
216
+ * @returns The normalized symbol.
217
+ */
218
+ declare const normalizeSymbol: (symbol: string | undefined) => string;
219
+
217
220
  declare const findAsset: (node: TNodeWithRelayChains, currency: TCurrencyInput, destination: TNodeWithRelayChains | null) => TAsset | null;
218
221
 
219
222
  declare const findAssetById: (assets: TForeignAsset[], assetId: TCurrency) => TForeignAsset | undefined;
@@ -224,6 +227,7 @@ declare const findAssetBySymbol: (node: TNodeWithRelayChains, destination: TNode
224
227
 
225
228
  declare const findAssetForNodeOrThrow: (node: TNodeWithRelayChains, currency: TCurrencyInput, destination: TNodeWithRelayChains | null) => TAsset;
226
229
 
230
+ declare const findAssetOnDest: (origin: TNodeWithRelayChains, destination: TNodeWithRelayChains, currency: TCurrencyInput, originAsset?: TAsset | null) => TAsset | null;
227
231
  declare const findAssetOnDestOrThrow: (origin: TNodeWithRelayChains, destination: TNodeWithRelayChains, currency: TCurrencyInput) => TAsset;
228
232
 
229
233
  declare const findBestMatches: <T extends {
@@ -281,5 +285,5 @@ declare const extractMultiAssetLoc: (multiAsset: TMultiAsset) => TMultiLocation;
281
285
 
282
286
  declare const getAssetMultiLocation: (node: TNodeWithRelayChains, currency: TCurrencyInput) => TMultiLocation | null;
283
287
 
284
- export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, compareMultiLocations, extractMultiAssetLoc, filterEthCompatibleAssets, findAsset, findAssetById, findAssetByMultiLocation, findAssetBySymbol, findAssetForNodeOrThrow, findAssetOnDestOrThrow, findBestMatches, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetMultiLocation, getAssets, getAssetsObject, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isSymbolSpecifier, isTMultiAsset, normalizeMultiLocation, normalizeSymbol };
288
+ export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, compareMultiLocations, extractMultiAssetLoc, filterEthCompatibleAssets, findAsset, findAssetById, findAssetByMultiLocation, findAssetBySymbol, findAssetForNodeOrThrow, findAssetOnDest, findAssetOnDestOrThrow, findBestMatches, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetMultiLocation, getAssets, getAssetsObject, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getSupportedDestinations, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isSymbolSpecifier, isTMultiAsset, normalizeMultiLocation, normalizeSymbol };
285
289
  export type { TAmount, TAsset, TAssetJsonMap, TCurrency, TCurrencyCore, TCurrencyInput, TCurrencyInputWithAmount, TCurrencySymbol, TCurrencySymbolValue, TForeignAsset, TMultiAsset, TMultiAssetV3, TMultiAssetV4, TMultiAssetWithFee, TMultiLocationValue, TMultiLocationValueWithOverride, TNativeAsset, TNodeAssets, TOverrideMultiLocationSpecifier, TSymbolSpecifier, WithAmount };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Version, deepEqual, replaceBigInt } from '@paraspell/sdk-common';
1
+ import { Version, deepEqual, replaceBigInt, NODES_WITH_RELAY_CHAINS } from '@paraspell/sdk-common';
2
2
 
3
3
  function _arrayLikeToArray(r, a) {
4
4
  (null == a || a > r.length) && (a = r.length);
@@ -12230,16 +12230,23 @@ var findAssetForNodeOrThrow = function findAssetForNodeOrThrow(node, currency, d
12230
12230
  return asset;
12231
12231
  };
12232
12232
 
12233
- var findAssetOnDestOrThrow = function findAssetOnDestOrThrow(origin, destination, currency) {
12233
+ var findAssetOnDest = function findAssetOnDest(origin, destination, currency, originAsset) {
12234
12234
  var isDotKsmBridge = origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot';
12235
- var originAsset = findAssetForNodeOrThrow(origin, currency, destination);
12236
- var assetByMultiLocation = !isDotKsmBridge && originAsset.multiLocation ? findAsset(destination, {
12237
- multilocation: originAsset.multiLocation
12235
+ var resolvedOriginAsset = originAsset !== null && originAsset !== void 0 ? originAsset : findAssetForNodeOrThrow(origin, currency, destination);
12236
+ var assetByMultiLocation = !isDotKsmBridge && resolvedOriginAsset.multiLocation ? findAsset(destination, {
12237
+ multilocation: resolvedOriginAsset.multiLocation
12238
12238
  }, null) : null;
12239
- return assetByMultiLocation !== null && assetByMultiLocation !== void 0 ? assetByMultiLocation : findAssetForNodeOrThrow(destination, {
12240
- symbol: originAsset.symbol
12239
+ return assetByMultiLocation !== null && assetByMultiLocation !== void 0 ? assetByMultiLocation : findAsset(destination, {
12240
+ symbol: resolvedOriginAsset.symbol
12241
12241
  }, null);
12242
12242
  };
12243
+ var findAssetOnDestOrThrow = function findAssetOnDestOrThrow(origin, destination, currency) {
12244
+ var asset = findAssetOnDest(origin, destination, currency);
12245
+ if (!asset) {
12246
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency, replaceBigInt), " not found on ").concat(destination));
12247
+ }
12248
+ return asset;
12249
+ };
12243
12250
 
12244
12251
  /**
12245
12252
  * Retrieves the existential deposit value for a given node.
@@ -12463,6 +12470,7 @@ var normalizeSymbol = function normalizeSymbol(symbol) {
12463
12470
  var lowerSymbol = symbol.toLowerCase();
12464
12471
  return lowerSymbol.startsWith('xc') ? lowerSymbol.substring(2) : lowerSymbol;
12465
12472
  };
12473
+
12466
12474
  /**
12467
12475
  * Retrieves the list of assets that are supported for transfers between two specified nodes.
12468
12476
  *
@@ -12505,6 +12513,31 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
12505
12513
  return supportedAssets;
12506
12514
  };
12507
12515
 
12516
+ var getSupportedDestinations = function getSupportedDestinations(origin, currency) {
12517
+ findAssetForNodeOrThrow(origin, currency, null);
12518
+ return NODES_WITH_RELAY_CHAINS.filter(function (destination) {
12519
+ if (destination === origin) return false;
12520
+ // Check if we still can find asset if we specify destination
12521
+ var originAsset;
12522
+ try {
12523
+ originAsset = findAssetForNodeOrThrow(origin, currency, destination);
12524
+ } catch (error) {
12525
+ if (error instanceof InvalidCurrencyError) {
12526
+ return false;
12527
+ }
12528
+ throw error;
12529
+ }
12530
+ try {
12531
+ return !!findAssetOnDest(origin, destination, currency, originAsset);
12532
+ } catch (error) {
12533
+ if (error instanceof DuplicateAssetError) {
12534
+ return true;
12535
+ }
12536
+ throw error;
12537
+ }
12538
+ });
12539
+ };
12540
+
12508
12541
  var isAssetEqual = function isAssetEqual(asset1, asset2) {
12509
12542
  var ml1 = asset1.multiLocation;
12510
12543
  var ml2 = asset2.multiLocation;
@@ -12525,4 +12558,4 @@ var getAssetMultiLocation = function getAssetMultiLocation(node, currency) {
12525
12558
  return asset.multiLocation;
12526
12559
  };
12527
12560
 
12528
- export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, compareMultiLocations, extractMultiAssetLoc, filterEthCompatibleAssets, findAsset, findAssetById, findAssetByMultiLocation, findAssetBySymbol, findAssetForNodeOrThrow, findAssetOnDestOrThrow, findBestMatches, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetMultiLocation, getAssets, getAssetsObject, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isSymbolSpecifier, isTMultiAsset, normalizeMultiLocation, normalizeSymbol };
12561
+ export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, compareMultiLocations, extractMultiAssetLoc, filterEthCompatibleAssets, findAsset, findAssetById, findAssetByMultiLocation, findAssetBySymbol, findAssetForNodeOrThrow, findAssetOnDest, findAssetOnDestOrThrow, findBestMatches, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetMultiLocation, getAssets, getAssetsObject, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getSupportedDestinations, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isSymbolSpecifier, isTMultiAsset, normalizeMultiLocation, normalizeSymbol };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/assets",
3
- "version": "10.4.9",
3
+ "version": "10.5.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": "10.4.9"
26
+ "@paraspell/sdk-common": "10.5.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@babel/plugin-syntax-import-attributes": "^7.27.1",