feat(opencode): scaffold Balance service for GetBalance - #1334
Merged
Conversation
Add the app-side layering (Api, Service, Repository, Controller) for the new Balance.GetBalance RPC now published in com.flipcash:ocp-client-protocol. GetBalanceRequest carries no auth/signature field, unlike every other OCP endpoint, so BalanceApi does not sign the request and BalanceController takes a bare PublicKey rather than an AccountCluster. No feature or ViewModel consumes this yet.
Picks up the Balance service added upstream in ea6418c5.
…type The `Balance` data class held one field, a quark count, and the doc comment on it argued the value could not be a `Fiat` because the response carries no currency code. That reasoning does not hold: `core_mint_value` is always USDF, and `Fiat.tokenBalance` already collapses to `Fiat(quarks, CurrencyCode.USD)` on the USDF branch. USDF is 6 decimals and `Fiat.MULTIPLIER` is 1_000_000, so the quark count transfers without conversion. Drop the wrapper and return `Fiat` through the service, repository, and controller. Callers get formatting and the arithmetic operators for free instead of unwrapping a Long and constructing the same `Fiat` themselves.
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.
Scaffolds the OpenCode
Balanceservice added upstream inocp-protobuf-api@ea6418c5, and bumps theocp-client-protocolpin to0.2.0to pick it up.What the contract adds
One unary RPC,
ocp.balance.v1.Balance/GetBalance. The request takes an owner account; the response carries a result enum (OK/DENIED/NOT_FOUND) andcore_mint_value, auint64in quarks. Nothing pre-existing changed.What this adds
The usual chain in
:services:opencode, down to the controller:BalanceApi→BalanceService→GetBalanceError→BalanceRepository/InternalBalanceRepository→BalanceController, plus the Hilt binding.Nothing consumes it yet. No feature or ViewModel is wired up, because there is no balance surface asking for this today.
Two calls worth review:
BalanceApi.getBalancedoes not sign the request.GetBalanceRequesthas no auth or signature field, unlike every other OpenCode endpoint here, so the Api only runsrequest.validate().orThrow(). That asymmetry is in the contract, not an oversight in this scaffold.BalanceController.getBalancetakes a barePublicKey, not theAccountClusterits sibling controllers take. The RPC resolves any owner's balance rather than the caller's own, so there is no signing authority to thread through. If parity with the neighbours matters more than the narrower type, this is the place to say so.core_mint_valueis typed asLongon the domain model, following theAccountInfo.balance: Longprecedent —Fiatneeds aCurrencyCodethe response does not carry. iOS wraps the same field asTokenAmount(quarks:mint:.usdf). The mint is not on the wire in either case, sincecore_mint_valueis core-mint quarks by definition and the contract never carries a core mint address, so this is only a difference in whether the domain model spells that constant out.Blocked on
0.2.0does not exist yet. CI cannot resolve the pin until code-payments/ocp-client-protocol#4 merges and is published, so this stays a draft until then.