@paraspell/assets 10.11.10 → 11.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 +10 -10
- package/dist/index.cjs +1425 -997
- package/dist/index.d.ts +112 -116
- package/dist/index.mjs +1414 -986
- package/package.json +3 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TLocation, TChain, Version } from '@paraspell/sdk-common';
|
|
2
|
+
|
|
3
|
+
type TAsset<T = bigint> = TAssetV3<T> | TAssetV4<T>;
|
|
4
|
+
interface TAssetV3<T = bigint> {
|
|
5
|
+
id: {
|
|
6
|
+
Concrete: TLocation;
|
|
7
|
+
};
|
|
8
|
+
fun: {
|
|
9
|
+
Fungible: T;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface TAssetV4<T = bigint> {
|
|
13
|
+
id: TLocation;
|
|
14
|
+
fun: {
|
|
15
|
+
Fungible: T;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
2
18
|
|
|
3
19
|
type AtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
4
20
|
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
|
5
21
|
}[Keys];
|
|
6
|
-
type
|
|
22
|
+
type TBaseAssetInfo = {
|
|
7
23
|
symbol: string;
|
|
8
|
-
decimals
|
|
24
|
+
decimals: number;
|
|
9
25
|
manuallyAdded?: boolean;
|
|
10
26
|
alias?: string;
|
|
11
27
|
existentialDeposit?: string;
|
|
12
28
|
isFeeAsset?: boolean;
|
|
13
29
|
};
|
|
14
|
-
type
|
|
30
|
+
type TNativeAssetInfo = TBaseAssetInfo & {
|
|
15
31
|
isNative: true;
|
|
16
|
-
|
|
32
|
+
location?: TLocation;
|
|
17
33
|
};
|
|
18
|
-
type
|
|
34
|
+
type TForeignAssetInfo = TBaseAssetInfo & AtLeastOne<{
|
|
19
35
|
assetId?: string;
|
|
20
|
-
|
|
36
|
+
location?: TLocation;
|
|
21
37
|
}>;
|
|
22
|
-
type TForeignAssetWithId =
|
|
38
|
+
type TForeignAssetWithId = TForeignAssetInfo & {
|
|
23
39
|
assetId: string;
|
|
24
40
|
};
|
|
25
|
-
type
|
|
26
|
-
type TAssetWithLocation =
|
|
27
|
-
|
|
41
|
+
type TAssetInfo = TNativeAssetInfo | TForeignAssetInfo;
|
|
42
|
+
type TAssetWithLocation = TAssetInfo & {
|
|
43
|
+
location: TLocation;
|
|
28
44
|
};
|
|
29
|
-
type
|
|
30
|
-
|
|
45
|
+
type TChainAssetsInfo = {
|
|
46
|
+
relaychainSymbol: string;
|
|
31
47
|
nativeAssetSymbol: string;
|
|
32
48
|
isEVM: boolean;
|
|
33
49
|
ss58Prefix: number;
|
|
34
50
|
supportsDryRunApi: boolean;
|
|
35
51
|
supportsXcmPaymentApi: boolean;
|
|
36
|
-
nativeAssets:
|
|
37
|
-
otherAssets:
|
|
52
|
+
nativeAssets: TNativeAssetInfo[];
|
|
53
|
+
otherAssets: TForeignAssetInfo[];
|
|
38
54
|
};
|
|
39
|
-
type TAssetJsonMap = Record<
|
|
40
|
-
|
|
41
|
-
type TMultiAsset<T = bigint> = TMultiAssetV3<T> | TMultiAssetV4<T>;
|
|
42
|
-
interface TMultiAssetV3<T = bigint> {
|
|
43
|
-
id: {
|
|
44
|
-
Concrete: TMultiLocation;
|
|
45
|
-
};
|
|
46
|
-
fun: {
|
|
47
|
-
Fungible: T;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
interface TMultiAssetV4<T = bigint> {
|
|
51
|
-
id: TMultiLocation;
|
|
52
|
-
fun: {
|
|
53
|
-
Fungible: T;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
55
|
+
type TAssetJsonMap = Record<TChain, TChainAssetsInfo>;
|
|
56
56
|
|
|
57
57
|
type TAmount = string | number | bigint;
|
|
58
58
|
type TCurrency = string | number | bigint;
|
|
@@ -60,9 +60,9 @@ type TSymbolSpecifier = {
|
|
|
60
60
|
type: 'Native' | 'Foreign' | 'ForeignAbstract';
|
|
61
61
|
value: string;
|
|
62
62
|
};
|
|
63
|
-
type
|
|
63
|
+
type TOverrideLocationSpecifier = {
|
|
64
64
|
type: 'Override';
|
|
65
|
-
value:
|
|
65
|
+
value: TLocation;
|
|
66
66
|
};
|
|
67
67
|
type TCurrencySymbolValue = string | TSymbolSpecifier;
|
|
68
68
|
type TCurrencySymbol = {
|
|
@@ -71,152 +71,148 @@ type TCurrencySymbol = {
|
|
|
71
71
|
type TCurrencyCore = TCurrencySymbol | {
|
|
72
72
|
id: TCurrency;
|
|
73
73
|
} | {
|
|
74
|
-
|
|
74
|
+
location: TLocationValue;
|
|
75
75
|
};
|
|
76
|
-
type
|
|
76
|
+
type TAssetWithFee = TAsset & {
|
|
77
77
|
isFeeAsset?: boolean;
|
|
78
78
|
};
|
|
79
|
-
type
|
|
80
|
-
type
|
|
79
|
+
type TLocationValue = string | TLocation;
|
|
80
|
+
type TLocationValueWithOverride = TLocationValue | TOverrideLocationSpecifier;
|
|
81
81
|
type TCurrencyInputWithAmount = WithComplexAmount<TCurrencySymbol | {
|
|
82
82
|
id: TCurrency;
|
|
83
83
|
} | {
|
|
84
|
-
|
|
85
|
-
}> |
|
|
86
|
-
multiasset: TMultiAsset<TAmount>[] | WithComplexAmount<TCurrencyCore>[];
|
|
87
|
-
};
|
|
84
|
+
location: TLocationValueWithOverride;
|
|
85
|
+
}> | TAsset<TAmount>[] | WithComplexAmount<TCurrencyCore>[];
|
|
88
86
|
type TCurrencyInput = TCurrencySymbol | {
|
|
89
87
|
id: TCurrency;
|
|
90
88
|
} | {
|
|
91
|
-
|
|
92
|
-
} |
|
|
93
|
-
multiasset: TMultiAsset<TAmount>[] | WithComplexAmount<TCurrencyCore>[];
|
|
94
|
-
};
|
|
89
|
+
location: TLocationValueWithOverride;
|
|
90
|
+
} | TAsset<TAmount>[] | WithComplexAmount<TCurrencyCore>[];
|
|
95
91
|
type WithAmount<TBase, T = bigint> = TBase & {
|
|
96
92
|
amount: T;
|
|
97
93
|
};
|
|
98
94
|
type WithComplexAmount<TBase> = WithAmount<TBase, TAmount>;
|
|
99
95
|
|
|
100
96
|
/**
|
|
101
|
-
* Retrieves the existential deposit value for a given
|
|
97
|
+
* Retrieves the existential deposit value for a given chain.
|
|
102
98
|
*
|
|
103
|
-
* @param
|
|
104
|
-
* @returns The existential deposit as a
|
|
99
|
+
* @param chain - The chain for which to get the existential deposit.
|
|
100
|
+
* @returns The existential deposit as a bigint if available; otherwise, null.
|
|
105
101
|
*/
|
|
106
|
-
declare const getExistentialDeposit: (
|
|
107
|
-
declare const getExistentialDepositOrThrow: (
|
|
102
|
+
declare const getExistentialDeposit: (chain: TChain, currency?: TCurrencyCore) => bigint | null;
|
|
103
|
+
declare const getExistentialDepositOrThrow: (chain: TChain, currency?: TCurrencyCore) => bigint;
|
|
108
104
|
|
|
109
|
-
declare const getFeeAssets: (
|
|
105
|
+
declare const getFeeAssets: (chain: TChain) => Omit<TAssetInfo, "isFeeAsset">[];
|
|
110
106
|
|
|
111
107
|
/**
|
|
112
|
-
* Retrieves the assets object for a given
|
|
108
|
+
* Retrieves the assets object for a given chain containing the native and foreign assets.
|
|
113
109
|
*
|
|
114
|
-
* @param
|
|
115
|
-
* @returns The assets object associated with the given
|
|
110
|
+
* @param chain - The chain for which to retrieve the assets object.
|
|
111
|
+
* @returns The assets object associated with the given chain.
|
|
116
112
|
*/
|
|
117
|
-
declare const getAssetsObject: (
|
|
118
|
-
declare const
|
|
113
|
+
declare const getAssetsObject: (chain: TChain) => TChainAssetsInfo;
|
|
114
|
+
declare const isChainEvm: (chain: TChain) => boolean;
|
|
119
115
|
/**
|
|
120
|
-
* Retrieves the asset ID for a given symbol on a specified
|
|
116
|
+
* Retrieves the asset ID for a given symbol on a specified chain.
|
|
121
117
|
*
|
|
122
|
-
* @param
|
|
118
|
+
* @param chain - The chain to search for the asset.
|
|
123
119
|
* @param symbol - The symbol of the asset.
|
|
124
120
|
* @returns The asset ID if found; otherwise, null.
|
|
125
121
|
*/
|
|
126
|
-
declare const getAssetId: (
|
|
122
|
+
declare const getAssetId: (chain: TChain, symbol: string) => string | null;
|
|
127
123
|
/**
|
|
128
|
-
* Retrieves the relay chain asset symbol for a specified
|
|
124
|
+
* Retrieves the relay chain asset symbol for a specified chain.
|
|
129
125
|
*
|
|
130
|
-
* @param
|
|
126
|
+
* @param chain - The chain for which to get the relay chain symbol.
|
|
131
127
|
* @returns The relay chain asset symbol.
|
|
132
128
|
*/
|
|
133
|
-
declare const getRelayChainSymbol: (
|
|
129
|
+
declare const getRelayChainSymbol: (chain: TChain) => string;
|
|
134
130
|
/**
|
|
135
|
-
* Retrieves the list of native assets for a specified
|
|
131
|
+
* Retrieves the list of native assets for a specified chain.
|
|
136
132
|
*
|
|
137
|
-
* @param
|
|
133
|
+
* @param chain - The chain for which to get native assets.
|
|
138
134
|
* @returns An array of native asset details.
|
|
139
135
|
*/
|
|
140
|
-
declare const getNativeAssets: (
|
|
136
|
+
declare const getNativeAssets: (chain: TChain) => TNativeAssetInfo[];
|
|
141
137
|
/**
|
|
142
|
-
* Retrieves the list of other (non-native) assets for a specified
|
|
138
|
+
* Retrieves the list of other (non-native) assets for a specified chain.
|
|
143
139
|
*
|
|
144
|
-
* @param
|
|
140
|
+
* @param chain - The chain for which to get other assets.
|
|
145
141
|
* @returns An array of other asset details.
|
|
146
142
|
*/
|
|
147
|
-
declare const getOtherAssets: (
|
|
143
|
+
declare const getOtherAssets: (chain: TChain) => TForeignAssetInfo[];
|
|
148
144
|
/**
|
|
149
|
-
* Retrieves the complete list of assets for a specified
|
|
145
|
+
* Retrieves the complete list of assets for a specified chain, including relay chain asset, native, and other assets.
|
|
150
146
|
*
|
|
151
|
-
* @param
|
|
152
|
-
* @returns An array of objects of all assets associated with the
|
|
147
|
+
* @param chain - The chain for which to get the assets.
|
|
148
|
+
* @returns An array of objects of all assets associated with the chain.
|
|
153
149
|
*/
|
|
154
|
-
declare const getAssets: (
|
|
150
|
+
declare const getAssets: (chain: TChain) => TAssetInfo[];
|
|
155
151
|
/**
|
|
156
|
-
* Retrieves the symbols of all assets (relay chain, native, and other assets) for a specified
|
|
152
|
+
* Retrieves the symbols of all assets (relay chain, native, and other assets) for a specified chain.
|
|
157
153
|
*
|
|
158
|
-
* @param
|
|
154
|
+
* @param chain - The chain for which to get asset symbols.
|
|
159
155
|
* @returns An array of asset symbols.
|
|
160
156
|
*/
|
|
161
|
-
declare const getAllAssetsSymbols: (
|
|
157
|
+
declare const getAllAssetsSymbols: (chain: TChain) => string[];
|
|
162
158
|
/**
|
|
163
|
-
* Retrieves the symbol of the native asset for a specified
|
|
159
|
+
* Retrieves the symbol of the native asset for a specified chain.
|
|
164
160
|
*
|
|
165
|
-
* @param
|
|
161
|
+
* @param chain - The chain for which to get the native asset symbol.
|
|
166
162
|
* @returns The symbol of the native asset.
|
|
167
163
|
*/
|
|
168
|
-
declare const getNativeAssetSymbol: (
|
|
164
|
+
declare const getNativeAssetSymbol: (chain: TChain) => string;
|
|
169
165
|
/**
|
|
170
|
-
* Determines whether a specified
|
|
166
|
+
* Determines whether a specified chain supports an asset with the given symbol.
|
|
171
167
|
*
|
|
172
|
-
* @param
|
|
168
|
+
* @param chain - The chain to check for asset support.
|
|
173
169
|
* @param symbol - The symbol of the asset to check.
|
|
174
170
|
* @returns True if the asset is supported; otherwise, false.
|
|
175
171
|
*/
|
|
176
|
-
declare const hasSupportForAsset: (
|
|
172
|
+
declare const hasSupportForAsset: (chain: TChain, symbol: string) => boolean;
|
|
177
173
|
/**
|
|
178
|
-
* Retrieves the number of decimals for an asset with the given symbol on a specified
|
|
174
|
+
* Retrieves the number of decimals for an asset with the given symbol on a specified chain.
|
|
179
175
|
*
|
|
180
|
-
* @param
|
|
176
|
+
* @param chain - The chain where the asset is located.
|
|
181
177
|
* @param symbol - The symbol of the asset.
|
|
182
178
|
* @returns The number of decimals if the asset is found; otherwise, null.
|
|
183
179
|
*/
|
|
184
|
-
declare const getAssetDecimals: (
|
|
185
|
-
declare const hasDryRunSupport: (
|
|
186
|
-
declare const hasXcmPaymentApiSupport: (
|
|
180
|
+
declare const getAssetDecimals: (chain: TChain, symbol: string) => number | null;
|
|
181
|
+
declare const hasDryRunSupport: (chain: TChain) => boolean;
|
|
182
|
+
declare const hasXcmPaymentApiSupport: (chain: TChain) => boolean;
|
|
187
183
|
|
|
188
184
|
declare const Native: (symbol: string) => TSymbolSpecifier;
|
|
189
185
|
declare const Foreign: (symbol: string) => TSymbolSpecifier;
|
|
190
186
|
declare const ForeignAbstract: (symbol: string) => TSymbolSpecifier;
|
|
191
|
-
declare const Override: (
|
|
187
|
+
declare const Override: (location: TLocation) => TOverrideLocationSpecifier;
|
|
192
188
|
|
|
193
|
-
declare const filterEthCompatibleAssets: (assets:
|
|
189
|
+
declare const filterEthCompatibleAssets: (assets: TForeignAssetInfo[]) => TForeignAssetInfo[];
|
|
194
190
|
|
|
195
191
|
/**
|
|
196
|
-
* Retrieves the list of assets that are supported for transfers between two specified
|
|
192
|
+
* Retrieves the list of assets that are supported for transfers between two specified chains.
|
|
197
193
|
*
|
|
198
|
-
* @param origin - The origin
|
|
199
|
-
* @param destination - The destination
|
|
200
|
-
* @returns An array of assets supported between the origin and destination
|
|
194
|
+
* @param origin - The origin chain.
|
|
195
|
+
* @param destination - The destination chain.
|
|
196
|
+
* @returns An array of assets supported between the origin and destination chains.
|
|
201
197
|
*/
|
|
202
|
-
declare const getSupportedAssets: (origin:
|
|
198
|
+
declare const getSupportedAssets: (origin: TChain, destination: TChain) => TAssetInfo[];
|
|
203
199
|
|
|
204
|
-
declare const getSupportedDestinations: (origin:
|
|
200
|
+
declare const getSupportedDestinations: (origin: TChain, currency: TCurrencyCore) => TChain[];
|
|
205
201
|
|
|
206
|
-
declare const isAssetEqual: (asset1:
|
|
202
|
+
declare const isAssetEqual: (asset1: TAssetInfo, asset2: TAssetInfo) => boolean;
|
|
207
203
|
|
|
208
204
|
declare const isSymbolMatch: (symbolA: string, symbolB: string) => boolean;
|
|
209
205
|
|
|
210
206
|
/**
|
|
211
|
-
* Converts a
|
|
207
|
+
* Converts a location to a specific XCM version
|
|
212
208
|
*
|
|
213
209
|
* In XCM v3, `interior.X1` is a single `Object`. In XCM V4, `interior.X1` is an `Array<Object>`.
|
|
214
210
|
*
|
|
215
|
-
* @param
|
|
216
|
-
* @param version - The target XCM version: `'V3'`, `'V4'` or `'V5'`. Defaults to `'
|
|
217
|
-
* @returns A new transformed `
|
|
211
|
+
* @param location - The location to normalize.
|
|
212
|
+
* @param version - The target XCM version: `'V3'`, `'V4'` or `'V5'`. Defaults to `'V5'`.
|
|
213
|
+
* @returns A new transformed `TLocation`
|
|
218
214
|
*/
|
|
219
|
-
declare const
|
|
215
|
+
declare const normalizeLocation: (location: TLocation, version?: Version) => TLocation;
|
|
220
216
|
|
|
221
217
|
/**
|
|
222
218
|
* Normalizes an asset symbol by stripping the 'xc' prefix (if present) and converting it to lowercase.
|
|
@@ -226,18 +222,18 @@ declare const normalizeMultiLocation: (multiLocation: TMultiLocation, version?:
|
|
|
226
222
|
*/
|
|
227
223
|
declare const normalizeSymbol: (symbol: string | undefined) => string;
|
|
228
224
|
|
|
229
|
-
declare const
|
|
225
|
+
declare const findAssetInfo: (chain: TChain, currency: TCurrencyInput, destination: TChain | null) => TAssetInfo | null;
|
|
230
226
|
|
|
231
|
-
declare const
|
|
227
|
+
declare const findAssetInfoById: (assets: TForeignAssetInfo[], assetId: TCurrency) => TForeignAssetInfo | undefined;
|
|
232
228
|
|
|
233
|
-
declare const
|
|
229
|
+
declare const findAssetInfoByLoc: (foreignAssets: TForeignAssetInfo[], location: string | TLocation) => TForeignAssetInfo | undefined;
|
|
234
230
|
|
|
235
|
-
declare const
|
|
231
|
+
declare const findAssetInfoBySymbol: (destination: TChain | null, otherAssets: TForeignAssetInfo[], nativeAssets: TNativeAssetInfo[], symbol: TCurrencySymbolValue) => TAssetInfo | undefined;
|
|
236
232
|
|
|
237
|
-
declare const
|
|
233
|
+
declare const findAssetInfoOnDest: (origin: TChain, destination: TChain, currency: TCurrencyInput, originAsset?: TAssetInfo | null) => TAssetInfo | null;
|
|
234
|
+
declare const findAssetOnDestOrThrow: (origin: TChain, destination: TChain, currency: TCurrencyInput) => TAssetInfo;
|
|
238
235
|
|
|
239
|
-
declare const
|
|
240
|
-
declare const findAssetOnDestOrThrow: (origin: TNodeWithRelayChains, destination: TNodeWithRelayChains, currency: TCurrencyInput) => TAsset;
|
|
236
|
+
declare const findAssetInfoOrThrow: (chain: TChain, currency: TCurrencyInput, destination: TChain | null) => TAssetInfo;
|
|
241
237
|
|
|
242
238
|
declare const findBestMatches: <T extends {
|
|
243
239
|
symbol: string;
|
|
@@ -280,19 +276,19 @@ declare class InvalidCurrencyError extends Error {
|
|
|
280
276
|
constructor(message: string);
|
|
281
277
|
}
|
|
282
278
|
|
|
283
|
-
declare const isForeignAsset: (asset:
|
|
279
|
+
declare const isForeignAsset: (asset: TAssetInfo) => asset is TForeignAssetInfo;
|
|
284
280
|
|
|
285
|
-
declare const
|
|
281
|
+
declare const isOverrideLocationSpecifier: (locationSpecifier: TLocationValueWithOverride) => locationSpecifier is TOverrideLocationSpecifier;
|
|
286
282
|
|
|
287
283
|
declare const isSymbolSpecifier: (currencySymbolValue: TCurrencySymbolValue) => currencySymbolValue is TSymbolSpecifier;
|
|
288
284
|
|
|
289
|
-
declare const
|
|
285
|
+
declare const isTAsset: <T = bigint>(value: unknown) => value is TAsset<T>;
|
|
290
286
|
|
|
291
|
-
declare const
|
|
287
|
+
declare const compareLocations: (input: string, asset: TForeignAssetInfo) => boolean;
|
|
292
288
|
|
|
293
|
-
declare const
|
|
289
|
+
declare const extractAssetLocation: <T = bigint>(asset: TAsset<T>) => TLocation;
|
|
294
290
|
|
|
295
|
-
declare const
|
|
291
|
+
declare const getAssetLocation: (chain: TChain, currency: TCurrencyInput) => TLocation | null;
|
|
296
292
|
|
|
297
|
-
export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override,
|
|
298
|
-
export type { TAmount, TAsset,
|
|
293
|
+
export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, compareLocations, extractAssetLocation, filterEthCompatibleAssets, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoOnDest, findAssetInfoOrThrow, findAssetOnDestOrThrow, findBestMatches, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsObject, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getSupportedDestinations, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isChainEvm, isForeignAsset, isOverrideLocationSpecifier, isSymbolMatch, isSymbolSpecifier, isTAsset, normalizeLocation, normalizeSymbol };
|
|
294
|
+
export type { TAmount, TAsset, TAssetInfo, TAssetJsonMap, TAssetV3, TAssetV4, TAssetWithFee, TAssetWithLocation, TChainAssetsInfo, TCurrency, TCurrencyCore, TCurrencyInput, TCurrencyInputWithAmount, TCurrencySymbol, TCurrencySymbolValue, TForeignAssetInfo, TForeignAssetWithId, TLocationValue, TLocationValueWithOverride, TNativeAssetInfo, TOverrideLocationSpecifier, TSymbolSpecifier, WithAmount, WithComplexAmount };
|