feat(antd-csharp): gRPC external-signer prepare/finalize parity with REST - #146
Closed
Nic-dorman wants to merge 1 commit into
Closed
Conversation
…REST
Replaces 7 `NotSupportedException` stubs on `AntdGrpcClient` with real
implementations:
* `PrepareUploadAsync(path, visibility)` / `PrepareUploadPublicAsync(path)`
* `PrepareDataUploadAsync(data, visibility)`
* `FinalizeUploadAsync(uploadId, txHashes)` (wave-batch)
* `FinalizeMerkleUploadAsync(uploadId, winnerPoolHash)`
* `PrepareChunkUploadAsync(data)` / `FinalizeChunkUploadAsync(uploadId, txHashes)`
All return `Task<T>` and a consumer can swap an `AntdRestClient` for an
`AntdGrpcClient` without code change in the external-signer flow.
Wallet stubs remain — wallet-over-gRPC is a separate ticket.
Client (`AntdGrpcClient.cs`):
* New `UploadService.UploadServiceClient _upload` field constructed
alongside the existing service clients.
* Introduces an internal constructor that accepts pre-built service
clients so tests can pass mock subclasses; the public string-target
constructor delegates via `GrpcChannel.ForAddress`.
* `MapPrepareResponse` helper builds `PrepareUploadResult`, populating
merkle-only fields (`Depth`, `PoolCommitments`,
`MerklePaymentTimestamp`) only when `PaymentType == "merkle"`.
Project plumbing:
* `Antd.Sdk.csproj` picks up `upload.proto` and adds
`InternalsVisibleTo("Antd.Sdk.Tests")` so the internal constructor is
visible to the test project.
* `Antd.Sdk.Tests.csproj` adds the `Grpc.Core.Testing` NuGet package
for `TestCalls.AsyncUnaryCall` — the canonical helper for wrapping a
pre-canned `Task<TResponse>` in the `AsyncUnaryCall<TResponse>`
return type the generated `*Async` methods produce.
Tests (`Antd.Sdk.Tests/GrpcClientTests.cs`):
* New file. `MockChunkServiceClient` and `MockUploadServiceClient`
subclass the generated service clients and override the relevant
virtual `*Async` methods; the other services use a stub `CallInvoker`
that throws if exercised.
* 11 xunit cases parallel to the antd-rust / antd-go / antd-py /
antd-java / antd-kotlin suites: visibility forwarded/omitted, public
convenience wrapper, wave-batch vs merkle, `data_map_address`
presence on public, merkle `FinalizeMerkleUpload`, chunk
already-stored short-circuit, chunk finalize body forwarding.
Gates on dev2:
* `dotnet build Antd.Sdk/` clean
* `dotnet test Antd.Sdk.Tests/` — 43/43 (32 existing REST + 11 new gRPC)
Depends on the antd-side daemon PR landing first.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 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
NotSupportedExceptionstubs onAntdGrpcClientwith real implementations. Consumers can now swap anAntdRestClientfor anAntdGrpcClientwithout code change in the external-signer flow.Depends on #140 (antd-side
UploadService+ chunks prepare/finalize).Methods replaced
PrepareUploadAsync(path, visibility)PrepareUploadPublicAsync(path)visibility="public"PrepareDataUploadAsync(data, visibility)FinalizeUploadAsync(uploadId, txHashes)FinalizeMerkleUploadAsync(uploadId, winnerPoolHash)PrepareChunkUploadAsync(data)FinalizeChunkUploadAsync(uploadId, txHashes)Wallet stubs remain — wallet-over-gRPC is a separate ticket.
Implementation notes
UploadService.UploadServiceClient _uploadfield constructed alongside the existing service clients.GrpcChannel.ForAddress.MapPrepareResponsehelper buildsPrepareUploadResult, populating merkle-only fields (Depth,PoolCommitments,MerklePaymentTimestamp) only whenPaymentType == "merkle".Project plumbing
Antd.Sdk.csprojpicks upupload.protoand addsInternalsVisibleTo("Antd.Sdk.Tests")so the internal test constructor is visible to the test project.Antd.Sdk.Tests.csprojadds theGrpc.Core.TestingNuGet package — providesTestCalls.AsyncUnaryCall<TResponse>(...), the canonical helper for wrapping a pre-cannedTask<TResponse>in theAsyncUnaryCall<TResponse>return type the generated*Asyncmethods produce.Tests
New
Antd.Sdk.Tests/GrpcClientTests.cs:MockChunkServiceClientandMockUploadServiceClientsubclass the generated service clients and override the relevant virtual*Asyncmethods.CallInvokerthat throws if exercised — keeps the constructor signature happy without spinning a real server.DataMapAddresspresence on public, merkle finalize, chunk already-stored short-circuit, chunk finalize body forwarding.Gates passed on dev2
dotnet build Antd.Sdk/Antd.Sdk.csprojcleandotnet test Antd.Sdk.Tests/Antd.Sdk.Tests.csproj— 43/43 (32 existing REST + 11 new gRPC)