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.
Add pre-flight payment safety checks with SEP-29 memo detection #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Add pre-flight payment safety checks with SEP-29 memo detection #68
Changes from all commits
491c734File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Endpoint logic looks correct, but this handler and
initializePayment's new preflight block (Lines 401-410) are byte-for-byte duplicated logic.Both compute
feeSplitPreviewand callpreflightPaymentwith the identical shape. If the operationCount logic or preflight params ever need a fix (e.g. addingsendAssetsupport), it's easy to update one call site and forget the other, silently reintroducing the exact race this PR is trying to close.Consider extracting a shared helper, e.g.:
♻️ Suggested extraction
Then call
runPreflight(...)from bothgetPaymentPreflightandinitializePayment.🤖 Prompt for AI Agents
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
No Jest coverage found for the new
getPaymentPreflightendpoint.The only tests supplied (
test/preflightPayment.test.js) exercisestellarService.preflightPayment/isMemoRequireddirectly, not the controller/route. Given this endpoint drives frontend payment gating, an endpoint-level test (mockingresolvePaymentDestination/preflightPayment, asserting the 400s for invaliditemType, missing wallet, free item, and the 200 success shape) would close the gap.As per path instructions, "New or changed endpoints need Jest coverage (the runner uses --experimental-vm-modules)."
🤖 Prompt for AI Agents
Source: Path instructions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Preflight gate correctly blocks and aborts on failure — but it only runs for the non-path-payment branch.
isPathPayment(Line 373) transactions skippreflightPaymententirely and go straight tobuildPathPaymentTransaction. That means for path payments, none of the destination checks (DESTINATION_ACCOUNT_MISSING,DESTINATION_NO_TRUSTLINE,DESTINATION_MEMO_REQUIRED) — which are asset-agnostic and would apply regardless of the source asset — are validated before the wallet is asked to sign. Issue#59explicitly calls for pre-flight validation "before unsigned XDR creation and wallet signing," without carving out an exception for path payments.I understand
preflightPayment's source-side checks (USDC balance/reserve) can't apply as-is to path payments since the source asset may not be USDC — but the destination-side checks could still run. Worth either:preflightPaymentso destination-only checks can be invoked independently of source-asset assumptions, orRight now the fallback (submit-time result-code handling) does still catch this at signing/submission time, which limits the blast radius — but the wallet will still be asked to sign a doomed-to-fail transaction, which is exactly what this PR set out to prevent.
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.