Skip to content

feat(indexer): add holder and supply-history aggregates (Closes #945) - #1060

Open
aishagbadamosi wants to merge 3 commits into
BCPathway:mainfrom
aishagbadamosi:feature/945-holders-supply-history
Open

aishagbadamosi wants to merge 3 commits into
BCPathway:mainfrom
aishagbadamosi:feature/945-holders-supply-history

Conversation

@aishagbadamosi

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds GET /api/v1/holders and GET /api/v1/supply-history to the indexer,
deriving current holder balances and supply history from the already-indexed
mint, transfer, and burn events.

closes #945

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • CI
  • Chore

Checklist

  • I ran pre-commit run --all-files locally and it passed
  • All CI jobs pass on this branch
  • I added or updated tests for new behaviour
  • I updated relevant docs / comments
  • No secrets or credentials are included
  • No breaking changes to public APIs (or I've documented them)

Breaking changes?

Related issues

Closes #945

@drips-wave

drips-wave Bot commented Sep 28, 2026

Copy link
Copy Markdown

@aishagbadamosi 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

@p3ris0n p3ris0n left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

The read API matches #945, but it cannot run against a migrated database.

What is in place:

  • GET /api/v1/holders returns balances folded from mint, transfer, and burn deltas, drops zero balances, and uses the existing limit/cursor pagination.
  • GET /api/v1/supply-history appends a timestamped point per mint or burn, from the event's new_supply or the previous point plus the delta. It does not call RPC.
  • aggregates.test.ts covers a mint then a transfer. CI on this branch is green.

What is missing:

  • schema.prisma adds Holder and SupplyPoint, and there is no Prisma migration. prisma migrate deploy will not create those tables, so both routes fail on a fresh or existing database.
  • Please add a committed migration for the new models (and keep it compatible with #1056's init migration if that lands first).

Holding merge until that migration is in the branch.

The Holder and SupplyPoint models added for BCPathway#945 were only declared in
schema.prisma, so "prisma migrate deploy" never created the tables and both
/api/v1/holders and /api/v1/supply-history failed against a fresh or existing
database.

Commits 20260928193226_add_holder_and_supply_point, generated with "prisma
migrate diff" against the pre-change schema so the DDL matches Prisma's
canonical output.

The migration is additive only and creates none of the base models, so it
applies in either order relative to the BCPathway#1056 init migration. Every CREATE is
guarded with IF NOT EXISTS so an init generated from a schema snapshot that
already includes these two models cannot fail the deploy; this is the only
deviation from Prisma's raw output and it is commented in the file.

Also fixes a duplicate "test" key in package.json. JSON keeps the last entry,
so CI was running a script that excluded ledger.test.ts, aggregates.test.ts,
and healthz.test.ts, including the aggregates coverage cited for BCPathway#945. Adds
migrations.test.ts to guard the schema/migration invariant, a prisma:deploy
script, and the migration flow in the README.
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.

Add holder and supply-history aggregates

2 participants