import React, { PropsWithChildren, useState } from 'react'

import { Chains } from '../../core'
import { ChainContext } from '../../store/wallet/chain-context'

interface ChainProviderProps {
  chains: Chains
}

export const ChainProvider: React.FC<PropsWithChildren<ChainProviderProps>> = ({
  chains,
  children
}) => {
  const [chainId, setChainId] = useState<string | undefined>()

  return (
    <ChainContext.Provider
      value={{
        chains,
        chainId,
        setChainId
      }}
    >
      {children}
    </ChainContext.Provider>
  )
}
