feat(stellar): attach unique snippet memo references and link transactions to snippets - #204
Merged
SudiptaPaul-31 merged 1 commit intoSep 27, 2026
Conversation
|
@ajetunmobiabdulsamad is attempting to deploy a commit to the Sudipta 's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@ajetunmobiabdulsamad 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
Stellar transactions that touch a snippet now carry a unique snippet reference in the transaction memo, and every submitted transaction is linked back to its snippet in the database. References respect Stellar's 28-byte
memo_textlimit and are validated: an over-long or malformed memo is rejected rather than silently truncated.Related Issue
Issue #194 — Implement Stellar Memo-Based Snippet References.
Changes
Snippet memo references
[ADD]
lib/snippet-memo.tsgenerateSnippetMemoRef(snippetId)produces a deterministicsnip:<12 hex>reference (17 bytes) — one reference per snippet, so references cannot collide.buildSnippetMemo(snippetId, contentHash?)producessnip:<ref>/snip:<ref>:<hash8>(26 bytes max);buildBatchSnippetMemo(batchHash)producessnipb:<12 hex>(18 bytes) for batch anchors.assertMemoWithinStellarLimitenforces the 28-byte limit in bytes (multi-byte aware) and throws instead of truncating;assertSnippetMemoRefrejects malformed references.parseSnippetMemo/parseBatchSnippetMemoresolve a reference back from an on-chain memo.[ADD]
lib/snippet-memo.test.tss:/lic:/tr:memos and malformed references.Transaction ↔ snippet association
[ADD]
lib/snippet-transaction.types.tsSnippetTransaction(pending/confirmed/failed), its row shape and link params.[ADD]
lib/snippet-transaction.repository.tslinkPendingupserts the association (unique persnippet_id + transaction_hash) and validates the memo reference before writing.markConfirmed(records the ledger sequence),markFailed,findBySnippetId,findByTransactionHash,findByMemoRef.[ADD]
scripts/add-snippet-transactions.sqlsnippet_transactionstable plus lookup indexes, matching the schema in the issue.[ADD]
lib/snippet-transaction-association.test.tsWiring
[MODIFY]
lib/stellar.tsStellarSubmitResultexposesmemoReffrom every submit helper.buildSnippetMemo/buildBatchSnippetMemo; the previousbuildMemoandbuildOwnershipTransferMemohelpers (which trimmed thetr:memo with.slice(0, 28)) are removed.[MODIFY]
lib/stellar-recovery.service.tsmemoRefis linked to every referenced snippet (snippetId, or everysnippets[].idfor a batch).confirmedwith the ledger sequence; a dead transaction flips an existing association tofailed.getSnippetTransactions(snippetId)exposes the association history.[MODIFY]
lib/activity-logger.tsstellar.memo.attached,snippet.transaction.linked,snippet.transaction.confirmed,snippet.transaction.failed.[MODIFY]
app/api/snippets/[id]/transaction-status/route.tssnippetTransactions(memo reference, transaction hash, ledger sequence, status) alongside the existing recovery transactions.Verification Results
Implemented through the GitHub Git Data API only (no local clone). The author did not run
pnpm lintorpnpm test --runInBandlocally, so the repository's checks are reported by CI rather than by this PR body. The new tests are limited to pure memo helpers and a mockedStellarRecoveryService, so no database or network access is required.buildSnippetMemoused by every snippet submit pathlinkPendingthenmarkConfirmedwith ledger sequencemarkFailed; no association without a memo referencesnip:<ref>+ unique(snippet_id, transaction_hash)snippetTransactionsarray on the snippet transaction-status endpointappendActivityLogactionsCloses #194