@paraspell/assets 9.2.1 → 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
@@ -202,6 +202,14 @@ var Polimec = {
202
202
  symbol: "PLMC",
203
203
  isNative: true,
204
204
  decimals: 10,
205
+ multiLocation: {
206
+ parents: 1,
207
+ interior: {
208
+ X1: {
209
+ Parachain: 3344
210
+ }
211
+ }
212
+ },
205
213
  existentialDeposit: "100000000"
206
214
  }
207
215
  ],
@@ -11734,6 +11742,31 @@ var assetsMapJson = {
11734
11742
  Peaq: Peaq
11735
11743
  };
11736
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
+
11737
11770
  /**
11738
11771
  * Error thrown when multiple assets with the same symbol are found.
11739
11772
  */
@@ -11794,31 +11827,6 @@ var InvalidCurrencyError = /*#__PURE__*/function (_Error) {
11794
11827
  return _createClass(InvalidCurrencyError);
11795
11828
  }(/*#__PURE__*/_wrapNativeSuper(Error));
11796
11829
 
11797
- var isForeignAsset = function isForeignAsset(asset) {
11798
- return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset) && !('isNative' in asset);
11799
- };
11800
-
11801
- var isOverrideMultiLocationSpecifier = function isOverrideMultiLocationSpecifier(multiLocationSpecifier) {
11802
- return _typeof(multiLocationSpecifier) === 'object' && 'type' in multiLocationSpecifier && 'value' in multiLocationSpecifier;
11803
- };
11804
-
11805
- var isSymbolSpecifier = function isSymbolSpecifier(currencySymbolValue) {
11806
- return _typeof(currencySymbolValue) === 'object' && 'type' in currencySymbolValue && 'value' in currencySymbolValue;
11807
- };
11808
-
11809
- var isTMultiAsset = function isTMultiAsset(value) {
11810
- return _typeof(value) === 'object' && value !== null && 'id' in value && 'fun' in value;
11811
- };
11812
-
11813
- var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
11814
- var ethAssets = getOtherAssets('Ethereum');
11815
- return assets.filter(function (asset) {
11816
- var assetMultiLoc = asset.multiLocation;
11817
- if (!assetMultiLoc) return false;
11818
- return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
11819
- });
11820
- };
11821
-
11822
11830
  var findAssetById = function findAssetById(assets, assetId) {
11823
11831
  var otherAssetsMatches = assets.filter(function (_ref) {
11824
11832
  var currentAssetId = _ref.assetId;
@@ -12126,6 +12134,25 @@ var findAsset = function findAsset(node, currency, destination) {
12126
12134
  return asset !== null && asset !== void 0 ? asset : null;
12127
12135
  };
12128
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
+
12129
12156
  /**
12130
12157
  * Retrieves the existential deposit value for a given node.
12131
12158
  *
@@ -12133,16 +12160,13 @@ var findAsset = function findAsset(node, currency, destination) {
12133
12160
  * @returns The existential deposit as a string if available; otherwise, null.
12134
12161
  */
12135
12162
  var getExistentialDeposit = function getExistentialDeposit(node, currency) {
12136
- var _findAsset, _asset$existentialDep;
12163
+ var _asset$existentialDep;
12137
12164
  var assetsObject = getAssetsObject(node);
12138
12165
  if (!currency) {
12139
12166
  var _assetsObject$nativeA;
12140
12167
  return (_assetsObject$nativeA = assetsObject.nativeAssets[0].existentialDeposit) !== null && _assetsObject$nativeA !== void 0 ? _assetsObject$nativeA : null;
12141
12168
  }
12142
- var asset = (_findAsset = findAsset(node, currency, null)) !== null && _findAsset !== void 0 ? _findAsset : node === 'AssetHubPolkadot' ? findAsset('Ethereum', currency, null) : null;
12143
- if (!asset) {
12144
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
12145
- }
12169
+ var asset = findAssetForNodeOrThrow(node, currency, null);
12146
12170
  return (_asset$existentialDep = asset.existentialDeposit) !== null && _asset$existentialDep !== void 0 ? _asset$existentialDep : null;
12147
12171
  };
12148
12172
 
@@ -12442,6 +12466,8 @@ exports.findAsset = findAsset;
12442
12466
  exports.findAssetById = findAssetById;
12443
12467
  exports.findAssetByMultiLocation = findAssetByMultiLocation;
12444
12468
  exports.findAssetBySymbol = findAssetBySymbol;
12469
+ exports.findAssetForNodeOrThrow = findAssetForNodeOrThrow;
12470
+ exports.findAssetOnDestOrThrow = findAssetOnDestOrThrow;
12445
12471
  exports.findBestMatches = findBestMatches;
12446
12472
  exports.getAllAssetsSymbols = getAllAssetsSymbols;
12447
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
@@ -200,6 +200,14 @@ var Polimec = {
200
200
  symbol: "PLMC",
201
201
  isNative: true,
202
202
  decimals: 10,
203
+ multiLocation: {
204
+ parents: 1,
205
+ interior: {
206
+ X1: {
207
+ Parachain: 3344
208
+ }
209
+ }
210
+ },
203
211
  existentialDeposit: "100000000"
204
212
  }
205
213
  ],
@@ -11732,6 +11740,31 @@ var assetsMapJson = {
11732
11740
  Peaq: Peaq
11733
11741
  };
11734
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
+
11735
11768
  /**
11736
11769
  * Error thrown when multiple assets with the same symbol are found.
11737
11770
  */
@@ -11792,31 +11825,6 @@ var InvalidCurrencyError = /*#__PURE__*/function (_Error) {
11792
11825
  return _createClass(InvalidCurrencyError);
11793
11826
  }(/*#__PURE__*/_wrapNativeSuper(Error));
11794
11827
 
11795
- var isForeignAsset = function isForeignAsset(asset) {
11796
- return _typeof(asset) === 'object' && asset !== null && ('assetId' in asset || 'multiLocation' in asset) && !('isNative' in asset);
11797
- };
11798
-
11799
- var isOverrideMultiLocationSpecifier = function isOverrideMultiLocationSpecifier(multiLocationSpecifier) {
11800
- return _typeof(multiLocationSpecifier) === 'object' && 'type' in multiLocationSpecifier && 'value' in multiLocationSpecifier;
11801
- };
11802
-
11803
- var isSymbolSpecifier = function isSymbolSpecifier(currencySymbolValue) {
11804
- return _typeof(currencySymbolValue) === 'object' && 'type' in currencySymbolValue && 'value' in currencySymbolValue;
11805
- };
11806
-
11807
- var isTMultiAsset = function isTMultiAsset(value) {
11808
- return _typeof(value) === 'object' && value !== null && 'id' in value && 'fun' in value;
11809
- };
11810
-
11811
- var filterEthCompatibleAssets = function filterEthCompatibleAssets(assets) {
11812
- var ethAssets = getOtherAssets('Ethereum');
11813
- return assets.filter(function (asset) {
11814
- var assetMultiLoc = asset.multiLocation;
11815
- if (!assetMultiLoc) return false;
11816
- return Boolean(findAssetByMultiLocation(ethAssets, assetMultiLoc));
11817
- });
11818
- };
11819
-
11820
11828
  var findAssetById = function findAssetById(assets, assetId) {
11821
11829
  var otherAssetsMatches = assets.filter(function (_ref) {
11822
11830
  var currentAssetId = _ref.assetId;
@@ -12124,6 +12132,25 @@ var findAsset = function findAsset(node, currency, destination) {
12124
12132
  return asset !== null && asset !== void 0 ? asset : null;
12125
12133
  };
12126
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
+
12127
12154
  /**
12128
12155
  * Retrieves the existential deposit value for a given node.
12129
12156
  *
@@ -12131,16 +12158,13 @@ var findAsset = function findAsset(node, currency, destination) {
12131
12158
  * @returns The existential deposit as a string if available; otherwise, null.
12132
12159
  */
12133
12160
  var getExistentialDeposit = function getExistentialDeposit(node, currency) {
12134
- var _findAsset, _asset$existentialDep;
12161
+ var _asset$existentialDep;
12135
12162
  var assetsObject = getAssetsObject(node);
12136
12163
  if (!currency) {
12137
12164
  var _assetsObject$nativeA;
12138
12165
  return (_assetsObject$nativeA = assetsObject.nativeAssets[0].existentialDeposit) !== null && _assetsObject$nativeA !== void 0 ? _assetsObject$nativeA : null;
12139
12166
  }
12140
- var asset = (_findAsset = findAsset(node, currency, null)) !== null && _findAsset !== void 0 ? _findAsset : node === 'AssetHubPolkadot' ? findAsset('Ethereum', currency, null) : null;
12141
- if (!asset) {
12142
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
12143
- }
12167
+ var asset = findAssetForNodeOrThrow(node, currency, null);
12144
12168
  return (_asset$existentialDep = asset.existentialDeposit) !== null && _asset$existentialDep !== void 0 ? _asset$existentialDep : null;
12145
12169
  };
12146
12170
 
@@ -12426,4 +12450,4 @@ var getAssetMultiLocation = function getAssetMultiLocation(node, currency) {
12426
12450
  return null;
12427
12451
  };
12428
12452
 
12429
- 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.1",
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.1"
26
+ "@paraspell/sdk-common": "10.0.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@babel/plugin-syntax-import-attributes": "^7.27.1",