Implement escrow expiry monitor cron job and admin review API - #78
Open
Elizabethxxx wants to merge 1 commit into
Open
Implement escrow expiry monitor cron job and admin review API#78Elizabethxxx wants to merge 1 commit into
Elizabethxxx wants to merge 1 commit into
Conversation
Adds a scheduled background job that scans escrow locks for TTL expiry and flags them for admin review, plus a versioned admin API to list and resolve flagged escrows. - New Escrow model tracking lock/TTL/expiry state - escrowService encapsulates the scan, listing, and resolution logic - node-cron powered job runs on a configurable schedule and stamps the current Soroban ledger sequence onto flagged escrows for an on-chain-anchored audit trail - GET /api/v1/admin/escrows/flagged and PATCH /api/v1/admin/escrows/:id/resolve, both admin-only - Tests cover the scan logic and the full admin API surface
|
@Elizabethxxx 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 #42
Summary
Adds a background cron job that monitors escrow locks for TTL expiry and flags them in the database, plus a versioned admin API to review and resolve flagged escrows.
Escrowmodel (src/models/Escrow.ts) trackingdeliveryId,amount,lockedAt,ttlSeconds,expiresAt, and lifecyclestatus(locked/expired/resolved/released)escrowService(src/services/escrowService.ts) encapsulates the scan, listing, and resolution logic; retrieval is always from MongoDB, no inline mocksescrowMonitorjob (src/jobs/escrowMonitor.ts) usesnode-cronon a configurable schedule (ESCROW_MONITOR_CRON, default every 5 minutes) to find locked escrows past their TTL and mark themexpiredsorobanService.getLatestLedger()) for an on-chain-anchored audit trailauthenticate+requireRole(ADMIN):GET /api/v1/admin/escrows/flagged— paginated list of expired escrowsPATCH /api/v1/admin/escrows/:id/resolve— marks a flagged escrow resolved with audit notesserver.tson process boot and stopped on graceful shutdownArchitecture
Follows the existing layered pattern:
escrowRoutes.ts->escrowController.ts->escrowService.ts->Escrowmodel, matching the conventions used byadminRoutes/adminController/adminService.Test plan
npx jest tests/escrow.test.ts— 11/11 passing, covering the scan logic (flags expired, ignores active, is idempotent) and the full admin API surface (200/400/401/403/404/409 paths)npx tsc --noEmit— introduces no new TypeScript errors (pre-existing unrelated errors indeliveryController.tsare untouched by this change)npx eslinton all added/changed files — no errorsnpx jestsuite — same 4 pre-existing failing suites as onmainprior to this branch; no regressions introduced