@lifi/data-types
Version:
Data types for the LI.FI stack
36 lines (32 loc) • 1.18 kB
text/typescript
import type { Chain, ChainKey } from '@lifi/types'
import { supportedEVMChains } from './supportedChains.evm.js'
import { supportedMVMChains } from './supportedChains.mvm.js'
import { supportedSVMChains } from './supportedChains.svm.js'
import { supportedUXTOChains } from './supportedChains.utxo.js'
import { supportedTVMChains } from './supportedChains.tvm.js'
import { supportedSTLChains } from './supportedChains.stl.js'
// This assignment is required to avoid breaking
// changes with the new non EVM support types release
// This will be removed in the future
export const supportedChains = [
...supportedEVMChains,
...supportedSVMChains,
...supportedMVMChains,
...supportedUXTOChains,
...supportedTVMChains,
...supportedSTLChains,
]
export const getChainByKey = (chainKey: ChainKey): Chain => {
const chain = supportedChains.find((c) => c.key === chainKey)
if (!chain) {
throw new Error(`Invalid chainKey '${chainKey}'`)
}
return chain
}
export const getChainById = (chainId: number): Chain => {
const chain = supportedChains.find((c) => c.id === chainId)
if (!chain) {
throw new Error(`Invalid chainId '${chainId}'`)
}
return chain
}