Skip to content

feat: cancellation phase UI for nextjs-evm and react-evm examples#74

Merged
EByrdS merged 9 commits into
mainfrom
cancellation-phase
May 6, 2026
Merged

feat: cancellation phase UI for nextjs-evm and react-evm examples#74
EByrdS merged 9 commits into
mainfrom
cancellation-phase

Conversation

@EByrdS

@EByrdS EByrdS commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a CancelCard component to both nextjs-evm and react-evm example apps, mirroring the structure of CommitCard but for the cancellation flow
  • Extends useSaleContract (and the react-evm equivalent hooks.ts) with a cancelBid() contract call and a contractStage read
  • Replaces the two-state toggle button in the demo control bar with a three-option dropdown: Pre-Sale, Sale Live, and Cancelled

Details

New: CancelCard component

  • Shows the entity's current committed amount from contract state
  • Calls cancelBid() on the settlement contract (no permit required)
  • Cancel Bid button is only enabled when contractStage === 2 (Cancellation); otherwise shows an amber warning instructing the developer to deploy their own contract and call unsafeSetStage(2)
  • If the committed amount is exactly 0, the button is hidden entirely and replaced with a "No active commitment to cancel" message

Hook changes

  • cancelBid() — simulates then submits the cancelBid contract call
  • contractStage — polls the contract's stage() getter every 3 seconds

Demo control bar

  • saleIsLive: booleansalePhase: "presale" | "live" | "cancelled" (persisted in localStorage)
  • Cancelled phase renders the entity selector and CancelCard; no Sonar eligibility gate (the cancel action is purely contract-side)

🤖 Generated with Claude Code

@EByrdS
EByrdS force-pushed the cancellation-phase branch from 312d174 to 84f38f7 Compare April 22, 2026 12:50
Comment thread examples/framework/nextjs-evm/src/app/page.tsx Outdated
<p className="text-amber-700 text-sm mt-1">
The &quot;Cancel Bid&quot; button is only active when the contract is in the Cancellation stage (stage
2). To test this feature, deploy your own contract and call{" "}
<code className="font-mono bg-amber-100 px-1 rounded">unsafeSetStage(2)</code> to move it to the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think instead of using this, we should be encouraging users to progress the sale in the normal way (i.e. openCancellation). And then to test again, they can just deploy a new contract.

It's now possible to do this via the Founder dashboard rather than by calling the contract directly so I think recommending that first but also linking to the contract docs here is probably best.

Comment thread examples/framework/nextjs-evm/src/app/components/sale/CancelCard.tsx Outdated
Comment thread examples/framework/nextjs-evm/src/app/hooks/use-sale-contract.ts Outdated
EByrdS and others added 7 commits May 5, 2026 16:15
CancelCard destructures entityState from useSaleContract but the hook
only exposed the derived currentTotalRaw scalar. Add entityState as a
return value in both react-evm and nextjs-evm hooks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Exposes cancelBid and contractStage from useSaleContract in both react-svm and nextjs-svm
- Updates settlement_sale IDL to include the cancel_bid instruction
- Fixes pkce-store singleton to survive Next.js hot module reloads (globalThis instead of module-scoped var)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename "cancelled" phase to "cancellation" throughout all 4 frameworks (EVM/SVM, React/Next.js)
- Replace red banner/card styling with neutral amber for the cancellation period
- CancelCard: hide committed amount when 0, show "No active commitment to cancel" instead
- CancelCard: update testing instructions to reference founder's dashboard + openCancellation, link to contract docs
- CommitCard: add warning + disabled state when contract is not in Commitment stage (openCommitment)
- Run prettier on all modified files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WillSewell
WillSewell previously approved these changes May 5, 2026
WillSewell
WillSewell previously approved these changes May 5, 2026
@EByrdS
EByrdS marked this pull request as ready for review May 5, 2026 16:27
@EByrdS
EByrdS merged commit 4ae4878 into main May 6, 2026
8 checks passed
@EByrdS
EByrdS deleted the cancellation-phase branch May 6, 2026 09:30
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