From 6bbd126e8141986792e40cbbf4d704194822a254 Mon Sep 17 00:00:00 2001 From: fishonamos Date: Sun, 1 Dec 2024 21:55:32 +0100 Subject: [PATCH] indexer --- land-registry-indexer/src/config.ts | 7 +++++++ land-registry-indexer/src/eventHandlers.ts | 19 +++++++++++++++++++ land-registry-indexer/src/index.ts | 8 ++++++++ 3 files changed, 34 insertions(+) diff --git a/land-registry-indexer/src/config.ts b/land-registry-indexer/src/config.ts index ab702956..59b4d7d5 100644 --- a/land-registry-indexer/src/config.ts +++ b/land-registry-indexer/src/config.ts @@ -1,3 +1,10 @@ +/** + * Configuration settings for the Land Registry Indexer + * + * This module loads environment variables from a .env file and provides + * configuration constants used throughout the application. + */ + import dotenv from 'dotenv'; dotenv.config(); diff --git a/land-registry-indexer/src/eventHandlers.ts b/land-registry-indexer/src/eventHandlers.ts index 3cae7911..e1440bdb 100644 --- a/land-registry-indexer/src/eventHandlers.ts +++ b/land-registry-indexer/src/eventHandlers.ts @@ -1,3 +1,22 @@ +/** + * Event handler functions for the Land Registry smart contract + * + * These functions process events emitted by the contract and store them in PostgreSQL. + * Each handler receives: + * - client: PostgreSQL client for database operations + * - data: Event data from the contract + * - cursor: Block/transaction metadata + * + * The handlers maintain the state of: + * - Land parcels (registration, transfers, verification) + * - Inspectors (adding/removing) + * - Marketplace listings (creation, updates, sales) + * + * All monetary values are stored as strings to preserve precision. + * Addresses are stored as strings in their full StarkNet format. + * Timestamps are converted from Unix seconds to JavaScript Date objects. + */ + import { PoolClient } from 'pg'; import { StarkNetCursor } from '@apibara/protocol'; diff --git a/land-registry-indexer/src/index.ts b/land-registry-indexer/src/index.ts index c8266063..431f9e5f 100644 --- a/land-registry-indexer/src/index.ts +++ b/land-registry-indexer/src/index.ts @@ -1,3 +1,11 @@ +/** + * Main entry point for the Land Registry Indexer + * + * This script initializes the indexer, connects to the PostgreSQL database, + * and starts processing events from the StarkNet node using Apibara. + + */ + import { Indexer, IndexerRunner } from '@apibara/indexer'; import { StarkNetCursor, Filter } from '@apibara/protocol'; import { Pool } from 'pg';