Pre-flight balance check across all chunked bundle txs#79
Conversation
✅ Deploy Preview for cosmos-proposal-builder ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
A wallet that could afford the manifest tx but not the full chunk series was able to begin a chunked submission and run out of funds mid-stream, leaving partial state on chain. The existing form-level check was also silently skipped whenever the swingset params query was still loading, so submission could begin with no real balance check at all. Add an optional validateCost callback to installBundle that fires once after compression and before the first signAndBroadcast in either the chunked or non-chunked path. agoric.tsx provides it, using the already-in-scope swingset params and account balances queries plus existing balance.ts helpers, and throws a toast error naming the shortfall (and the manifest-of-N total when chunked) if the wallet can't cover costPerByte * compressedSize. The form-level guard now also refuses when cost data isn't available rather than falling through. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Make installBundle the single source of truth: drop the redundant
form-level balance check from BundleForm, since validateCost now
covers it authoritatively and uses the compressed-byte total
(tighter and consistent with what the chain stores). Two layers
of checking against two different snapshots (uncompressed file
size vs. compressed bytes) was a source of divergence.
- Use hasSufficientBalance helper instead of recomputing remaining
cost manually in agoric.tsx; only compute display details in the
insufficient branch.
- Display amounts via scaleToDenomBase so the toast says "1.5 IST"
instead of "1500000 uist", matching the form-level cost display
in CodeInput.
- Match the existing insufficient-funds wording from
transactionParser ("X IST required, only Y IST available")
rather than inventing a parallel format.
- Use 3000ms autoClose to match the rest of the app.
- Replace the chunkCount=0 overload in validateCost's info object
with chunked: boolean; chunkCount?: number, matching the existing
InstallBundleProgress preflight event shape.
- Add unit tests for installBundle covering: validateCost throw
aborts before any signAndBroadcast, chunked path passes
chunked=true with a chunk count, and the happy path proceeds.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
eb0463e to
4c08d9c
Compare
|
We applied the following findings against PR #79 in a workspace on Findings (suggested next steps):
We did not pursue these intentionally (each is sound on its own merits but out of scope for this round):
Local validations on the branch pass: |
…CFoundation/cosmos-proposal-builder#79; one summary comment posted
Summary
validateCostcallback toinstallBundle()that runs once after compression and before the firstsignAndBroadcast(in both chunked and non-chunked paths), so a chunked submission can no longer begin with a balance that can't cover the full series.agoric.tsxprovides the callback using already-in-scopeswingSetParamsandaccountBalancesqueries plus existingbalance.tshelpers; throws a toast error naming the shortfall and (when chunked) the "manifest of N total" framing.BundleForm.tsxwhere the form-level check was skipped whencostPerBytewasn't loaded yet.Test plan
yarn tsc --noEmitcleanyarn lintclean (3 pre-existing fast-refresh warnings unrelated to this change)yarn test:unit14/14 passing?enable-chunking) with insufficientuist— toast names shortfall, manifest-of-N description; no wallet signing prompt; nothing left on chain🤖 Generated with Claude Code