[#1254] Build ReferralCTA.tsx (link + copy + share)#1292
Conversation
Fetches referral code via unauth GET /api/airdrop/referral-code. Shows referral URL with copy-to-clipboard (desktop + mobile fallback) and X share intent button. Multiplier benefit hint. Graceful empty state when code not yet created. Closes #1254 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
realproject7
left a comment
There was a problem hiding this comment.
@re2 review — APPROVE ✅
Checked against issue #1254 acceptance criteria:
| Criterion | Status |
|---|---|
| Unauth GET for ref code display (Risk A preserved) | ✅ no SIWE |
| Copy works desktop + mobile | ✅ clipboard API + execCommand fallback |
| X share intent with prefilled text | ✅ encoded URL + share text |
| Graceful empty state (no code yet) | ✅ |
| Multiplier benefit hint | ✅ "+0.2 per qualified referral (up to 3.0×)" |
| Version 1.38.0 → 1.39.0 (feature) | ✅ |
Code notes:
- Proper cleanup with
cancelledflag - Truncated URL display for mobile responsiveness
- 2-second copy confirmation feedback
- Share text suggests multiplier benefit for both parties
- Only renders in Mining state (parent state machine gates this)
No issues found.
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
The component uses the correct unauthenticated GET endpoint and implements copy/share UI, but it can display and share the wrong wallet’s referral link after wallet changes or a { code: null } response.
Findings
- [high] Referral code state is never cleared when the current wallet has no code.
- File:
src/components/airdrop/ReferralCTA.tsx:17 - The GET endpoint intentionally returns
200 { code: null }when no code exists. This handler only callssetCodewhend?.codeis truthy, so if wallet A has a code and the user switches to wallet B with no code, the old code remains rendered and the Copy/Share buttons continue promoting wallet A’s referral link. The same stale state can persist on disconnect until the parent unmounts. - Suggestion: track the fetch result by address and set
codetod?.code ?? nullfor every completed request, and clear/derive empty state when!isConnected || !address. This also gives the documented graceful{ code: null }path.
- File:
Decision
Requesting changes until referral code state is keyed/cleared so the displayed link always belongs to the active wallet. CI was still pending at review time.
Track fetched address in state so code clears automatically when wallet changes. Derive displayed code from address match instead of sync setState in effect. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The requested stale-code issue is resolved. ReferralCTA now keys the fetched code by active address and treats { code: null } as an empty result, so wallet switches cannot continue showing another wallet’s referral link.
Findings
- None blocking.
Decision
Approving PR #1292. The component uses the unauthenticated display endpoint, provides copy/share behavior, handles the empty-code state correctly, remains mining-gated by the parent state machine, and latest CI is green.
Summary
GET /api/airdrop/referral-code?address=X(Risk A preserved — no SIWE for display)https://plotlink.xyz/?ref=CODEwith truncated previewexecCommandfallback for mobileVersion
1.38.0 → 1.39.0 (feature)
Closes #1254
🤖 Generated with Claude Code