This PR resolves two backend issues:
- Issue #524 [Backend] Indexer ignores fee_config_updated and admin_transferred governance events: Added indexing and SSE broadcasting for
fee_config_updatedandadmin_transferredcontract governance events. Used an elegant, referentially safestreamId = 0system stream fallback to preserve Prisma schema integrity and foreign-key constraints. - Issue #525 [Backend] migration_lock.toml declares sqlite but the datasource is postgresql: Fixed a production-blocking validation mismatch in Prisma by changing
providerfrom"sqlite"to"postgresql"inmigration_lock.toml.
- 🐛 Bug fix (non-breaking change which fixes an issue)
- ✨ New feature (non-breaking change which adds functionality)
- 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
- 📚 Documentation update
- 🔧 Refactoring (no functional changes)
- ⚡ Performance improvement
- 🧪 Test addition or update
Closes #524 Closes #525
- Database Configuration:
- Updated
providerinbackend/prisma/migrations/migration_lock.tomlto"postgresql".
- Updated
- Worker Indexer (
soroban-event-worker.ts):- Added
decodeU32helper function to decodeu32event values. - Implemented
ensureSystemStreamto upsert a system user and stream withstreamId = 0during transaction callbacks to prevent database foreign-key constraint violations when writing protocol-level events. - Modified
processEventto allow single-topic events (topic.length === 1) for the two new protocol events while keeping thestreamIdrequirement for per-stream events. - Implemented
handleFeeConfigUpdatedandhandleAdminTransferredhandlers to write records of typesFEE_CONFIG_UPDATEDandADMIN_TRANSFERREDand broadcast payloads over the SSE admin channelsstream.fee_config_updatedandstream.admin_transferred.
- Added
- Classification Lists:
- Added
FEE_CONFIG_UPDATEDandADMIN_TRANSFERREDto allowed list arrays inevents.routes.ts(EVENT_TYPES) andstream.controller.ts(validEventTypes).
- Added
- Syntax and Compile Fixes:
- Resolved a pre-existing syntax error (missing arrow function opening brace
{) inbackend/tests/integration/stream-actions.test.tsto allow the test runner to compile all files.
- Resolved a pre-existing syntax error (missing arrow function opening brace
- Unit tests added/updated
- Integration tests added/updated
- Manual testing performed
- Run mocked event worker unit tests validating governance event decoding, database upserts, and SSE broadcast trigger:
npx vitest run tests/soroban-event-worker.test.ts
- Run database-mocked integration tests asserting the event lifecycle:
DATABASE_URL=postgresql://localhost/flowfi npx vitest run src/__tests__/integration/streams.test.ts
- Verify that the Prisma migrate status check successfully resolves schema and migration lock providers without crashing:
DATABASE_URL=postgresql://localhost/flowfi npx prisma migrate status
- My code follows the project's style guidelines
- I have performed a self-review of my own code
- I have commented my code, particularly in hard-to-understand areas
- I have made corresponding changes to the documentation
- My changes generate no new warnings
- I have added tests that prove my fix is effective or that my feature works
- New and existing unit tests pass locally with my changes
- Any dependent changes have been merged and published
- I have checked for breaking changes and documented them if applicable