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