feat(antd-py): prepare_upload_public + data_map_address#59
Draft
Nic-dorman wants to merge 1 commit into
Draft
Conversation
…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>
2 tasks
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
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
visibilityfield is ignored upstream and the newdata_map_addressfield defaults to"". Nothing breaks for existing callers.Change
prepare_upload_public(self, path)onRestClientandAsyncRestClient. POSTs{"path": path, "visibility": "public"}to/v1/upload/prepare. Sibling of the existing privateprepare_upload(path).data_map_address: str = ""onFinalizeUploadResultdataclass. Populated byfinalize_uploadandfinalize_merkle_uploadfrom the daemon's response (sync + async).addressfield onFinalizeUploadResultkeeps its semantics — it's the legacy path wherestore_data_map=Truemade the daemon's internal wallet pay for a separate DataMap-store call. New callers should preferprepare_upload_public+data_map_address.Behavior
prepare_upload(path)prepare_upload_public(path)finalize_uploadreturnsdata_map_addressprepare_upload_public(path)visibility);data_map_addressstays""addressfield still set when caller passedstore_data_map=Trueto finalize_merkle_uploadTest plan
pytest tests/test_rest_client.py— 21/21 pass (4 new tests).test_sends_visibility_public— captures the request body and assertsvisibility="public"was sent.test_finalize_surfaces_data_map_address_for_public— daemon returnsdata_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.Wire-compat
data_map_addresshas a default value of""on the dataclass and is read withj.get("data_map_address", "")from the response. Old daemons that don't emit the field → SDK seesNonefrom.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_publicfor the in-memorybytespath. The daemon returns 501 forvisibility="public"on/v1/data/prepareuntil upstreamWithAutonomi/ant-client#73shipsdata_prepare_upload_with_visibility. Will add the SDK method once the daemon supports it.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