fix(hooks): normalizePayment handles Soroban and account_merge payments - #266
Merged
RaceeyXo merged 6 commits intoSep 2, 2026
Conversation
|
@Nathanpvd 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! 🚀 |
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.
Overview
This PR fixes
normalizePaymentso it stops fabricating blank0 XLMrows for Soroban transfers and account merges.invoke_host_functionrecords are now parsed from Horizon'sasset_balance_changes, producing one normalized row per asset balance change that involves the queried address.account_mergenow uses the real merged amount from the operation effects instead of hardcoding"0". The silent fall-through is replaced with an explicit throw, so no unrecognized payment record can ever be returned as an empty zero-amount row again.Related Issue
Closes #[issue number]
Changes
🔧 Payment Normalization Fix
[MODIFY]
packages/core/src/hooks/usePayments.tsinvoke_host_functionbranch that extracts entries fromasset_balance_changes; each change involving the queried address is emitted as aNormalizedPaymentrow with realfrom,to,amount, andasset.account_mergeso the hook fetches the operation's effects and passes theaccount_credited/account_debitedamount intonormalizePayment, replacing the hardcoded"0".ifchain with anelsethat throws on any unsupportedPaymentRecordtype, making the old fabricated blank row unreachable.[MODIFY]
packages/core/src/hooks/usePayments.test.tsxPaymentRecordunion.from/to, non-zeroamount, and the correctasset; thataccount_mergereturns the real merged amount; and that unsupported types throw instead of returning zeroed rows.[ADD]
packages/core/src/__tests__/fixtures/horizon-payments.ts/paymentsresponses forpayment,create_account,account_merge,path_payment_strict_receive,path_payment_strict_send, andinvoke_host_function.account_mergeeffects fixture so the test verifies the real merged amount.[MODIFY]
CHANGELOG.mdVerification Results
invoke_host_functionrecords produce realfrom/to/amount/assetasset_balance_changesentry involving the queried addressaccount_mergereports the actual merged amount, or an explicitly documentednull"0"elsethrows on unsupported typesPaymentRecordtypes now throw instead of returning initialized rowsPaymentRecordunionhorizon-payments.tsfixturessrc/__tests__/fixtures//paymentsresponsesdocs/reference/types.mdandCHANGELOG.mdNormalizedPaymenttype changes needed;CHANGELOG.mddocuments the fixpnpm test,pnpm lint,pnpm typecheck, andpnpm buildall pass locallyCloses #[issue number]Closes #226