@paraspell/assets 9.2.2 → 10.0.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
@@ -11742,6 +11742,31 @@ var assetsMapJson = {
11742
11742
  Peaq: Peaq
11743
11743
  };
11744
11744
 
11745
+ var isForeignAsset = function isForeignAsset(asset) {
11746
+ return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset) && !('isNative' in asset);
11747
+ };
11748
+
11749
+ var isOverrideMultiLocationSpecifier = function isOverrideMultiLocationSpecifier(multiLocationSpecifier) {
11750
+ return _typeof(multiLocationSpecifier) === 'object' && 'type' in multiLocationSpecifier && 'value' in multiLocationSpecifier;
11751
+ };
11752
+
11753
+ var isSymbolSpecifier = function isSymbolSpecifier(currencySymbolValue) {
11754
+ return _typeof(currencySymbolValue) === 'object' && 'type' in currencySymbolValue && 'value' in currencySymbolValue;
11755
+ };
11756
+
11757
+ var isTMultiAsset = function isTMultiAsset(value) {
11758
+ return _typeof(value) === 'object' && value !== null && 'id' in value && 'fun' in value;
11759
+ };
11760
+
11761
+ var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
11762
+ var ethAssets = getOtherAssets('Ethereum');
11763
+ return assets.filter(function (asset) {
11764
+ var assetMultiLoc = asset.multiLocation;
11765
+ if (!assetMultiLoc) return false;
11766
+ return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
11767
+ });
11768
+ };
11769
+
11745
11770
  /**
11746
11771
  * Error thrown when multiple assets with the same symbol are found.
11747
11772
  */
@@ -11802,31 +11827,6 @@ var InvalidCurrencyError = /*#__PURE__*/function (_Error) {
11802
11827
  return _createClass(InvalidCurrencyError);
11803
11828
  }(/*#__PURE__*/_wrapNativeSuper(Error));
11804
11829
 
11805
- var isForeignAsset = function isForeignAsset(asset) {
11806
- return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset) && !('isNative' in asset);
11807
- };
11808
-
11809
- var isOverrideMultiLocationSpecifier = function isOverrideMultiLocationSpecifier(multiLocationSpecifier) {
11810
- return _typeof(multiLocationSpecifier) === 'object' && 'type' in multiLocationSpecifier && 'value' in multiLocationSpecifier;
11811
- };
11812
-
11813
- var isSymbolSpecifier = function isSymbolSpecifier(currencySymbolValue) {
11814
- return _typeof(currencySymbolValue) === 'object' && 'type' in currencySymbolValue && 'value' in currencySymbolValue;
11815
- };
11816
-
11817
- var isTMultiAsset = function isTMultiAsset(value) {
11818
- return _typeof(value) === 'object' && value !== null && 'id' in value && 'fun' in value;
11819
- };
11820
-
11821
- var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
11822
- var ethAssets = getOtherAssets('Ethereum');
11823
- return assets.filter(function (asset) {
11824
- var assetMultiLoc = asset.multiLocation;
11825
- if (!assetMultiLoc) return false;
11826
- return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
11827
- });
11828
- };
11829
-
11830
11830
  var findAssetById = function findAssetById(assets, assetId) {
11831
11831
  var otherAssetsMatches = assets.filter(function (_ref) {
11832
11832
  var currentAssetId = _ref.assetId;
@@ -12134,6 +12134,25 @@ var findAsset = function findAsset(node, currency, destination) {
12134
12134
  return asset !== null && asset !== void 0 ? asset : null;
12135
12135
  };
12136
12136
 
12137
+ var findAssetForNodeOrThrow = function findAssetForNodeOrThrow(node, currency, destination) {
12138
+ var _findAsset;
12139
+ var asset = (_findAsset = findAsset(node, currency, destination)) !== null && _findAsset !== void 0 ? _findAsset : node === 'AssetHubPolkadot' ? findAsset('Ethereum', currency, null) : null;
12140
+ if (!asset) {
12141
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
12142
+ }
12143
+ return asset;
12144
+ };
12145
+
12146
+ var findAssetOnDestOrThrow = function findAssetOnDestOrThrow(origin, destination, currency) {
12147
+ var originAsset = findAssetForNodeOrThrow(origin, currency, destination);
12148
+ var assetByMultiLocation = originAsset.multiLocation ? findAsset(destination, {
12149
+ multilocation: originAsset.multiLocation
12150
+ }, null) : null;
12151
+ return assetByMultiLocation !== null && assetByMultiLocation !== void 0 ? assetByMultiLocation : findAssetForNodeOrThrow(destination, {
12152
+ symbol: originAsset.symbol
12153
+ }, null);
12154
+ };
12155
+
12137
12156
  /**
12138
12157
  * Retrieves the existential deposit value for a given node.
12139
12158
  *
@@ -12141,16 +12160,13 @@ var findAsset = function findAsset(node, currency, destination) {
12141
12160
  * @returns The existential deposit as a string if available; otherwise, null.
12142
12161
  */
12143
12162
  var getExistentialDeposit = function getExistentialDeposit(node, currency) {
12144
- var _findAsset, _asset$existentialDep;
12163
+ var _asset$existentialDep;
12145
12164
  var assetsObject = getAssetsObject(node);
12146
12165
  if (!currency) {
12147
12166
  var _assetsObject$nativeA;
12148
12167
  return (_assetsObject$nativeA = assetsObject.nativeAssets[0].existentialDeposit) !== null && _assetsObject$nativeA !== void 0 ? _assetsObject$nativeA : null;
12149
12168
  }
12150
- var asset = (_findAsset = findAsset(node, currency, null)) !== null && _findAsset !== void 0 ? _findAsset : node === 'AssetHubPolkadot' ? findAsset('Ethereum', currency, null) : null;
12151
- if (!asset) {
12152
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
12153
- }
12169
+ var asset = findAssetForNodeOrThrow(node, currency, null);
12154
12170
  return (_asset$existentialDep = asset.existentialDeposit) !== null && _asset$existentialDep !== void 0 ? _asset$existentialDep : null;
12155
12171
  };
12156
12172
 
@@ -12450,6 +12466,8 @@ exports.findAsset = findAsset;
12450
12466
  exports.findAssetById = findAssetById;
12451
12467
  exports.findAssetByMultiLocation = findAssetByMultiLocation;
12452
12468
  exports.findAssetBySymbol = findAssetBySymbol;
12469
+ exports.findAssetForNodeOrThrow = findAssetForNodeOrThrow;
12470
+ exports.findAssetOnDestOrThrow = findAssetOnDestOrThrow;
12453
12471
  exports.findBestMatches = findBestMatches;
12454
12472
  exports.getAllAssetsSymbols = getAllAssetsSymbols;
12455
12473
  exports.getAssetDecimals = getAssetDecimals;
package/dist/index.d.ts CHANGED
@@ -210,6 +210,10 @@ declare const findAssetByMultiLocation: (foreignAssets: TForeignAsset[], multiLo
210
210
 
211
211
  declare const findAssetBySymbol: (node: TNodeWithRelayChains, destination: TNodeWithRelayChains | null, otherAssets: TForeignAsset[], nativeAssets: TNativeAsset[], symbol: TCurrencySymbolValue) => TAsset | undefined;
212
212
 
213
+ declare const findAssetForNodeOrThrow: (node: TNodeWithRelayChains, currency: TCurrencyInput, destination: TNodeWithRelayChains | null) => TAsset;
214
+
215
+ declare const findAssetOnDestOrThrow: (origin: TNodeWithRelayChains, destination: TNodeWithRelayChains, currency: TCurrencyInput) => TAsset;
216
+
213
217
  declare const findBestMatches: <T extends {
214
218
  symbol: string;
215
219
  alias?: string;
@@ -265,5 +269,5 @@ declare const extractMultiAssetLoc: (multiAsset: TMultiAsset) => TMultiLocation;
265
269
 
266
270
  declare const getAssetMultiLocation: (node: TNodeWithRelayChains, currency: TCurrencyInput) => TMultiLocation | null;
267
271
 
268
- export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, compareMultiLocations, extractMultiAssetLoc, filterEthCompatibleAssets, findAsset, findAssetById, findAssetByMultiLocation, findAssetBySymbol, findBestMatches, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetMultiLocation, getAssets, getAssetsObject, getExistentialDeposit, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isSymbolSpecifier, isTMultiAsset, normalizeSymbol };
272
+ 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, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isSymbolSpecifier, isTMultiAsset, normalizeSymbol };
269
273
  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
@@ -11740,6 +11740,31 @@ var assetsMapJson = {
11740
11740
  Peaq: Peaq
11741
11741
  };
11742
11742
 
11743
+ var isForeignAsset = function isForeignAsset(asset) {
11744
+ return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset) && !('isNative' in asset);
11745
+ };
11746
+
11747
+ var isOverrideMultiLocationSpecifier = function isOverrideMultiLocationSpecifier(multiLocationSpecifier) {
11748
+ return _typeof(multiLocationSpecifier) === 'object' && 'type' in multiLocationSpecifier && 'value' in multiLocationSpecifier;
11749
+ };
11750
+
11751
+ var isSymbolSpecifier = function isSymbolSpecifier(currencySymbolValue) {
11752
+ return _typeof(currencySymbolValue) === 'object' && 'type' in currencySymbolValue && 'value' in currencySymbolValue;
11753
+ };
11754
+
11755
+ var isTMultiAsset = function isTMultiAsset(value) {
11756
+ return _typeof(value) === 'object' && value !== null && 'id' in value && 'fun' in value;
11757
+ };
11758
+
11759
+ var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
11760
+ var ethAssets = getOtherAssets('Ethereum');
11761
+ return assets.filter(function (asset) {
11762
+ var assetMultiLoc = asset.multiLocation;
11763
+ if (!assetMultiLoc) return false;
11764
+ return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
11765
+ });
11766
+ };
11767
+
11743
11768
  /**
11744
11769
  * Error thrown when multiple assets with the same symbol are found.
11745
11770
  */
@@ -11800,31 +11825,6 @@ var InvalidCurrencyError = /*#__PURE__*/function (_Error) {
11800
11825
  return _createClass(InvalidCurrencyError);
11801
11826
  }(/*#__PURE__*/_wrapNativeSuper(Error));
11802
11827
 
11803
- var isForeignAsset = function isForeignAsset(asset) {
11804
- return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset) && !('isNative' in asset);
11805
- };
11806
-
11807
- var isOverrideMultiLocationSpecifier = function isOverrideMultiLocationSpecifier(multiLocationSpecifier) {
11808
- return _typeof(multiLocationSpecifier) === 'object' && 'type' in multiLocationSpecifier && 'value' in multiLocationSpecifier;
11809
- };
11810
-
11811
- var isSymbolSpecifier = function isSymbolSpecifier(currencySymbolValue) {
11812
- return _typeof(currencySymbolValue) === 'object' && 'type' in currencySymbolValue && 'value' in currencySymbolValue;
11813
- };
11814
-
11815
- var isTMultiAsset = function isTMultiAsset(value) {
11816
- return _typeof(value) === 'object' && value !== null && 'id' in value && 'fun' in value;
11817
- };
11818
-
11819
- var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
11820
- var ethAssets = getOtherAssets('Ethereum');
11821
- return assets.filter(function (asset) {
11822
- var assetMultiLoc = asset.multiLocation;
11823
- if (!assetMultiLoc) return false;
11824
- return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
11825
- });
11826
- };
11827
-
11828
11828
  var findAssetById = function findAssetById(assets, assetId) {
11829
11829
  var otherAssetsMatches = assets.filter(function (_ref) {
11830
11830
  var currentAssetId = _ref.assetId;
@@ -12132,6 +12132,25 @@ var findAsset = function findAsset(node, currency, destination) {
12132
12132
  return asset !== null && asset !== void 0 ? asset : null;
12133
12133
  };
12134
12134
 
12135
+ var findAssetForNodeOrThrow = function findAssetForNodeOrThrow(node, currency, destination) {
12136
+ var _findAsset;
12137
+ var asset = (_findAsset = findAsset(node, currency, destination)) !== null && _findAsset !== void 0 ? _findAsset : node === 'AssetHubPolkadot' ? findAsset('Ethereum', currency, null) : null;
12138
+ if (!asset) {
12139
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
12140
+ }
12141
+ return asset;
12142
+ };
12143
+
12144
+ var findAssetOnDestOrThrow = function findAssetOnDestOrThrow(origin, destination, currency) {
12145
+ var originAsset = findAssetForNodeOrThrow(origin, currency, destination);
12146
+ var assetByMultiLocation = originAsset.multiLocation ? findAsset(destination, {
12147
+ multilocation: originAsset.multiLocation
12148
+ }, null) : null;
12149
+ return assetByMultiLocation !== null && assetByMultiLocation !== void 0 ? assetByMultiLocation : findAssetForNodeOrThrow(destination, {
12150
+ symbol: originAsset.symbol
12151
+ }, null);
12152
+ };
12153
+
12135
12154
  /**
12136
12155
  * Retrieves the existential deposit value for a given node.
12137
12156
  *
@@ -12139,16 +12158,13 @@ var findAsset = function findAsset(node, currency, destination) {
12139
12158
  * @returns The existential deposit as a string if available; otherwise, null.
12140
12159
  */
12141
12160
  var getExistentialDeposit = function getExistentialDeposit(node, currency) {
12142
- var _findAsset, _asset$existentialDep;
12161
+ var _asset$existentialDep;
12143
12162
  var assetsObject = getAssetsObject(node);
12144
12163
  if (!currency) {
12145
12164
  var _assetsObject$nativeA;
12146
12165
  return (_assetsObject$nativeA = assetsObject.nativeAssets[0].existentialDeposit) !== null && _assetsObject$nativeA !== void 0 ? _assetsObject$nativeA : null;
12147
12166
  }
12148
- var asset = (_findAsset = findAsset(node, currency, null)) !== null && _findAsset !== void 0 ? _findAsset : node === 'AssetHubPolkadot' ? findAsset('Ethereum', currency, null) : null;
12149
- if (!asset) {
12150
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
12151
- }
12167
+ var asset = findAssetForNodeOrThrow(node, currency, null);
12152
12168
  return (_asset$existentialDep = asset.existentialDeposit) !== null && _asset$existentialDep !== void 0 ? _asset$existentialDep : null;
12153
12169
  };
12154
12170
 
@@ -12434,4 +12450,4 @@ var getAssetMultiLocation = function getAssetMultiLocation(node, currency) {
12434
12450
  return null;
12435
12451
  };
12436
12452
 
12437
- export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, compareMultiLocations, extractMultiAssetLoc, filterEthCompatibleAssets, findAsset, findAssetById, findAssetByMultiLocation, findAssetBySymbol, findBestMatches, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetMultiLocation, getAssets, getAssetsObject, getExistentialDeposit, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isSymbolSpecifier, isTMultiAsset, normalizeSymbol };
12453
+ 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, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isForeignAsset, isNodeEvm, isOverrideMultiLocationSpecifier, isSymbolSpecifier, isTMultiAsset, normalizeSymbol };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/assets",
3
- "version": "9.2.2",
3
+ "version": "10.0.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": "9.2.2"
26
+ "@paraspell/sdk-common": "10.0.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@babel/plugin-syntax-import-attributes": "^7.27.1",