Repository navigation
Open the wallet prompt without waiting for simulation - #333
luchobonatti wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🔵 Needs a closer look
It reworks the wallet-signing and submission path for every investor and admin action with concurrency-sensitive caching (refs, generation counters, timers, query-cache subscriptions), so despite strong test coverage and no concrete defect found, the risk warrants final human review.
No open issues 🎉
What changed in this PR
This PR removes the perceptible delay between clicking an action and the Freighter wallet prompt. Previously the click triggered getAccount + simulateTransaction (0.5–1 s+ on testnet) before the wallet opened. Now ready actions are simulated in the background, and a click signs the already-simulated transaction (AssembledTransaction.sign() makes no network call) when it is still fresh, falling back to the previous simulate-on-click flow otherwise.
Changes:
useContractTransactiongains ausePreparedhelper exposingprepare(arg, grant) => Releaseandtake(key): it caches one background-simulated transaction per request (keyed by owner/arg/authority/standing), reuses it for 30 s, and drops it on submit, on a changed matching read, or on expiry;submitconsumes the cached tx and signs/sends it viasubmitSigned.- A new
{ kind: "stale" }failure is surfaced when a reused transaction is refused for a consumed sequence number ("The transaction went stale", with Try again), and the in-flight hash is now shown for reused submissions. - The admin rails report their open-and-ready action (400 ms after it settles) through a shared
onReady/Send(submitTo/prepareFor) indirection, gated byactive; the investor page prepares once a valid amount settles.
| File | Description |
|---|---|
app/src/hooks/useContractTransaction.ts |
Core change: usePrepared background simulation, prepare/take, reuse on submit, stale failure, early hash. |
app/src/hooks/usePendingTransaction.ts |
Adds prepare passthrough and the Send/Sendable/submitTo/prepareFor dispatch helpers. |
app/src/hooks/use*{RequestDeposit,RequestRedeem,Fund,FulfillEpoch,FinalizeWindDownRound,DeployToCustodian,CloseEpoch,ClaimRedeem,ClaimDeposit,CancelRedeem,CancelDeposit,Attest,ActivateWindDown}.ts |
Add prepare: (...) => Release to each hook's public interface. |
app/src/pages/VaultPreview.tsx |
Prepares the subscribe/redeem hook 400 ms after a valid, in-balance amount settles. |
app/src/components/admin/CycleActionRail.tsx |
Reports the open ready action via onReady after a 400 ms settle; releases on collapse/block/unmount. |
app/src/components/admin/{Cycle,Emergency,Configuration,Governance,Compliance}Section.tsx |
Refactor run into dispatch(action, send) and wire onReady (prepare) gated by active. |
app/src/components/vault/TransactionModal.tsx |
Adds stale failure copy, step state, and Try-again handling. |
app/src/**/*.test.{ts,tsx} |
Extensive new coverage for preparation, reuse, expiry, stale, release, and hidden-tab gating. |
Review effort: Balanced
Summary
Closes #318
After a click, Freighter waited for
getAccountandsimulateTransaction(0.5 to over 1 s on testnet). Ready actions are now simulated in the background, and the click signs the simulated transaction when it is still fresh.Changes
submitSigned; a consumed sequence shows "The transaction went stale" with Try again, and the next click simulates freshAcceptance criteria
Test plan
Automated tests
npx vitest run: 1746 tests pass.Manual verification
On the local network with a local signer, Close epoch, Attest price and Subscribe each reached
sendTransaction46 to 95 ms after the click with nosimulateTransactionin between; before, the simulation ran after the click.Breaking changes
None.
Checklist
Screenshots
None.