UNPKG

@sky-mavis/tanto-widget

Version:
29 lines 1.3 kB
import {useMemo}from'react';import {useWidgetUIConfig}from'../../../../contexts/widget-ui-config/useWidgetUIConfig.mjs';import {useIsMobileView}from'../../../../hooks/useIsMobileView.mjs';import {isWaypointConnector,isWCConnector,isInjectedConnector}from'../../../../utils/walletDetection.mjs';function useWalletState(wallet) { const { icon, connector, displayOptions = {} } = wallet; const { thumbnail, highlightBackground } = displayOptions; const { markKeylessWalletConnected = false, markWCConnected = false } = useWidgetUIConfig(); const isMobile = useIsMobileView(); return useMemo(() => { const isWaypointWallet = isWaypointConnector(connector?.id); const isWCWallet = isWCConnector(connector?.id); const isInjected = isInjectedConnector(connector?.type); const isMarkedConnected = isWaypointWallet && markKeylessWalletConnected || isWCWallet && markWCConnected; return { walletLogo: thumbnail ?? icon, isMarkedConnected, isInjected, isWCWallet, highlightContent: highlightBackground ? isMobile ? 'Fastest' : 'Fastest to start' : undefined }; }, [thumbnail, icon, connector?.id, connector?.type, markKeylessWalletConnected, markWCConnected, highlightBackground, isMobile]); }export{useWalletState};