From e9c6f13b2c2582cab143087e064e4b424134059e Mon Sep 17 00:00:00 2001 From: julink-eth Date: Thu, 18 Apr 2024 10:29:32 +0200 Subject: [PATCH] fix: ens-app build linting --- .../[name]/registration/CompletePoh.tsx | 41 ------------------- .../[name]/registration/RegistrationPoh.tsx | 3 +- .../registration/steps/PohCheck/PohCheck.tsx | 13 ++---- .../[name]/registration/steps/PohInfo.tsx | 1 - .../ens-app-v3/src/hooks/usePohRegistered.ts | 6 +-- packages/ens-app-v3/src/hooks/usePohStatus.ts | 4 +- .../src/hooks/useRegistrationPohParams.ts | 2 +- 7 files changed, 10 insertions(+), 60 deletions(-) diff --git a/packages/ens-app-v3/src/components/pages/profile/[name]/registration/CompletePoh.tsx b/packages/ens-app-v3/src/components/pages/profile/[name]/registration/CompletePoh.tsx index bbe04de8a..504c29599 100644 --- a/packages/ens-app-v3/src/components/pages/profile/[name]/registration/CompletePoh.tsx +++ b/packages/ens-app-v3/src/components/pages/profile/[name]/registration/CompletePoh.tsx @@ -97,47 +97,6 @@ const SubtitleWithGradient = styled(Typography)( `, ) -const nameRegisteredSnippet = [ - { - anonymous: false, - inputs: [ - { - indexed: false, - name: 'name', - type: 'string', - }, - { - indexed: true, - name: 'label', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'address', - name: 'owner', - type: 'address', - }, - { - indexed: false, - name: 'baseCost', - type: 'uint256', - }, - { - indexed: false, - name: 'premium', - type: 'uint256', - }, - { - indexed: false, - name: 'expires', - type: 'uint256', - }, - ], - name: 'NameRegistered', - type: 'event', - }, -] as const - const Confetti = dynamic(() => import('react-confetti').then((mod) => mod.default as typeof ConfettiT), ) diff --git a/packages/ens-app-v3/src/components/pages/profile/[name]/registration/RegistrationPoh.tsx b/packages/ens-app-v3/src/components/pages/profile/[name]/registration/RegistrationPoh.tsx index 1593fd597..ac24ea5fd 100644 --- a/packages/ens-app-v3/src/components/pages/profile/[name]/registration/RegistrationPoh.tsx +++ b/packages/ens-app-v3/src/components/pages/profile/[name]/registration/RegistrationPoh.tsx @@ -128,7 +128,7 @@ const Registration = ({ nameDetails, isLoading }: Props) => { const commitKey = `commit-${keySuffix}` const registerKey = `register-${keySuffix}` - const pohSignature = address ? usePohSignature(address) : undefined + const pohSignature = usePohSignature(address) const { cleanupFlow } = useTransactionFlow() @@ -283,7 +283,6 @@ const Registration = ({ nameDetails, isLoading }: Props) => { ), info: ( + const [reverseRecord] = useState(() => registrationData.started ? registrationData.reverseRecord : !hasPrimaryName, ) - - let pohAlreadyRegistered - if (address) { - const { data: pohAlreadyRegisteredData } = usePohRegistered(address) - pohAlreadyRegistered = pohAlreadyRegisteredData - } + const { data: pohAlreadyRegistered } = usePohRegistered(address) const fullEstimate = useEstimateFullRegistrationPoh({ name, @@ -198,7 +191,7 @@ const PohCheck = ({ {!pohSignature && ( {t('steps.pohCheck.getPoh')}{' '} - + {t('steps.pohCheck.getPohHereLink')} diff --git a/packages/ens-app-v3/src/components/pages/profile/[name]/registration/steps/PohInfo.tsx b/packages/ens-app-v3/src/components/pages/profile/[name]/registration/steps/PohInfo.tsx index 53d95d906..ea009dadc 100644 --- a/packages/ens-app-v3/src/components/pages/profile/[name]/registration/steps/PohInfo.tsx +++ b/packages/ens-app-v3/src/components/pages/profile/[name]/registration/steps/PohInfo.tsx @@ -96,7 +96,6 @@ const infoItemArr = Array.from({ length: 3 }, (_, i) => `steps.info.ethItems.${i type Props = { registrationData: RegistrationReducerDataItem - name: string callback: (data: { back: boolean }) => void onProfileClick: () => void } diff --git a/packages/ens-app-v3/src/hooks/usePohRegistered.ts b/packages/ens-app-v3/src/hooks/usePohRegistered.ts index c1f204d04..496dd0eb1 100644 --- a/packages/ens-app-v3/src/hooks/usePohRegistered.ts +++ b/packages/ens-app-v3/src/hooks/usePohRegistered.ts @@ -1,9 +1,9 @@ -import { Address } from 'viem' +import { Address, zeroAddress } from 'viem' import { useReadContract } from 'wagmi' import { useContractAddress } from './chain/useContractAddress' -export const usePohRegistered = (address: Address) => { +export const usePohRegistered = (address: Address | undefined) => { const ethRegistrarControllerAddress = useContractAddress({ contract: 'ensEthRegistrarController', }) @@ -19,7 +19,7 @@ export const usePohRegistered = (address: Address) => { }, ], address: ethRegistrarControllerAddress, - args: [address], + args: [address || zeroAddress], functionName: 'hasRegisteredPoh', }) } diff --git a/packages/ens-app-v3/src/hooks/usePohStatus.ts b/packages/ens-app-v3/src/hooks/usePohStatus.ts index 9a4bb8667..f445ded35 100644 --- a/packages/ens-app-v3/src/hooks/usePohStatus.ts +++ b/packages/ens-app-v3/src/hooks/usePohStatus.ts @@ -1,7 +1,7 @@ import { useMemo, useState } from 'react' import { Address, Hex } from 'viem' -export const usePohSignature = (address: Address): Hex | undefined => { +export const usePohSignature = (address: Address | undefined): Hex | undefined => { const [signature, setSignature] = useState(undefined) useMemo(async () => { const pohSignatureApi = process.env.NEXT_PUBLIC_POH_SIGNATURE_API @@ -12,7 +12,7 @@ export const usePohSignature = (address: Address): Hex | undefined => { }) const respResult = resp.ok ? await resp.text() : undefined setSignature(respResult) - }, []) + }, [address]) return signature ? (signature as `0x${string}`) : undefined } diff --git a/packages/ens-app-v3/src/hooks/useRegistrationPohParams.ts b/packages/ens-app-v3/src/hooks/useRegistrationPohParams.ts index 7e418cadf..f47887b81 100644 --- a/packages/ens-app-v3/src/hooks/useRegistrationPohParams.ts +++ b/packages/ens-app-v3/src/hooks/useRegistrationPohParams.ts @@ -47,7 +47,7 @@ const useRegistrationPohParams = ({ name, owner, registrationData, pohSignature reverseRecord: registrationData.reverseRecord, signature: pohSignature, }), - [owner, name, registrationData], + [owner, name, registrationData, pohSignature], ) return registrationParams