@paraspell/assets 13.5.0 → 13.6.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.d.ts CHANGED
@@ -79,6 +79,16 @@ type WithAmount<TBase, T = bigint> = TBase & {
79
79
  };
80
80
  type WithComplexAmount<TBase> = WithAmount<TBase, TAmount>;
81
81
 
82
+ type TCustomAssetInfo = TAssetInfo & {
83
+ forceOverride?: boolean;
84
+ };
85
+ type TCustomAssetsMap = Partial<Record<TChain, TCustomAssetInfo[]>>;
86
+ type TCustomAssetsMapNormalized = Partial<Record<TChain, TAssetInfo[]>>;
87
+ type TCustomCtx = {
88
+ customAssets?: TCustomAssetsMapNormalized;
89
+ customChainAssets?: Record<string, TChainAssetsInfo>;
90
+ };
91
+
82
92
  /**
83
93
  * Retrieves the existential deposit value for a given chain.
84
94
  *
@@ -92,6 +102,7 @@ declare const getEdFromAssetOrThrow: (asset: TAssetInfo) => bigint;
92
102
 
93
103
  declare const getFeeAssets: (chain: TChain) => Omit<TAssetInfo, "isFeeAsset">[];
94
104
 
105
+ declare const getAssetsObjectImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => TChainAssetsInfo;
95
106
  /**
96
107
  * Retrieves the assets object for a given chain containing the native and foreign assets.
97
108
  *
@@ -99,7 +110,8 @@ declare const getFeeAssets: (chain: TChain) => Omit<TAssetInfo, "isFeeAsset">[];
99
110
  * @returns The assets object associated with the given chain.
100
111
  */
101
112
  declare const getAssetsObject: (chain: TChain) => TChainAssetsInfo;
102
- declare const isChainEvm: (chain: TChain) => boolean;
113
+ declare const isChainEvmImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => boolean;
114
+ declare const isChainEvm: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => boolean;
103
115
  /**
104
116
  * Retrieves the asset ID for a given symbol on a specified chain.
105
117
  *
@@ -110,6 +122,7 @@ declare const isChainEvm: (chain: TChain) => boolean;
110
122
  * @returns The asset ID if found; otherwise, null.
111
123
  */
112
124
  declare const getAssetId: (chain: TChain, symbol: string) => string | null;
125
+ declare const getRelayChainSymbolImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => string;
113
126
  /**
114
127
  * Retrieves the relay chain asset symbol for a specified chain.
115
128
  *
@@ -117,6 +130,7 @@ declare const getAssetId: (chain: TChain, symbol: string) => string | null;
117
130
  * @returns The relay chain asset symbol.
118
131
  */
119
132
  declare const getRelayChainSymbol: (chain: TChain) => string;
133
+ declare const getNativeAssetsImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => TAssetInfo[];
120
134
  /**
121
135
  * Retrieves the list of native assets for a specified chain.
122
136
  *
@@ -124,13 +138,15 @@ declare const getRelayChainSymbol: (chain: TChain) => string;
124
138
  * @returns An array of native asset details.
125
139
  */
126
140
  declare const getNativeAssets: (chain: TChain) => TAssetInfo[];
141
+ declare const getOtherAssetsImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => TAssetInfo[];
127
142
  /**
128
143
  * Retrieves the list of other (non-native) assets for a specified chain.
129
144
  *
130
145
  * @param chain - The chain for which to get other assets.
131
146
  * @returns An array of other asset details.
132
147
  */
133
- declare const getOtherAssets: (chain: TChain) => TAssetInfo[];
148
+ declare const getOtherAssets: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => TAssetInfo[];
149
+ declare const getAssetsImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => TAssetInfo[];
134
150
  /**
135
151
  * Retrieves the complete list of assets for a specified chain, including relay chain asset, native, and other assets.
136
152
  *
@@ -145,13 +161,14 @@ declare const getAssets: (chain: TChain) => TAssetInfo[];
145
161
  * @returns An array of asset symbols.
146
162
  */
147
163
  declare const getAllAssetsSymbols: (chain: TChain) => string[];
164
+ declare const getNativeAssetSymbolImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => string;
148
165
  /**
149
166
  * Retrieves the symbol of the native asset for a specified chain.
150
167
  *
151
168
  * @param chain - The chain for which to get the native asset symbol.
152
169
  * @returns The symbol of the native asset.
153
170
  */
154
- declare const getNativeAssetSymbol: (chain: TChain) => string;
171
+ declare const getNativeAssetSymbol: <TCustomChain extends string = never>(chain: TChain | TCustomChain) => string;
155
172
  /**
156
173
  * Determines whether a specified chain supports an asset with the given symbol.
157
174
  *
@@ -172,14 +189,23 @@ declare const hasSupportForAsset: (chain: TChain, symbol: string) => boolean;
172
189
  * @returns The number of decimals if the asset is found; otherwise, null.
173
190
  */
174
191
  declare const getAssetDecimals: (chain: TChain, symbol: string) => number | null;
192
+ declare const hasDryRunSupportImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => boolean;
175
193
  declare const hasDryRunSupport: (chain: TChain) => boolean;
194
+ declare const hasXcmPaymentApiSupportImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => boolean;
176
195
  declare const hasXcmPaymentApiSupport: (chain: TChain) => boolean;
177
196
 
178
197
  declare const Native: (symbol: string) => TSymbolSpecifier;
179
198
  declare const Foreign: (symbol: string) => TSymbolSpecifier;
180
199
  declare const ForeignAbstract: (symbol: string) => TSymbolSpecifier;
200
+ /**
201
+ * @deprecated Use the `customAssets` Builder option to register the asset instead. Will be removed in v14.
202
+ */
181
203
  declare const Override: (location: TLocation) => TOverrideLocationSpecifier;
182
204
 
205
+ declare const normalizeCustomAssets: (map: TCustomAssetsMap | undefined) => TCustomAssetsMapNormalized;
206
+ declare const isCustomAsset: (chain: TChain, asset: TAssetInfo, ctx?: Pick<TCustomCtx, "customAssets">) => boolean;
207
+
208
+ declare const getSupportedAssetsImpl: <TCustomChain extends string = never>(origin: TChain | TCustomChain, destination: TChain | TCustomChain, ctx?: TCustomCtx) => TAssetInfo[];
183
209
  /**
184
210
  * Retrieves the list of assets that are supported for transfers between two specified chains.
185
211
  *
@@ -212,6 +238,7 @@ declare const isBridgedSystemAsset: (asset: TAssetInfo, relayChains: readonly TR
212
238
  * @returns A new transformed `TLocation`
213
239
  */
214
240
  declare const normalizeLocation: (location: TLocation, version?: Version) => TLocation;
241
+ declare const canonicalizeLocation: (location: TLocation) => TLocation;
215
242
 
216
243
  /**
217
244
  * Normalizes an asset symbol by stripping the 'xc' prefix (if present) and converting it to lowercase.
@@ -221,24 +248,38 @@ declare const normalizeLocation: (location: TLocation, version?: Version) => TLo
221
248
  */
222
249
  declare const normalizeSymbol: (symbol?: string) => string;
223
250
 
251
+ declare const findAssetInfoImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, currency: TCurrencyInput, destination?: TChain | TCustomChain | null, ctx?: TCustomCtx) => TAssetInfo | null;
224
252
  declare const findAssetInfo: (chain: TChain, currency: TCurrencyInput, destination?: TChain | null) => TAssetInfo | null;
225
253
 
226
254
  declare const findAssetInfoById: (assets: TAssetInfo[], assetId: TCurrency) => TAssetInfo;
227
255
 
228
256
  declare const findAssetInfoByLoc: (foreignAssets: TAssetInfo[], location: string | TLocation) => TAssetInfo | undefined;
229
257
 
230
- declare const findAssetInfoBySymbol: (otherAssets: TAssetInfo[], nativeAssets: TAssetInfo[], symbol: TCurrencySymbolValue, destination?: TChain) => TAssetInfo | undefined;
258
+ declare const findAssetInfoBySymbol: <TCustomChain extends string = never>(otherAssets: TAssetInfo[], nativeAssets: TAssetInfo[], symbol: TCurrencySymbolValue, destination?: TChain | TCustomChain) => TAssetInfo | undefined;
231
259
 
260
+ declare const findAssetInfoOnDestImpl: <TCustomChain extends string = never>(origin: TChain | TCustomChain, destination: TChain | TCustomChain, currency: TCurrencyInput, originAsset?: TAssetInfo | null, ctx?: TCustomCtx) => TAssetInfo | null;
232
261
  declare const findAssetInfoOnDest: (origin: TChain, destination: TChain, currency: TCurrencyInput, originAsset?: TAssetInfo | null) => TAssetInfo | null;
262
+ declare const findAssetOnDestOrThrowImpl: <TCustomChain extends string = never>(origin: TChain | TCustomChain, destination: TChain | TCustomChain, currency: TCurrencyInput, ctx?: TCustomCtx) => TAssetInfo;
233
263
  declare const findAssetOnDestOrThrow: (origin: TChain, destination: TChain, currency: TCurrencyInput) => TAssetInfo;
234
264
 
265
+ declare const findAssetInfoOrThrowImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, currency: TCurrencyInput, destination?: TChain | TCustomChain | null, ctx?: TCustomCtx) => TAssetInfo;
235
266
  declare const findAssetInfoOrThrow: (chain: TChain, currency: TCurrencyInput, destination?: TChain | null) => TAssetInfo;
236
267
 
237
268
  declare const findBestMatches: (assets: TAssetInfo[], value: string, property?: "symbol" | "alias") => TAssetInfo[];
238
269
 
270
+ declare const findNativeAssetInfoImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => TAssetInfo | null;
239
271
  declare const findNativeAssetInfo: (chain: TChain) => TAssetInfo | null;
272
+ declare const findNativeAssetInfoOrThrowImpl: <TCustomChain extends string = never>(chain: TChain | TCustomChain, ctx?: TCustomCtx) => TAssetInfo;
240
273
  declare const findNativeAssetInfoOrThrow: (chain: TChain) => TAssetInfo;
241
274
 
275
+ /**
276
+ * Error thrown when a custom asset's location collides with an existing
277
+ * registry asset and `forceOverride` was not set.
278
+ */
279
+ declare class CustomAssetConflictError extends Error {
280
+ constructor(msg: string);
281
+ }
282
+
242
283
  /**
243
284
  * Error thrown when multiple assets with the same symbol are found.
244
285
  */
@@ -287,5 +328,5 @@ declare const extractAssetLocation: <T = bigint>(asset: TAsset<T>) => TLocation;
287
328
 
288
329
  declare const getAssetLocation: (chain: TChain, currency: TCurrencyInput) => TLocation | null;
289
330
 
290
- export { DuplicateAssetError, DuplicateAssetIdError, Foreign, ForeignAbstract, InvalidCurrencyError, Native, Override, assertEdDefined, compareLocations, extractAssetLocation, findAssetInfo, findAssetInfoById, findAssetInfoByLoc, findAssetInfoBySymbol, findAssetInfoOnDest, findAssetInfoOrThrow, findAssetOnDestOrThrow, findBestMatches, findNativeAssetInfo, findNativeAssetInfoOrThrow, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssetLocation, getAssets, getAssetsObject, getEdFromAssetOrThrow, getExistentialDeposit, getExistentialDepositOrThrow, getFeeAssets, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getSupportedDestinations, hasDryRunSupport, hasSupportForAsset, hasXcmPaymentApiSupport, isAssetEqual, isAssetXcEqual, isBridgedSystemAsset, isChainEvm, isOverrideLocationSpecifier, isStableCoinAsset, isSymbolMatch, isSymbolSpecifier, isSystemAsset, isTAsset, normalizeLocation, normalizeSymbol };
291
- export type { TAmount, TAsset, TAssetInfo, TAssetInfoWithId, TAssetJsonMap, TAssetV3, TAssetV4, TAssetWithFee, TChainAssetsInfo, TCurrency, TCurrencyCore, TCurrencyInput, TCurrencyInputWithAmount, TCurrencySymbol, TCurrencySymbolValue, TLocationValue, TLocationValueWithOverride, TOverrideLocationSpecifier, TSymbolSpecifier, WithAmount, WithComplexAmount };
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 };
332
+ 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 };