Skip to content

Conversation

@storywithoutend
Copy link
Collaborator

Summary

Enables the referrer parameter to accept ENS names and automatically resolve them to addresses using forward resolution.

Changes

  • Added resolveReferrerToHex utility function with ENS forward resolution (address record → owner fallback)
  • Created useResolvedReferrer React hook with React Query caching (5min stale time)
  • Integrated into ExtendNames transaction flow with loading states
  • Integrated into Registration flow with automatic updates
  • Integrated into DesyncedMessage component with loading states

Resolution Flow

  1. referrer=vitalik.eth (ENS name)
  2. Try getAddressRecord('vitalik.eth') → if exists, use address
  3. If no address record, try getOwner('vitalik.eth') → use owner/registrant
  4. Convert address to 32-byte hex: 0x000...000<address>

Test Coverage

  • ✅ 13 test cases for resolveReferrerToHex utility
  • ✅ 5 test cases for useResolvedReferrer hook
  • ✅ 3 integration test cases for ExtendNames flow
  • ✅ All 1,717 existing tests passing
  • ✅ Type checking passes
  • ✅ Linting passes

Files Changed

  • 8 files modified (+392 lines, -22 lines)
  • New utility: src/utils/referrer.ts
  • New hook: src/hooks/useResolvedReferrer.ts
  • Updated flows: ExtendNames, Registration, DesyncedMessage

Backward Compatibility

✅ Hex addresses still work as before (passthrough)
✅ Failed resolution doesn't block user flows (graceful degradation)
✅ Optional parameter - transactions proceed without referrer if resolution fails

🤖 Generated with Claude Code

storywithoutend and others added 6 commits November 20, 2025 11:01
- Resolves ENS names to addresses (address record → owner fallback)
- Converts resolved addresses to 32-byte hex format
- Handles invalid names and resolution errors gracefully
- React hook wrapping resolveReferrerToHex utility
- Uses React Query for caching with 5min stale time
- Returns loading/error states for UI integration
- Use useResolvedReferrer hook to resolve ENS names
- Add loading state for referrer resolution
- Remove direct use of getReferrerHex utility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Use useResolvedReferrer to resolve ENS names to addresses
- Update registration reducer with resolved hex value
- Automatic resolution on component mount and when referrer changes
- Replace getReferrerHex with useResolvedReferrer hook
- Add loading state (disabled button while resolving)
- Use referrerHex ?? undefined pattern for null to undefined conversion
- Follows same pattern as ExtendNames flow

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Documents the complete implementation plan for referrer parameter enhancement
- Includes detailed steps for adding forward resolution (ENS name → address)
- Resolution flow: address record → owner fallback → 32-byte hex conversion
@socket-security
Copy link

socket-security bot commented Nov 20, 2025

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 20, 2025

Deploying ens-app-v3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: a5c3f91
Status: ✅  Deploy successful!
Preview URL: https://f79624e2.ens-app-v3.pages.dev
Branch Preview URL: https://feature-fet-2614-add-reverse.ens-app-v3.pages.dev

View logs

@storywithoutend storywithoutend changed the base branch from main to feature/fet-2425-update-manager-app-for-ens-contracts160 November 20, 2025 04:15
Base automatically changed from feature/fet-2425-update-manager-app-for-ens-contracts160 to main November 29, 2025 09:44
storywithoutend and others added 7 commits December 8, 2025 16:17
…tate

Move setReferrer dispatch from useEffect to pricingCallback to ensure
referrer is set synchronously when user proceeds. Add isLoading prop to
Pricing component to disable continue button while referrer is resolving.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add DesyncedMessage.test.tsx with tests for button disabled state
  during referrer resolution and referrer passed to transaction
- Add Pricing.test.tsx test for isLoading prop showing loading button
- Add useResolvedReferrer.test.tsx test for hex address pass-through
- Rename referrerParam to referrer and referrerHex to resolvedReferrer
  across all components for clarity
- Remove debug console.logs from useResolvedReferrer and ExtendNames
- Simplify resolveReferrer to only use getAddressRecord (remove getOwner)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Move ENS name resolution logic from utility function into useResolvedReferrer
hook to follow React Query semantics. Add loading indicators to buttons in
ExtendNames, DesyncedMessage, and Pricing flows while referrer resolves.

- Remove resolveReferrer utility, keep only getReferrerHex
- Inline resolution logic in hook's query function
- Show loading spinner on buttons during referrer resolution
- Update tests to mock getAddressRecord directly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ation

- Use ExtendNamesModal page object instead of unreliable button selectors
- Fix success message case sensitivity (Extend names not Extend Names)
- Add wait for button to be enabled when resolving ENS name referrers
- Add isValidEnsName check before attempting ENS resolution
- Add ensValidation utility with normalize from viem/ens
- Update tests to follow existing patterns and handle async resolution

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add ReferrerNotifications component that displays a toast when resolvedReferrer
errors (e.g., invalid ENS name or address). The toast shows only once per referrer
value to avoid spamming the user.

- Create ReferrerNotifications component with show-once logic using useRef
- Add unit tests for error display and show-once behavior
- Add e2e tests for referrer error scenarios
- Add translation key for referrer error title
- Mount component in _app.tsx

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sonarqubecloud
Copy link

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.

2 participants