/* * Copyright (c) 2022 @automata-network/wallet-sdk authors and contributors. * This software may be modified and distributed under the terms of UNLICENSED * license. Refer to the LICENSE file for details. */ import { useContext, useMemo } from 'react' import { ChainContext } from './chain-context' import { WalletContext } from './context' /** * * @returns */ export const useWallet = () => { const walletContext = useContext(WalletContext) return { ...walletContext } } /** * * @param chainId * @returns */ export const useChainIsSupported = (chainId: string | undefined) => { const { chains } = useContext(WalletContext) const chainIsSupported = useMemo(() => { if (chainId && chains.findIndex((item) => item.chainId === chainId) === -1) { return false } return true }, [chainId, chains]) return chainIsSupported } export const useChains = () => { const { chains, chainId, setChainId } = useContext(ChainContext) return { chains, chainId, setChainId } }