Skip to content

feat(external-signer): add Visibility arg to file_prepare_upload#39

Open
Nic-dorman wants to merge 1 commit intomainfrom
feat/external-signer-public-upload
Open

feat(external-signer): add Visibility arg to file_prepare_upload#39
Nic-dorman wants to merge 1 commit intomainfrom
feat/external-signer-public-upload

Conversation

@Nic-dorman
Copy link
Copy Markdown
Contributor

Summary

Adds an external-signer pathway for public file uploads. Calling Client::file_prepare_upload_with_visibility(path, Visibility::Public) bundles the serialized DataMap into the existing payment batch (wave-batch or merkle) as one additional chunk. After finalize_upload / finalize_upload_merkle, FileUploadResult.data_map_address carries the chunk address of the published DataMap — a single network address the uploader can share so anyone can retrieve the file.

This unblocks public uploads in the Autonomi desktop GUI (ant-gui). The GUI currently has its Public upload option disabled in the UI (WithAutonomi/ant-ui#12, merged) because no external-signer pathway exists for publishing the data map. Once this lands and ant-gui bumps the git dep, a follow-up PR on that repo will thread the visibility flag through the Tauri commands and re-enable the Public button.

Why bundling, not a separate call

Publishing the data map means storing one extra content-addressed chunk. The two obvious alternatives both hit dead ends on the external-signer path:

  • client.data_map_store(&data_map) after finalize_upload — what ant-cli does. Internally goes through pay_for_storage, which hard-requires self.require_wallet()? (ant-core/src/data/client/payment.rs:46). ant-gui's Rust client has no wallet — all payments go via WalletConnect / direct-wallet on the frontend.
  • Hand-roll chunk storage externally. The internal chunk-storage helpers (store_paid_chunks, chunk_put_to_close_group, merkle_upload_chunks) are all pub(crate), so external callers cannot reproduce the flow.

Bundling the data map chunk into the existing PaymentIntent (wave-batch) or merkle batch reuses the one-signature flow that already works for file chunks. The external signer pays for the data chunks and the data map chunk in a single on-chain transaction, and finalize_upload[_merkle] stores them all in the same wave.

Changes

  • Visibility enum (Private default, Public) in data::client::file, re-exported from data::.
  • Client::file_prepare_upload_with_visibility(path, visibility). The existing file_prepare_upload(path) delegates with Visibility::Private — signature and behaviour are preserved for existing callers.
  • PreparedUpload.data_map_address: Option<[u8; 32]> carries the address between prepare and finalize.
  • FileUploadResult.data_map_address: Option<[u8; 32]> is Some(addr) for public uploads. Pair it with data_map_fetch(&addr) + file_download(&data_map, dest) to retrieve the file.
  • Both finalize_upload and finalize_upload_merkle propagate data_map_address; no extra network call needed, since the data map chunk is stored alongside the rest of the batch.
  • The internal-wallet path (file_upload_with_mode) is unchanged — ant-cli continues to use file_upload + data_map_store for its public flow.

Test plan

  • cargo fmt -p ant-core clean
  • cargo check --workspace --all-features passes
  • cargo clippy --tests -p ant-core --all-features -- -D warnings clean
  • New e2e test test_file_prepare_upload_visibility in ant-core/tests/e2e_file.rs verifies:
    • Private prepare leaves data_map_address unset
    • Public prepare records the address, and the recorded address equals compute_address(rmp_serde::to_vec(&data_map))
    • For wave-batch, the Public path adds exactly one extra prepared chunk (the data map) to the batch, at the recorded address
  • End-to-end verification on ant-gui lands in a follow-up PR (wiring visibility through Tauri commands and re-enabling the button)

🤖 Generated with Claude Code

Adds an external-signer path for public uploads. When a PreparedUpload
is prepared with Visibility::Public, the serialized DataMap is bundled
into the payment batch (wave-batch or merkle) as an additional chunk.
FileUploadResult::data_map_address then carries the chunk address of
the stored DataMap, giving the uploader a single network address to
share for retrieval.

Motivation: ant-gui (the Autonomi desktop GUI) currently has to block
its Public upload option in the UI because no external-signer pathway
exists for publishing the data map — `data_map_store` internally calls
`pay_for_storage`, which hard-requires a wallet, and the chunk-storage
plumbing (`store_paid_chunks`, `chunk_put_to_close_group`,
`merkle_upload_chunks`) is pub(crate), so consumers on the
external-signer path cannot hand-roll it. Bundling the data map chunk
into the existing payment batch reuses the one-signature flow that
wave-batch and merkle already use for file chunks, which lets ant-gui
thread a `visibility` flag through its existing code path and re-enable
the Public option with no extra wallet round-trip.

- `Visibility::{Private, Public}` enum (default Private)
- `Client::file_prepare_upload_with_visibility(path, visibility)`;
  the existing `file_prepare_upload(path)` now delegates with Private
  for backward compatibility
- `PreparedUpload.data_map_address: Option<[u8; 32]>` carries the
  address between prepare and finalize
- `FileUploadResult.data_map_address` is Some for public uploads
- Both `finalize_upload` and `finalize_upload_merkle` propagate the
  field; no separate network call is needed because the data map chunk
  is stored alongside the rest of the batch
- e2e test verifies Private leaves the address unset, Public records
  it, and the recorded address matches the serialized data map

The internal-wallet path (`file_upload_with_mode`) is unchanged —
ant-cli continues to use `file_upload` followed by `data_map_store`
for its public upload flow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants