-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededhigh prio
Description
We need to expose reserved vs ready balances without breaking the existing WalletApi.getBalances() public API. The current API returns a total balances, which hides reservations made by operations. We will add new breakdown APIs and deprecate the old ones while preserving behavior.
Scope / Plan:
- Types:
- Add
BalanceBreakdownandBalancesBreakdownByMintinpackages/core/types.ts. - Export new types from
packages/core/index.ts.
- Add
- Core services:
- Add
ProofService.getBalanceBreakdown(mintUrl)andProofService.getBalancesBreakdown()to computeready,reserved,total. - Add
ProofService.getTrustedBalancesBreakdown()for trusted mint filtering. - Change
getBalance()/getBalances()to return ready-only;
- Add
- Public API:
- Add
WalletApi.getBalancesBreakdown()andWalletApi.getTrustedBalancesBreakdown()(public). - Keep
WalletApi.getBalances()intact but have it return ready-only.
- Add
- Internal consumers:
- Update
PaymentRequestServiceto usegetTrustedBalancesBreakdown()and compare againstready. - Update React hook
useTrustedBalanceto consume breakdown for ready/reserved totals and have it return ready-only.
- Update
- Docs:
- Update
packages/core/README.mdand docs examples to showgetBalancesBreakdown().
- Update
- Tests:
- Add unit tests for breakdown calculation in
ProofService. - Update
PaymentRequestServicetests/mocks to return breakdowns. - Keep existing integration tests that rely on
getBalances()unless they should assert reserved/ready explicitly.
- Add unit tests for breakdown calculation in
Notes:
- Breakdown shape:
{ [mintUrl]: { ready: number; reserved: number; total: number } }withtotal = ready + reserved. - Reserved definition: proofs with
state === 'ready'andusedByOperationIdset. - Ready definition: proofs with
state === 'ready'and no reservation.
Acceptance criteria:
- No breaking changes to existing
getBalances()calls. - New breakdown methods available in
WalletApi. - PaymentRequest mint selection uses ready balances only.
- Docs reflect new API and deprecation notice.
- Tests cover ready/reserved/total computation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededhigh prio
Type
Projects
Status
In Progress