feat(antd-kotlin): gRPC external-signer prepare/finalize parity with REST - #145
Closed
Nic-dorman wants to merge 1 commit into
Closed
Conversation
…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>
3 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
Replaces 7
UnsupportedOperationExceptionstubs onAntdGrpcClientwith real implementations. Consumers can now swap anAntdRestClientfor anAntdGrpcClientwithout code change in the external-signer flow — both classes already satisfy theIAntdClientinterface contract.Depends on #140 (antd-side
UploadService+ chunks prepare/finalize).Methods replaced
prepareUpload(path, visibility)prepareUploadPublic(path)visibility="public"prepareDataUpload(data, visibility)finalizeUpload(uploadId, txHashes)finalizeMerkleUpload(uploadId, winnerPoolHash)prepareChunkUpload(data)finalizeChunkUpload(uploadId, txHashes)All are
suspend funper the existing interface. Wallet stubs remain — wallet-over-gRPC is a separate ticket.Implementation notes
UploadServiceGrpcKt.UploadServiceCoroutineStub uploadStubalongside the existing service stubs.ManagedChannel; the publicString-target constructor delegates to it.mapPrepareUploadResponsehelper buildsPrepareUploadResult, populating merkle-only fields (depth,poolCommitments,merklePaymentTimestamp) only whenpaymentType == "merkle".Proto/build
Upload.*,Common.PaymentEntry, andChunks.PrepareChunk*/Chunks.FinalizeChunk*Kotlin DSL builders + coroutine stubs from../../antd/proto/antd/v1/.lib/build.gradle.ktsadds twotestImplementationdeps —io.grpc:grpc-inprocessandio.grpc:grpc-testing— to support the new in-process server tests.Tests
New
lib/src/test/kotlin/com/autonomi/sdk/GrpcClientTest.kt:InProcessServerBuilder/InProcessChannelBuilder.MockChunkServicecoversprepareChunk(new + already-stored short-circuit) andfinalizeChunk(echoesupload_id).MockUploadServicecoversprepareFileUpload/prepareDataUpload/finalizeUploadwith visibility round-trip viaupload_idencoding and merkle vs wave-batch branches.Gates passed on dev2
./gradlew :lib:compileKotlinclean./gradlew :lib:test— 47/47 (29 REST + 7 smoke + 11 new gRPC)./gradlew :lib:build— full project passes