feat(antd-dart): gRPC external-signer prepare/finalize parity with REST - #148
Closed
Nic-dorman wants to merge 1 commit into
Closed
Conversation
Adds 7 new methods on `GrpcAntdClient` mirroring the existing REST `AntdClient` external-signer surface: * `prepareUpload(path, visibility:)` / `prepareUploadPublic(path)` * `prepareDataUpload(data, visibility:)` * `finalizeUpload(uploadId, txHashes)` (wave-batch) * `finalizeMerkleUpload(uploadId, winnerPoolHash, storeDataMap:)` * `prepareChunkUpload(data)` / `finalizeChunkUpload(uploadId, txHashes)` Consumers can swap a `AntdClient` for a `GrpcAntdClient` without code change in the external-signer flow. Proto regen: * `./tool/generate_proto.sh` now includes `antd/v1/upload.proto`. Per reference_dart_protoc_plugin_pin, protoc_plugin must be pinned to 22.3.0; the regen script header now states that explicitly. * New `upload.pb.dart` / `upload.pbgrpc.dart` / `upload.pbjson.dart`. `chunks.*` gain `PrepareChunk` / `FinalizeChunk`; `common.*` adds `PaymentEntry`. Client (`lib/src/grpc_client.dart`): * New `_uploadStub` field constructed alongside the existing service clients. * Helper `_mapPrepareUploadResponse` translates the proto into `PrepareUploadResult`, populating the merkle-only fields (`depth`, `poolCommitments`, `merklePaymentTimestamp`) only when `paymentType == "merkle"`. Tests (`test/grpc_client_external_signer_test.dart`): * New file. Spins up a real `grpc-dart` server bound to 127.0.0.1:0 with mock service implementations, then exercises the real `GrpcAntdClient` against it — covers the actual proto wire-shape mapping (in contrast to the existing `grpc_client_test.dart` which uses a hand-rolled fake to avoid the proto dependency). * `_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. * 12 new tests parallel to the antd-rust / antd-go / antd-py / antd-java / antd-kotlin / antd-csharp / antd-ruby suites. Gates on dev2: * `dart analyze lib/` — 1 pre-existing warning (`_doHead` unused); no new issues from this PR. * `dart test` — 63/63 passing (51 existing + 12 new). 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
Adds 7 new methods on
GrpcAntdClientmirroring the existing RESTAntdClientexternal-signer surface. Consumers can swap anAntdClientfor aGrpcAntdClientwithout code change in the prepare/finalize flow.Depends on #140 (antd-side
UploadService+ chunks prepare/finalize).Methods
prepareUpload(path, visibility:)prepareUploadPublic(path)visibility: 'public'prepareDataUpload(data, visibility:)finalizeUpload(uploadId, txHashes)finalizeMerkleUpload(uploadId, winnerPoolHash, storeDataMap:)prepareChunkUpload(data)finalizeChunkUpload(uploadId, txHashes)Proto regen
./tool/generate_proto.shnow includesantd/v1/upload.proto. Per the existingreference_dart_protoc_plugin_pinconvention,protoc_pluginmust be pinned to22.3.0; the regen script's header now states that explicitly.upload.pb.dart/upload.pbgrpc.dart/upload.pbjson.dart.chunks.*gainPrepareChunk/FinalizeChunk;common.*addsPaymentEntry.Implementation notes
_uploadStubfield constructed alongside the existing service clients._mapPrepareUploadResponsetranslates the proto intoPrepareUploadResult, populating the merkle-only fields (depth,poolCommitments,merklePaymentTimestamp) only whenpaymentType == "merkle".Tests
New
test/grpc_client_external_signer_test.dart:grpc-dartserver bound to127.0.0.1:0with mock service implementations, then exercises the realGrpcAntdClientagainst it. This actually tests the proto wire-shape mapping, in contrast to the existinggrpc_client_test.dartwhich uses a hand-rolled fake that doesn't depend on the generated stubs._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
dart analyze lib/— 1 pre-existing warning (_doHeadunused); no new issues from this PR.dart test— 63/63 passing (51 existing + 12 new).