Skip to content

fix(server): advance campaign to InProduction on first tranche release (#173) - #176

Open
trenysx wants to merge 1 commit into
Cylo-Traders:masterfrom
trenysx:fix/tranche-status-inproduction-173
Open

fix(server): advance campaign to InProduction on first tranche release (#173)#176
trenysx wants to merge 1 commit into
Cylo-Traders:masterfrom
trenysx:fix/tranche-status-inproduction-173

Conversation

@trenysx

@trenysx trenysx commented Aug 18, 2026

Copy link
Copy Markdown

Summary

Closes #173

Per the escrow contract's state machine, the first tranche release transitions a campaign from Funded to InProduction (see release_tranche in contracts/production_escrow/src/lib.rs, which accepts both Funded and InProduction). The indexer's handleTrancheReleased only created a Tranche row and upserted the recipient user, leaving Campaign.status stuck at Funded until HarvestReported fired.

Change

In server/src/indexer/parsers/event-parser.service.ts, handleTrancheReleased now performs a conditional updateMany that advances status to InProduction only when the current stored status is Funded:

  • where: { id: campaignId, status: 'Funded' }
  • data: { status: 'InProduction' }

Because the where clause includes the current status, a second/third tranche release on an already-InProduction campaign matches zero rows and is a no-op rather than an unnecessary write.

Tests

Added a TrancheReleased -> InProduction status block to event-parser.service.spec.ts:

  1. First release flips a Funded campaign to InProduction (asserts the exact conditional update call).
  2. Two releases are asserted to only ever issue the Funded-guarded update (matching count 0 simulates an already-released campaign), proving later releases cannot reset or duplicate-write the status.

All 47 unit tests in event-parser.service.spec.ts pass; tsc --noEmit and eslint are clean for the changed files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] Indexed campaign status never advances to InProduction when a tranche is released

1 participant