Skip to content

security(frontend): transaction simulation before submission #216

Description

@samjay8

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

  1. Before broadcasting, call simulateTransaction on the Soroban RPC
  2. Parse the simulation result to show: expected state changes, token movements, and success probability
  3. Show a confirmation dialog with the simulation results before final submission
  4. If simulation indicates failure, block the submission and show the error
  5. 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

  • Every high-value transaction (accept, repay, cancel) shows simulation results before submission
  • Simulation shows expected token movements and state changes
  • Failed simulations block submission with error explanation
  • Simulation cached for 5 seconds to avoid duplicate calls
  • Works on testnet and mainnet

Complexity: high-complexity

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignfrontendNext.js frontend workhigh-complexityLarge multi-part effort — new subsystems, cross-cutting changessecuritySecurity and access control

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions