feat: implement On-Chain Event Correlation Service#643
Open
nazteeemba wants to merge 1 commit into
Open
Conversation
|
@nazteeemba is attempting to deploy a commit to the Cedarich's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@nazteeemba 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! 🚀 |
Contributor
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 #546
Summary
Implements the On-Chain Event Correlation Service — a NestJS module that automatically fetches Soroban smart contract events, maps them to internal
AidPackageandClaimrecords bypackage_id/claim_id, and persists the mapping (tx hash, ledger, event topic) idempotently. Correlated events are surfaced on the claim and package read endpoints.Changes
New files
prisma/migrations/.../migration.sqlOnChainEventandCorrelationCursortables with unique index and 4 query indexessrc/onchain/event-correlation/event-mapper.tsEventMapper— decodes ScVal topics/values, extractspackage_id/claim_id, DB lookups, full error handlingsrc/onchain/event-correlation/event-correlation.service.tscorrelate()with cursor-based ledger resumption,@Cronscheduler (every 5 min),isRunningconcurrency guardsrc/onchain/event-correlation/event-correlation.controller.tsPOST /v1/onchain/events/correlate— on-demand trigger with ledger validation, HTTP 502 on RPC failuresrc/onchain/event-correlation/dto/correlation-result.dto.tsCorrelationResultinterfaceModified files
prisma/schema.prismaOnChainEventandCorrelationCursormodelssrc/onchain/onchain.module.tsEventMapper,EventCorrelationService,EventCorrelationControllersrc/onchain/aid-escrow.controller.tsGET /onchain/aid-escrow/packages/:idreturnsonChainEventsarraysrc/onchain/aid-escrow.module.tsPrismaServiceto providerssrc/claims/claims.service.tsfindOneincludesonChainEventsarray (always present, empty when no events)Acceptance criteria
POST /v1/onchain/events/correlateGET /v1/claims/:idandGET /onchain/aid-escrow/packages/:idTesting