feat(balance): move to the batched GetBalances RPC - #764
Merged
Merged
Conversation
ocp-protobuf-api removed GetBalance in favour of GetBalances, which takes a list of owners and returns an owner -> mint -> value map instead of a flat total. BalanceService.getBalance stays single-owner-shaped for now (nothing in the app needs the batched or mint-filtered form yet) and reads its one owner back out of the map. The response's NOT_FOUND result case is gone; an owner absent from the map now means zero balance rather than a distinct error, so ErrorGetBalance drops .notFound and getBalance treats a missing entry as a zero TokenAmount.
bmc08gt
force-pushed
the
feat/ocp-get-balances
branch
from
September 15, 2026 17:24
d9bbd58 to
78b744c
Compare
bmc08gt
added a commit
that referenced
this pull request
Sep 15, 2026
… pins (#778) #764 bumped ocp to 0.4.0 and #769 bumped flipcash2 to 0.6.0 without regenerating the workspace's Package.resolved, so it still recorded 0.3.0 and 0.5.0. Xcode Cloud archives with automatic dependency resolution disabled, which turns that mismatch into a hard error rather than a silent re-resolve: "Deploy Flipcash" build #542 failed with "an out-of-date resolved file was detected". The vector gate builds the SPM schemes with resolution enabled and never opens Code.xcodeproj, so it stayed green. Regenerated with xcodebuild -resolvePackageDependencies. Only the two contract entries and originHash move.
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.
Blocked on code-payments/ocp-client-protocol#6. Draft until
0.4.0is published, because theexact:requirement inFlipcashAPI/Package.swifthas no tag to resolve until then. CI never sees the local override, sinceFLIPCASH_PROTO_LOCALis a shell variable.Why
ocp-protobuf-apiremovedGetBalancein favour ofGetBalances(#66). TheBalanceservice had exactly one RPC, so there is no way to take the new package without moving the call site.What changed
One file,
FlipcashCore/Sources/FlipcashCore/Clients/Payments API/Services/BalanceService.swift:Ocp_Balance_V1_GetBalanceRequest.with { $0.owner = ... }→Ocp_Balance_V1_GetBalancesRequest.with { $0.owners = [owner.solanaAccountID] }service.getBalance(...)→service.getBalances(...), stilloptions: .unaryDefaultresponse.coreMintValue→response.balancesByOwner[owner.base58]?.coreMintValue ?? 0, since the total now lives one level down, keyed by owner addressErrorGetBalance:.notFoundremoved, and thereportingLevelswitch loses that armClient+Balance.swiftneeded no change. It does not touch the removed types, and its "no signature required" doc comment still holds —GetBalancesRequestcarries no auth field either.The rawValue mapping
ErrorGetBalance(rawValue: response.result.rawValue)maps positionally onto the protoResultenum, which is the case worth checking whenever an enum changes. The old enum wasOK=0, DENIED=1, NOT_FOUND=2; the new one isOK=0, DENIED=1. The surviving cases keep their numbers, so this is a clean case removal with no silent rawValue drift.An owner with no balances is now absent from
balances_by_ownerrather than reported through a result code, so a missing entry maps to a zeroTokenAmountand counts as success, not an error.