-
Notifications
You must be signed in to change notification settings - Fork 86
feat(routing): add SEP-0029 memo requirement checks #314
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
Merged
codeZe-us
merged 4 commits into
Boxkit-Labs:main
from
MaxiTech444:fix/311-sep0029-memo-requirement
Aug 29, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5c02bd1
feat(routing): add SEP-0029 memo requirement checks
MaxiTech444 28f5a15
fix(spec): allow invalid strkey warnings
MaxiTech444 4d43d6e
Revert "fix(spec): allow invalid strkey warnings"
MaxiTech444 ffff3b5
fix(spec): allow invalid strkey warnings
MaxiTech444 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import type { MemoRequirementFetcher, RoutingInput, RoutingResult } from "./types"; | ||
| import { extractRouting } from "./extract"; | ||
|
|
||
| const DEFAULT_HORIZON_URL = "https://horizon.stellar.org"; | ||
|
|
||
| export type MemoRequirement = { | ||
| required: boolean; | ||
| }; | ||
|
|
||
| function decodeDataValue(value: unknown): boolean { | ||
| if (value === "1" || value === 1 || value === true) return true; | ||
| if (typeof value !== "string") return false; | ||
| try { | ||
| return atob(value) === "1"; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| /** Fetches the SEP-0029 memo requirement from a Horizon account response. */ | ||
| export async function fetchMemoRequirement( | ||
| baseAccount: string, | ||
| fetchImpl: typeof fetch = fetch, | ||
| horizonUrl = DEFAULT_HORIZON_URL | ||
| ): Promise<boolean> { | ||
| const response = await fetchImpl( | ||
| `${horizonUrl.replace(/\/$/, "")}/accounts/${encodeURIComponent(baseAccount)}` | ||
| ); | ||
| if (!response.ok) return false; | ||
|
|
||
| const account = (await response.json()) as { data?: Record<string, unknown> }; | ||
| return decodeDataValue(account.data?.["config.memo_required"]) || | ||
| decodeDataValue(account.data?.["config.requiring_memo"]); | ||
| } | ||
|
|
||
| /** | ||
| * Performs normal routing extraction and optionally checks SEP-0029 account data. | ||
| * A failed network lookup is treated as unknown and does not block parsing. | ||
| */ | ||
| export async function extractRoutingAsync( | ||
| input: RoutingInput, | ||
| requirementFetcher: MemoRequirementFetcher = fetchMemoRequirement | ||
| ): Promise<RoutingResult> { | ||
| const result = extractRouting(input); | ||
| if (!result.destinationBaseAccount || result.routingId !== null || result.destinationError) { | ||
| return result; | ||
| } | ||
|
|
||
| try { | ||
| if (await requirementFetcher(result.destinationBaseAccount)) { | ||
| result.warnings = [ | ||
| ...result.warnings, | ||
| { | ||
| code: "MISSING_REQUIRED_MEMO", | ||
| severity: "error", | ||
| message: "Destination account requires a memo, but no routing ID was provided.", | ||
| }, | ||
| ]; | ||
| } | ||
| } catch { | ||
| // Network/configuration failures must not change the synchronous result. | ||
| } | ||
| return result; | ||
| } | ||
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
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
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
Oops, something went wrong.
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.
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.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: Boxkit-Labs/stellar-address-kit
Length of output: 5880
🏁 Script executed:
Repository: Boxkit-Labs/stellar-address-kit
Length of output: 11424
Bound the Horizon lookup.
When
fetchImplremains pending,fetchMemoRequirementremains pending, soextractRoutingAsynccannot return the synchronous routing result. Add a timeout and returnfalsewhen it expires.🤖 Prompt for AI Agents