Problem
When a user submits a transaction (accept offer, repay invoice), the transaction is broadcast directly to the network. If the parameters are wrong or the state has changed since the page loaded, the transaction fails on-chain and the user loses the network fee. There is no way to preview the effects before committing.
Proposed Solution
- Before broadcasting, call
simulateTransaction on the Soroban RPC
- Parse the simulation result to show: expected state changes, token movements, and success probability
- Show a confirmation dialog with the simulation results before final submission
- If simulation indicates failure, block the submission and show the error
- Cache simulation results briefly (5 seconds) to avoid duplicate RPC calls
Files to modify
invofi/apps/frontend/src/lib/simulate.ts (new) — simulation helper
invofi/apps/frontend/src/components/common/SimulateConfirm.tsx (new) — confirmation dialog
invofi/apps/frontend/src/lib/contract.ts — wrap calls with simulation
Acceptance Criteria
Complexity: high-complexity
Problem
When a user submits a transaction (accept offer, repay invoice), the transaction is broadcast directly to the network. If the parameters are wrong or the state has changed since the page loaded, the transaction fails on-chain and the user loses the network fee. There is no way to preview the effects before committing.
Proposed Solution
simulateTransactionon the Soroban RPCFiles to modify
invofi/apps/frontend/src/lib/simulate.ts(new) — simulation helperinvofi/apps/frontend/src/components/common/SimulateConfirm.tsx(new) — confirmation dialoginvofi/apps/frontend/src/lib/contract.ts— wrap calls with simulationAcceptance Criteria
Complexity: high-complexity