Skip to content

fix(antd-kotlin): make put-response cost optional; ship missing gradle wrapper#77

Open
Nic-dorman wants to merge 1 commit into
mainfrom
fix/kotlin-dto-and-wrapper
Open

fix(antd-kotlin): make put-response cost optional; ship missing gradle wrapper#77
Nic-dorman wants to merge 1 commit into
mainfrom
fix/kotlin-dto-and-wrapper

Conversation

@Nic-dorman
Copy link
Copy Markdown
Collaborator

Fixes #69.

Two issues blocked antd-kotlin example 02 from running. Both fixed here because either one alone leaves the binding non-functional out of the box.

1. DataPutPublicDto deserialization failure

The example fataled on:

Caused by: kotlinx.serialization.MissingFieldException:
  Field 'cost' is required for type with serial name
  'com.autonomi.sdk.DataPutPublicDto', but it was missing
        at com.autonomi.sdk.AntdRestClient$dataPutPublic$$inlined$postJson$1.invokeSuspend(AntdRestClient.kt:284)

The daemon currently returns {address, chunks_stored, payment_mode_used} for PUT /v1/data/public — no cost field:

$ curl -s -X POST http://127.0.0.1:8082/v1/data/public \
       -H 'Content-Type: application/json' \
       -d '{"data":"SGVsbG8gd29ybGQ="}'
{"address":"5c0…666","chunks_stored":3,"payment_mode_used":"single"}

Make cost default to empty in DataPutPublicDto (and DataPutPrivateDto), mirroring how the PHP REST client falls back to '' and how the Python REST client uses .get(...) with implicit None. Non-breaking — PutResult.cost still ends up the same String type downstream.

2. Missing gradle wrapper files

antd-kotlin/ shipped gradle/wrapper/gradle-wrapper.properties but not gradlew or gradle/wrapper/gradle-wrapper.jar. The README tells users to run ./gradlew :examples:run --args=2, which gives:

bash: ./gradlew: No such file or directory

Add the wrapper script (executable) and the wrapper jar, copied from antd-java/. gradle-wrapper.jar is a checked-in binary in both antd-java/ and other JVM projects in this repo, so adding it here is consistent.

Test plan

Sample output

=== Example 02: Public Data ===
Estimate: 16 bytes in 3 chunks, storage 0 atto, gas 0 wei, mode single
Stored at address: 01b06330e4f4a8c565087e4087caabf860bdadbe96b7b8f0447493b0081c2335
Actual cost:  atto tokens
Retrieved: Hello, Autonomi network!
Public data round-trip OK!

(Actual cost blank for the same reason — daemon doesn't return it on this path. That's worth its own ticket if cost is supposed to be populated on PUT responses; the SDK-side change in this PR is correct either way since "optional with default" matches reality.)

…e wrapper

Two issues blocking antd-kotlin example 02 from running:

1) DataPutPublicDto deserialization failed:
   MissingFieldException: Field cost is required for type with serial name
   com.autonomi.sdk.DataPutPublicDto, but it was missing

   The daemon currently returns address, chunks_stored, payment_mode_used
   for PUT /v1/data/public, with no cost field. Make cost default to empty,
   mirroring how the PHP REST client falls back to empty string. Same for
   the DataPutPrivateDto sibling.

2) antd-kotlin/gradlew and antd-kotlin/gradle/wrapper/gradle-wrapper.jar
   were not committed - only gradle-wrapper.properties was. With the
   wrapper script absent, the README example invocation failed immediately
   with "No such file or directory". Add the wrapper files (copied from
   antd-java which shipped them correctly, modulo a missing executable bit).

Closes #69
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-kotlin example 02 fails: DataPutPublicDto requires field 'cost' but daemon response omits it

1 participant