Skip to content

feat(frontend): add preflight simulation before value-moving transactions - #270

Open
woahwhattheheck wants to merge 1 commit into
YieldVault-Org:mainfrom
woahwhattheheck:latch/yieldvault-264-preflight-sim
Open

woahwhattheheck wants to merge 1 commit into
YieldVault-Org:mainfrom
woahwhattheheck:latch/yieldvault-264-preflight-sim

Conversation

@woahwhattheheck

Copy link
Copy Markdown

Summary

Closes #264.

Adds a read-only preflight simulation step for deposits and withdrawals so deterministic failures are caught before the wallet asks for a signature. Successful simulation is advisory only; contract-side validation and the provider result remain authoritative.

Trust boundary

  • Preflight is a read-only check against the current wallet, connected network, and exact serialized transaction payload.
  • status: ok never means the transfer is confirmed or settled.
  • Sign + submit still run after a passing preflight; on-chain / provider outcome is final.
  • Preflight never bypasses vault service validation.

Race / invalidation handling

  • Each result is bound to fingerprint = network::serializedTx.
  • Changing amount, wallet, or network marks the result stale and blocks signing until preflight is run again.
  • Concurrent runs use a generation counter so outdated responses cannot overwrite newer state.

User-visible states

State Behavior
running “Running preflight…” — submit disabled
ok Advisory pass message — signature may be requested
rejected Actionable reason (stale balance, paused vault, contract rejection, network mismatch) — no signature
timeout / unsupported Safe Retry preflight path — no signature
stale Intent drifted — retry required before signing

Acceptance criteria

  • Deposits and withdrawals do not request a signature when preflight detects a deterministic failure
  • Preflight results are tied to the exact serialized transaction and connected network
  • Provider timeouts and unsupported simulation responses produce a safe retry path

Test evidence

  • test/utils/preflight.test.js — serialize / fingerprint / binding / signature gate
  • test/services/preflight.test.js — success, contract rejection, timeout, unsupported, stale balance, paused vault, network mismatch, insufficient position
  • test/hooks/usePreflight.test.jsx — changed payload, network switch, timeout retry
  • test/components/DepositForm.preflight.test.jsx — no signAndSubmit on reject / timeout / stale / wrong network; success still signs

npm test — 236 passed. tsc -b — clean for touched packages.

Out of scope

  • Replacing authoritative contract validation
  • Redesigning wallet integrations

Run a read-only preflight against the current wallet, network, and
serialized deposit/withdraw payload before requesting a signature.
Deterministic failures (stale balance, paused vault, contract rejection,
network mismatch) block signing; provider timeouts and unsupported
simulation responses offer an explicit retry. Successful simulation is
advisory only — on-chain validation remains authoritative.

Closes YieldVault-Org#264
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.

feat(frontend): add preflight simulation before value-moving transactions

1 participant