From ce92c6d4dd8f516039fb92b79ff0a8f4c37b405b Mon Sep 17 00:00:00 2001 From: gitwoz <177856586+gitwoz@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:54:29 +0800 Subject: [PATCH] feat(ipns): show IPNS (RSS) dialog only if user has ENS --- src/common/utils/wallet.ts | 6 +++--- src/views/User/UserProfile/DropdownActions/index.tsx | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/common/utils/wallet.ts b/src/common/utils/wallet.ts index 98aa371d45..b25eda65c6 100644 --- a/src/common/utils/wallet.ts +++ b/src/common/utils/wallet.ts @@ -1,11 +1,11 @@ import { Chain, configureChains, createConfig } from 'wagmi' import { - goerli, mainnet, optimism, optimismSepolia, polygon, polygonMumbai, + sepolia, } from 'wagmi/chains' import { InjectedConnector } from 'wagmi/connectors/injected' import { WalletConnectConnector } from 'wagmi/connectors/walletConnect' @@ -20,7 +20,7 @@ const alchemyId = process.env.NEXT_PUBLIC_ALCHEMY_KEY! export const featureSupportedChains = { billboard: isProd ? [optimism] : [optimismSepolia], curation: isProd ? [optimism] : [optimismSepolia], - ens: isProd ? [mainnet] : [goerli], + ens: isProd ? [mainnet] : [sepolia], } export const explorers = { @@ -34,7 +34,7 @@ export const explorers = { const defaultChains: Chain[] = isProd ? [mainnet, optimism] - : [goerli, optimismSepolia] + : [sepolia, optimismSepolia] export const { publicClient, chains } = configureChains(defaultChains, [ alchemyProvider({ apiKey: alchemyId }), diff --git a/src/views/User/UserProfile/DropdownActions/index.tsx b/src/views/User/UserProfile/DropdownActions/index.tsx index ac18a449af..edb2b6d9f2 100644 --- a/src/views/User/UserProfile/DropdownActions/index.tsx +++ b/src/views/User/UserProfile/DropdownActions/index.tsx @@ -4,10 +4,12 @@ import _pickBy from 'lodash/pickBy' import dynamic from 'next/dynamic' import { useContext } from 'react' import { FormattedMessage, useIntl } from 'react-intl' +import { useEnsName } from 'wagmi' import { ReactComponent as IconMore } from '@/public/static/icons/24px/more.svg' import { ReactComponent as IconRss } from '@/public/static/icons/24px/rss.svg' import { ReactComponent as IconShare } from '@/public/static/icons/24px/share.svg' +import { featureSupportedChains } from '~/common/utils' import { Button, Dropdown, @@ -230,11 +232,17 @@ const BaseDropdownActions = ({ const DropdownActions = ({ user, isMe, isInAside }: DropdownActionsProps) => { const viewer = useContext(ViewerContext) + const targetNetwork = featureSupportedChains.ens[0] + const { data: ensName } = useEnsName({ + address: user.info.ethAddress as `0x${string}`, + chainId: targetNetwork.id, + }) const controls = { hasEditProfile: isMe, hasBlockUser: !!viewer.id && !isMe, - hasRssFeed: user?.articles.totalCount > 0 && !!user?.info.ipnsKey, + hasRssFeed: + ensName && user?.articles.totalCount > 0 && !!user?.info.ipnsKey, } const WithShare = withDialog>(