Skip to content

Wire IndexerModule into the app and implement the Soroban polling loop #1035

Description

@BigBen-7

GistPin — GrantFox bounty issue. Reviewed against the acceptance criteria below. Read contracts/README.md first — it has the full ABI, event schema, and error codes for the deployed contract.

Context

GistPin's design intent (see Backend/README.md) is that the chain is the
source of truth
— gists posted directly on-chain (e.g. by a future
wallet-direct frontend) must still show up via the API. That requires an
indexer that polls Soroban and reconciles into Postgres. The module exists
but is inert.

Problem

Backend/src/indexer/indexer.module.ts and indexer.service.ts exist but
IndexerModule is never imported into AppModule. It currently does
nothing when the app runs.

Scope

In scope:

  • Import IndexerModule into AppModule so its poll loop actually runs.
  • Implement/complete the poll loop: track the last-processed ledger
    (persist it — don't reprocess from genesis on every restart), fetch new
    events since that ledger via SorobanService.getEventsSince, and hand
    each decoded event off to a handler (the persistence logic is a separate
    issue — this issue is the polling/scheduling plumbing).
  • Sensible polling interval (use @nestjs/schedule, already a dependency)
    and basic error handling (a single bad event/ledger must not permanently
    wedge the loop).

Out of scope: the actual DB writes for each event type (next issue) —
stub/log them here if that issue isn't merged yet, or coordinate order.

Acceptance Criteria

  • IndexerModule runs as part of the app on startup
  • The last-processed ledger is persisted (survives a restart — no
    reprocessing from scratch every time)
  • A malformed/unexpected event does not crash the poll loop or stop
    subsequent ledgers from being processed
  • Unit tests cover: normal polling advances the ledger cursor, and a bad
    event is skipped without halting the loop
  • npm run build && npm test pass

How to verify your own work

cd Backend && npm run start:dev
# post a gist directly via the contract CLI (bypassing the API) and confirm
# the indexer's logs show it being picked up on the next poll
stellar contract invoke --id CCOVX5S3SYHVKUKM3NUXLH6COIYLV5BL3XD6HPFLLR4VLQEQGINJMDRV --source <your-identity> --network testnet --send=yes -- post_gist --location_cell "idxtest" --content_hash "QmIdx"

Depends on: the event-decoding issue.
Blocks: the "persist events to Postgres" issue.
Estimated effort: Medium (1-2 days). NestJS scheduling knowledge helpful.

Metadata

Metadata

Assignees

Labels

BackendBackend issuesGrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third Campaign

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions