feat: add Escrow Mongoose schema#83
Open
Olorunfemi20 wants to merge 1 commit into
Open
Conversation
Add an Escrow model to track funds locked in Soroban escrow contracts per delivery. The schema records the on-chain contract id, amount, asset, lock status lifecycle (pending, locked, released, refunded), and an append-only list of associated transaction hashes with type and ledger metadata. A unique index on contractId prevents duplicate escrow records, and a sparse unique index on transactions.hash guards against an indexer recording the same on-chain transaction twice. Covered by tests/escrow.model.test.ts using mongodb-memory-server against a real in-process MongoDB instance.
|
@Olorunfemi20 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 #37
Summary
Adds the Escrow Mongoose model used to track funds locked in a Soroban
escrow contract for a delivery.
contractId— deployed Soroban contract id (unique)amount/asset— escrowed value and asset codelockStatus— pending | locked | released | refundeddelivery— ObjectId reference to the Delivery documenttransactions[]— append-only log of associated on-chain transactionhashes, each with a type (fund/release/refund), ledger number, and
timestamp
timestamps: truefor createdAt/updatedAtA unique index on
contractIdand a sparse unique index ontransactions.hashprevent duplicate escrow records and duplicatetransaction ingestion (the latter matters once an indexer is polling
the chain and could otherwise reprocess the same event).
Work done
src/models/Escrow.tstests/escrow.model.test.ts— validation, defaults,duplicate contractId rejection, duplicate transaction hash rejection,
negative amount rejection, required-field enforcement
Test plan
npx jest tests/escrow.model.test.ts— 6 passednpx tsc --noEmit— no new type errorsnpx eslint src/models/Escrow.ts tests/escrow.model.test.ts— cleanNotes for reviewers
This PR is scoped strictly to the schema per the issue's implementation
directory. The Controller/Service/API layers that read and write this
model are introduced in the escrow_funded indexer work (#38), which
depends on this schema.