Skip to content

feat(backend): Crowdfund Vault Sync Worker — contributions, milestones, refund windows (#711)#831

Open
Mormentz wants to merge 3 commits into
Pulsefy:mainfrom
Mormentz:feat/711-crowdfund-vault-sync-worker
Open

feat(backend): Crowdfund Vault Sync Worker — contributions, milestones, refund windows (#711)#831
Mormentz wants to merge 3 commits into
Pulsefy:mainfrom
Mormentz:feat/711-crowdfund-vault-sync-worker

Conversation

@Mormentz

@Mormentz Mormentz commented Jun 1, 2026

Copy link
Copy Markdown

Summary

Closes #711

Adds a backend worker that tracks crowdfund vault Soroban events on testnet and materializes them into Postgres:

  • Deposits / contributionscrowdfund_vault_projects, crowdfund_vault_contributors
  • Milestone approvalscrowdfund_vault_milestones
  • Refund window / reversals → project status + contribution adjustments (ProjectExpiredEvent, ContributionRefundedEvent, ContributionClawedBackEvent)

Events flow through the existing soroban-events BullMQ pipeline (webhook ingest) and an optional RPC poller (getEvents) when STELLAR_CONTRACT_CROWDFUND_VAULT is configured.

Design

  • Idempotency: UNIQUE (txHash, eventIndex) on raw events; BullMQ jobId unchanged
  • Ledger sequencing: skip materialization when incomingLedgerSeq < stored lastLedgerSeq (same pattern as project_registry)
  • Replay-safe: re-delivering the same event is a no-op after the raw row exists

Schema

New migration: 1780200000000-CreateCrowdfundVaultSync.ts

Test plan

  • npx jest --testPathPattern=crowdfund-vault-sync (6 tests)
  • npm run build
  • Run migration: npm run migration:run (from apps/backend)
  • Set STELLAR_CONTRACT_CROWDFUND_VAULT + STELLAR_SOROBAN_RPC_URL on testnet
  • POST a sample DepositEvent to /soroban-events/ingest and verify rows in crowdfund_vault_* tables
  • Confirm cron poller queues events when contract ID is set (check logs)

Notes

  • CrowdfundService remains in-memory for now; API can be wired to crowdfund_vault_projects in a follow-up.
  • Project registry routing now prefers config.stellar.contracts.projectRegistry over the legacy PROJECT_REGISTRY_CONTRACT_ID env var.

Mormentz and others added 2 commits June 1, 2026 14:54
Materialize vault deposits, milestones, and refund-window events from Soroban ingestion with ledger-sequenced idempotent upserts, DB migrations, RPC poller, and unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@drips-wave

drips-wave Bot commented Jun 1, 2026

Copy link
Copy Markdown

@Mormentz 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! 🚀

Learn more about application limits

@Cedarich

Cedarich commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

@Mormentz please fix workflow

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: Crowdfund Vault Sync Worker (Contributions, Milestones, Refund Windows)

2 participants