Description
Build a sophisticated optimistic mutation layer in React Query that updates token balances instantly upon wallet signature, handling complex rollbacks if the network rejects the transaction.
Architecture & Context
Waiting for blockchain finality destroys the UX of trading fractional assets. The UI must predict the outcome of the trade, update the local cache immediately, and invisibly reconcile the true state once the block closes.
Technical Requirements
- Intercept tRPC/React Query
onMutate hooks to snapshot the previous cache state.
- Apply the exact fractional math locally to predict the new user balances.
- Implement
onError handlers to cleanly restore the snapshot if the Soroban RPC returns a tx_failed status.
Acceptance Criteria
Description
Build a sophisticated optimistic mutation layer in React Query that updates token balances instantly upon wallet signature, handling complex rollbacks if the network rejects the transaction.
Architecture & Context
Waiting for blockchain finality destroys the UX of trading fractional assets. The UI must predict the outcome of the trade, update the local cache immediately, and invisibly reconcile the true state once the block closes.
Technical Requirements
onMutatehooks to snapshot the previous cache state.onErrorhandlers to cleanly restore the snapshot if the Soroban RPC returns atx_failedstatus.Acceptance Criteria