Skip to content

Reject non-normalized primary names across profile UI#1146

Merged
laurgk merged 10 commits into
mainfrom
feature/web-532-bug-non-normalized-ens-names-displaying-in-app-instead-of
Jun 24, 2026
Merged

Reject non-normalized primary names across profile UI#1146
laurgk merged 10 commits into
mainfrom
feature/web-532-bug-non-normalized-ens-names-displaying-in-app-instead-of

Conversation

@svemat01

Copy link
Copy Markdown
Member

Summary

  • Treat non-normalized reverse records as invalid primary names
  • Centralize primary-name display checks so UI falls back to addresses when needed
  • Update profile, wallet, and transaction views to use the validated display name path

Testing

  • Updated unit coverage for primary-name resolution to include non-normalized reverse records
  • Not run (not requested)

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 23, 2026

Copy link
Copy Markdown

Deploying ens-app-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2584246
Status: ✅  Deploy successful!
Preview URL: https://6e00ab20.ens-app-v3.pages.dev
Branch Preview URL: https://feature-web-532-bug-non-norm.ens-app-v3.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens primary-name handling across the UI by treating non-normalized reverse records as invalid and centralizing “should we display a primary name vs fall back to address” logic.

Changes:

  • Add primaryNameUtils helpers (hasValidPrimaryName, getPrimaryDisplayName) and adopt them across profile/wallet/transaction UI.
  • Enforce normalization/validation in primary-name resolution (including raw reverse-name normalization checks and forward-resolution verification).
  • Update unit tests to cover unnormalized raw reverse names.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/transaction-flow/input/EditRoles/hooks/useSimpleSearch.ts Adds normalization validation for address → name search results (now includes an extra reverse read).
src/pages/profile.tsx Uses hasValidPrimaryName so self-profile falls back to address when primary is invalid.
src/hooks/reverseRecord/usePrimaryNameOrAddress.ts Centralizes display-name selection via primaryNameUtils and falls back to shortened address.
src/hooks/primary/queries/getPrimaryNameQuery.ts Rejects non-normalized reverse names and verifies forward resolution matches the address.
src/hooks/pages/profile/[name]/profile/useProfileActions/useProfileActions.ts Prevents invalid primary names from affecting “available primary name” logic.
src/hooks/ensjs/public/usePrimaryName.ts Adds raw reverse-name normalization check (via Universal Resolver) and returns null when invalid by default.
src/hooks/ensjs/public/usePrimaryName.test.ts Adds coverage for rejecting unnormalized raw reverse names; updates mocks.
src/hooks/ensjs/public/primaryNameUtils.ts Introduces shared helpers for validating and displaying primary names.
src/components/TabBar.tsx Only treats primary name as present when validated.
src/components/pages/profile/settings/PrimarySection/PrimarySection.tsx Gates primary-name UI paths behind hasValidPrimaryName.
src/components/pages/profile/ProfileButton.tsx Uses getPrimaryDisplayName and validated primary-name gating for profile link + copy actions.
src/components/pages/profile/NameSnippet.tsx Displays validated primary display name (with truncation) instead of always using beautifiedName.
src/components/pages/profile/[name]/tabs/ProfileTab.tsx Updates isPrimary to require a valid primary name.
src/components/pages/profile/[name]/tabs/OwnershipTab/sections/RolesSection/components/RoleRow.tsx Avoids using invalid primary names for explorer/profile actions and avatar identifiers.
src/components/pages/profile/[name]/tabs/MoreTab/PrimaryName.tsx Only shows the “primary” tag when the wallet primary name is valid.
src/components/pages/profile/[name]/tabs/MoreTab/Ownership.tsx Displays owner name via getPrimaryDisplayName with fallback to address.
src/components/pages/profile/[name]/registration/Registration.tsx Uses validated primary-name presence when passing hasPrimaryName.
src/components/pages/import/[name]/steps/onchain/ImportTransaction.tsx Uses getPrimaryDisplayName for invoice owner display.
src/components/@molecules/TransactionDialogManager/DisplayItems.tsx Uses getPrimaryDisplayName to decide address subtitle vs name display.
src/components/@molecules/ConnectButton/utils.tsx Uses hasValidPrimaryName to decide whether to show “My Profile” dropdown entry.
src/components/@molecules/ConnectButton/ConnectButton.tsx Uses getPrimaryDisplayName for header profile ENS label.
src/components/@molecules/AvatarWithIdentifier/AvatarWithIdentifier.tsx Uses getPrimaryDisplayName when primary name is fetched internally.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +46 to +57
const name = await getName(client, { address })
if (!name?.name || !name.match) return null

const ensUniversalResolverAddress = client.chain?.contracts?.ensUniversalResolver?.address
if (!ensUniversalResolverAddress) return null

const rawNameResult = await readContract(client, {
address: ensUniversalResolverAddress,
abi: universalResolverReverseSnippet,
functionName: 'reverse',
args: [address, 60n],
})
svemat01 added 5 commits June 24, 2026 02:19
Remove custom ENS reverse lookup and normalization logic. Rely on `getName` from `@ensdomains/ensjs/public` to correctly resolve and normalize names, addressing issues where non-normalized names could appear.
Updates the address page UI and `usePrimaryProfile` hook to no longer consider or display mismatched primary ENS names. This aligns with the underlying logic that now only returns normalized primary names, preventing unnormalized names from being shown in the profile snippet.
Adjusts primary name descriptions to use present tense "are shown" for normalized names, aligning messaging with current system behavior from WEB-532.

Updates the i18n link component key for better specificity and maintainability.
@svemat01 svemat01 marked this pull request as ready for review June 24, 2026 12:22
@svemat01 svemat01 requested a review from sugh01 as a code owner June 24, 2026 12:22
@laurgk laurgk merged commit c49c46d into main Jun 24, 2026
91 checks passed
@laurgk laurgk deleted the feature/web-532-bug-non-normalized-ens-names-displaying-in-app-instead-of branch June 24, 2026 17:02
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants