feat: Implement Optimistic UI with Rollback for Escrow State Transitions (#62) - #85
Conversation
|
@dahgold001 is attempting to deploy a commit to the Meshack Yaro's projects Team on Vercel. A member of the Team first needs to authorize it. |
meshackyaro
left a comment
There was a problem hiding this comment.
Really solid piece of work. Using useSyncExternalStore for the optimistic layer is the right call — it keeps the store framework-agnostic and avoids the read tearing you'd risk with a context-based approach when multiple components watch escrow state mid-transition. The hook abstraction around applyOptimisticUpdate/confirmUpdate/rollbackUpdate is clean and makes the optimistic/pessimistic boundary explicit rather than smeared across call sites.
The UI touches are thoughtful too — pulsing states for pending and a shake on rollback give users real feedback about what's happening to their transaction, which matters a lot for something as high-stakes as escrow. Good instinct building the milestone tracker as a proper component with the full action surface (Fund/Release/Dispute/Refund) rather than bolting actions onto existing UI.
Appreciate the test coverage on both the store and the hook — that's exactly where optimistic-update bugs like to hide. Nice work all around.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Description
This PR implements the optimistic UI layer for Escrow State Transitions as detailed in #62.
The core objective is to introduce an optimistic update layer that reflects escrow state changes (
Funded→InProgress→Released/Disputed) instantly in the UI and cleanly rolls back on transaction rejection or ledger failure.Related Issue
Closes #62
Type of Change
Changes Made
shared/optimistic/escrow-state.tsutilizinguseSyncExternalStorefor framework-agnostic, instant optimistic state management.hooks/useOptimisticEscrow.tsto wrapuseEscrowContractcalls withapplyOptimisticUpdate,confirmUpdate, androllbackUpdate.EscrowStateBadgeatom to visually represent statuses with pulsing animations for pending states and shake animations for rollbacks.EscrowMilestoneTrackermolecule to display a timeline of milestones and manage actions (Fund, Release, Dispute, Refund).pages/dashboard.tsxwith a demo gig to test optimistic actions and simulated rollbacks.actions/cachefor npm dependencies in.github/workflows/ci.yml.escrow-state.test.ts) and hook (useOptimisticEscrow.test.ts).Checklist
npm run lintand fixed all issuesnpm run typecheckwith no errorsnpm run buildsuccessfully