@coin-voyage/paykit
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
20 lines (19 loc) • 694 B
JavaScript
import { useAccount, useConfig as useBigmiConfig } from "@bigmi/react";
import { isBitcoinAddress } from "@coin-voyage/shared/common";
import { ChainType } from "@coin-voyage/shared/types";
import { useConfig } from "wagmi";
export function useChainIsSupported(chainType, chainId) {
const { chains } = useConfig();
const config = useBigmiConfig();
const { account } = useAccount({ config });
if (!chainId) {
return false;
}
if (chainType === ChainType.UTXO) {
return Boolean(account?.address && isBitcoinAddress(account.address));
}
if (chainType === ChainType.EVM) {
return chains.some((x) => x.id === chainId);
}
return true;
}