Background
Wraith's schema has no network dimension — every table keys on contract/address/ledger only. If a mainnet instance and a testnet instance ever share a database, records collide: eventId is globally @unique on TokenTransfer/HostFnLog/NftTransfer (RPC paging tokens can repeat across networks and silently overwrite), and IndexerState/BackfillCursor are singleton rows (@id @default(1)) — one cursor for the whole DB. Dual-network is impossible until storage is network-aware.
What to build
Add a network field ("testnet" | "mainnet") to every model and fold it into every uniqueness constraint and query.
Key files
prisma/schema.prisma — add network to TokenTransfer, HostFnLog, NftTransfer, NftMetadata, AccountSummary, WebhookSubscription/Delivery, IndexerState, IndexerCheckpoint, BackfillCursor, RetentionJobRun
src/db.ts — thread network into every read/write
- a new Prisma migration
Suggested execution
git checkout -b feat/network-column
- Add
network String @default("testnet") to each model
- Change
eventId @unique → @@unique([network, eventId]); make IndexerState/BackfillCursor keyed by network instead of the singleton id=1
- Update
AccountSummary (@@unique([network, address])) and NftMetadata (@@unique([network, contractId, tokenId]))
- Regenerate:
npx prisma migrate dev --name add-network
- Update every query in
src/db.ts to pass/filter network
Acceptance criteria
Drips Wave · Complexity: Advanced · 200 points
Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk
Background
Wraith's schema has no network dimension — every table keys on contract/address/ledger only. If a mainnet instance and a testnet instance ever share a database, records collide:
eventIdis globally@uniqueonTokenTransfer/HostFnLog/NftTransfer(RPC paging tokens can repeat across networks and silently overwrite), andIndexerState/BackfillCursorare singleton rows (@id @default(1)) — one cursor for the whole DB. Dual-network is impossible until storage is network-aware.What to build
Add a
networkfield ("testnet" | "mainnet") to every model and fold it into every uniqueness constraint and query.Key files
prisma/schema.prisma— addnetworktoTokenTransfer,HostFnLog,NftTransfer,NftMetadata,AccountSummary,WebhookSubscription/Delivery,IndexerState,IndexerCheckpoint,BackfillCursor,RetentionJobRunsrc/db.ts— threadnetworkinto every read/writeSuggested execution
network String @default("testnet")to each modeleventId @unique→@@unique([network, eventId]); makeIndexerState/BackfillCursorkeyed bynetworkinstead of the singletonid=1AccountSummary(@@unique([network, address])) andNftMetadata(@@unique([network, contractId, tokenId]))npx prisma migrate dev --name add-networksrc/db.tsto pass/filternetworkAcceptance criteria
network; all@unique/@@uniquekeys include itIndexerState/BackfillCursorare per-network, not singleton rowsRequired: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk