Repository navigation
feat(hooks): add useSettlementBreakdown hook for post-delivery fund distribution - #899
Merged
johdanike merged 2 commits intoOct 5, 2026
Conversation
|
@BigManly4 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Conflicts!! |
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.
Closes #782
Summary
Adds
useSettlementBreakdown, which fetches the finalized settlement for an escrow fromGET /api/escrow/{id}/settlementand polls until the release transaction reaches a terminal state.Changes
services/escrowSettlementService.ts: calls the settlement endpoint through the sharedapiClient, maps axios failures to aSettlementServiceError(backend message, 404 message, or generic fallback) and exposesisTerminalStatus.hooks/useSettlementBreakdown.ts: TanStack Query hook. It returnssettlement,formattedamounts,taxBreakdown,explorerUrl,isLoading,isFetching,isFinalizing,isTerminal,errorandrefetch.pendingorfinalizing, and stops onconfirmedorfailed.types/settlementBreakdown.ts:SettlementBreakdownwith driver payout, platform fee and rate, tax withholdings, held amount and reason, remaining balance, transaction hash and ledger, and delivery summary.lib/settlementFormatters.ts: asset amount formatting (Stellar 7-decimal precision), percentage formatting and the stellar.expert transaction URL builder.Layering: Component ->
useSettlementBreakdown->escrowSettlementService-> backend. Test data lives inhooks/__tests__/fixtures/settlementApiResponses.ts. Nothing is mocked inline in the source.Tests
hooks/__tests__/useSettlementBreakdown.test.tsx(11): structured data, formatted values, tax breakdown, explorer link, polling until confirmed or failed, no retry on 4xx, retry on 5xx, recovery through refetch, disabled or missing id.services/__tests__/escrowSettlementService.test.ts(10) andlib/__tests__/settlementFormatters.test.ts(4).Note: CI on
mainis already failing at the Lint step because of existing errors (for example the parse error inapp/error.tsx). The files in this PR pass eslint andtsc --noEmitwith no errors.Screenshots