@particle-network/connectkit
Version:
8 lines (7 loc) • 3.82 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/pages/walletInfo/title.tsx"],
"sourcesContent": ["import { isSolanaChain } from '@particle-network/connector-core';\nimport { useMemo } from 'react';\nimport ShareIconCircle from '../../assets/icons/ShareIconCircle';\nimport CopyToClipboard from '../../components/copyToClipboard';\nimport WalletAAIcon from '../../components/walletAAIcon';\nimport WalletIcon from '../../components/walletIcon';\nimport { useAccount } from '../../hooks/useAccount';\nimport { useAddress } from '../../hooks/useAddress';\nimport { useChains } from '../../hooks/useChains';\nimport { useSmartAccount } from '../../hooks/useSmartAccount';\nimport { shortAddress } from '../../utils';\nimport { StyleAddressInfo, StyleShareContent, TitleContainer } from './styles';\n\nconst Title = () => {\n const chainList = useChains();\n const { chainId: currentChainId } = useAccount();\n const smartAccount = useSmartAccount();\n const address = useAddress();\n\n // @ts-ignore\n const aaIconName = smartAccount?.smartAccountContract?.name?.toUpperCase();\n /**\n * get block explorer url\n */\n const blockExplorerUrl = useMemo(() => {\n if (!currentChainId || !address || !chainList) {\n return '';\n }\n\n const currentChain = chainList.find((chain) => chain.id === currentChainId);\n\n if (!currentChain || !currentChain.blockExplorers) {\n return '';\n }\n\n const explorerUrl = currentChain.blockExplorers.default.url;\n\n if (isSolanaChain(currentChain)) {\n return `${explorerUrl}/account/${address}`;\n }\n\n return `${explorerUrl}/address/${address}`;\n }, [currentChainId, address, chainList]);\n\n return (\n <TitleContainer>\n <StyleAddressInfo>\n {!!address && (\n <>\n {/* <WalletIconWrapper>{walletConnection?.walletProps.icon}</WalletIconWrapper> */}\n {aaIconName ? <WalletAAIcon size={26} aaName={aaIconName} /> : <WalletIcon size={26} />}\n <CopyToClipboard string={address}>{shortAddress(address || '--')}</CopyToClipboard>\n <StyleShareContent>\n <ShareIconCircle\n style={blockExplorerUrl ? { cursor: 'pointer' } : { cursor: 'not-allowed', opacity: 0.4 }}\n onClick={() => {\n if (blockExplorerUrl) {\n window.open(blockExplor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