Skip to content

feat(antd-py): prepare_upload_public + data_map_address#59

Draft
Nic-dorman wants to merge 1 commit into
mainfrom
feat/antd-py-prepare-upload-public
Draft

feat(antd-py): prepare_upload_public + data_map_address#59
Nic-dorman wants to merge 1 commit into
mainfrom
feat/antd-py-prepare-upload-public

Conversation

@Nic-dorman
Copy link
Copy Markdown
Collaborator

Summary

Mirrors the antd 0.5.0 wire shape introduced in #57 into the Python SDK so consumers can do truly atomic external-signer public uploads — one EVM transaction covering data chunks + the bundled DataMap chunk.

Draft until #57 merges and antd is released as 0.5.0. The shape is wire-compatible: against older daemons, the new visibility field is ignored upstream and the new data_map_address field defaults to "". Nothing breaks for existing callers.

Change

  • New method prepare_upload_public(self, path) on RestClient and AsyncRestClient. POSTs {"path": path, "visibility": "public"} to /v1/upload/prepare. Sibling of the existing private prepare_upload(path).
  • New field data_map_address: str = "" on FinalizeUploadResult dataclass. Populated by finalize_upload and finalize_merkle_upload from the daemon's response (sync + async).
  • The existing address field on FinalizeUploadResult keeps its semantics — it's the legacy path where store_data_map=True made the daemon's internal wallet pay for a separate DataMap-store call. New callers should prefer prepare_upload_public + data_map_address.

Behavior

Caller Daemon Result
prepare_upload(path) any unchanged — private prepare
prepare_upload_public(path) antd >= 0.5.0 public prepare — finalize_upload returns data_map_address
prepare_upload_public(path) antd < 0.5.0 silently degrades to private (server ignores visibility); data_map_address stays ""
Any caller any address field still set when caller passed store_data_map=True to finalize_merkle_upload

Test plan

  • pytest tests/test_rest_client.py — 21/21 pass (4 new tests).
  • New tests:
    • test_sends_visibility_public — captures the request body and asserts visibility="public" was sent.
    • test_finalize_surfaces_data_map_address_for_public — daemon returns data_map_address; SDK surfaces it on the dataclass.
    • test_finalize_omits_data_map_address_for_private — old daemon doesn't emit the field; SDK defaults it to "".
    • test_returned_result_is_a_finalize_upload_result — defensive check that other dataclass fields stay populated.
  • Reviewer: end-to-end smoke once an antd 0.5.0 build is available.

Wire-compat

data_map_address has a default value of "" on the dataclass and is read with j.get("data_map_address", "") from the response. Old daemons that don't emit the field → SDK sees None from .get(..., "") and uses the default. Old SDK versions talking to a new daemon → simply ignore the new response field. No breaking change either direction.

Out of scope

  • prepare_data_upload_public for the in-memory bytes path. The daemon returns 501 for visibility="public" on /v1/data/prepare until upstream WithAutonomi/ant-client#73 ships data_prepare_upload_with_visibility. Will add the SDK method once the daemon supports it.
  • Mirror change for the other 13 SDKs.
  • FinalizeUploadResult.data_map (the raw hex DataMap) is still missing from the dataclass — pre-existing oversight that predates this PR. Worth a follow-up; not in scope here.

🤖 Generated with Claude Code

…ternal-signer public uploads

Mirrors the wire shape from antd #57:

- New method prepare_upload_public(path) on both RestClient and
  AsyncRestClient — POSTs visibility:"public" to /v1/upload/prepare. The
  daemon bundles the serialized DataMap as one extra chunk in the same
  PreparedUpload payment batch, so the external signer signs ONE EVM
  transaction covering chunks + DataMap.
- New field data_map_address on FinalizeUploadResult, populated from the
  daemon's response when the upload was prepared with visibility:"public".
  Defaults to "" so callers talking to old (pre-0.5.0) daemons see the
  empty value rather than a missing-field crash.
- Existing prepare_upload / finalize_upload signatures unchanged.

Tests verify:
- prepare_upload_public actually sends visibility:"public" in the request.
- finalize_upload surfaces data_map_address when the daemon returns it.
- finalize_upload defaults data_map_address to "" when the daemon doesn't
  emit the field (wire-compat with old daemons).
- The returned dataclass shape is unchanged (existing address /
  chunks_stored fields still populated).

Requires antd >= 0.5.0 to take effect; calls against older daemons
silently degrade to the private path (the visibility field is ignored
upstream and data_map_address stays empty).

Co-Authored-By: Claude Opus 4.7 (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.

1 participant