antd 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {antd-0.2.0 → antd-0.3.0}/.gitignore +9 -0
  2. {antd-0.2.0 → antd-0.3.0}/PKG-INFO +113 -3
  3. {antd-0.2.0 → antd-0.3.0}/README.md +112 -2
  4. {antd-0.2.0 → antd-0.3.0}/pyproject.toml +1 -1
  5. {antd-0.2.0 → antd-0.3.0}/src/antd/__init__.py +43 -0
  6. {antd-0.2.0 → antd-0.3.0}/src/antd/_grpc.py +454 -2
  7. antd-0.3.0/src/antd/_manifests.py +261 -0
  8. antd-0.3.0/src/antd/_pointers.py +363 -0
  9. antd-0.3.0/src/antd/_proto/antd/v1/data_pb2.py +64 -0
  10. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/data_pb2.pyi +12 -4
  11. antd-0.3.0/src/antd/_proto/antd/v1/manifests_pb2.py +49 -0
  12. antd-0.3.0/src/antd/_proto/antd/v1/manifests_pb2.pyi +85 -0
  13. antd-0.3.0/src/antd/_proto/antd/v1/manifests_pb2_grpc.py +176 -0
  14. antd-0.3.0/src/antd/_proto/antd/v1/pointers_pb2.py +82 -0
  15. antd-0.3.0/src/antd/_proto/antd/v1/pointers_pb2.pyi +239 -0
  16. antd-0.3.0/src/antd/_proto/antd/v1/pointers_pb2_grpc.py +540 -0
  17. {antd-0.2.0 → antd-0.3.0}/src/antd/_rest.py +415 -1
  18. {antd-0.2.0 → antd-0.3.0}/src/antd/exceptions.py +143 -7
  19. antd-0.3.0/src/antd/models.py +544 -0
  20. antd-0.2.0/src/antd/_proto/antd/v1/data_pb2.py +0 -64
  21. antd-0.2.0/src/antd/models.py +0 -247
  22. {antd-0.2.0 → antd-0.3.0}/LICENSE-APACHE +0 -0
  23. {antd-0.2.0 → antd-0.3.0}/LICENSE-MIT +0 -0
  24. {antd-0.2.0 → antd-0.3.0}/src/antd/_discover.py +0 -0
  25. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/__init__.py +0 -0
  26. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/__init__.py +0 -0
  27. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/__init__.py +0 -0
  28. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/chunks_pb2.py +0 -0
  29. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/chunks_pb2.pyi +0 -0
  30. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/chunks_pb2_grpc.py +0 -0
  31. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/common_pb2.py +0 -0
  32. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/common_pb2.pyi +0 -0
  33. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/common_pb2_grpc.py +0 -0
  34. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/data_pb2_grpc.py +0 -0
  35. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/events_pb2.py +0 -0
  36. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/events_pb2.pyi +0 -0
  37. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/events_pb2_grpc.py +0 -0
  38. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/files_pb2.py +0 -0
  39. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/files_pb2.pyi +0 -0
  40. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/files_pb2_grpc.py +0 -0
  41. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/health_pb2.py +0 -0
  42. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/health_pb2.pyi +0 -0
  43. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/health_pb2_grpc.py +0 -0
  44. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/upload_pb2.py +0 -0
  45. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/upload_pb2.pyi +0 -0
  46. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/upload_pb2_grpc.py +0 -0
  47. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/wallet_pb2.py +0 -0
  48. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/wallet_pb2.pyi +0 -0
  49. {antd-0.2.0 → antd-0.3.0}/src/antd/_proto/antd/v1/wallet_pb2_grpc.py +0 -0
@@ -49,6 +49,8 @@ _build/
49
49
  deps/
50
50
  .elixir_ls/
51
51
  mix.lock
52
+ # antd-elixir is a library but commits its lock: CI and dev resolve the same tree
53
+ !antd-elixir/mix.lock
52
54
 
53
55
  # Zig
54
56
  .zig-cache/
@@ -89,3 +91,10 @@ out/
89
91
 
90
92
  # ffi/scripts/build-native-manylinux.sh output (per-arch libant_ffi.so for packaging)
91
93
  ffi/rust/native-out/
94
+
95
+ # Third-party notices generated by scripts/third_party_notices/generate.py;
96
+ # the release workflow builds them.
97
+ /THIRD-PARTY-NOTICES*.txt
98
+ /RUST-STD-COPYRIGHT*.html
99
+ /antd/*.THIRD-PARTY-NOTICES.txt
100
+ /antd/*.RUST-STD-COPYRIGHT.html
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: antd
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Python client for the antd daemon: store and fetch data on the Autonomi network over REST or gRPC (not the Ant Design UI library)
5
5
  Project-URL: Homepage, https://autonomi.com
6
6
  Project-URL: Repository, https://github.com/WithAutonomi/ant-sdk
@@ -63,7 +63,7 @@ pip install -e ".[all]"
63
63
 
64
64
  ## Compatibility
65
65
 
66
- This package talks to a running [antd](https://github.com/WithAutonomi/ant-sdk/tree/main/antd) daemon; it does not join the network itself. Python 3.10+. Tested against antd 0.12.x; `health()` fields such as `version`/`evm_network` need antd 0.4.0 or newer. For a daemon-less client see the `ant-sdk` package (import `ant_ffi`). Not related to the Ant Design UI library.
66
+ This package talks to a running [antd](https://github.com/WithAutonomi/ant-sdk/tree/main/antd) daemon; it does not join the network itself. Python 3.10+. Tested against antd 0.12.x; `health()` fields such as `version`/`evm_network` need antd 0.4.0 or newer, and the [pointer](#pointers) methods need antd 0.16.0 or later, the first release with pointers. For a daemon-less client see the `ant-sdk` package (import `ant_ffi`). Not related to the Ant Design UI library.
67
67
 
68
68
  ## Quick Start
69
69
 
@@ -101,6 +101,15 @@ status = await aclient.health()
101
101
  await aclient.close()
102
102
  ```
103
103
 
104
+ The gRPC stubs in `src/antd/_proto/` are generated from `antd/proto` and
105
+ committed. After changing the protos, regenerate them and commit the result
106
+ (CI fails when they drift):
107
+
108
+ ```bash
109
+ pip install grpcio-tools==1.80.0 # the version the script pins
110
+ python scripts/generate_proto.py
111
+ ```
112
+
104
113
  ## API Reference
105
114
 
106
115
  ### Factory Functions
@@ -145,6 +154,45 @@ await aclient.close()
145
154
  | `file_get_public(address, dest_path)` | `None` | Download a public file by address |
146
155
  | `file_cost(path, is_public, payment_mode=...)` | `UploadCostEstimate` | Estimate file cost — size, chunks, gas, payment mode |
147
156
 
157
+ #### Manifests
158
+
159
+ A manifest (ADR-0006) describes a set of files as one `.ant` file, or as an `ant://manifest/` link when it is small enough. Each entry has an optional path and size, and either an embedded DataMap (a private file: the manifest is its key) or a public DataMap address. The daemon builds and decodes manifests through ant-core, so the SDK never handles the format. Every method is on all four clients (sync and async, REST and gRPC) with the same signatures, types and errors, and needs antd 0.16.0 or later, the first release with manifests. See `examples/10_manifests.py`.
160
+
161
+ **Nothing is uploaded or paid for.** Building and decoding only read the network: on build the default embedding policy resolves shrunk DataMaps, and on decode `resolve=True` fetches each entry's DataMap (never its content). A call can therefore time out, and retrying it is safe. Upload the files first (`data_put_public`, `file_put`, ...) and pass their addresses or DataMaps.
162
+
163
+ The `.ant` bytes are always raw `bytes` in this API: REST carries them as base64 and gRPC as bytes, and the clients convert. Sizes are Python `int`s, and an unset `size` or `exact_size` is `None`, never `0` (0 is an empty file). Over gRPC the manifest calls use a second channel to the same target, with its message limits raised to 256 MiB each way (a manifest can be 64 MiB); every other call keeps gRPC's defaults.
164
+
165
+ | Method | Returns | Description |
166
+ |--------|---------|-------------|
167
+ | `build_manifest(entries, *, name=None, torrent_info_hashes=None, embed_roots=True)` | `BuiltManifest` | Build a manifest from `ManifestEntryInput`s, each with exactly one of `data_map` or `address` (both or neither raises `BadRequestError` before sending). `embed_roots=True` (the default) resolves each shrunk DataMap and embeds its root when it is at most 64 KiB, so recipients skip that fetch; `False` embeds DataMaps as given. `link` is `None` when the link would exceed 1,500 bytes |
168
+ | `decode_manifest(manifest, resolve=False)` | `DecodedManifest` | Decode `.ant` bytes. With `resolve`, each entry's `exact_size` comes from the network, and a failure lands in that entry's `error` rather than failing the call |
169
+ | `decode_manifest_link(link, resolve=False)` | `DecodedManifest` | Decode an `ant://manifest/` link, a file link or a bare 64-hex address (`source="file_link"`: one public entry, no path) |
170
+
171
+ An invalid entry, such as a bad path (`../x`) or malformed hex, raises `BadRequestError` (HTTP 400 / gRPC `INVALID_ARGUMENT`) with the daemon's message, which names `entries[i]`. One the client refuses before sending (both or neither of `data_map`/`address`, a bad `size`, empty decode input) is the same error with `status_code` 400 and the daemon's wording, such as `2 invalid entries: entries[0]: give data_map or address, not both; entries[2]: needs a data_map or an address`, so one `except` covers both.
172
+
173
+ ```python
174
+ from antd import AntdClient, ManifestEntryInput
175
+
176
+ client = AntdClient()
177
+ a = client.data_put_public(b"note one").address # pays
178
+ b = client.data_put_public(b"note two").address # pays
179
+
180
+ built = client.build_manifest( # free
181
+ [
182
+ ManifestEntryInput(address=a, path="notes/one.txt"),
183
+ ManifestEntryInput(address=b, path="notes/two.txt"),
184
+ ],
185
+ name="example",
186
+ )
187
+ print(built.link)
188
+
189
+ decoded = client.decode_manifest_link(built.link, resolve=True) # free
190
+ for e in decoded.entries:
191
+ print(e.effective_name, e.kind, e.exact_size)
192
+ ```
193
+
194
+ Run the example with `ANTD_BASE_URL=http://localhost:8082 python examples/10_manifests.py`; it needs a wallet, and pays for its two uploads only.
195
+
148
196
  #### External Signer
149
197
 
150
198
  Two-phase upload — daemon prepares the payment intent, caller signs + submits the payForQuotes tx, daemon finalizes once the chain confirms. See `examples/07_external_signer.py` + `docs/external-signer-flow.md`. A finalize that stores only some chunks raises `PartialUploadError` — see [Partial uploads](#partial-uploads) for how to finish the upload without paying twice.
@@ -159,6 +207,44 @@ Two-phase upload — daemon prepares the payment intent, caller signs + submits
159
207
  | `finalize_merkle_upload(upload_id, winner_pool_hash, store_data_map=False)` | `FinalizeUploadResult` | Submit a prepared merkle-batch upload after selecting the winning pool. Raises `PartialUploadError` on a partial store |
160
208
  | `finalize_chunk_upload(upload_id, tx_hashes)` | `str` | Submit a prepared chunk after external payment; returns the chunk address |
161
209
 
210
+ #### Pointers
211
+
212
+ A pointer is a small, owner-signed, mutable reference. Its address is derived from the owner's key and never changes; what it points at (a chunk, such as a public data or file address, or another pointer) can be changed by the owner. The daemon holds the owner keys, loaded at startup with `antd --pointer-keys <file-or-dir>` (files in the format `ant pointer keygen` writes), so every write names the pointer by its address (`owner`), never by a key. Every method is on all four clients (sync and async, REST and gRPC) with the same signatures, types and errors. See `examples/09_pointers.py`.
213
+
214
+ **Every write pays, and the SDK never retries one.** A create, update or transfer costs about the price of one chunk, and every attempt pays again, so do not retry `pointer_create`, `pointer_update`, `pointer_transfer` or `pointer_finalize` automatically. The one exception is a `pointer_finalize` that raises `CloseGroupShortfallError` with `retryable=True`: the daemon kept the paid state, and repeating the call with the same `upload_id` stores it against the same payment (bound that loop). Reads are free to retry; a read during an update or churn can raise `CloseGroupShortfallError`.
215
+
216
+ Counters are Python `int`s. The daemon sends them as decimal strings because a final state (a transfer or freeze) sits at `POINTER_FINAL_COUNTER` (2^64−1); a counter that is not a decimal u64 raises `InternalError` instead of reading as 0. Addresses are 64 hex characters; the daemon accepts a `0x` prefix on input but always returns bare lowercase hex, so normalise before comparing.
217
+
218
+ | Method | Returns | Description |
219
+ |--------|---------|-------------|
220
+ | `pointer_keys()` | `list[str]` | Addresses of the pointers this daemon holds owner keys for, so can write |
221
+ | `pointer_create(owner, target, kind=PointerKind.CHUNK)` | `PointerWriteResult` | Create a pointer, paid by the daemon wallet. `AlreadyExistsError` if it exists, refused before paying |
222
+ | `pointer_update(owner, target, kind=PointerKind.CHUNK)` | `PointerWriteResult` | Point a pointer at a new target, paid by the daemon wallet; creates it if missing. `kind=PointerKind.POINTER` makes a forwarding the owner can still change. `PointerFinalError` once transferred or frozen |
223
+ | `pointer_transfer(owner, recipient)` | `PointerTransferResult` | Hand a pointer over for good to the recipient's pointer, which must exist: readers of the address are redirected there. Irreversible. Carries the close group's `finality`, or `finality_error` if that check failed |
224
+ | `pointer_get(address)` | `PointerRecord` | Read a pointer: `counter`, `target`, `kind`/`kind_tag`, `is_final`, `transferred_to`, the owner's public key. `NotFoundError` if there is none |
225
+ | `pointer_resolve(address)` | `PointerTarget` | Follow a chain of pointers (forwardings and transfers) to the target at its end |
226
+ | `pointer_finality(address)` | `PointerFinality` | Ask the whole close group where a pointer stands: `status` is a `PointerFinalityStatus` (`OPEN`, `SETTLING`, `UNCONFIRMED`, `FINAL`, `FORKED`, or `UNKNOWN` with the daemon's string in `raw_status`). Check `is_final` before relying on a transfer |
227
+ | `pointer_controller(address)` | `PointerController` | Follow transfers to the pointer whose owner now decides |
228
+ | `pointer_prepare(owner, op, *, target=None, kind=None, recipient=None, include_signed_quotes=False)` | `PointerPrepareResult` | External signer: the daemon signs `PointerOp.CREATE` / `UPDATE` (pass `target`) or `TRANSFER` (pass `recipient`) and quotes it (wave-batch `payments` for `payForQuotes()`). Needs no daemon wallet. Other writes to the pointer raise `ConflictError` until it is finalized or expires (one hour) |
229
+ | `pointer_finalize(upload_id, tx_hashes)` | `PointerFinalizeResult` | External signer: store the prepared write once paid. `CloseGroupShortfallError` with `retryable=True` means repeat the same call |
230
+
231
+ ```python
232
+ from antd import AntdClient, PointerFinalityStatus
233
+
234
+ client = AntdClient()
235
+ owner = client.pointer_keys()[0]
236
+
237
+ v1 = client.data_put_public(b"version 1").address
238
+ v2 = client.data_put_public(b"version 2").address
239
+
240
+ client.pointer_create(owner, v1) # pays once
241
+ client.pointer_update(owner, v2) # pays once; counter 1
242
+ assert client.pointer_resolve(owner).target == v2
243
+
244
+ f = client.pointer_finality(owner)
245
+ print(f.status is PointerFinalityStatus.OPEN, f.counter)
246
+ ```
247
+
162
248
  ## Models
163
249
 
164
250
  All models are frozen dataclasses (immutable).
@@ -171,7 +257,23 @@ All models are frozen dataclasses (immutable).
171
257
  | `DataPutPublicResult` | `address`, `chunks_stored`, `payment_mode_used` | Public data put — DataMap stored on-network |
172
258
  | `FilePutResult` | `data_map`, `storage_cost_atto`, `gas_cost_wei`, `chunks_stored`, `payment_mode_used` | Private file put — DataMap returned to caller |
173
259
  | `FilePutPublicResult` | `address`, `storage_cost_atto`, `gas_cost_wei`, `chunks_stored`, `payment_mode_used` | Public file put — DataMap stored on-network |
260
+ | `ManifestEntryInput` | `data_map`, `address`, `path`, `size` (keyword-only) | One file for `build_manifest`: exactly one of `data_map` (embedded) or `address` (public) |
261
+ | `ManifestEntryInfo` | `effective_name`, `path`, `size`, `kind`, `content_address`, `data_map`, `exact_size`, `error` | What a manifest says about one entry. `kind` is `"embedded"` or `"public"`; `data_map` is set by a decode, for embedded entries; `error` only by a resolving decode |
262
+ | `BuiltManifest` | `manifest` (`bytes`), `link`, `entries` | A built manifest: the `.ant` bytes, the link when it fits, the entries sorted by effective name |
263
+ | `DecodedManifest` | `source`, `name`, `torrent_info_hash_v1`, `torrent_info_hash_v2`, `entries` | A decoded manifest. `source` is `"manifest"` or `"file_link"` |
174
264
  | `UploadCostEstimate` | `cost`, `file_size`, `chunk_count`, `estimated_gas_cost_wei`, `payment_mode` | Pre-upload cost breakdown |
265
+ | `PointerWriteResult` | `address`, `state_id`, `counter` | State a pointer create/update stored |
266
+ | `PointerRecord` | `address`, `owner`, `counter`, `kind`, `kind_tag`, `target`, `state_id`, `is_final`, `transferred_to`; property `target_kind` | A pointer's current state |
267
+ | `PointerTarget` | `kind`, `kind_tag`, `target`; property `target_kind` | Where a chain of pointers ends |
268
+ | `PointerFinality` | `address`, `group`, `answered`, `status`, `raw_status`, `counter`, `state`, `states`, `majority`, `transferred_to`; property `is_final` | The close group's view of a pointer |
269
+ | `PointerFinalState` | `state_id`, `kind`, `kind_tag`, `target`, `holders`, `transferred_to` | One final state in a finality check |
270
+ | `PointerController` | `pointer`, `transfers`, `frozen` | Whose pointer decides, after every transfer |
271
+ | `PointerTransferResult` | `address`, `state_id`, `finality`, `finality_error` | What a transfer stored |
272
+ | `PointerPrepareResult` | `upload_id`, `op`, `address`, `state_id`, `counter`, `payment_type`, `payments`, `total_amount`, `payment_vault_address`, `payment_token_address`, `rpc_url`, `signed_quotes` | A signed pointer write quoted for an external signer |
273
+ | `PointerFinalizeResult` | `address`, `state_id`, `counter`, `finality` | What a pointer finalize stored (`finality` for a transfer) |
274
+ | `SignedQuoteEntry` | `quote_hash`, `quote`, `commitment_sidecar` | A quote in full signed form (base64), with `include_signed_quotes=True` |
275
+
276
+ Enums: `PointerKind` (`CHUNK`, `POINTER`), `PointerOp` (`CREATE`, `UPDATE`, `TRANSFER`), `PointerFinalityStatus` (above). Unset values read as `None` on both transports (REST sends `null`, gRPC an empty string or absent message).
175
277
 
176
278
  ## Error Handling
177
279
 
@@ -203,6 +305,12 @@ except AntdError as e:
203
305
  | `InternalError` | 500 | `INTERNAL` | Server error |
204
306
  | `NetworkError` | 502 | `UNAVAILABLE` | Network unreachable |
205
307
  | `PartialUploadError` | 502 (`code: "PARTIAL_UPLOAD"`) | `ABORTED` (message starts `Partial upload:`) | Finalize stored some chunks, not all — subclass of `NetworkError`; carries `chunks_stored`, `chunks_failed`, `total_chunks`, `retryable` |
308
+ | `PointerFinalError` | 409 (`code: "POINTER_FINAL"`) | `FAILED_PRECONDITION` + `x-antd-error-code: POINTER_FINAL` | The pointer is transferred or frozen; nothing can change it |
309
+ | `PointerForkedError` | 409 (`code: "POINTER_FORKED"`) | `FAILED_PRECONDITION` + `x-antd-error-code: POINTER_FORKED` | The owner signed two final states and no majority holds either — subclass of `ForkError` |
310
+ | `ConflictError` | 409 (`code: "CONFLICT"`) | `ABORTED` + `x-antd-error-code: CONFLICT` | A pointer write while a prepared write to it awaits payment, or an update that lost to a newer state |
311
+ | `CloseGroupShortfallError` | 503 (`code: "CLOSE_GROUP_SHORTFALL"`) | `UNAVAILABLE` + `x-antd-error-code: CLOSE_GROUP_SHORTFALL` | Too few of the close group answered or stored; `retryable` is `True` only for a pointer finalize that kept the paid state |
312
+
313
+ The four pointer-era codes share their status with older errors, so the SDK reads the REST body's `code`, and over gRPC the `x-antd-error-code` trailing metadata, which it trusts only when it agrees with the status code (a `FAILED_PRECONDITION` without the tag is still a `PaymentError`). The daemon tags these on any call, so a chunk or data store whose close group fell short raises `CloseGroupShortfallError` too; daemons before the pointer API sent that as a 500 (`InternalError`).
206
314
 
207
315
  ### Partial uploads
208
316
 
@@ -256,9 +364,11 @@ python examples/04_files.py # File upload/download
256
364
  python examples/06_private_data.py # Private data with data maps
257
365
  python examples/07_external_signer.py # External-signer file + chunk upload
258
366
  python examples/08_grpc.py # gRPC transport (requires antd[grpc])
259
- python examples/08_grpc.py # gRPC transport (instead of REST)
367
+ ANTD_POINTER_OWNER=<address> python examples/09_pointers.py # Create, update, resolve a pointer (pays)
260
368
  ```
261
369
 
370
+ The pointer example needs a daemon started with `--pointer-keys` and a wallet; `ANTD_POINTER_OWNER` is one of its `pointer_keys()`. Set `ANTD_BASE_URL` to reach a daemon that is not on `http://localhost:8082`.
371
+
262
372
  Or use the dev CLI:
263
373
 
264
374
  ```bash
@@ -20,7 +20,7 @@ pip install -e ".[all]"
20
20
 
21
21
  ## Compatibility
22
22
 
23
- This package talks to a running [antd](https://github.com/WithAutonomi/ant-sdk/tree/main/antd) daemon; it does not join the network itself. Python 3.10+. Tested against antd 0.12.x; `health()` fields such as `version`/`evm_network` need antd 0.4.0 or newer. For a daemon-less client see the `ant-sdk` package (import `ant_ffi`). Not related to the Ant Design UI library.
23
+ This package talks to a running [antd](https://github.com/WithAutonomi/ant-sdk/tree/main/antd) daemon; it does not join the network itself. Python 3.10+. Tested against antd 0.12.x; `health()` fields such as `version`/`evm_network` need antd 0.4.0 or newer, and the [pointer](#pointers) methods need antd 0.16.0 or later, the first release with pointers. For a daemon-less client see the `ant-sdk` package (import `ant_ffi`). Not related to the Ant Design UI library.
24
24
 
25
25
  ## Quick Start
26
26
 
@@ -58,6 +58,15 @@ status = await aclient.health()
58
58
  await aclient.close()
59
59
  ```
60
60
 
61
+ The gRPC stubs in `src/antd/_proto/` are generated from `antd/proto` and
62
+ committed. After changing the protos, regenerate them and commit the result
63
+ (CI fails when they drift):
64
+
65
+ ```bash
66
+ pip install grpcio-tools==1.80.0 # the version the script pins
67
+ python scripts/generate_proto.py
68
+ ```
69
+
61
70
  ## API Reference
62
71
 
63
72
  ### Factory Functions
@@ -102,6 +111,45 @@ await aclient.close()
102
111
  | `file_get_public(address, dest_path)` | `None` | Download a public file by address |
103
112
  | `file_cost(path, is_public, payment_mode=...)` | `UploadCostEstimate` | Estimate file cost — size, chunks, gas, payment mode |
104
113
 
114
+ #### Manifests
115
+
116
+ A manifest (ADR-0006) describes a set of files as one `.ant` file, or as an `ant://manifest/` link when it is small enough. Each entry has an optional path and size, and either an embedded DataMap (a private file: the manifest is its key) or a public DataMap address. The daemon builds and decodes manifests through ant-core, so the SDK never handles the format. Every method is on all four clients (sync and async, REST and gRPC) with the same signatures, types and errors, and needs antd 0.16.0 or later, the first release with manifests. See `examples/10_manifests.py`.
117
+
118
+ **Nothing is uploaded or paid for.** Building and decoding only read the network: on build the default embedding policy resolves shrunk DataMaps, and on decode `resolve=True` fetches each entry's DataMap (never its content). A call can therefore time out, and retrying it is safe. Upload the files first (`data_put_public`, `file_put`, ...) and pass their addresses or DataMaps.
119
+
120
+ The `.ant` bytes are always raw `bytes` in this API: REST carries them as base64 and gRPC as bytes, and the clients convert. Sizes are Python `int`s, and an unset `size` or `exact_size` is `None`, never `0` (0 is an empty file). Over gRPC the manifest calls use a second channel to the same target, with its message limits raised to 256 MiB each way (a manifest can be 64 MiB); every other call keeps gRPC's defaults.
121
+
122
+ | Method | Returns | Description |
123
+ |--------|---------|-------------|
124
+ | `build_manifest(entries, *, name=None, torrent_info_hashes=None, embed_roots=True)` | `BuiltManifest` | Build a manifest from `ManifestEntryInput`s, each with exactly one of `data_map` or `address` (both or neither raises `BadRequestError` before sending). `embed_roots=True` (the default) resolves each shrunk DataMap and embeds its root when it is at most 64 KiB, so recipients skip that fetch; `False` embeds DataMaps as given. `link` is `None` when the link would exceed 1,500 bytes |
125
+ | `decode_manifest(manifest, resolve=False)` | `DecodedManifest` | Decode `.ant` bytes. With `resolve`, each entry's `exact_size` comes from the network, and a failure lands in that entry's `error` rather than failing the call |
126
+ | `decode_manifest_link(link, resolve=False)` | `DecodedManifest` | Decode an `ant://manifest/` link, a file link or a bare 64-hex address (`source="file_link"`: one public entry, no path) |
127
+
128
+ An invalid entry, such as a bad path (`../x`) or malformed hex, raises `BadRequestError` (HTTP 400 / gRPC `INVALID_ARGUMENT`) with the daemon's message, which names `entries[i]`. One the client refuses before sending (both or neither of `data_map`/`address`, a bad `size`, empty decode input) is the same error with `status_code` 400 and the daemon's wording, such as `2 invalid entries: entries[0]: give data_map or address, not both; entries[2]: needs a data_map or an address`, so one `except` covers both.
129
+
130
+ ```python
131
+ from antd import AntdClient, ManifestEntryInput
132
+
133
+ client = AntdClient()
134
+ a = client.data_put_public(b"note one").address # pays
135
+ b = client.data_put_public(b"note two").address # pays
136
+
137
+ built = client.build_manifest( # free
138
+ [
139
+ ManifestEntryInput(address=a, path="notes/one.txt"),
140
+ ManifestEntryInput(address=b, path="notes/two.txt"),
141
+ ],
142
+ name="example",
143
+ )
144
+ print(built.link)
145
+
146
+ decoded = client.decode_manifest_link(built.link, resolve=True) # free
147
+ for e in decoded.entries:
148
+ print(e.effective_name, e.kind, e.exact_size)
149
+ ```
150
+
151
+ Run the example with `ANTD_BASE_URL=http://localhost:8082 python examples/10_manifests.py`; it needs a wallet, and pays for its two uploads only.
152
+
105
153
  #### External Signer
106
154
 
107
155
  Two-phase upload — daemon prepares the payment intent, caller signs + submits the payForQuotes tx, daemon finalizes once the chain confirms. See `examples/07_external_signer.py` + `docs/external-signer-flow.md`. A finalize that stores only some chunks raises `PartialUploadError` — see [Partial uploads](#partial-uploads) for how to finish the upload without paying twice.
@@ -116,6 +164,44 @@ Two-phase upload — daemon prepares the payment intent, caller signs + submits
116
164
  | `finalize_merkle_upload(upload_id, winner_pool_hash, store_data_map=False)` | `FinalizeUploadResult` | Submit a prepared merkle-batch upload after selecting the winning pool. Raises `PartialUploadError` on a partial store |
117
165
  | `finalize_chunk_upload(upload_id, tx_hashes)` | `str` | Submit a prepared chunk after external payment; returns the chunk address |
118
166
 
167
+ #### Pointers
168
+
169
+ A pointer is a small, owner-signed, mutable reference. Its address is derived from the owner's key and never changes; what it points at (a chunk, such as a public data or file address, or another pointer) can be changed by the owner. The daemon holds the owner keys, loaded at startup with `antd --pointer-keys <file-or-dir>` (files in the format `ant pointer keygen` writes), so every write names the pointer by its address (`owner`), never by a key. Every method is on all four clients (sync and async, REST and gRPC) with the same signatures, types and errors. See `examples/09_pointers.py`.
170
+
171
+ **Every write pays, and the SDK never retries one.** A create, update or transfer costs about the price of one chunk, and every attempt pays again, so do not retry `pointer_create`, `pointer_update`, `pointer_transfer` or `pointer_finalize` automatically. The one exception is a `pointer_finalize` that raises `CloseGroupShortfallError` with `retryable=True`: the daemon kept the paid state, and repeating the call with the same `upload_id` stores it against the same payment (bound that loop). Reads are free to retry; a read during an update or churn can raise `CloseGroupShortfallError`.
172
+
173
+ Counters are Python `int`s. The daemon sends them as decimal strings because a final state (a transfer or freeze) sits at `POINTER_FINAL_COUNTER` (2^64−1); a counter that is not a decimal u64 raises `InternalError` instead of reading as 0. Addresses are 64 hex characters; the daemon accepts a `0x` prefix on input but always returns bare lowercase hex, so normalise before comparing.
174
+
175
+ | Method | Returns | Description |
176
+ |--------|---------|-------------|
177
+ | `pointer_keys()` | `list[str]` | Addresses of the pointers this daemon holds owner keys for, so can write |
178
+ | `pointer_create(owner, target, kind=PointerKind.CHUNK)` | `PointerWriteResult` | Create a pointer, paid by the daemon wallet. `AlreadyExistsError` if it exists, refused before paying |
179
+ | `pointer_update(owner, target, kind=PointerKind.CHUNK)` | `PointerWriteResult` | Point a pointer at a new target, paid by the daemon wallet; creates it if missing. `kind=PointerKind.POINTER` makes a forwarding the owner can still change. `PointerFinalError` once transferred or frozen |
180
+ | `pointer_transfer(owner, recipient)` | `PointerTransferResult` | Hand a pointer over for good to the recipient's pointer, which must exist: readers of the address are redirected there. Irreversible. Carries the close group's `finality`, or `finality_error` if that check failed |
181
+ | `pointer_get(address)` | `PointerRecord` | Read a pointer: `counter`, `target`, `kind`/`kind_tag`, `is_final`, `transferred_to`, the owner's public key. `NotFoundError` if there is none |
182
+ | `pointer_resolve(address)` | `PointerTarget` | Follow a chain of pointers (forwardings and transfers) to the target at its end |
183
+ | `pointer_finality(address)` | `PointerFinality` | Ask the whole close group where a pointer stands: `status` is a `PointerFinalityStatus` (`OPEN`, `SETTLING`, `UNCONFIRMED`, `FINAL`, `FORKED`, or `UNKNOWN` with the daemon's string in `raw_status`). Check `is_final` before relying on a transfer |
184
+ | `pointer_controller(address)` | `PointerController` | Follow transfers to the pointer whose owner now decides |
185
+ | `pointer_prepare(owner, op, *, target=None, kind=None, recipient=None, include_signed_quotes=False)` | `PointerPrepareResult` | External signer: the daemon signs `PointerOp.CREATE` / `UPDATE` (pass `target`) or `TRANSFER` (pass `recipient`) and quotes it (wave-batch `payments` for `payForQuotes()`). Needs no daemon wallet. Other writes to the pointer raise `ConflictError` until it is finalized or expires (one hour) |
186
+ | `pointer_finalize(upload_id, tx_hashes)` | `PointerFinalizeResult` | External signer: store the prepared write once paid. `CloseGroupShortfallError` with `retryable=True` means repeat the same call |
187
+
188
+ ```python
189
+ from antd import AntdClient, PointerFinalityStatus
190
+
191
+ client = AntdClient()
192
+ owner = client.pointer_keys()[0]
193
+
194
+ v1 = client.data_put_public(b"version 1").address
195
+ v2 = client.data_put_public(b"version 2").address
196
+
197
+ client.pointer_create(owner, v1) # pays once
198
+ client.pointer_update(owner, v2) # pays once; counter 1
199
+ assert client.pointer_resolve(owner).target == v2
200
+
201
+ f = client.pointer_finality(owner)
202
+ print(f.status is PointerFinalityStatus.OPEN, f.counter)
203
+ ```
204
+
119
205
  ## Models
120
206
 
121
207
  All models are frozen dataclasses (immutable).
@@ -128,7 +214,23 @@ All models are frozen dataclasses (immutable).
128
214
  | `DataPutPublicResult` | `address`, `chunks_stored`, `payment_mode_used` | Public data put — DataMap stored on-network |
129
215
  | `FilePutResult` | `data_map`, `storage_cost_atto`, `gas_cost_wei`, `chunks_stored`, `payment_mode_used` | Private file put — DataMap returned to caller |
130
216
  | `FilePutPublicResult` | `address`, `storage_cost_atto`, `gas_cost_wei`, `chunks_stored`, `payment_mode_used` | Public file put — DataMap stored on-network |
217
+ | `ManifestEntryInput` | `data_map`, `address`, `path`, `size` (keyword-only) | One file for `build_manifest`: exactly one of `data_map` (embedded) or `address` (public) |
218
+ | `ManifestEntryInfo` | `effective_name`, `path`, `size`, `kind`, `content_address`, `data_map`, `exact_size`, `error` | What a manifest says about one entry. `kind` is `"embedded"` or `"public"`; `data_map` is set by a decode, for embedded entries; `error` only by a resolving decode |
219
+ | `BuiltManifest` | `manifest` (`bytes`), `link`, `entries` | A built manifest: the `.ant` bytes, the link when it fits, the entries sorted by effective name |
220
+ | `DecodedManifest` | `source`, `name`, `torrent_info_hash_v1`, `torrent_info_hash_v2`, `entries` | A decoded manifest. `source` is `"manifest"` or `"file_link"` |
131
221
  | `UploadCostEstimate` | `cost`, `file_size`, `chunk_count`, `estimated_gas_cost_wei`, `payment_mode` | Pre-upload cost breakdown |
222
+ | `PointerWriteResult` | `address`, `state_id`, `counter` | State a pointer create/update stored |
223
+ | `PointerRecord` | `address`, `owner`, `counter`, `kind`, `kind_tag`, `target`, `state_id`, `is_final`, `transferred_to`; property `target_kind` | A pointer's current state |
224
+ | `PointerTarget` | `kind`, `kind_tag`, `target`; property `target_kind` | Where a chain of pointers ends |
225
+ | `PointerFinality` | `address`, `group`, `answered`, `status`, `raw_status`, `counter`, `state`, `states`, `majority`, `transferred_to`; property `is_final` | The close group's view of a pointer |
226
+ | `PointerFinalState` | `state_id`, `kind`, `kind_tag`, `target`, `holders`, `transferred_to` | One final state in a finality check |
227
+ | `PointerController` | `pointer`, `transfers`, `frozen` | Whose pointer decides, after every transfer |
228
+ | `PointerTransferResult` | `address`, `state_id`, `finality`, `finality_error` | What a transfer stored |
229
+ | `PointerPrepareResult` | `upload_id`, `op`, `address`, `state_id`, `counter`, `payment_type`, `payments`, `total_amount`, `payment_vault_address`, `payment_token_address`, `rpc_url`, `signed_quotes` | A signed pointer write quoted for an external signer |
230
+ | `PointerFinalizeResult` | `address`, `state_id`, `counter`, `finality` | What a pointer finalize stored (`finality` for a transfer) |
231
+ | `SignedQuoteEntry` | `quote_hash`, `quote`, `commitment_sidecar` | A quote in full signed form (base64), with `include_signed_quotes=True` |
232
+
233
+ Enums: `PointerKind` (`CHUNK`, `POINTER`), `PointerOp` (`CREATE`, `UPDATE`, `TRANSFER`), `PointerFinalityStatus` (above). Unset values read as `None` on both transports (REST sends `null`, gRPC an empty string or absent message).
132
234
 
133
235
  ## Error Handling
134
236
 
@@ -160,6 +262,12 @@ except AntdError as e:
160
262
  | `InternalError` | 500 | `INTERNAL` | Server error |
161
263
  | `NetworkError` | 502 | `UNAVAILABLE` | Network unreachable |
162
264
  | `PartialUploadError` | 502 (`code: "PARTIAL_UPLOAD"`) | `ABORTED` (message starts `Partial upload:`) | Finalize stored some chunks, not all — subclass of `NetworkError`; carries `chunks_stored`, `chunks_failed`, `total_chunks`, `retryable` |
265
+ | `PointerFinalError` | 409 (`code: "POINTER_FINAL"`) | `FAILED_PRECONDITION` + `x-antd-error-code: POINTER_FINAL` | The pointer is transferred or frozen; nothing can change it |
266
+ | `PointerForkedError` | 409 (`code: "POINTER_FORKED"`) | `FAILED_PRECONDITION` + `x-antd-error-code: POINTER_FORKED` | The owner signed two final states and no majority holds either — subclass of `ForkError` |
267
+ | `ConflictError` | 409 (`code: "CONFLICT"`) | `ABORTED` + `x-antd-error-code: CONFLICT` | A pointer write while a prepared write to it awaits payment, or an update that lost to a newer state |
268
+ | `CloseGroupShortfallError` | 503 (`code: "CLOSE_GROUP_SHORTFALL"`) | `UNAVAILABLE` + `x-antd-error-code: CLOSE_GROUP_SHORTFALL` | Too few of the close group answered or stored; `retryable` is `True` only for a pointer finalize that kept the paid state |
269
+
270
+ The four pointer-era codes share their status with older errors, so the SDK reads the REST body's `code`, and over gRPC the `x-antd-error-code` trailing metadata, which it trusts only when it agrees with the status code (a `FAILED_PRECONDITION` without the tag is still a `PaymentError`). The daemon tags these on any call, so a chunk or data store whose close group fell short raises `CloseGroupShortfallError` too; daemons before the pointer API sent that as a 500 (`InternalError`).
163
271
 
164
272
  ### Partial uploads
165
273
 
@@ -213,9 +321,11 @@ python examples/04_files.py # File upload/download
213
321
  python examples/06_private_data.py # Private data with data maps
214
322
  python examples/07_external_signer.py # External-signer file + chunk upload
215
323
  python examples/08_grpc.py # gRPC transport (requires antd[grpc])
216
- python examples/08_grpc.py # gRPC transport (instead of REST)
324
+ ANTD_POINTER_OWNER=<address> python examples/09_pointers.py # Create, update, resolve a pointer (pays)
217
325
  ```
218
326
 
327
+ The pointer example needs a daemon started with `--pointer-keys` and a wallet; `ANTD_POINTER_OWNER` is one of its `pointer_keys()`. Set `ANTD_BASE_URL` to reach a daemon that is not on `http://localhost:8082`.
328
+
219
329
  Or use the dev CLI:
220
330
 
221
331
  ```bash
@@ -7,7 +7,7 @@ build-backend = "hatchling.build"
7
7
  # Decided 2026-09-04 (V2-1157). Not related to the Ant Design UI library of the
8
8
  # same name on npm — the description line disambiguates on PyPI.
9
9
  name = "antd"
10
- version = "0.2.0" # tracks the daemon-client API, independent of the antd daemon and the ant-sdk FFI package
10
+ version = "0.3.0" # tracks the daemon-client API, independent of the antd daemon and the ant-sdk FFI package
11
11
  description = "Python client for the antd daemon: store and fetch data on the Autonomi network over REST or gRPC (not the Ant Design UI library)"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.10"
@@ -19,6 +19,7 @@ except PackageNotFoundError: # running from a source checkout that is not insta
19
19
  __version__ = "0.0.0"
20
20
 
21
21
  from .models import (
22
+ POINTER_FINAL_COUNTER,
22
23
  CandidateNodeEntry,
23
24
  DataPutPublicResult,
24
25
  DataPutResult,
@@ -30,25 +31,43 @@ from .models import (
30
31
  HealthStatus,
31
32
  PaymentInfo,
32
33
  PaymentMode,
34
+ PointerController,
35
+ PointerFinality,
36
+ PointerFinalityStatus,
37
+ PointerFinalizeResult,
38
+ PointerFinalState,
39
+ PointerKind,
40
+ PointerOp,
41
+ PointerPrepareResult,
42
+ PointerRecord,
43
+ PointerTarget,
44
+ PointerTransferResult,
45
+ PointerWriteResult,
33
46
  PoolCommitmentEntry,
34
47
  PrepareChunkResult,
35
48
  PrepareUploadResult,
36
49
  PutResult,
50
+ SignedQuoteEntry,
37
51
  UploadCostEstimate,
38
52
  WalletAddress,
39
53
  WalletBalance,
40
54
  )
55
+ from .models import BuiltManifest, DecodedManifest, ManifestEntryInfo, ManifestEntryInput
41
56
  from ._discover import discover_daemon_url, discover_grpc_target
42
57
  from .exceptions import (
43
58
  AntdError,
44
59
  AlreadyExistsError,
45
60
  BadRequestError,
61
+ CloseGroupShortfallError,
62
+ ConflictError,
46
63
  ForkError,
47
64
  InternalError,
48
65
  NetworkError,
49
66
  NotFoundError,
50
67
  PartialUploadError,
51
68
  PaymentError,
69
+ PointerFinalError,
70
+ PointerForkedError,
52
71
  TooLargeError,
53
72
  )
54
73
 
@@ -76,20 +95,44 @@ __all__ = [
76
95
  "PrepareChunkResult",
77
96
  "PrepareUploadResult",
78
97
  "PutResult",
98
+ "SignedQuoteEntry",
79
99
  "UploadCostEstimate",
80
100
  "WalletAddress",
81
101
  "WalletBalance",
102
+ # Pointers
103
+ "POINTER_FINAL_COUNTER",
104
+ "PointerController",
105
+ "PointerFinalState",
106
+ "PointerFinality",
107
+ "PointerFinalityStatus",
108
+ "PointerFinalizeResult",
109
+ "PointerKind",
110
+ "PointerOp",
111
+ "PointerPrepareResult",
112
+ "PointerRecord",
113
+ "PointerTarget",
114
+ "PointerTransferResult",
115
+ "PointerWriteResult",
82
116
  # Exceptions
83
117
  "AntdError",
84
118
  "AlreadyExistsError",
85
119
  "BadRequestError",
120
+ "CloseGroupShortfallError",
121
+ "ConflictError",
86
122
  "ForkError",
87
123
  "InternalError",
88
124
  "NetworkError",
89
125
  "NotFoundError",
90
126
  "PartialUploadError",
91
127
  "PaymentError",
128
+ "PointerFinalError",
129
+ "PointerForkedError",
92
130
  "TooLargeError",
131
+ # Manifests
132
+ "BuiltManifest",
133
+ "DecodedManifest",
134
+ "ManifestEntryInfo",
135
+ "ManifestEntryInput",
93
136
  ]
94
137
 
95
138