@sky-mavis/tanto-widget
Version:
Tanto Widget
39 lines (35 loc) • 1.41 kB
JavaScript
;
var react = require('react');
var useWidgetUIConfig = require('../../../../contexts/widget-ui-config/useWidgetUIConfig.cjs');
var useIsMobileView = require('../../../../hooks/useIsMobileView.cjs');
var walletDetection = require('../../../../utils/walletDetection.cjs');
function useWalletState(wallet) {
const {
icon,
connector,
displayOptions = {}
} = wallet;
const {
thumbnail,
highlightBackground
} = displayOptions;
const {
markKeylessWalletConnected = false,
markWCConnected = false
} = useWidgetUIConfig.useWidgetUIConfig();
const isMobile = useIsMobileView.useIsMobileView();
return react.useMemo(() => {
const isWaypointWallet = walletDetection.isWaypointConnector(connector?.id);
const isWCWallet = walletDetection.isWCConnector(connector?.id);
const isInjected = walletDetection.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]);
}
exports.useWalletState = useWalletState;