feat(ffi): cost estimation + file/data-map API symmetry (V2-584 A+B)#207
Merged
Conversation
Bridge ant-core's existing estimate_upload_cost through the FFI so the mobile SDK can preview upload cost before preparing/paying. No wallet required (~seconds), safe to call ahead of prepare_file_upload in the external-signer flow. - New CostEstimate uniffi Record (file_size, chunk_count, storage_cost_atto, estimated_gas_cost_wei, payment_mode, confidence). - Client::estimate_file_cost(path, payment_mode), mirroring file_upload_public's path+mode handling. - format_cost_confidence helper with stable snake_case strings so callers can tell a genuinely-free "0" from a best-effort "0" guess. Part of V2-584 (item A). Swift/Kotlin bindings regenerate cleanly; build/clippy(-D)/fmt/test green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fill the obvious holes in the current FFI surface so the mobile SDK is symmetric across public/private and prepare paths: - file_upload_private: the private counterpart of file_upload_public, returning the serialized data map (hex) instead of publishing it — the file analog of data_put_private. New FilePutPrivateResult record. - data_map_store / data_map_fetch: publish an existing private data map as a public chunk (and the inverse), so a private upload can become a shareable public address without re-uploading the data. - prepare_file_upload_with_progress: surfaces the "encrypting"/"quoting" phases that prepare_file_upload runs silently, reusing the existing upload_progress_bridge. File-only — ant-core has no data-prepare progress variant. Part of V2-584 (item B). Swift/Kotlin bindings regenerate cleanly; build/clippy(-D)/fmt/test green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Hermes reviewI reviewed PR #207 ( Verdict: no blocking code issues found. The new FFI methods build and regenerate into both Swift and Kotlin, and the data-map hex guard is applied consistently on the new Verified locally from
Non-blocking notes:
I did not approve/merge; leaving this as an advisory review/comment. |
All doc-only, no behavior change: - ProgressUpdate: the "encrypting"/"quoting" upload phases ARE now surfaced (via prepare_file_upload_with_progress) — corrected the stale "not currently surfaced / future follow-up" note. - data_map_store: state that it stores/pays for the serialized data-map chunk (unless already stored) and so needs a wallet-backed client. - estimate_file_cost: note it prices data chunks only and excludes the extra public data-map chunk — not the guaranteed total public-publish cost. - Make the new methods' doc comments binding-neutral: drop Rust `[`Self::x`]` intra-doc links that leak verbatim into Swift/Kotlin docs. - ffi/README.md API Surface: rewrite the stale/wrong table (it listed phantom dir_*/*_cost/data_get/data_put/init() methods) to the real surface + note the network is immutable-only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Thanks @dirvine — all five notes addressed in
|
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.
Expands the mobile FFI surface within what the WithAutonomi network actually supports. Part of V2-584 (parent V2-580 mobile-SDK readiness).
Scope note: V2-584 originally also listed registers/pointers/scratchpad/vault/GraphEntry and directories. Those are Maidsafe
autonomiconcepts and do not exist in the WithAutonomi network (verified by grep of ant-client7255f5b) — dropped from the ticket, not deferred. This PR is the real, achievable surface: cost estimation + symmetry gaps. Streaming was left as a docs-only concern (files already stream; only the byte APIs load fullVec<u8>).A — Cost estimation
Client.estimate_file_cost(path, payment_mode) -> CostEstimatebridging ant-core's existingestimate_upload_cost(no wallet, samples chunk addresses, ~seconds).CostEstimaterecord with aconfidencefield (priced_sample/verified_all_already_stored/all_samples_already_stored_incomplete) so consumers never present a best-effort"0"as guaranteed-free.B — API symmetry gaps
file_upload_private— private counterpart offile_upload_public(returns the hex data map); newFilePutPrivateResult.data_map_store/data_map_fetch— publish an existing private data map as a public chunk and back, so a private upload becomes a shareable public address without re-uploading.prepare_file_upload_with_progress— surfaces theencrypting/quotingphasesprepare_file_uploadruns silently, reusing the existing progress bridge. File-only (ant-core has no data-prepare progress variant).Verification
cargo build/clippy --all-targets -D warnings/fmt --check/testall green.estimate_file_cost+prepare_file_uploadend-to-end at compile time.🤖 Generated with Claude Code