@paraspell/assets 13.10.1 → 14.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/README.md +1 -22
- package/dist/index.d.ts +6 -47
- package/dist/index.mjs +118 -142
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ npm install | pnpm add | yarn add @paraspell/assets
|
|
|
36
36
|
To use this functionality, you first have to import it in the following way.
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
import { getSupportedDestinations, getSupportedAssets, getFeeAssets, getAssetsObject,
|
|
39
|
+
import { getSupportedDestinations, getSupportedAssets, getFeeAssets, getAssetsObject, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, getParaId, getTChain, getAssetLocation, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/assets'
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
|
|
@@ -47,13 +47,6 @@ This function returns `assets object` from `assets.json` for `particular Paracha
|
|
|
47
47
|
getAssetsObject(TChain)
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
### Query asset ID
|
|
51
|
-
This function returns `assetId` for `particular Parachain` and `asset symbol`. Function uses [TChain](https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types) types.
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
getAssetId(TChain, ASSET_SYMBOL)
|
|
55
|
-
```
|
|
56
|
-
|
|
57
50
|
### Query Relay chain asset symbol
|
|
58
51
|
This function returns the `symbol` of the Relay chain for a particular Parachain. Either `DOT` or `KSM` or `WND` or `PAS`. Function uses [TChain](https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types) types.
|
|
59
52
|
|
|
@@ -82,20 +75,6 @@ Function returns string array of all asset symbols for a specific Parachain. (na
|
|
|
82
75
|
getAllAssetsSymbols(TChain)
|
|
83
76
|
```
|
|
84
77
|
|
|
85
|
-
### Query asset support
|
|
86
|
-
The function checks if Parachain supports a particular asset. (Both native and foreign assets are searched). Returns boolean. Function uses [TChain](https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types) types.
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
hasSupportForAsset(TChain, ASSET_SYMBOL)
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Query asset decimals
|
|
93
|
-
The function returns decimals for a specific asset. Function uses [TChain](https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types) types.
|
|
94
|
-
|
|
95
|
-
```ts
|
|
96
|
-
getAssetDecimals(TChain, ASSET_SYMBOL)
|
|
97
|
-
```
|
|
98
|
-
|
|
99
78
|
### Query Parachain ID
|
|
100
79
|
The function returns specific Parachain id. Function uses [TChain](https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types) types.
|
|
101
80
|
|
package/dist/index.d.ts
CHANGED
|
@@ -46,10 +46,6 @@ type TSymbolSpecifier = {
|
|
|
46
46
|
type: 'Native' | 'Foreign' | 'ForeignAbstract';
|
|
47
47
|
value: string;
|
|
48
48
|
};
|
|
49
|
-
type TOverrideLocationSpecifier = {
|
|
50
|
-
type: 'Override';
|
|
51
|
-
value: TLocation;
|
|
52
|
-
};
|
|
53
49
|
type TCurrencySymbolValue = string | TSymbolSpecifier;
|
|
54
50
|
type TCurrencySymbol = {
|
|
55
51
|
symbol: TCurrencySymbolValue;
|
|
@@ -63,19 +59,18 @@ type TAssetWithFee = TAsset & {
|
|
|
63
59
|
isFeeAsset?: boolean;
|
|
64
60
|
};
|
|
65
61
|
type TLocationValue = string | TLocation;
|
|
66
|
-
type TLocationValueWithOverride = TLocationValue | TOverrideLocationSpecifier;
|
|
67
62
|
type TCurrencyInputWithAmount = WithComplexAmount<TCurrencySymbol | {
|
|
68
63
|
id: TCurrency;
|
|
69
64
|
} | {
|
|
70
|
-
location:
|
|
71
|
-
}> |
|
|
65
|
+
location: TLocationValue;
|
|
66
|
+
}> | WithComplexAmount<TCurrencyCore>[];
|
|
72
67
|
type TSingleCurrencyInputWithAmount = Exclude<TCurrencyInputWithAmount, unknown[]>;
|
|
73
68
|
type TSingleCurrencyInput = Exclude<TCurrencyInput, unknown[]>;
|
|
74
69
|
type TCurrencyInput = TCurrencySymbol | {
|
|
75
70
|
id: TCurrency;
|
|
76
71
|
} | {
|
|
77
|
-
location:
|
|
78
|
-
} |
|
|
72
|
+
location: TLocationValue;
|
|
73
|
+
} | WithComplexAmount<TCurrencyCore>[];
|
|
79
74
|
type WithAmount<TBase, T = bigint> = TBase & {
|
|
80
75
|
amount: T;
|
|
81
76
|
};
|
|
@@ -119,16 +114,6 @@ declare const getAssetsObjectImpl: <TCustomChain extends string = never>(chain:
|
|
|
119
114
|
declare const getAssetsObject: (chain: TChain) => TChainAssetsInfo;
|
|
120
115
|
declare const isChainEvmImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => boolean;
|
|
121
116
|
declare const isChainEvm: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Retrieves the asset ID for a given symbol on a specified chain.
|
|
124
|
-
*
|
|
125
|
-
* @deprecated Use `findAssetInfo` instead. Will be removed in v14.
|
|
126
|
-
*
|
|
127
|
-
* @param chain - The chain to search for the asset.
|
|
128
|
-
* @param symbol - The symbol of the asset.
|
|
129
|
-
* @returns The asset ID if found; otherwise, null.
|
|
130
|
-
*/
|
|
131
|
-
declare const getAssetId: (chain: TChain, symbol: string) => string | null;
|
|
132
117
|
declare const getRelayChainSymbolImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => string;
|
|
133
118
|
/**
|
|
134
119
|
* Retrieves the relay chain asset symbol for a specified chain.
|
|
@@ -176,26 +161,6 @@ declare const getNativeAssetSymbolImpl: <TCustomChain extends string = never>(ch
|
|
|
176
161
|
* @returns The symbol of the native asset.
|
|
177
162
|
*/
|
|
178
163
|
declare const getNativeAssetSymbol: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => string;
|
|
179
|
-
/**
|
|
180
|
-
* Determines whether a specified chain supports an asset with the given symbol.
|
|
181
|
-
*
|
|
182
|
-
* @deprecated Use `findAssetInfo` instead. Will be removed in v14.
|
|
183
|
-
*
|
|
184
|
-
* @param chain - The chain to check for asset support.
|
|
185
|
-
* @param symbol - The symbol of the asset to check.
|
|
186
|
-
* @returns True if the asset is supported; otherwise, false.
|
|
187
|
-
*/
|
|
188
|
-
declare const hasSupportForAsset: (chain: TChain, symbol: string) => boolean;
|
|
189
|
-
/**
|
|
190
|
-
* Retrieves the number of decimals for an asset with the given symbol on a specified chain.
|
|
191
|
-
*
|
|
192
|
-
* @deprecated Use `findAssetInfo` instead. Will be removed in v14.
|
|
193
|
-
*
|
|
194
|
-
* @param chain - The chain where the asset is located.
|
|
195
|
-
* @param symbol - The symbol of the asset.
|
|
196
|
-
* @returns The number of decimals if the asset is found; otherwise, null.
|
|
197
|
-
*/
|
|
198
|
-
declare const getAssetDecimals: (chain: TChain, symbol: string) => number | null;
|
|
199
164
|
declare const hasDryRunSupportImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => boolean;
|
|
200
165
|
declare const hasDryRunSupport: (chain: TChain) => boolean;
|
|
201
166
|
declare const hasXcmPaymentApiSupportImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => boolean;
|
|
@@ -204,10 +169,6 @@ declare const hasXcmPaymentApiSupport: (chain: TChain) => boolean;
|
|
|
204
169
|
declare const Native: (symbol: string) => TSymbolSpecifier;
|
|
205
170
|
declare const Foreign: (symbol: string) => TSymbolSpecifier;
|
|
206
171
|
declare const ForeignAbstract: (symbol: string) => TSymbolSpecifier;
|
|
207
|
-
/**
|
|
208
|
-
* @deprecated Use the `customAssets` Builder option to register the asset instead. Will be removed in v14.
|
|
209
|
-
*/
|
|
210
|
-
declare const Override: (location: TLocation) => TOverrideLocationSpecifier;
|
|
211
172
|
|
|
212
173
|
declare const normalizeCustomAssets: (map: TCustomAssetsMap | undefined) => TCustomAssetsMapNormalized;
|
|
213
174
|
declare const isCustomAsset: (chain: TChain, asset: TAssetInfo, ctx?: Pick<TCustomCtx, "customAssets">) => boolean;
|
|
@@ -321,8 +282,6 @@ declare class InvalidCurrencyError extends Error {
|
|
|
321
282
|
constructor(message: string);
|
|
322
283
|
}
|
|
323
284
|
|
|
324
|
-
declare const isOverrideLocationSpecifier: (locationSpecifier: TLocationValueWithOverride) => locationSpecifier is TOverrideLocationSpecifier;
|
|
325
|
-
|
|
326
285
|
declare const isSymbolSpecifier: (currencySymbolValue: TCurrencySymbolValue) => currencySymbolValue is TSymbolSpecifier;
|
|
327
286
|
|
|
328
287
|
declare const isTAsset: <T = bigint>(value: unknown) => value is TAsset<T>;
|
|
@@ -333,5 +292,5 @@ declare const extractAssetLocation: <T = bigint>(asset: TAsset<T>) => TLocation;
|
|
|
333
292
|
|
|
334
293
|
declare const getAssetLocation: (chain: TChain, currency: TCurrencyInput) => TLocation | null;
|
|
335
294
|
|
|
336
|
-
export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native,
|
|
337
|
-
export type { TAmount, TAsset, TAssetInfo, TAssetInfoWithId, TAssetJsonMap, TAssetV3, TAssetV4, TAssetWithFee, TChainAssetsInfo, TCurrency, TCurrencyCore, TCurrencyInput, TCurrencyInputWithAmount, TCurrencySymbol, TCurrencySymbolValue, TCustomAssetInfo, TCustomAssetsMap, TCustomAssetsMapNormalized, TCustomCtx, TLocationValue,
|
|
295
|
+
export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositImpl, getExistentialDepositOrThrow, getExistentialDepositOrThrowImpl, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeCustomAssets, normalizeLocation, normalizeSymbol };
|
|
296
|
+
export type { TAmount, TAsset, TAssetInfo, TAssetInfoWithId, TAssetJsonMap, TAssetV3, TAssetV4, TAssetWithFee, TChainAssetsInfo, TCurrency, TCurrencyCore, TCurrencyInput, TCurrencyInputWithAmount, TCurrencySymbol, TCurrencySymbolValue, TCustomAssetInfo, TCustomAssetsMap, TCustomAssetsMapNormalized, TCustomCtx, TLocationValue, TSingleCurrencyInput, TSingleCurrencyInputWithAmount, TSymbolSpecifier, WithAmount, WithComplexAmount, WithOptionalAmount };
|
package/dist/index.mjs
CHANGED
|
@@ -410,7 +410,7 @@ var Paseo = {
|
|
|
410
410
|
relaychainSymbol: "PAS",
|
|
411
411
|
nativeAssetSymbol: "PAS",
|
|
412
412
|
isEVM: false,
|
|
413
|
-
ss58Prefix:
|
|
413
|
+
ss58Prefix: 42,
|
|
414
414
|
supportsDryRunApi: true,
|
|
415
415
|
supportsXcmPaymentApi: true,
|
|
416
416
|
assets: [
|
|
@@ -3279,6 +3279,29 @@ var Hydration = {
|
|
|
3279
3279
|
},
|
|
3280
3280
|
isFeeAsset: true
|
|
3281
3281
|
},
|
|
3282
|
+
{
|
|
3283
|
+
assetId: "67",
|
|
3284
|
+
symbol: "GIGAHDX",
|
|
3285
|
+
decimals: 12,
|
|
3286
|
+
existentialDeposit: "0",
|
|
3287
|
+
location: {
|
|
3288
|
+
parents: 1,
|
|
3289
|
+
interior: {
|
|
3290
|
+
X2: [
|
|
3291
|
+
{
|
|
3292
|
+
Parachain: 2034
|
|
3293
|
+
},
|
|
3294
|
+
{
|
|
3295
|
+
AccountKey20: {
|
|
3296
|
+
network: null,
|
|
3297
|
+
key: "0x6b9ac524ec8f08c49ec80176b138d16eb461c3d8"
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
]
|
|
3301
|
+
}
|
|
3302
|
+
},
|
|
3303
|
+
isFeeAsset: true
|
|
3304
|
+
},
|
|
3282
3305
|
{
|
|
3283
3306
|
assetId: "20",
|
|
3284
3307
|
symbol: "WETH",
|
|
@@ -7541,6 +7564,29 @@ var AssetHubPolkadot = {
|
|
|
7541
7564
|
},
|
|
7542
7565
|
existentialDeposit: "100000000"
|
|
7543
7566
|
},
|
|
7567
|
+
{
|
|
7568
|
+
assetId: "50000534",
|
|
7569
|
+
symbol: "DOT",
|
|
7570
|
+
decimals: 10,
|
|
7571
|
+
location: {
|
|
7572
|
+
parents: 1,
|
|
7573
|
+
interior: {
|
|
7574
|
+
X3: [
|
|
7575
|
+
{
|
|
7576
|
+
Parachain: 1000
|
|
7577
|
+
},
|
|
7578
|
+
{
|
|
7579
|
+
PalletInstance: 50
|
|
7580
|
+
},
|
|
7581
|
+
{
|
|
7582
|
+
GeneralIndex: 50000534
|
|
7583
|
+
}
|
|
7584
|
+
]
|
|
7585
|
+
}
|
|
7586
|
+
},
|
|
7587
|
+
existentialDeposit: "1",
|
|
7588
|
+
alias: "DOT3"
|
|
7589
|
+
},
|
|
7544
7590
|
{
|
|
7545
7591
|
assetId: "50000073",
|
|
7546
7592
|
symbol: "VDOT",
|
|
@@ -12242,7 +12288,8 @@ var AssetHubKusama = {
|
|
|
12242
12288
|
]
|
|
12243
12289
|
}
|
|
12244
12290
|
},
|
|
12245
|
-
existentialDeposit: "10000"
|
|
12291
|
+
existentialDeposit: "10000",
|
|
12292
|
+
alias: "KSM1"
|
|
12246
12293
|
},
|
|
12247
12294
|
{
|
|
12248
12295
|
assetId: "223",
|
|
@@ -12267,6 +12314,29 @@ var AssetHubKusama = {
|
|
|
12267
12314
|
existentialDeposit: "10000",
|
|
12268
12315
|
isFeeAsset: true
|
|
12269
12316
|
},
|
|
12317
|
+
{
|
|
12318
|
+
assetId: "50000011",
|
|
12319
|
+
symbol: "KSM",
|
|
12320
|
+
decimals: 12,
|
|
12321
|
+
location: {
|
|
12322
|
+
parents: 1,
|
|
12323
|
+
interior: {
|
|
12324
|
+
X3: [
|
|
12325
|
+
{
|
|
12326
|
+
Parachain: 1000
|
|
12327
|
+
},
|
|
12328
|
+
{
|
|
12329
|
+
PalletInstance: 50
|
|
12330
|
+
},
|
|
12331
|
+
{
|
|
12332
|
+
GeneralIndex: 50000011
|
|
12333
|
+
}
|
|
12334
|
+
]
|
|
12335
|
+
}
|
|
12336
|
+
},
|
|
12337
|
+
existentialDeposit: "1",
|
|
12338
|
+
alias: "KSM2"
|
|
12339
|
+
},
|
|
12270
12340
|
{
|
|
12271
12341
|
assetId: "2000",
|
|
12272
12342
|
symbol: "USDT",
|
|
@@ -16288,23 +16358,6 @@ var AssetHubWestend = {
|
|
|
16288
16358
|
},
|
|
16289
16359
|
existentialDeposit: "20000000000000000"
|
|
16290
16360
|
},
|
|
16291
|
-
{
|
|
16292
|
-
symbol: "ROC",
|
|
16293
|
-
decimals: 12,
|
|
16294
|
-
location: {
|
|
16295
|
-
parents: 2,
|
|
16296
|
-
interior: {
|
|
16297
|
-
X1: [
|
|
16298
|
-
{
|
|
16299
|
-
GlobalConsensus: {
|
|
16300
|
-
unused5: null
|
|
16301
|
-
}
|
|
16302
|
-
}
|
|
16303
|
-
]
|
|
16304
|
-
}
|
|
16305
|
-
},
|
|
16306
|
-
existentialDeposit: "10000000000"
|
|
16307
|
-
},
|
|
16308
16361
|
{
|
|
16309
16362
|
symbol: "WETH",
|
|
16310
16363
|
decimals: 18,
|
|
@@ -17103,14 +17156,14 @@ var HeimaPaseo = {
|
|
|
17103
17156
|
};
|
|
17104
17157
|
var EnergyWebXPaseo = {
|
|
17105
17158
|
relaychainSymbol: "PAS",
|
|
17106
|
-
nativeAssetSymbol: "
|
|
17159
|
+
nativeAssetSymbol: "VT",
|
|
17107
17160
|
isEVM: false,
|
|
17108
17161
|
ss58Prefix: 42,
|
|
17109
17162
|
supportsDryRunApi: true,
|
|
17110
17163
|
supportsXcmPaymentApi: true,
|
|
17111
17164
|
assets: [
|
|
17112
17165
|
{
|
|
17113
|
-
symbol: "
|
|
17166
|
+
symbol: "VT",
|
|
17114
17167
|
isNative: true,
|
|
17115
17168
|
decimals: 18,
|
|
17116
17169
|
existentialDeposit: "0",
|
|
@@ -19404,34 +19457,23 @@ var isCustomAsset = function isCustomAsset(chain, asset, ctx) {
|
|
|
19404
19457
|
});
|
|
19405
19458
|
};
|
|
19406
19459
|
|
|
19407
|
-
|
|
19408
|
-
|
|
19409
|
-
|
|
19410
|
-
|
|
19411
|
-
|
|
19412
|
-
*/
|
|
19413
|
-
var normalizeSymbol = function normalizeSymbol(symbol) {
|
|
19414
|
-
if (!symbol) return '';
|
|
19415
|
-
var s = symbol.toLowerCase();
|
|
19416
|
-
if (s.startsWith('xc')) s = s.substring(2);
|
|
19417
|
-
if (s.endsWith('.e')) s = s.slice(0, -2);
|
|
19418
|
-
return s;
|
|
19419
|
-
};
|
|
19420
|
-
|
|
19421
|
-
var isSymbolMatch = function isSymbolMatch(symbolA, symbolB) {
|
|
19422
|
-
return normalizeSymbol(symbolA) === normalizeSymbol(symbolB);
|
|
19423
|
-
};
|
|
19424
|
-
|
|
19425
|
-
var isOverrideLocationSpecifier = function isOverrideLocationSpecifier(locationSpecifier) {
|
|
19426
|
-
return _typeof(locationSpecifier) === 'object' && 'type' in locationSpecifier && 'value' in locationSpecifier;
|
|
19460
|
+
var Native = function Native(symbol) {
|
|
19461
|
+
return {
|
|
19462
|
+
type: 'Native',
|
|
19463
|
+
value: symbol
|
|
19464
|
+
};
|
|
19427
19465
|
};
|
|
19428
|
-
|
|
19429
|
-
|
|
19430
|
-
|
|
19466
|
+
var Foreign = function Foreign(symbol) {
|
|
19467
|
+
return {
|
|
19468
|
+
type: 'Foreign',
|
|
19469
|
+
value: symbol
|
|
19470
|
+
};
|
|
19431
19471
|
};
|
|
19432
|
-
|
|
19433
|
-
|
|
19434
|
-
|
|
19472
|
+
var ForeignAbstract = function ForeignAbstract(symbol) {
|
|
19473
|
+
return {
|
|
19474
|
+
type: 'ForeignAbstract',
|
|
19475
|
+
value: symbol
|
|
19476
|
+
};
|
|
19435
19477
|
};
|
|
19436
19478
|
|
|
19437
19479
|
var findAssetInfoById = function findAssetInfoById(assets, assetId) {
|
|
@@ -19486,6 +19528,14 @@ var findAssetInfoByLoc = function findAssetInfoByLoc(foreignAssets, location) {
|
|
|
19486
19528
|
});
|
|
19487
19529
|
};
|
|
19488
19530
|
|
|
19531
|
+
var isSymbolSpecifier = function isSymbolSpecifier(currencySymbolValue) {
|
|
19532
|
+
return _typeof(currencySymbolValue) === 'object' && 'type' in currencySymbolValue && 'value' in currencySymbolValue;
|
|
19533
|
+
};
|
|
19534
|
+
|
|
19535
|
+
var isTAsset = function isTAsset(value) {
|
|
19536
|
+
return _typeof(value) === 'object' && value !== null && 'id' in value && 'fun' in value;
|
|
19537
|
+
};
|
|
19538
|
+
|
|
19489
19539
|
var findBestMatches = function findBestMatches(assets, value) {
|
|
19490
19540
|
var property = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'symbol';
|
|
19491
19541
|
// First, exact match
|
|
@@ -19659,14 +19709,14 @@ var findAssetInfoBySymbol = function findAssetInfoBySymbol(otherAssets, nativeAs
|
|
|
19659
19709
|
};
|
|
19660
19710
|
|
|
19661
19711
|
var findAssetInfoImpl = function findAssetInfoImpl(chain, currency, destination, ctx) {
|
|
19662
|
-
if (
|
|
19712
|
+
if (Array.isArray(currency)) {
|
|
19663
19713
|
return null;
|
|
19664
19714
|
}
|
|
19665
19715
|
var otherAssets = getOtherAssetsImpl(chain, ctx);
|
|
19666
19716
|
var nativeAssets = getNativeAssetsImpl(chain, ctx);
|
|
19667
19717
|
var assets = [].concat(_toConsumableArray(nativeAssets), _toConsumableArray(otherAssets));
|
|
19668
19718
|
var asset;
|
|
19669
|
-
if ('location' in currency
|
|
19719
|
+
if ('location' in currency) {
|
|
19670
19720
|
asset = findAssetInfoByLoc(assets, currency.location);
|
|
19671
19721
|
} else if ('symbol' in currency) {
|
|
19672
19722
|
asset = findAssetInfoBySymbol(otherAssets, nativeAssets, currency.symbol, destination !== null && destination !== void 0 ? destination : undefined);
|
|
@@ -19679,34 +19729,6 @@ var findAssetInfo = function findAssetInfo(chain, currency, destination) {
|
|
|
19679
19729
|
return findAssetInfoImpl(chain, currency, destination);
|
|
19680
19730
|
};
|
|
19681
19731
|
|
|
19682
|
-
var Native = function Native(symbol) {
|
|
19683
|
-
return {
|
|
19684
|
-
type: 'Native',
|
|
19685
|
-
value: symbol
|
|
19686
|
-
};
|
|
19687
|
-
};
|
|
19688
|
-
var Foreign = function Foreign(symbol) {
|
|
19689
|
-
return {
|
|
19690
|
-
type: 'Foreign',
|
|
19691
|
-
value: symbol
|
|
19692
|
-
};
|
|
19693
|
-
};
|
|
19694
|
-
var ForeignAbstract = function ForeignAbstract(symbol) {
|
|
19695
|
-
return {
|
|
19696
|
-
type: 'ForeignAbstract',
|
|
19697
|
-
value: symbol
|
|
19698
|
-
};
|
|
19699
|
-
};
|
|
19700
|
-
/**
|
|
19701
|
-
* @deprecated Use the `customAssets` Builder option to register the asset instead. Will be removed in v14.
|
|
19702
|
-
*/
|
|
19703
|
-
var Override = function Override(location) {
|
|
19704
|
-
return {
|
|
19705
|
-
type: 'Override',
|
|
19706
|
-
value: location
|
|
19707
|
-
};
|
|
19708
|
-
};
|
|
19709
|
-
|
|
19710
19732
|
var STABLECOIN_IDS = [1984, 1337];
|
|
19711
19733
|
|
|
19712
19734
|
var hasStablecoinIndex = function hasStablecoinIndex(location, assetId) {
|
|
@@ -19947,21 +19969,6 @@ var isChainEvmImpl = function isChainEvmImpl(chain, ctx) {
|
|
|
19947
19969
|
var isChainEvm = function isChainEvm(chain) {
|
|
19948
19970
|
return isChainEvmImpl(chain);
|
|
19949
19971
|
};
|
|
19950
|
-
/**
|
|
19951
|
-
* Retrieves the asset ID for a given symbol on a specified chain.
|
|
19952
|
-
*
|
|
19953
|
-
* @deprecated Use `findAssetInfo` instead. Will be removed in v14.
|
|
19954
|
-
*
|
|
19955
|
-
* @param chain - The chain to search for the asset.
|
|
19956
|
-
* @param symbol - The symbol of the asset.
|
|
19957
|
-
* @returns The asset ID if found; otherwise, null.
|
|
19958
|
-
*/
|
|
19959
|
-
var getAssetId = function getAssetId(chain, symbol) {
|
|
19960
|
-
var asset = getAssetsObject(chain).assets.find(function (o) {
|
|
19961
|
-
return o.symbol === symbol;
|
|
19962
|
-
});
|
|
19963
|
-
return asset != null && asset.assetId ? asset.assetId : null;
|
|
19964
|
-
};
|
|
19965
19972
|
var getRelayChainSymbolImpl = function getRelayChainSymbolImpl(chain, ctx) {
|
|
19966
19973
|
return getAssetsObjectImpl(chain, ctx).relaychainSymbol;
|
|
19967
19974
|
};
|
|
@@ -20040,55 +20047,6 @@ var getNativeAssetSymbolImpl = function getNativeAssetSymbolImpl(chain, ctx) {
|
|
|
20040
20047
|
var getNativeAssetSymbol = function getNativeAssetSymbol(chain) {
|
|
20041
20048
|
return getNativeAssetSymbolImpl(chain);
|
|
20042
20049
|
};
|
|
20043
|
-
/**
|
|
20044
|
-
* Determines whether a specified chain supports an asset with the given symbol.
|
|
20045
|
-
*
|
|
20046
|
-
* @deprecated Use `findAssetInfo` instead. Will be removed in v14.
|
|
20047
|
-
*
|
|
20048
|
-
* @param chain - The chain to check for asset support.
|
|
20049
|
-
* @param symbol - The symbol of the asset to check.
|
|
20050
|
-
* @returns True if the asset is supported; otherwise, false.
|
|
20051
|
-
*/
|
|
20052
|
-
var hasSupportForAsset = function hasSupportForAsset(chain, symbol) {
|
|
20053
|
-
var lowerSymbol = symbol.toLowerCase();
|
|
20054
|
-
var symbolsToCheck = new Set();
|
|
20055
|
-
symbolsToCheck.add(lowerSymbol);
|
|
20056
|
-
if (lowerSymbol.startsWith('xc')) {
|
|
20057
|
-
symbolsToCheck.add(lowerSymbol.substring(2));
|
|
20058
|
-
} else {
|
|
20059
|
-
symbolsToCheck.add("xc".concat(lowerSymbol));
|
|
20060
|
-
}
|
|
20061
|
-
if (lowerSymbol.endsWith('.e')) {
|
|
20062
|
-
symbolsToCheck.add(lowerSymbol.substring(0, lowerSymbol.length - 2));
|
|
20063
|
-
} else {
|
|
20064
|
-
symbolsToCheck.add("".concat(lowerSymbol, ".e"));
|
|
20065
|
-
}
|
|
20066
|
-
var chainSymbols = getAllAssetsSymbols(chain).map(function (s) {
|
|
20067
|
-
return s.toLowerCase();
|
|
20068
|
-
});
|
|
20069
|
-
return chainSymbols.some(function (chainSymbol) {
|
|
20070
|
-
return symbolsToCheck.has(chainSymbol);
|
|
20071
|
-
});
|
|
20072
|
-
};
|
|
20073
|
-
/**
|
|
20074
|
-
* Retrieves the number of decimals for an asset with the given symbol on a specified chain.
|
|
20075
|
-
*
|
|
20076
|
-
* @deprecated Use `findAssetInfo` instead. Will be removed in v14.
|
|
20077
|
-
*
|
|
20078
|
-
* @param chain - The chain where the asset is located.
|
|
20079
|
-
* @param symbol - The symbol of the asset.
|
|
20080
|
-
* @returns The number of decimals if the asset is found; otherwise, null.
|
|
20081
|
-
*/
|
|
20082
|
-
var getAssetDecimals = function getAssetDecimals(chain, symbol) {
|
|
20083
|
-
var _getAssetsObject2 = getAssetsObject(chain),
|
|
20084
|
-
assets = _getAssetsObject2.assets;
|
|
20085
|
-
var isMainNativeAsset = isSymbolMatch(symbol, getNativeAssetSymbol(chain));
|
|
20086
|
-
if (isMainNativeAsset) return findNativeAssetInfoOrThrowImpl(chain).decimals;
|
|
20087
|
-
var asset = assets.find(function (o) {
|
|
20088
|
-
return o.symbol === symbol;
|
|
20089
|
-
});
|
|
20090
|
-
return (asset === null || asset === void 0 ? void 0 : asset.decimals) !== undefined ? asset.decimals : null;
|
|
20091
|
-
};
|
|
20092
20050
|
var hasDryRunSupportImpl = function hasDryRunSupportImpl(chain, ctx) {
|
|
20093
20051
|
// These chains have DryRun but it's not working
|
|
20094
20052
|
var DISABLED_CHAINS = ['Basilisk', 'Jamton'];
|
|
@@ -20217,4 +20175,22 @@ var getSupportedDestinations = function getSupportedDestinations(origin, currenc
|
|
|
20217
20175
|
});
|
|
20218
20176
|
};
|
|
20219
20177
|
|
|
20220
|
-
|
|
20178
|
+
/**
|
|
20179
|
+
* Normalizes an asset symbol by stripping the 'xc' prefix (if present) and converting it to lowercase.
|
|
20180
|
+
*
|
|
20181
|
+
* @param symbol - The symbol to normalize.
|
|
20182
|
+
* @returns The normalized symbol.
|
|
20183
|
+
*/
|
|
20184
|
+
var normalizeSymbol = function normalizeSymbol(symbol) {
|
|
20185
|
+
if (!symbol) return '';
|
|
20186
|
+
var s = symbol.toLowerCase();
|
|
20187
|
+
if (s.startsWith('xc')) s = s.substring(2);
|
|
20188
|
+
if (s.endsWith('.e')) s = s.slice(0, -2);
|
|
20189
|
+
return s;
|
|
20190
|
+
};
|
|
20191
|
+
|
|
20192
|
+
var isSymbolMatch = function isSymbolMatch(symbolA, symbolB) {
|
|
20193
|
+
return normalizeSymbol(symbolA) === normalizeSymbol(symbolB);
|
|
20194
|
+
};
|
|
20195
|
+
|
|
20196
|
+
export { CustomAssetConflictError, DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, assertEdDefined, canonicalizeLocation, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoImpl, findAssetInfoOnDest, findAssetInfoOnDestImpl, findAssetInfoOrThrow, findAssetInfoOrThrowImpl, findAssetOnDestOrThrow, findAssetOnDestOrThrowImpl, findBestMatches, findNativeAssetInfo, findNativeAssetInfoImpl, findNativeAssetInfoOrThrow, findNativeAssetInfoOrThrowImpl, getAllAssetsSymbols, getAssetLocation, getAssets, getAssetsImpl, getAssetsObject, getAssetsObjectImpl, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositImpl, getExistentialDepositOrThrow, getExistentialDepositOrThrowImpl, getFeeAssets, getNativeAssetSymbol, getNativeAssetSymbolImpl, getNativeAssets, getNativeAssetsImpl, getOtherAssets, getOtherAssetsImpl, getRelayChainSymbol, getRelayChainSymbolImpl, getSupportedAssets, getSupportedAssetsImpl, getSupportedDestinations, hasDryRunSupport, hasDryRunSupportImpl, hasXcmPaymentApiSupport, hasXcmPaymentApiSupportImpl, isAssetEqual, isBridgedSystemAsset, isChainEvm, isChainEvmImpl, isCustomAsset, 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": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "Assets for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,12 +22,14 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@paraspell/sdk-common": "
|
|
25
|
+
"@paraspell/sdk-common": "14.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/plugin-syntax-import-attributes": "^7.29.7",
|
|
29
29
|
"@babel/preset-env": "^7.29.7",
|
|
30
30
|
"@codecov/rollup-plugin": "^2.0.1",
|
|
31
|
+
"@polkadot-api/metadata-builders": "^0.14.3",
|
|
32
|
+
"@polkadot-api/substrate-bindings": "^0.20.3",
|
|
31
33
|
"@rollup/plugin-babel": "^7.1.0",
|
|
32
34
|
"@rollup/plugin-json": "^6.1.0",
|
|
33
35
|
"@rollup/plugin-typescript": "^12.3.0",
|