Skip to content

feat(antd-elixir): gRPC WalletService parity with REST#168

Closed
Nic-dorman wants to merge 2 commits into
nic/v2-286-antd-grpc-walletservicefrom
nic/v2-286-antd-elixir-grpc-walletservice
Closed

feat(antd-elixir): gRPC WalletService parity with REST#168
Nic-dorman wants to merge 2 commits into
nic/v2-286-antd-grpc-walletservicefrom
nic/v2-286-antd-elixir-grpc-walletservice

Conversation

@Nic-dorman

Copy link
Copy Markdown
Collaborator

Summary

Adds 3 new functions on Antd.GrpcClient mirroring REST Antd.Client:

  • wallet_address(client) -> {:ok, WalletAddress} | {:error, Exception}
  • wallet_balance(client) -> {:ok, WalletBalance} | {:error, Exception}
  • wallet_approve(client) -> {:ok, boolean} | {:error, Exception}

Bang variants (!/N) throughout.

Depends on #154.

Implementation notes

  • New lib/antd/v1/wallet.pb.ex generated via protoc-gen-elixir 0.16.0.
  • Request types constructed via %Antd.V1.X{} struct literal syntax (.new/1 was dropped in protobuf 0.16 per the gotcha noted by V2-284 elixir PR feat(antd-elixir): gRPC external-signer prepare/finalize parity with REST #153).
  • A missing daemon wallet emits gRPC FailedPrecondition; the existing translate_error/1 surfaces it as PaymentError.

Tests

test/antd/grpc_wallet_test.exs (new):

  • Spins up a real grpc-elixir server on 127.0.0.1:0 via GRPC.Server.start_endpoint with two endpoints: HappyEndpoint (MockWalletServer) and UnconfiguredEndpoint (raises FailedPrecondition).
  • setup_all starts GRPC.Client.Supervisor (grpc-elixir 0.11 doesn't auto-start it).
  • 4 tests: address, balance, approve, plus the unconfigured-wallet PaymentError path.

Gates passed on dev2

  • mix compile — clean
  • mix test — 78/78 passing (74 existing + 4 new wallet)

Nic-dorman and others added 2 commits May 28, 2026 14:24
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 functions on Antd.GrpcClient mirroring REST Antd.Client:

* wallet_address(client) -> {:ok, WalletAddress} | {:error, Exception}
* wallet_balance(client) -> {:ok, WalletBalance} | {:error, Exception}
* wallet_approve(client) -> {:ok, boolean} | {:error, Exception}

Bang variants (!/N) included throughout.

Implementation notes:

* New lib/antd/v1/wallet.pb.ex generated via protoc-gen-elixir 0.16.0
  (matches the existing files regen'd in V2-284 PR #153).
* Request types constructed via %Antd.V1.X{} struct literal syntax
  (.new/1 was dropped in protobuf 0.16 per the recipe gotcha noted by
  the V2-284 elixir PR).
* A missing daemon wallet emits gRPC FailedPrecondition; the existing
  translate_error/1 surfaces it as PaymentError (established
  FailedPrecondition->Payment convention across all SDKs).

Tests (test/antd/grpc_wallet_test.exs, new):

* Spins up a real grpc-elixir server on 127.0.0.1:0 via
  GRPC.Server.start_endpoint with two endpoints: HappyEndpoint
  (MockWalletServer) and UnconfiguredEndpoint (raises
  FailedPrecondition).
* setup_all starts GRPC.Client.Supervisor (grpc-elixir 0.11 doesn't
  auto-start it).
* 4 tests: address, balance, approve, plus the unconfigured-wallet
  PaymentError path.

Gates on dev2:

* mix compile — clean.
* mix test — 78/78 passing (74 existing + 4 new wallet).

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 force-pushed the nic/v2-286-antd-grpc-walletservice branch from b02ff94 to 1cfddfb Compare May 28, 2026 15:51
@Nic-dorman Nic-dorman deleted the branch nic/v2-286-antd-grpc-walletservice May 28, 2026 15:53
@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