feat: add on-chain event correlation service (#546)#683
Open
CHKM001 wants to merge 1 commit into
Open
Conversation
- Add SorobanEventCorrelationService with extractIdentifiers mapper - Add SorobanEventCorrelationScheduler for scheduled/on-demand jobs - Handle EVENT_CORRELATION jobs in OnchainProcessor - Add GET /onchain/aid-escrow/packages/:id/events endpoint - Add GET /claims/:id/events endpoint - Add POST /onchain/aid-escrow/correlate/:txHash endpoint - Add GET /onchain/aid-escrow/events with filtering/pagination - Add 16 unit tests for extractIdentifiers mapper logic - Fix Prisma schema reverse relations for SorobanEventCorrelation
|
@CHKM001 is attempting to deploy a commit to the Cedarich's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@CHKM001 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
|
@CHKM001 please fix workflow |
Author
|
okay |
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 #546 : Add On-Chain Event Correlation Service
Summary
Implements a service that correlates Soroban on-chain events to internal records using
package_id/claim_idand stores the mapping (tx hash, ledger, event topic). This enables full auditability between blockchain activity and internal claim/package state.Changes
New Files
src/onchain/soroban-event-correlation.service.tspackage_id/claim_idfrom payloads, and stores correlation records inSorobanEventCorrelationtablesrc/onchain/soroban-event-correlation.scheduler.tssrc/onchain/soroban-event-correlation.service.spec.tsextractIdentifiersmapper logicModified Files
prisma/schema.prismasorobanEventCorrelationstoClaimandAidPackagemodels (required by Prisma)src/onchain/interfaces/onchain-job.interface.tsEVENT_CORRELATIONandEVENT_CORRELATION_TRANSACTIONtoOnchainOperationTypeenumsrc/onchain/onchain.processor.tsSorobanEventCorrelationService; added handlers for the two new job typessrc/onchain/onchain.module.tsSorobanEventCorrelationService,SorobanEventCorrelationScheduler; exported service; addedScheduleModulesrc/onchain/aid-escrow.module.tsSorobanEventCorrelationServiceto exportssrc/onchain/aid-escrow.controller.tssrc/claims/claims.controller.tstest/transaction-status.spec.tsSorobanEventCorrelationServiceprovidertest/aid-escrow.integration.spec.tsSorobanEventCorrelationServiceproviderNew API Endpoints
Package Events
Returns all Soroban on-chain events correlated to a specific aid package.
Claim Events
Returns all Soroban on-chain events correlated to a specific claim.
On-Demand Correlation
Triggers immediate event correlation for a specific transaction hash.
All Events (Filtered)
Returns all event correlations with filtering by topic, claim, package, or ledger range.
How It Works
Scheduled Job (
SorobanEventCorrelationScheduler): Runs every 5 minutes, queries Soroban RPC for new events since the last processed ledger, and queues correlation jobs via BullMQ.On-Demand Trigger: Admin/operator can trigger correlation for a specific transaction hash via the
POST /correlate/:txHashendpoint.Correlation Logic (
SorobanEventCorrelationService):package_created,claim_disbursed, etc.)package_id/claim_idfrom event payloads using flexible path resolutiontxHash + eventIndex)Read Endpoints: Claim and package read endpoints now include correlated on-chain event data.
Mapper Logic (
extractIdentifiers)The mapper resolves identifiers from event payloads using a prioritized path search:
{ packageId }if found (takes priority){ claimId }if no package ID found{}if neither foundTesting
extractIdentifierscovering all payload structures, edge cases, and type coercionEnvironment Variables
AID_ESCROW_CONTRACT_ID''STELLAR_RPC_URLhttps://soroban-testnet.stellar.orgSTELLAR_NETWORK_PASSPHRASETest SDF Network ; September 2015Acceptance Criteria
Closes #546