federated addr. memo type inference#2744
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for SEP-0002 federation memo handling in the Send flow by persisting the federation-provided memo + memo_type, validating them, and using the correct Stellar memo type when building classic transactions.
Changes:
- Added
validateFederationMemo/buildMemoFromFederationhelper (SEP-0002 constraints) with unit tests. - Threaded
memoTypethrough Redux + Send flow and used it when building the classic transaction XDR for simulation. - Added Playwright stubs + e2e coverage for federation responses that include memo fields, plus a new i18n string for invalid federation
account_id.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| extension/src/popup/locales/pt/translation.json | Adds new federation-validation error string (pt locale). |
| extension/src/popup/locales/en/translation.json | Adds new federation-validation error string (en locale). |
| extension/src/popup/helpers/federationMemo.ts | New SEP-0002 memo validation + memo builder helper. |
| extension/src/popup/helpers/tests/federationMemo.test.ts | Unit tests covering memo validation + memo construction. |
| extension/src/popup/ducks/transactionSubmission.ts | Persists memoType in transaction submission state and adds reducer/action. |
| extension/src/popup/components/send/SendTo/index.tsx | Saves federation memo + memo type into Redux during destination resolution. |
| extension/src/popup/components/send/SendTo/hooks/useSendToData.tsx | Parses/validates federation response (account_id, memo, memo_type). |
| extension/src/popup/components/send/SendAmount/hooks/useSimulateTxData.tsx | Uses memoType when building the memo for classic tx simulation. |
| extension/e2e-tests/sendPayment.test.ts | Adds e2e tests for federation memos and invalid federation account_id. |
| extension/e2e-tests/helpers/stubs.ts | Adds stubFederationWithMemo to override the default federation route. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| const MAX_MEMO_BYTES = 28; | ||
| const MAX_UINT64 = BigInt("18446744073709551615"); | ||
| const HEX_32_BYTES_RE = /^[0-9a-fA-F]{64}$/; |
There was a problem hiding this comment.
these var were set in federationMemo.ts. Let's reuse
Code reviewFound 2 issues:
freighter/extension/src/popup/components/send/SendTo/index.tsx Lines 125 to 136 in 647a0f8
freighter/extension/src/popup/components/send/SendAmount/index.tsx Lines 759 to 772 in 647a0f8 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
The Claude review had 2 good finds here: For 1, it wasn't clear to me if Similar concern on issue 2 |
….com/stellar/freighter into fix/harden-federated-memo-validation
|
@piyalbasu yep. it's a good catch. I updated it to save memo and type together, and clearing memo when switching from federated address + added the e2e tests for it |
closes #2717
This PR adds safer support for federation-provided memos in Send
It now recognizes the main SEP-0002 memo formats (text, id, hash) instead of treating everything the same way.
It improves validation/error handling when federation servers return invalid data (including invalid destination addresses).
It also fixes send-flow behavior so memo data is kept consistent when users change recipient input.
+ it adds test coverage for the new federation memo scenarios, including prefill, invalid responses, and recipient switching.
federated-switch-address-clears-memo.webm
federated-hash-memo.webm
federated-id-memo.webm
federated-text-memo.webm
federated-invalid-account-id-memo.webm