PR: Transaction Memo & Metadata Storage#111
Open
clintjeff2 wants to merge 22 commits intoSynapse-bridgez:mainfrom
Open
PR: Transaction Memo & Metadata Storage#111clintjeff2 wants to merge 22 commits intoSynapse-bridgez:mainfrom
clintjeff2 wants to merge 22 commits intoSynapse-bridgez:mainfrom
Conversation
… callback handler
…::Server for v0.6
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.
PR: Transaction Memo & Metadata Storage
Branch:
feature/issue-45-transaction-metadataTarget:
developIssue: #89 — Transaction Memo & Metadata Storage
Summary
Extends the transaction model to support a human-readable memo field, a memo_type classifier, and an arbitrary metadata JSONB column. This allows richer context from the Anchor Platform (memo, memo_type) and partner-defined key-value data (reference IDs, customer notes, compliance tags) to flow through the bridge pipeline.
All new fields are nullable — existing integrations are fully backward-compatible.
Changes
Migration
migrations/20260222000000_transaction_memo_metadata.sql— Addsmemo(TEXT),memo_type(VARCHAR(10)), andmetadata(JSONB) columns to thetransactionstable, all nullable.Model Layer
src/db/models.rs— Addedmemo,memo_type,metadatafields to theTransactionstruct. UpdatedTransaction::new()to accept the new parameters. Updated all existing unit tests.src/domain/transaction.rs— Mirrored the new fields in the domain-layerTransactionentity. UpdatedTransaction::new().src/schemas.rs— Addedmemo,memo_type,metadatatoTransactionSchemafor OpenAPI documentation.Data Access
src/db/queries.rs— Updatedinsert_transactionto persist the new columns. Updated audit log payload to include memo and metadata.src/adapters/postgres_transaction_repository.rs— UpdatedTransactionRow, INSERT query, andinto_domain()conversion to include the new fields.Handler Layer
src/handlers/webhook.rs— IntroducedCallbackPayloadstruct withmemo,memo_type, andmetadatafields. Implemented thecallbackhandler to parse, validatememo_type(must betext,hash, orid), create and persist aTransaction, and return201 Created. Updatedget_transactionto expose all fields including memo/metadata in responses.Service / Use Case Layer
src/use_cases/process_deposit.rs— Addedmemo,memo_type,metadatatoDepositInputand passed through toTransaction::new().src/services/processor.rs— Updated the explicitSELECTcolumn list in the background processor to include the new columns.Configuration
Cargo.toml— Added"json"feature tosqlxfor JSONB serialization/deserialization.Tests
tests/integration_test.rs— Added five new integration test cases:test_callback_with_memo_and_metadata— full payload with memo, memo_type, and metadata; verifies persistence and retrieval.test_callback_with_hash_memo_type— validateshashmemo_type acceptance.test_callback_with_invalid_memo_type— verifies 400 rejection for invalid memo_type values.test_callback_with_metadata_only— metadata without memo fields; confirms partial payloads work.test_valid_deposit_flowupdated to assert null memo/metadata on plain payloads.Proof of Implementation
Build Success
How to Verify
Closes #89