You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+
## Commands
6
+
7
+
```bash
8
+
# Run all tests (requires Docker for PostgreSQL containers)
9
+
make test
10
+
# or: go test -p 8 -timeout 60s ./...
11
+
12
+
# Run a single test
13
+
go test -run TestCelestialsTestSuite/TestSync ./pkg/module/...
14
+
15
+
# Lint
16
+
make lint
17
+
18
+
# Regenerate mocks and enums
19
+
make generate
20
+
```
21
+
22
+
## Architecture
23
+
24
+
This is a **Celestia blockchain indexing module** built on the [DipDup indexer SDK](https://github.com/dipdup-net/indexer-sdk). It scans for changes to Celestial IDs (blockchain domains) from an external API and persists them to PostgreSQL.
25
+
26
+
### Data flow
27
+
28
+
1.`Module` (pkg/module) runs a periodic sync loop (default: 1 min interval)
29
+
2. Fetches changes from external API (`pkg/api/v1`) starting from the last known `change_id`
30
+
3. Writes results to PostgreSQL in a transaction: upsert celestials → update state → flush
31
+
4.`CelestialState` table tracks the last processed `change_id` to enable resumable syncing
32
+
33
+
### Key packages
34
+
35
+
-**`pkg/module`** — Core orchestration. `Module` embeds DipDup's `BaseModule` and implements the sync loop. Configured via `ModuleOption` functions (`WithIndexPeriod`, `WithLimit`, `WithDatabaseTimeout`). Accepts an `AddressHandler` callback to resolve blockchain addresses.
36
+
-**`pkg/api`** — External Celestials API client interface + `v1/` HTTP implementation using fast-shot (rate-limited to 5 req/s).
37
+
-**`pkg/storage`** — Storage interfaces (`ICelestial`, `ICelestialState`, `CelestialTransaction`) and status enum (`NOT_VERIFIED`, `VERIFIED`, `PRIMARY`).
38
+
-**`pkg/storage/postgres`** — Bun ORM implementation. Uses PostgreSQL `ON CONFLICT DO UPDATE` for idempotent upserts. Status transitions: `PRIMARY → VERIFIED` when a new primary address is set for an existing celestial.
39
+
40
+
### Testing
41
+
42
+
Tests use `testcontainers` to spin up a real PostgreSQL 15.8 + TimescaleDB instance. Fixtures are loaded from `/test/*.yml` via go-testfixtures. Mocks for all interfaces are auto-generated via mockgen (stored in `pkg/*/mock/`).
43
+
44
+
When adding new interfaces, add a `//go:generate mockgen ...` directive and run `make generate`.
Package containig Celestials module for indexing its data
1
+
# Celestial Module
2
+
3
+
A Go module for indexing [Celestial IDs](https://celestials.id/) — domain names on the Celestia network. Built on top of the [DipDup Indexer SDK](https://github.com/dipdup-net/indexer-sdk) and designed to be embedded into an indexer as a standalone module.
4
+
5
+
## What it does
6
+
7
+
The module periodically polls the external Celestials API, fetches domain changes (registrations, address updates, status changes), and persists them to PostgreSQL. It tracks progress using a `change_id` — the module remembers the last processed identifier and resumes from that point on restart.
0 commit comments