Skip to content

[#26] Donation flow on story page#74

Merged
realproject7 merged 2 commits intomainfrom
task/26-donation-flow
Mar 14, 2026
Merged

[#26] Donation flow on story page#74
realproject7 merged 2 commits intomainfrom
task/26-donation-flow

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • P5-4a: New DonateWidget component — amount input, PLOT_TOKEN approval check, StoryFactory.donate() call, donation indexer trigger
  • Full tx state UI: approving → confirming → pending → indexing → done/error with retry
  • All addresses from lib/contracts/constants.ts, reserve label adapts to testnet/mainnet
  • Placed after trading widget on story page

Fixes #26

Test plan

  • Verify donation flow executes: approve → donate → index
  • Verify widget hidden when wallet not connected
  • Verify donation appears in reader dashboard after indexing
  • npm run lint and npm run typecheck pass

🤖 Generated with Claude Code

Fixes #26

- P5-4a: New DonateWidget component — amount input, PLOT_TOKEN approval,
  StoryFactory.donate() call, donation indexer trigger
- Full tx state UI: approving → confirming → pending → indexing → done
- All addresses from lib/contracts/constants.ts
- Placed after trading widget on story page

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

LGTM. Clean donation widget — approval flow correctly targets PLOT_TOKEN → STORY_FACTORY, contract addresses from constants.ts, complete tx state machine with indexer trigger.

Minor note (non-blocking): if the indexer POST at line 80 fails after a successful on-chain donation, the catch block shows "error" state even though the donation was recorded on-chain. Consider catching indexer errors separately to show a softer "donation succeeded but indexing failed" message in a follow-up.

Approved.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: REQUEST CHANGES

Summary

The donate transaction flow is mostly in place, but the post-transaction indexing step is treated as successful even when the donation indexer returns an error.

Findings

  • [medium] DonateWidget always advances to done after calling /api/index/donation without checking res.ok or surfacing any failure. If the transaction succeeds but indexing fails (receipt fetch error, decode failure, Supabase error, etc.), the UI still reports success even though the donation will not appear in the reader dashboard as required by the ticket.
    • File: src/components/DonateWidget.tsx:73
    • Suggestion: Check the response from /api/index/donation and treat non-2xx responses as an error or at least a distinct partial-success state so the user isn't told indexing succeeded when it didn't.

Decision

Requesting changes because the current UI can falsely report a completed donation flow while the indexing step has actually failed.

Shows informative error when on-chain donation succeeds but indexing
fails, rather than showing a false success state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

LGTM. Indexer response now properly checked — informative error message distinguishes on-chain success from indexing failure. Approved.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: APPROVE

Summary

The donation flow now handles the on-chain tx and post-tx indexing step correctly, including an explicit error path when indexing fails after a successful donation. The PR matches issue #26 and lint-and-typecheck is passing.

Findings

  • none

Decision

Approving because the story-page donation widget now presents a correct user flow for approval, donation submission, and indexer feedback.

@realproject7 realproject7 merged commit 6b1b5c9 into main Mar 14, 2026
1 check passed
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.

[P5-4] Donation Flow

2 participants