feat(upload): use ant-core estimate_upload_cost for pre-upload quotes#47
Merged
Nic-dorman merged 2 commits intomainfrom Apr 22, 2026
Merged
feat(upload): use ant-core estimate_upload_cost for pre-upload quotes#47Nic-dorman merged 2 commits intomainfrom
Nic-dorman merged 2 commits intomainfrom
Conversation
Both the Estimate Cost top-bar button and the Upload dialog's pre-quote used to call start_upload (file_prepare_upload), which encrypts the whole file to a spill and parks a PreparedUpload in pending_uploads for 30 minutes. Every dialog open or estimate click paid that full cost even if the user cancelled, leaving hundreds of encrypted chunks in memory until the GC loop expired them. Switch both paths to the new estimate_upload_cost API (ant-core #44): samples a single network quote for a representative chunk and extrapolates total cost. No encryption-to-spill, no parked upload, no wallet required. Estimates now run in parallel too — each is independent, so multi-file dialog latency drops to the slowest sample. Confirm click still runs the real start_upload via startRealUpload, so the actual encryption + quote collection happens only when the user commits. Drop the preQuote handoff plumbing and the pendingQuotes map; startRealUpload's fresh-quote branch already does the right thing. Rename the 'quoting' status label to "Preparing upload..." since the heavy work now happens post-confirm. Drop utils/payment.ts::estimatePaymentGasCost — PR #44's gas heuristic replaces it. Its leftover GAS_* constants and getGasPrice import go with it. Bump ant-core pin f88c95d -> b0c501a (PR #44 merge). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Before the PR #44 rework, this comment was accurate — the dialog called getUploadQuote directly. After the rework, the dialog uses estimateFileCost and getUploadQuote is only reached via startRealUpload once the user has committed. Update the comment to match. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
start_upload→file_prepare_upload, which encrypts the whole file to disk and parks aPreparedUploadfor 30 minutes. Every cancelled estimate leaked hundreds of encrypted chunks into memory.Client::estimate_upload_cost(ant-core PR fix(wallet): direct-key + Arbitrum One mainnet payments #44, mergeb0c501a): samples a single network quote for a representative chunk and extrapolates. No encryption-to-spill, no parked upload, no wallet required.Promise.all), so dialog-open latency tracks the slowest single quote instead of the sum.start_uploadviastartRealUpload, so the heavy work happens only on commit. Dropped thepreQuotehandoff plumbing and thependingQuotesmap.'quoting'status label to "Preparing upload…" now that the heavy phase sits post-Confirm.utils/payment.ts::estimatePaymentGasCost— PR fix(wallet): direct-key + Arbitrum One mainnet payments #44's gas heuristic replaces it. Its leftoverGAS_*constants andgetGasPriceimport go with it.Dependency bump
ant-corepinf88c95d→b0c501a(PR #44 merge). Cascades toant-node 0.10.0 → 0.10.1andsaorsa-core 0.23.0 → 0.23.1via the resolver.Test plan
cargo checkcleanvitest— 19/19 passpending_uploadsemptypending_uploadsemptyKnown follow-ups
Visibilityarg) merges upstream,estimate_file_costneeds avisibilityhint so the chunk count includes the DataMap chunk for public uploads.CostEstimationInconclusiveerror path currently reaches the frontend as a genericwarn+nullreturn. A friendlier toast ("Cost estimate unavailable, try another file") would be nicer.🤖 Generated with Claude Code