Skip to content

fix(antd-zig): pass payment_mode to dataPutPublic/dataPutPrivate in examples#79

Merged
Nic-dorman merged 1 commit into
mainfrom
fix/zig-example-arity
May 14, 2026
Merged

fix(antd-zig): pass payment_mode to dataPutPublic/dataPutPrivate in examples#79
Nic-dorman merged 1 commit into
mainfrom
fix/zig-example-arity

Conversation

@Nic-dorman
Copy link
Copy Markdown
Collaborator

Fixes #70.

examples/02-data.zig and examples/06-private-data.zig were calling the SDK's put methods with one arg short:

examples/02-data.zig:16:34: error: member function expected 2 argument(s), found 1
    const put_result = try client.dataPutPublic(message);
                           ~~~~~~^~~~~~~~~~~~~~
src/antd.zig:181:9: note: function declared here
    pub fn dataPutPublic(self: *Client, data: []const u8, payment_mode: ?[]const u8) !PutResult {

Pass null for the optional payment-mode (mirrors 04-files.zig, which already passes null to fileUploadPublic).

Affected:

  • 02-data.zig:16dataPutPublic
  • 06-private-data.zig:16dataPutPrivate

03-chunks.zig (chunkPut is single-arg) and 04-files.zig (already correct) are unchanged.

Test plan

  • Type-checks the SDK API surface with the new arity (the compiler error from the wrong arity is gone)
  • End-to-end run currently blocked by an unrelated Zig-version mismatch in src/json_helpers.zig / src/antd.zig itself: the source uses .empty (Zig 0.15-dev) AND http.Client.open (Zig 0.14.x), which don't coexist in any released Zig. Filed separately as antd-zig source uses Zig APIs from incompatible versions; doesn't compile on any released Zig #78. Once that lands, zig build run-02-data should green up.

Out of scope (worth a separate ticket)

examples/05-graph.zig calls graphEntryPut, graphEntryGet, graphEntryExists, and graphEntryCost, none of which exist on Client in src/antd.zig — looks like the entire graph example is targeting an API surface that hasn't landed yet. Not touching it here.

…xamples

The example call sites were one arg short:

  examples/02-data.zig:16: error: member function expected 2 argument(s), found 1
      const put_result = try client.dataPutPublic(message);

The SDK signature has been two-arg for a while:

  pub fn dataPutPublic(self: *Client, data: []const u8,
                       payment_mode: ?[]const u8) !PutResult

Pass null for the optional payment mode (matches what fileUploadPublic
already does in 04-files.zig).

Affected examples:
- 02-data.zig:16 dataPutPublic
- 06-private-data.zig:16 dataPutPrivate

Note: end-to-end execution is currently blocked on an unrelated Zig version
mismatch in the SDK source itself (.empty initializer + http.Client.open
do not coexist in any released Zig) - tracked in #78. The type-check of
the call sites passes once that is sorted; this PR fixes the example
shape independently.

Closes #70
Nic-dorman added a commit that referenced this pull request May 14, 2026
…inimum) (#82)

The source mixed APIs from different Zig versions and did not compile on
any released Zig (see #78):

- json_helpers.zig used 0.15-dev ArrayList style:
    var list: std.ArrayList(u8) = .empty;
    list.append(allocator, c);
    list.deinit(allocator);
    list.toOwnedSlice(allocator);

  These are not present in Zig 0.14.x, which is what build.zig.zon
  declares as minimum_zig_version. Switch to the 0.14 style:
    var list = std.ArrayList(u8).init(allocator);
    list.append(c);
    list.deinit();
    list.toOwnedSlice();

- antd.zig used req.status which is a 0.15-dev shortcut. In 0.14.x the
  response struct sits one level deeper:
    @intFromEnum(req.status)         -> @intFromEnum(req.response.status)

- tests.zig referenced a json_helpers.parseCost helper that no longer
  exists. Rename the test to use parseCostEstimate (the actual helper)
  and adjust the expected JSON body + assertion.

After this change:
  $ zig version
  0.14.1
  $ zig build           # builds clean
  $ zig build test      # all unit tests pass
  $ zig build run-01-connect  # connects to a live antd daemon
  $ zig build run-03-chunks   # stores a chunk on the local devnet

Examples 02 + 06 still need the arity fix tracked in #70 (PR #79) before
they can run end-to-end; 04-files fails at runtime when /tmp/example.txt
is absent (test data, not a compile concern); 05-graph references SDK
methods (graphEntryPut/Get/Exists/Cost) that do not exist in src/antd.zig
- a separate issue worth filing.

Closes #78
@Nic-dorman Nic-dorman merged commit 12ae5cb into main May 14, 2026
@Nic-dorman Nic-dorman deleted the fix/zig-example-arity branch May 14, 2026 11:03
Nic-dorman added a commit that referenced this pull request May 14, 2026
Cuts v0.7.1 atop v0.7.0. Primarily refreshes the upstream `ant-core`
pin to the `ant-cli-v0.2.3` release tag (no API change for antd
consumers). Bundles a substantial round of cross-SDK example/build
fixes, dispatcher improvements, and CI/release workflow hardening.

## antd

- chore(antd): bump ant-core to v0.2.3 (#85)

## SDK example/build fixes

- fix(antd-php): use cost-estimate fields in example 02 (#74)
- fix(antd-elixir): print cost-estimate fields in examples (#75)
- fix(antd-lua): add missing discover module to rockspec (#76)
- fix(antd-kotlin): make put-response cost optional + ship gradle wrapper (#77)
- fix(antd-zig): pass payment_mode to dataPutPublic/dataPutPrivate (#79)
- fix(antd-java): make examples runnable via gradle :examples subproject (#80)
- fix(antd-zig): align stdlib API to declared 0.14.x minimum (#82)
- fix(antd-swift): port to Linux + populate cost-estimate fields (#87)

## ant-dev (developer CLI)

- fix(ant-dev): clean up orphan anvil/antnode and stale node identities on stop (#81)
- fix(ant-dev): tooling cluster — flag alias, sys.executable, anvil preflight, README (#83)
- feat(ant-dev): expand `ant dev example` to dispatch all 15 SDKs (#84)
- fix(ant-dev): dispatcher swift no-skip + lua LUA_PATH wrap (#86)
- feat(ant-dev): expose --preset flag on `ant dev start` (default: small) (#88)

## CI / release

- ci: authenticate arduino/setup-protoc on ci.yml too (#60)
- feat(release): publish antd-linux-arm64 artifact (#89)

## Validation

15/15 SDKs round-tripped end-to-end against a daemon built from this
commit on a Linux dev box (Ubuntu 24.04, 0.7.1 atop ant-core v0.2.3).

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.

antd-zig: example 02-data calls dataPutPublic(message) but API requires (data, payment_mode)

1 participant