@paraspell/assets 13.6.0 → 13.7.1
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 +4 -2
- package/dist/index.mjs +72 -20
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ type TCustomCtx = {
|
|
|
89
89
|
customChainAssets?: Record<string, TChainAssetsInfo>;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
+
declare const getExistentialDepositImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, currency?: TCurrencyCore, ctx?: TCustomCtx) => bigint | null;
|
|
92
93
|
/**
|
|
93
94
|
* Retrieves the existential deposit value for a given chain.
|
|
94
95
|
*
|
|
@@ -96,7 +97,8 @@ type TCustomCtx = {
|
|
|
96
97
|
* @returns The existential deposit as a bigint if available; otherwise, null.
|
|
97
98
|
*/
|
|
98
99
|
declare const getExistentialDeposit: (chain: TChain, currency?: TCurrencyCore) => bigint | null;
|
|
99
|
-
declare const assertEdDefined: (ed: bigint | null, chain?: TChain, currency?: TCurrencyCore) => asserts ed is bigint;
|
|
100
|
+
declare const assertEdDefined: <TCustomChain extends string = never>(ed: bigint | null, chain?: TChain | TCustomChain, currency?: TCurrencyCore) => asserts ed is bigint;
|
|
101
|
+
declare const getExistentialDepositOrThrowImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, currency?: TCurrencyCore, ctx?: TCustomCtx) => bigint;
|
|
100
102
|
declare const getExistentialDepositOrThrow: (chain: TChain, currency?: TCurrencyCore) => bigint;
|
|
101
103
|
declare const getEdFromAssetOrThrow: (asset: TAssetInfo) => bigint;
|
|
102
104
|
|
|
@@ -328,5 +330,5 @@ declare const extractAssetLocation: <T = bigint>(asset: TAsset<T>) => TLocation;
|
|
|
328
330
|
|
|
329
331
|
declare const getAssetLocation: (chain: TChain, currency: TCurrencyInput) => TLocation | null;
|
|
330
332
|
|
|
331
|
-
export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasSupportForAsset, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeCustomAssets, normalizeLocation, normalizeSymbol };
|
|
333
|
+
export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositImpl, getExistentialDepositOrThrow, getExistentialDepositOrThrowImpl, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasSupportForAsset, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeCustomAssets, normalizeLocation, normalizeSymbol };
|
|
332
334
|
export type { TAmount, TAsset, TAssetInfo, TAssetInfoWithId, TAssetJsonMap, TAssetV3, TAssetV4, TAssetWithFee, TChainAssetsInfo, TCurrency, TCurrencyCore, TCurrencyInput, TCurrencyInputWithAmount, TCurrencySymbol, TCurrencySymbolValue, TCustomAssetInfo, TCustomAssetsMap, TCustomAssetsMapNormalized, TCustomCtx, TLocationValue, TLocationValueWithOverride, TOverrideLocationSpecifier, TSymbolSpecifier, WithAmount, WithComplexAmount };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Version, deepEqual, isChain, isExternalChain, getJunctionValue, hasJunction, Parents, RELAYCHAINS, replaceBigInt, isCustomChain, isSubstrateBridge, isSnowbridge, CHAINS } from '@paraspell/sdk-common';
|
|
1
|
+
import { Version, deepEqual, isChain, isExternalChain, getJunctionValue, hasJunction, Parents, RELAYCHAINS, replaceBigInt, isCustomChain, isSubstrateBridge, isSnowbridge, SUBSTRATE_CHAINS, CHAINS, ETHEREUM_BRIDGE_ORIGINS } from '@paraspell/sdk-common';
|
|
2
2
|
|
|
3
3
|
function _arrayLikeToArray(r, a) {
|
|
4
4
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -8723,6 +8723,22 @@ var AssetHubPolkadot = {
|
|
|
8723
8723
|
},
|
|
8724
8724
|
existentialDeposit: "1"
|
|
8725
8725
|
},
|
|
8726
|
+
{
|
|
8727
|
+
symbol: "MOS",
|
|
8728
|
+
decimals: 18,
|
|
8729
|
+
location: {
|
|
8730
|
+
parents: 1,
|
|
8731
|
+
interior: {
|
|
8732
|
+
X1: [
|
|
8733
|
+
{
|
|
8734
|
+
Parachain: 3377
|
|
8735
|
+
}
|
|
8736
|
+
]
|
|
8737
|
+
}
|
|
8738
|
+
},
|
|
8739
|
+
existentialDeposit: "100000000000000000",
|
|
8740
|
+
isFeeAsset: true
|
|
8741
|
+
},
|
|
8726
8742
|
{
|
|
8727
8743
|
symbol: "ETH",
|
|
8728
8744
|
decimals: 18,
|
|
@@ -19581,10 +19597,10 @@ var findAssetInfoImpl = function findAssetInfoImpl(chain, currency, destination,
|
|
|
19581
19597
|
var nativeAssets = getNativeAssetsImpl(chain, ctx);
|
|
19582
19598
|
var assets = [].concat(_toConsumableArray(nativeAssets), _toConsumableArray(otherAssets));
|
|
19583
19599
|
var asset;
|
|
19584
|
-
if ('
|
|
19585
|
-
asset = findAssetInfoBySymbol(otherAssets, nativeAssets, currency.symbol, destination !== null && destination !== void 0 ? destination : undefined);
|
|
19586
|
-
} else if ('location' in currency && !isOverrideLocationSpecifier(currency.location)) {
|
|
19600
|
+
if ('location' in currency && !isOverrideLocationSpecifier(currency.location)) {
|
|
19587
19601
|
asset = findAssetInfoByLoc(assets, currency.location);
|
|
19602
|
+
} else if ('symbol' in currency) {
|
|
19603
|
+
asset = findAssetInfoBySymbol(otherAssets, nativeAssets, currency.symbol, destination !== null && destination !== void 0 ? destination : undefined);
|
|
19588
19604
|
} else if ('id' in currency) {
|
|
19589
19605
|
asset = findAssetInfoById(assets, currency.id);
|
|
19590
19606
|
}
|
|
@@ -19761,37 +19777,43 @@ var findNativeAssetInfoOrThrow = function findNativeAssetInfoOrThrow(chain) {
|
|
|
19761
19777
|
var extractEdFromAsset = function extractEdFromAsset(asset) {
|
|
19762
19778
|
return asset.existentialDeposit ? BigInt(asset.existentialDeposit) : null;
|
|
19763
19779
|
};
|
|
19764
|
-
|
|
19765
|
-
* Retrieves the existential deposit value for a given chain.
|
|
19766
|
-
*
|
|
19767
|
-
* @param chain - The chain for which to get the existential deposit.
|
|
19768
|
-
* @returns The existential deposit as a bigint if available; otherwise, null.
|
|
19769
|
-
*/
|
|
19770
|
-
var getExistentialDeposit = function getExistentialDeposit(chain, currency) {
|
|
19780
|
+
var getExistentialDepositImpl = function getExistentialDepositImpl(chain, currency, ctx) {
|
|
19771
19781
|
var asset;
|
|
19772
19782
|
if (!currency) {
|
|
19773
|
-
var
|
|
19774
|
-
var nativeAssetSymbol =
|
|
19775
|
-
asset = (
|
|
19783
|
+
var _findAssetInfoImpl;
|
|
19784
|
+
var nativeAssetSymbol = getNativeAssetSymbolImpl(chain, ctx);
|
|
19785
|
+
asset = (_findAssetInfoImpl = findAssetInfoImpl(chain, {
|
|
19776
19786
|
symbol: Native(nativeAssetSymbol)
|
|
19777
|
-
})) !== null &&
|
|
19787
|
+
}, undefined, ctx)) !== null && _findAssetInfoImpl !== void 0 ? _findAssetInfoImpl : findAssetInfoOrThrowImpl(chain, {
|
|
19778
19788
|
symbol: nativeAssetSymbol
|
|
19779
|
-
});
|
|
19789
|
+
}, undefined, ctx);
|
|
19780
19790
|
} else {
|
|
19781
|
-
asset =
|
|
19791
|
+
asset = findAssetInfoOrThrowImpl(chain, currency, undefined, ctx);
|
|
19782
19792
|
}
|
|
19783
19793
|
return extractEdFromAsset(asset);
|
|
19784
19794
|
};
|
|
19795
|
+
/**
|
|
19796
|
+
* Retrieves the existential deposit value for a given chain.
|
|
19797
|
+
*
|
|
19798
|
+
* @param chain - The chain for which to get the existential deposit.
|
|
19799
|
+
* @returns The existential deposit as a bigint if available; otherwise, null.
|
|
19800
|
+
*/
|
|
19801
|
+
var getExistentialDeposit = function getExistentialDeposit(chain, currency) {
|
|
19802
|
+
return getExistentialDepositImpl(chain, currency);
|
|
19803
|
+
};
|
|
19785
19804
|
var assertEdDefined = function assertEdDefined(ed, chain, currency) {
|
|
19786
19805
|
if (ed === undefined || ed === null) {
|
|
19787
19806
|
throw new InvalidCurrencyError("Existential deposit not found for currency ".concat(JSON.stringify(currency, replaceBigInt)).concat(chain ? " on chain ".concat(chain, ".") : '.'));
|
|
19788
19807
|
}
|
|
19789
19808
|
};
|
|
19790
|
-
var
|
|
19791
|
-
var ed =
|
|
19809
|
+
var getExistentialDepositOrThrowImpl = function getExistentialDepositOrThrowImpl(chain, currency, ctx) {
|
|
19810
|
+
var ed = getExistentialDepositImpl(chain, currency, ctx);
|
|
19792
19811
|
assertEdDefined(ed, chain, currency);
|
|
19793
19812
|
return ed;
|
|
19794
19813
|
};
|
|
19814
|
+
var getExistentialDepositOrThrow = function getExistentialDepositOrThrow(chain, currency) {
|
|
19815
|
+
return getExistentialDepositOrThrowImpl(chain, currency);
|
|
19816
|
+
};
|
|
19795
19817
|
var getEdFromAssetOrThrow = function getEdFromAssetOrThrow(asset) {
|
|
19796
19818
|
var ed = extractEdFromAsset(asset);
|
|
19797
19819
|
assertEdDefined(ed, undefined, asset);
|
|
@@ -20075,10 +20097,36 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
|
|
|
20075
20097
|
return getSupportedAssetsImpl(origin, destination);
|
|
20076
20098
|
};
|
|
20077
20099
|
|
|
20100
|
+
var isDestinationReachable = function isDestinationReachable(origin, destination) {
|
|
20101
|
+
if (isExternalChain(origin) || isExternalChain(destination)) {
|
|
20102
|
+
var substrateSide = isExternalChain(origin) ? destination : origin;
|
|
20103
|
+
if (isExternalChain(substrateSide)) return false;
|
|
20104
|
+
return ETHEREUM_BRIDGE_ORIGINS.includes(substrateSide);
|
|
20105
|
+
}
|
|
20106
|
+
if (isSubstrateBridge(origin, destination)) return true;
|
|
20107
|
+
return getRelayChainSymbol(origin) === getRelayChainSymbol(destination);
|
|
20108
|
+
};
|
|
20109
|
+
var isUnsupportedAssetHubNative = function isUnsupportedAssetHubNative(origin, destination, originAsset, nativeAssets) {
|
|
20110
|
+
if (isExternalChain(origin) || isExternalChain(destination)) return false;
|
|
20111
|
+
var originIsAssetHub = origin.startsWith('AssetHub');
|
|
20112
|
+
var destinationIsAssetHub = destination.startsWith('AssetHub');
|
|
20113
|
+
if (originIsAssetHub === destinationIsAssetHub) return false;
|
|
20114
|
+
if (isSystemAsset(originAsset)) return false;
|
|
20115
|
+
return nativeAssets.some(function (_native) {
|
|
20116
|
+
return isAssetEqual(originAsset, _native);
|
|
20117
|
+
});
|
|
20118
|
+
};
|
|
20078
20119
|
var getSupportedDestinations = function getSupportedDestinations(origin, currency) {
|
|
20079
20120
|
findAssetInfoOrThrow(origin, currency);
|
|
20121
|
+
var ecosystem = getRelayChainSymbol(origin);
|
|
20122
|
+
var nativeAssets = SUBSTRATE_CHAINS.filter(function (chain) {
|
|
20123
|
+
return getRelayChainSymbol(chain) === ecosystem;
|
|
20124
|
+
}).map(function (chain) {
|
|
20125
|
+
return findNativeAssetInfoOrThrow(chain);
|
|
20126
|
+
});
|
|
20080
20127
|
return CHAINS.filter(function (destination) {
|
|
20081
20128
|
if (destination === origin) return false;
|
|
20129
|
+
if (!isDestinationReachable(origin, destination)) return false;
|
|
20082
20130
|
// Check if we still can find asset if we specify destination
|
|
20083
20131
|
var originAsset;
|
|
20084
20132
|
try {
|
|
@@ -20089,6 +20137,10 @@ var getSupportedDestinations = function getSupportedDestinations(origin, currenc
|
|
|
20089
20137
|
}
|
|
20090
20138
|
throw error;
|
|
20091
20139
|
}
|
|
20140
|
+
if (isUnsupportedAssetHubNative(origin, destination, originAsset, nativeAssets)) return false;
|
|
20141
|
+
if (isSubstrateBridge(origin, destination)) {
|
|
20142
|
+
return isSystemAsset(originAsset) || isStableCoinAsset(originAsset);
|
|
20143
|
+
}
|
|
20092
20144
|
try {
|
|
20093
20145
|
return !!findAssetInfoOnDest(origin, destination, currency, originAsset);
|
|
20094
20146
|
} catch (error) {
|
|
@@ -20100,4 +20152,4 @@ var getSupportedDestinations = function getSupportedDestinations(origin, currenc
|
|
|
20100
20152
|
});
|
|
20101
20153
|
};
|
|
20102
20154
|
|
|
20103
|
-
export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasSupportForAsset, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeCustomAssets, normalizeLocation, normalizeSymbol };
|
|
20155
|
+
export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositImpl, getExistentialDepositOrThrow, getExistentialDepositOrThrowImpl, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasSupportForAsset, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeCustomAssets, normalizeLocation, normalizeSymbol };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/assets",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.7.1",
|
|
4
4
|
"description": "Assets for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@paraspell/sdk-common": "13.
|
|
25
|
+
"@paraspell/sdk-common": "13.7.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/plugin-syntax-import-attributes": "^7.29.7",
|