feat(antd-kotlin): gRPC WalletService parity with REST#161
Closed
Nic-dorman wants to merge 2 commits into
Closed
Conversation
Adds WalletService over gRPC mirroring the existing REST surface 1:1: * GetAddress(GetWalletAddressRequest) → GetWalletAddressResponse * GetBalance(GetWalletBalanceRequest) → GetWalletBalanceResponse * Approve(WalletApproveRequest) → WalletApproveResponse Pure-gRPC consumers (e.g. Indelible's wallet-less external-signer flow that still wants /diagnostics + balance) no longer need to keep a REST client alongside just for wallet ops, and the dual-transport SDKs can stop returning UnsupportedOperationException on their *GrpcClient. Implementation notes: * New proto/antd/v1/wallet.proto added to build.rs's compile list and the grpc/mod.rs serve registration. * WalletServiceImpl in grpc/service.rs reuses antd/src/rest/wallet.rs's handler bodies — Client::wallet() access is transport-agnostic; the approve path spawns a tokio task to match REST. * Missing wallet returns Status::failed_precondition (the gRPC analog of REST's 503 service-unavailable for this case) with the same "wallet not configured — set AUTONOMI_WALLET_KEY" message. Out of scope: * SDK fan-out — covered in 11 follow-up PRs (rust/go/py/java/kotlin/ csharp/ruby/dart/swift/cpp/elixir). * Wallet configuration over gRPC — V2-335 (post-v1.0). * External-signer prepare/finalize — shipped separately via the UploadService + ChunkService PrepareChunk/FinalizeChunk RPCs from the V2-284 daemon PR. Gates on dev2: * cargo check / clippy -- -D warnings — clean on antd + antd-rust. * cargo test — 37/37 passing. * cargo fmt --check — clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds 3 new methods on AntdGrpcClient mirroring REST AntdRestClient: * suspend fun walletAddress(): WalletAddress * suspend fun walletBalance(): WalletBalance * suspend fun walletApprove(): Boolean Implementation notes: * New walletStub (WalletServiceGrpcKt.WalletServiceCoroutineStub) on AntdGrpcClient, constructed alongside the existing health/data/chunk/ file stubs. * lib/src/main/proto/antd/v1/wallet.proto copied from antd/proto/ (kotlin keeps its own copy under lib/src/main/proto/). * Added internal constructor(channel: ManagedChannel) on AntdGrpcClient so tests can inject an InProcessChannel without spinning a TCP socket. * A missing daemon wallet emits gRPC FailedPrecondition; the existing ExceptionMapping.fromGrpcStatus surfaces it as PaymentException (established FailedPrecondition->Payment convention across all SDKs). * grpc-kotlin coroutine stubs throw io.grpc.StatusException (checked, suspend-friendly) NOT StatusRuntimeException — the existing code only catches StatusRuntimeException and would have missed errors here. Wallet methods catch both types and route them through the same mapping. Pre-existing code paths have the same latent gap but are not in V2-286 scope to refactor. Tests: * GrpcWalletTest.kt (new) — InProcessServerBuilder + InProcessChannelBuilder with a MockWallet service. 4 tests: address, balance, approve, plus the unconfigured-wallet PaymentException path (separate in-process server). * New testImplementation dep on io.grpc:grpc-inprocess:1.65.1 for the InProcess transport (already transitive via grpc-netty-shaded for the runtime, but needs an explicit declaration for test sources). Gates on dev2: * ./gradlew :lib:compileKotlin — clean. * ./gradlew :lib:test — all suites passing (RestClientTest 29, SmokeTests 7, GrpcWalletTest 4). Depends on the antd-side daemon PR landing first. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b02ff94 to
1cfddfb
Compare
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 3 new suspend methods on
AntdGrpcClientmirroring RESTAntdRestClient:suspend fun walletAddress(): WalletAddresssuspend fun walletBalance(): WalletBalancesuspend fun walletApprove(): BooleanDepends on #154.
Implementation notes
walletStub(WalletServiceGrpcKt.WalletServiceCoroutineStub) onAntdGrpcClient, constructed alongside the existing health/data/chunk/file stubs.lib/src/main/proto/antd/v1/wallet.protocopied fromantd/proto/(kotlin keeps its own copy underlib/src/main/proto/).internal constructor(channel: ManagedChannel)onAntdGrpcClientso tests can inject anInProcessChannelwithout spinning a TCP socket.FailedPrecondition; the existingExceptionMapping.fromGrpcStatussurfaces it asPaymentException(establishedFailedPrecondition→Paymentconvention across all SDKs).io.grpc.StatusException(checked, suspend-friendly) NOTStatusRuntimeException— the existing code only catchesStatusRuntimeExceptionand would have missed errors here. Wallet methods catch both types and route through the same mapping. Pre-existing code paths have the same latent gap but are not in V2-286 scope to refactor.Tests
GrpcWalletTest.kt(new) —InProcessServerBuilder+InProcessChannelBuilderwith aMockWalletservice. 4 tests: address, balance, approve, plus the unconfigured-walletPaymentExceptionpath (separate in-process server).testImplementationdep onio.grpc:grpc-inprocess:1.65.1.Gates passed on dev2
./gradlew :lib:compileKotlin— clean./gradlew :lib:test— all suites passing (RestClientTest 29, SmokeTests 7, GrpcWalletTest 4)