@chainflip/utils 0.8.4 → 0.8.6

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.
@@ -247,19 +247,7 @@ var assetContractId = {
247
247
  HubUsdt: 12,
248
248
  HubUsdc: 13
249
249
  };
250
- function isValidAssetAndChain(assetAndChain) {
251
- const { asset, chain } = assetAndChain;
252
- if (!(chain in chainConstants)) return false;
253
- const validAssets = chainConstants[chain].assets;
254
- return validAssets.includes(asset);
255
- }
256
250
  function getInternalAsset(asset, assert = true) {
257
- if (!isValidAssetAndChain(asset)) {
258
- if (assert) {
259
- throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
260
- }
261
- return null;
262
- }
263
251
  const map = {
264
252
  Ethereum: {
265
253
  USDC: "Usdc",
@@ -288,7 +276,14 @@ function getInternalAsset(asset, assert = true) {
288
276
  }
289
277
  };
290
278
  const chain = map[asset.chain];
291
- return chain[asset.asset];
279
+ const internalAsset = chain?.[asset.asset];
280
+ if (internalAsset) return internalAsset;
281
+ if (assert) throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
282
+ return null;
283
+ }
284
+ function isValidAssetAndChain(assetAndChain) {
285
+ const asset = getInternalAsset(assetAndChain, false);
286
+ return asset !== null;
292
287
  }
293
288
  function getInternalAssets({
294
289
  srcAsset,
@@ -31,10 +31,16 @@ type BaseChainAssetMap<T> = {
31
31
  };
32
32
  type AssetAndChain = {
33
33
  [C in ChainflipChain]: {
34
- chain: C;
35
- asset: keyof ChainAssetMap<unknown>[C];
36
- };
34
+ [A in keyof ChainAssetMap<unknown>[C]]: {
35
+ chain: C;
36
+ asset: A;
37
+ };
38
+ }[keyof ChainAssetMap<unknown>[C]];
37
39
  }[ChainflipChain];
40
+ type BaseAssetAndChain = Exclude<AssetAndChain, {
41
+ chain: 'Ethereum';
42
+ asset: 'USDC';
43
+ }>;
38
44
  type ChainMap<T> = {
39
45
  [C in ChainflipChain]: T;
40
46
  };
@@ -181,10 +187,12 @@ declare const chainConstants: {
181
187
  declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain>;
182
188
  declare const chainContractId: ChainMap<number>;
183
189
  declare const assetContractId: InternalAssetMap<number>;
184
- declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
190
+ declare function getInternalAsset(asset: BaseAssetAndChain): BaseChainflipAsset;
191
+ declare function getInternalAsset(asset: AssetAndChain): ChainflipAsset;
185
192
  declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
186
193
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
187
194
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
195
+ declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
188
196
  declare function getInternalAssets(data: {
189
197
  srcAsset: AssetSymbol;
190
198
  srcChain: ChainflipChain;
@@ -213,4 +221,4 @@ declare function getInternalAssets(data: {
213
221
  destAsset: ChainflipAsset | null;
214
222
  };
215
223
 
216
- export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
224
+ export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseAssetAndChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
@@ -31,10 +31,16 @@ type BaseChainAssetMap<T> = {
31
31
  };
32
32
  type AssetAndChain = {
33
33
  [C in ChainflipChain]: {
34
- chain: C;
35
- asset: keyof ChainAssetMap<unknown>[C];
36
- };
34
+ [A in keyof ChainAssetMap<unknown>[C]]: {
35
+ chain: C;
36
+ asset: A;
37
+ };
38
+ }[keyof ChainAssetMap<unknown>[C]];
37
39
  }[ChainflipChain];
40
+ type BaseAssetAndChain = Exclude<AssetAndChain, {
41
+ chain: 'Ethereum';
42
+ asset: 'USDC';
43
+ }>;
38
44
  type ChainMap<T> = {
39
45
  [C in ChainflipChain]: T;
40
46
  };
@@ -181,10 +187,12 @@ declare const chainConstants: {
181
187
  declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain>;
182
188
  declare const chainContractId: ChainMap<number>;
183
189
  declare const assetContractId: InternalAssetMap<number>;
184
- declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
190
+ declare function getInternalAsset(asset: BaseAssetAndChain): BaseChainflipAsset;
191
+ declare function getInternalAsset(asset: AssetAndChain): ChainflipAsset;
185
192
  declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
186
193
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
187
194
  declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
195
+ declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
188
196
  declare function getInternalAssets(data: {
189
197
  srcAsset: AssetSymbol;
190
198
  srcChain: ChainflipChain;
@@ -213,4 +221,4 @@ declare function getInternalAssets(data: {
213
221
  destAsset: ChainflipAsset | null;
214
222
  };
215
223
 
216
- export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
224
+ export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseAssetAndChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
package/dist/chainflip.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  isValidAssetAndChain,
17
17
  readAssetValue,
18
18
  rpcAssets
19
- } from "./chunk-6LZGVCU6.js";
19
+ } from "./chunk-4DFBUXHM.js";
20
20
  export {
21
21
  addressTypes,
22
22
  assetConstants,
@@ -207,19 +207,7 @@ var assetContractId = {
207
207
  HubUsdt: 12,
208
208
  HubUsdc: 13
209
209
  };
210
- function isValidAssetAndChain(assetAndChain) {
211
- const { asset, chain } = assetAndChain;
212
- if (!(chain in chainConstants)) return false;
213
- const validAssets = chainConstants[chain].assets;
214
- return validAssets.includes(asset);
215
- }
216
210
  function getInternalAsset(asset, assert = true) {
217
- if (!isValidAssetAndChain(asset)) {
218
- if (assert) {
219
- throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
220
- }
221
- return null;
222
- }
223
211
  const map = {
224
212
  Ethereum: {
225
213
  USDC: "Usdc",
@@ -248,7 +236,14 @@ function getInternalAsset(asset, assert = true) {
248
236
  }
249
237
  };
250
238
  const chain = map[asset.chain];
251
- return chain[asset.asset];
239
+ const internalAsset = chain?.[asset.asset];
240
+ if (internalAsset) return internalAsset;
241
+ if (assert) throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
242
+ return null;
243
+ }
244
+ function isValidAssetAndChain(assetAndChain) {
245
+ const asset = getInternalAsset(assetAndChain, false);
246
+ return asset !== null;
252
247
  }
253
248
  function getInternalAssets({
254
249
  srcAsset,
@@ -277,7 +272,7 @@ export {
277
272
  internalAssetToRpcAsset,
278
273
  chainContractId,
279
274
  assetContractId,
280
- isValidAssetAndChain,
281
275
  getInternalAsset,
276
+ isValidAssetAndChain,
282
277
  getInternalAssets
283
278
  };
package/dist/consts.cjs CHANGED
@@ -153,6 +153,10 @@ var brokerAliasMap = {
153
153
  cFPD5DrrsHb7Wi5nmBcFuPDcGRsWhv5Bz6vvzGqFYPFhbR3Sw: {
154
154
  name: "Squid",
155
155
  twitter: "@squidrouter"
156
+ },
157
+ cFJZvt5AiEGwUiFFNxhDuLRcgC1WBR6tE7gaQQfe8dqbzoYkx: {
158
+ name: "Symbiosis",
159
+ twitter: "@symbiosis_fi"
156
160
  }
157
161
  };
158
162
  var lpAliasMap = {
package/dist/consts.js CHANGED
@@ -119,6 +119,10 @@ var brokerAliasMap = {
119
119
  cFPD5DrrsHb7Wi5nmBcFuPDcGRsWhv5Bz6vvzGqFYPFhbR3Sw: {
120
120
  name: "Squid",
121
121
  twitter: "@squidrouter"
122
+ },
123
+ cFJZvt5AiEGwUiFFNxhDuLRcgC1WBR6tE7gaQQfe8dqbzoYkx: {
124
+ name: "Symbiosis",
125
+ twitter: "@symbiosis_fi"
122
126
  }
123
127
  };
124
128
  var lpAliasMap = {
package/dist/tickMath.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assetConstants
3
- } from "./chunk-6LZGVCU6.js";
3
+ } from "./chunk-4DFBUXHM.js";
4
4
 
5
5
  // src/tickMath.ts
6
6
  import BigNumber from "bignumber.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/utils",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",