fix(antd): honor is_public on FileCostRequest#56
Merged
Conversation
The is_public flag was on the wire shape (REST + gRPC, all 14 SDKs already emit it) but the Rust handlers ignored it. A public upload bundles one extra chunk — the serialized DataMap — into the same payment batch, so the cost estimate must reflect that. Add adjust_for_public_upload(chunk_count, storage_cost_atto) to types.rs which bumps chunk_count by 1 and scales storage_cost_atto by the average per-chunk cost. Wire it into both the REST handler at rest::files::file_cost and the gRPC handler at grpc::service::get_file_cost. Use ant-core's re-exported U256 to keep arithmetic correct for atto values larger than u64 (a 10K-ANT estimate is already 1e22 atto). Behavior change: callers explicitly passing is_public=true previously received the data-only chunk count and cost; they now receive the public-correct +1 chunk equivalent. Callers passing is_public=false are unaffected. Tests cover even/uneven division, large U256 atto values, the already-stored zero-cost case, and unparseable input. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b4d5e43 to
f9e3028
Compare
Nic-dorman
added a commit
that referenced
this pull request
May 6, 2026
Cuts v0.6.1 atop v0.6.0. Adds the public-uploads chain: - feat(antd): wire visibility through /v1/upload/prepare (#57) - visibility: Option<String> on PrepareUploadRequest / PrepareDataUploadRequest - data_map_address: Option<String> on FinalizeUploadResponse - prepare_upload now calls file_prepare_upload_with_visibility — public prepare bundles the serialized DataMap chunk into the same external- signer payment batch (one EVM tx covers chunks + DataMap) - /v1/data/prepare returns 501 for visibility:"public" until upstream data_prepare_upload_with_visibility lands - fix(antd): honor is_public on FileCostRequest (#56) - cost endpoint adds +1 chunk and proportional storage cost when is_public=true (was a no-op before) Validated end-to-end on Arbitrum One mainnet against this dep set: external-signer wave-batch public upload of a 10 KB file, atomic payForQuotes for 4 quotes (3 data + 1 DataMap), finalize returned data_map_address, /v1/files/download/public via that address round- tripped byte-for-byte. ~0.047 ANT cost. Same ant-core / evmlib pin as v0.6.0 (ant-cli-v0.2.2, evmlib 0.8.1). 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
Closes the no-op
is_publicflag onFileCostRequest. The flag was on the wire shape (REST + gRPC) and all 14 SDKs already emit it, but the Rust handlers ignored it. A public upload bundles one extra chunk — the serialized DataMap chunk — into the same payment batch, so the cost estimate has been under-reporting public uploads by exactly 1 chunk and the equivalent storage cost.Independent of the public-uploads visibility wiring (#57); can ship today.
Change
adjust_for_public_upload(chunk_count, storage_cost_atto) -> (usize, String)inantd/src/types.rs. Bumpschunk_countby 1 and scalesstorage_cost_attoby the average per-chunk cost. Uses ant-core's re-exportedU256(ant_core::data::U256) so atto values larger thanu64round-trip correctly — a 10K-ANT estimate is already 1e22 atto.rest::files::file_costandgrpc::service::get_file_cost. Theis_publicfield onFileCostRequestno longer carries#[allow(dead_code)].Behavior change
is_publictrue(explicit, default in REST DTO)falseCallers explicitly passing
is_public: truewill see slightly higher numbers — that's the bug being fixed. Callers passingis_public: falseare unaffected.Test plan
cargo test— 25 pass (6 new tests for the helper + existing)Notes
estimated_gas_cost_wei) is intentionally unchanged. Adding 1 chunk to a wave-batch usually doesn't add a transaction — gas already includes the per-tx-budget heuristic with explicit caveats in ant-core./v1/files/upload/publicor/v1/dirs/upload/public— those endpoints already do the right thing on the upload side via the two-call dance. Only the cost endpoint was lying.🤖 Generated with Claude Code