@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.
21 lines (17 loc) • 580 B
text/typescript
import { useMemo } from 'react'
import type { FormType } from '../form/types.js'
import { useChainOrderStore } from './ChainOrderStore.js'
import { maxChainsToOrder } from './createChainOrderStore.js'
export const useChainOrder = (
type: FormType
): [number[], (chainId: number, type: FormType) => void] => {
const [chainOrder, setChain] = useChainOrderStore((state) => [
state.chainOrder[type],
state.setChain,
])
const limitedChainOrder = useMemo(
() => chainOrder.slice(0, maxChainsToOrder),
[chainOrder]
)
return [limitedChainOrder, setChain]
}