@lifi/widget
Version:
LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.
31 lines (27 loc) • 865 B
text/typescript
import { isUTXOAddress } from '@bigmi/core'
import { ChainId, ChainType, isSVMAddress } from '@lifi/sdk'
import { isValidSuiAddress } from '@mysten/sui/utils'
import { isAddress as isEVMAddress } from 'viem'
const chainTypeAddressValidation = {
[]: isEVMAddress,
[]: isSVMAddress,
[]: isValidSuiAddress,
[]: isUTXOAddress,
}
export const getChainTypeFromAddress = (
address: string
): ChainType | undefined => {
for (const chainType in chainTypeAddressValidation) {
const isChainType =
chainTypeAddressValidation[chainType as ChainType](address)
if (isChainType) {
return chainType as ChainType
}
}
}
export const defaultChainIdsByType = {
[]: ChainId.ETH,
[]: ChainId.SOL,
[]: ChainId.BTC,
[]: ChainId.SUI,
}