Repository navigation
feat(snippets): record per-snippet blockchain verification history - #206
Merged
SudiptaPaul-31 merged 1 commit intoOct 3, 2026
Conversation
Maintain an append-only history of Stellar verification events (transaction hash, ledger sequence, timestamp, confirmation status) for each snippet, so reprocessing and retries can be audited instead of overwriting mutable state. - Migration 004 adds snippet_verification_history with a real FK to snippets(id) ON DELETE CASCADE and UNIQUE(transaction_hash) - Recovery service records pending/confirmed/failed events at the existing submit, confirm, and failure points; history writes are best-effort and never abort the transaction flow - Idempotent upsert on transaction hash converges retried transactions into one row without downgrading confirmed events - New GET /api/snippets/[id]/verification-history returns events chronologically with pagination, 400 on invalid UUID, 404 on unknown snippet 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@JemimahEkong is attempting to deploy a commit to the Sudipta 's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@JemimahEkong 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.
Closes #195
Summary
Snippets are anchored on Stellar via the recovery engine, but the only durable record of a verification was a single mutable column on
snippets(on_chain_hash,transaction_hash,verified_at) — retried and reprocessed transactions overwrote it, leaving no audit trail. This PR maintains an append-only history of blockchain verification events per snippet (transaction hash, ledger sequence, timestamp, confirmation status) and exposes it via a new public API endpoint.Changes
Migration (
scripts/migrations/004_add_snippet_verification_history.sql)snippet_verification_historytable with a real FK tosnippets.id,UNIQUEtransaction hash,status(pending/confirmed/failed), ledger sequence, error message, and timestamps(snippet_id, created_at ASC)for chronological lookupsCREATE TABLE IF NOT EXISTS);updated_atmaintained at the application layer since the migration runner executes statements individuallyRecording (
lib/stellar-recovery.service.ts)submitToHorizon():pendingon submission,confirmedafterpollForConfirmation(with ledger sequence +verified_at),failedon retryable/permanent failurecollectSnippetIds()helperIdempotency
INSERT … ON CONFLICT (transaction_hash) DO UPDATE, same pattern assnippet_transactions.linkPending()— reprocessing merges ledger/verified_atviaCOALESCE, with a guard so confirmed rows are never downgradedNew endpoint —
GET /api/snippets/[id]/verification-historyverification-audit,transaction-status)400invalid UUID,404unknown snippet,200chronological history withlimit/offsetpagination (default 20, max 100)Testing
app/api/snippetstest folderDeploy notes
Run migration
004_add_snippet_verification_history.sqlviascripts/run-optimization-migration.ts(auto-picked up) or manually against production.