Skip to content

feat(antd-kotlin): gRPC external-signer prepare/finalize parity with REST - #145

Closed
Nic-dorman wants to merge 1 commit into
nic/v2-284-grpc-external-signer-prepare-finalizefrom
nic/v2-284-antd-kotlin-grpc-external-signer
Closed

feat(antd-kotlin): gRPC external-signer prepare/finalize parity with REST#145
Nic-dorman wants to merge 1 commit into
nic/v2-284-grpc-external-signer-prepare-finalizefrom
nic/v2-284-antd-kotlin-grpc-external-signer

Conversation

@Nic-dorman

Copy link
Copy Markdown
Collaborator

Summary

Replaces 7 UnsupportedOperationException stubs on AntdGrpcClient with real implementations. Consumers can now swap an AntdRestClient for an AntdGrpcClient without code change in the external-signer flow — both classes already satisfy the IAntdClient interface contract.

Depends on #140 (antd-side UploadService + chunks prepare/finalize).

Methods replaced

method purpose
prepareUpload(path, visibility) external-signer prepare for a file
prepareUploadPublic(path) convenience wrapper for visibility="public"
prepareDataUpload(data, visibility) external-signer prepare for in-memory bytes
finalizeUpload(uploadId, txHashes) finalize wave-batch upload
finalizeMerkleUpload(uploadId, winnerPoolHash) finalize merkle-batch upload
prepareChunkUpload(data) single-chunk external-signer prepare
finalizeChunkUpload(uploadId, txHashes) single-chunk finalize, returns address

All are suspend fun per the existing interface. Wallet stubs remain — wallet-over-gRPC is a separate ticket.

Implementation notes

  • New UploadServiceGrpcKt.UploadServiceCoroutineStub uploadStub alongside the existing service stubs.
  • Introduces an internal channel-injecting constructor so tests can pass an in-process ManagedChannel; the public String-target constructor delegates to it.
  • mapPrepareUploadResponse helper builds PrepareUploadResult, populating merkle-only fields (depth, poolCommitments, merklePaymentTimestamp) only when paymentType == "merkle".

Proto/build

  • Gradle's protobuf plugin auto-generates the new Upload.*, Common.PaymentEntry, and Chunks.PrepareChunk* / Chunks.FinalizeChunk* Kotlin DSL builders + coroutine stubs from ../../antd/proto/antd/v1/.
  • lib/build.gradle.kts adds two testImplementation deps — io.grpc:grpc-inprocess and io.grpc:grpc-testing — to support the new in-process server tests.

Tests

New lib/src/test/kotlin/com/autonomi/sdk/GrpcClientTest.kt:

  • In-process gRPC server using InProcessServerBuilder / InProcessChannelBuilder.
  • MockChunkService covers prepareChunk (new + already-stored short-circuit) and finalizeChunk (echoes upload_id).
  • MockUploadService covers prepareFileUpload / prepareDataUpload / finalizeUpload with visibility round-trip via upload_id encoding and merkle vs wave-batch branches.
  • 11 new tests parallel to the antd-rust / antd-go / antd-py / antd-java suites.

Gates passed on dev2

  • ./gradlew :lib:compileKotlin clean
  • ./gradlew :lib:test — 47/47 (29 REST + 7 smoke + 11 new gRPC)
  • ./gradlew :lib:build — full project passes

…REST

Replaces 7 `UnsupportedOperationException` stubs on `AntdGrpcClient` with
real implementations:

* `prepareUpload(path, visibility)` / `prepareUploadPublic(path)`
* `prepareDataUpload(data, visibility)`
* `finalizeUpload(uploadId, txHashes)` (wave-batch)
* `finalizeMerkleUpload(uploadId, winnerPoolHash)`
* `prepareChunkUpload(data)` / `finalizeChunkUpload(uploadId, txHashes)`

All methods are `suspend fun` matching the `IAntdClient` interface
contract, and a consumer can now swap a `AntdRestClient` for an
`AntdGrpcClient` without code change in the external-signer flow.

Wallet stubs remain — wallet-over-gRPC is a separate ticket.

Client changes (`AntdGrpcClient.kt`):

* Adds `UploadServiceGrpcKt.UploadServiceCoroutineStub uploadStub` alongside
  the existing service stubs.
* Introduces an internal channel-injecting constructor so tests can pass
  an in-process `ManagedChannel`; the public `String`-target constructor
  delegates to it.
* `mapPrepareUploadResponse` helper builds `PrepareUploadResult`,
  populating merkle-only fields (`depth`, `poolCommitments`,
  `merklePaymentTimestamp`) only when `paymentType == "merkle"`.

Proto/build:

* Gradle's protobuf plugin auto-generates `Upload.*`,
  `Common.PaymentEntry`, and the new `Chunks.PrepareChunk*` /
  `Chunks.FinalizeChunk*` messages from `../../antd/proto/antd/v1/`.
* `lib/build.gradle.kts` adds two `testImplementation` deps —
  `io.grpc:grpc-inprocess` and `io.grpc:grpc-testing` — to support the
  new in-process server tests.

Tests (`lib/src/test/kotlin/com/autonomi/sdk/GrpcClientTest.kt`):

* In-process gRPC server using `InProcessServerBuilder` /
  `InProcessChannelBuilder`.
* `MockChunkService` covers `prepareChunk` (new + already-stored
  short-circuit) and `finalizeChunk` (echoes `upload_id`).
* `MockUploadService` covers `prepareFileUpload` / `prepareDataUpload`
  / `finalizeUpload` with visibility round-trip via `upload_id`
  encoding and merkle vs wave-batch branches.
* 11 new tests parallel to the antd-rust / antd-go / antd-py /
  antd-java suites.

Gates on dev2:

* `./gradlew :lib:compileKotlin` clean
* `./gradlew :lib:test` — 47/47 (29 REST + 7 smoke + 11 new gRPC)
* `./gradlew :lib:build` — full project passes

Depends on the antd-side daemon PR landing first.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Nic-dorman
Nic-dorman deleted the branch nic/v2-284-grpc-external-signer-prepare-finalize May 28, 2026 15:47
@Nic-dorman Nic-dorman closed this May 28, 2026
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