create-eclesia-indexer 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ services:
2
+ postgres:
3
+ image: postgres:16
4
+ restart: always
5
+ environment:
6
+ POSTGRES_DB: indexer
7
+ POSTGRES_USER: postgres
8
+ POSTGRES_PASSWORD: password
9
+ ports:
10
+ - "5432:5432"
11
+ volumes:
12
+ - postgres_data:/var/lib/postgresql/data
13
+ healthcheck:
14
+ test: ["CMD-SHELL", "pg_isready -U postgres -d {{PROJECT_NAME}}"]
15
+ interval: 10s
16
+ timeout: 5s
17
+ retries: 5
18
+ indexer:
19
+ build: .
20
+ environment:
21
+ - RPC_ENDPOINT={{RPC_ENDPOINT}}
22
+ - PG_CONNECTION_STRING=postgres://postgres:password@postgres:5432/indexer
23
+ - LOG_LEVEL={{LOG_LEVEL}}
24
+ - USE_POLLING={{USE_POLLING}}
25
+ - QUEUE_SIZE={{QUEUE_SIZE}}
26
+ - PROCESS_GENESIS={{PROCESS_GENESIS}}
27
+ - CHAIN_PREFIX={{CHAIN_PREFIX}}
28
+ - START_HEIGHT={{START_HEIGHT}}
29
+ volumes:
30
+ - {{GENESIS_PATH}}:/usr/src/app/genesis.json
31
+ depends_on:
32
+ postgres:
33
+ condition: service_healthy
34
+ restart: unless-stopped
35
+ graphql-engine:
36
+ image: hasura/graphql-engine:v2.38.0
37
+ ports:
38
+ - "8080:8080"
39
+ restart: always
40
+ environment:
41
+ ## postgres database to store Hasura metadata
42
+ HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:password@postgres:5432/indexer
43
+ ## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs
44
+ HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:password@postgres:5432/indexer
45
+ ## enable the console served by server
46
+ HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
47
+ ## enable debugging mode. It is recommended to disable this in production
48
+ HASURA_GRAPHQL_DEV_MODE: "true"
49
+ HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES: "true"
50
+ HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
51
+ ## uncomment next line to run console offline (i.e load console assets from server instead of CDN)
52
+ # HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets
53
+ ## uncomment next line to set an admin secret
54
+ # HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
55
+ volumes:
56
+ postgres_data:
@@ -0,0 +1,84 @@
1
+ import eslint from "@eslint/js";
2
+ import stylistic from "@stylistic/eslint-plugin";
3
+ import simpleImportSort from "eslint-plugin-simple-import-sort";
4
+ import tseslint from "typescript-eslint";
5
+ export default tseslint.config([
6
+ {
7
+ name: "app/files-to-lint",
8
+ files: ["**/*.{ts,mts,tsx,js,mjs}", "eslint.config.mjs"],
9
+ },
10
+ {
11
+ name: "app/files-to-ignore",
12
+ ignores: ["**/lib/**", "**/dist-ssr/**", "**/dist/**", "**/coverage/**"],
13
+ },
14
+ {
15
+ plugins: {
16
+ "@stylistic": stylistic,
17
+ },
18
+ },
19
+
20
+ eslint.configs.recommended,
21
+ tseslint.configs.recommended,
22
+ stylistic.configs.customize(),
23
+ {
24
+ rules: {
25
+ "@stylistic/array-element-newline": [
26
+ "error",
27
+ {
28
+ multiline: true,
29
+ },
30
+ ],
31
+ "@stylistic/array-bracket-newline": [
32
+ "error",
33
+ {
34
+ multiline: true,
35
+ },
36
+ ],
37
+ "@stylistic/object-curly-newline": ["error", "always"],
38
+ "@stylistic/object-curly-spacing": ["error", "always"],
39
+ "@stylistic/object-property-newline": "error",
40
+ "@stylistic/indent": ["error", 2],
41
+ "@stylistic/quote-props": ["error", "as-needed"],
42
+ "@stylistic/block-spacing": ["error", "always"],
43
+ "@stylistic/semi": ["error", "always"],
44
+ "@stylistic/quotes": ["error", "double"],
45
+ "@typescript-eslint/no-unused-vars": [
46
+ "error", // or "error"
47
+ {
48
+ argsIgnorePattern: "^_",
49
+ varsIgnorePattern: "^_",
50
+ caughtErrorsIgnorePattern: "^_",
51
+ },
52
+ ],
53
+ "max-lines": [
54
+ "warn",
55
+ {
56
+ max: 700,
57
+ skipBlankLines: true,
58
+ skipComments: true,
59
+ },
60
+ ],
61
+ "max-lines-per-function": [
62
+ "warn",
63
+ {
64
+ max: 350,
65
+ skipBlankLines: true,
66
+ skipComments: true,
67
+ },
68
+ ],
69
+ },
70
+ },
71
+ {
72
+ plugins: {
73
+ "simple-import-sort": simpleImportSort,
74
+ },
75
+ rules: {
76
+ "simple-import-sort/imports": "error",
77
+ "simple-import-sort/exports": "error",
78
+ },
79
+ },
80
+ {
81
+ ignores: ["node_modules/*", "dist/*"],
82
+ },
83
+ ],
84
+ );
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "{{PROJECT_NAME}}",
3
+ "version": "1.0.0",
4
+ "description": "{{DESCRIPTION}}",
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "tsc --noEmit && tsdown && {{PACKAGE_MANAGER}} run postbuild",
8
+ "postbuild": "copyfiles -u 1 \"src/**/*.sql\" dist",
9
+ "lint": "eslint src/**/*.ts",
10
+ "lint:fix": "eslint src/**/*.ts --fix",
11
+ "start": "node dist/index.js",
12
+ "dev": "tsx watch src/index.ts",
13
+ "docker:build": "docker build -t {{PROJECT_NAME}} .",
14
+ "docker:run": "docker run --env-file .env {{PROJECT_NAME}}",
15
+ "local-dev:start": "docker compose up -d",
16
+ "local-dev:stop": "docker compose down"
17
+ },
18
+ "bin": {
19
+ "{{PROJECT_NAME}}": "./dist/index.js"
20
+ },
21
+ "keywords": [
22
+ "cosmos",
23
+ "indexer",
24
+ "{{CHAIN_NAME}}",
25
+ "blockchain"
26
+ ],
27
+ "author": "",
28
+ "license": "ISC",
29
+ "dependencies": {
30
+ "@cosmjs/proto-signing": "^0.36.0",
31
+ "@cosmjs/stargate": "^0.36.0",
32
+ "@cosmjs/tendermint-rpc": "^0.36.0",
33
+ "@eclesia/basic-pg-indexer": "^2.9.1",
34
+ "@eclesia/core-modules-pg": "^2.9.1",
35
+ "@eclesia/indexer-engine": "^2.9.1",
36
+ "bignumber.js": "^9.3.1",
37
+ "json-with-bigint": "^3.4.4",
38
+ "pg": "^8.16.3"
39
+ },
40
+ "devDependencies": {
41
+ "@arethetypeswrong/core": "^0.18.2",
42
+ "@eslint/js": "^9.35.0",
43
+ "@stylistic/eslint-plugin": "^5.3.1",
44
+ "@types/json-bigint": "^1.0.4",
45
+ "@types/node": "^22.7.5",
46
+ "@types/pg": "^8.15.5",
47
+ "copyfiles": "^2.4.1",
48
+ "eslint": "^9.35.0",
49
+ "eslint-plugin-simple-import-sort": "^12.1.1",
50
+ "tsdown": "^0.15.2",
51
+ "tsx": "^4.19.1",
52
+ "typescript": "^5.9.2",
53
+ "typescript-eslint": "^8.44.0"
54
+ },
55
+ "main": "dist/index.cjs",
56
+ "module": "dist/index.js",
57
+ "types": "dist/index.d.cts",
58
+ "exports": {
59
+ ".": {
60
+ "import": {
61
+ "types": "./dist/index.d.ts",
62
+ "default": "./dist/index.js"
63
+ },
64
+ "require": "./dist/index.cjs",
65
+ "types": "./dist/index.d.ts",
66
+ "default": "./dist/index.js"
67
+ },
68
+ "./package.json": "./package.json"
69
+ }
70
+ }
@@ -0,0 +1,2 @@
1
+ onlyBuiltDependencies:
2
+ - esbuild
@@ -0,0 +1,49 @@
1
+ import {
2
+ defaultRegistryTypes,
3
+ } from "@cosmjs/stargate";
4
+ import {
5
+ PgIndexer, PgIndexerConfig,
6
+ } from "@eclesia/basic-pg-indexer";
7
+ {{MODULES_IMPORT}}
8
+
9
+ const config: PgIndexerConfig = {
10
+ startHeight: Number(process.env.START_HEIGHT) || {{START_HEIGHT}},
11
+ batchSize: Number(process.env.QUEUE_SIZE) || {{QUEUE_SIZE}},
12
+ modules: [],
13
+ rpcUrl: process.env.RPC_ENDPOINT || "{{RPC_ENDPOINT}}",
14
+ logLevel: process.env.LOG_LEVEL as PgIndexerConfig["logLevel"] ?? "debug",
15
+ usePolling: process.env.USE_POLLING == "true" || false,
16
+ pollingInterval: 3000,
17
+ processGenesis: process.env.PROCESS_GENESIS == "true" || false,
18
+ minimal: process.env.MINIMAL == "true" || false,
19
+ genesisPath: "./genesis.json",
20
+ dbConnectionString: process.env.PG_CONNECTION_STRING || "{{PG_CONNECTION_STRING}}",
21
+ };
22
+
23
+ // Initialize protocol registry
24
+ // You may need to import specific protocol registries for your chain
25
+ const registry = defaultRegistryTypes.concat([]); // Add your chain's proto registry here eg. defaultRegistryTypes.concat(myCustomRegistryTypes)
26
+
27
+ // Initialize modules
28
+ {{MODULES_INSTANTIATION}}
29
+
30
+ const indexer = new PgIndexer(config, {{MODULES_ARRAY}});
31
+
32
+ process.on("unhandledRejection", (reason, promise) => {
33
+ console.log("Unhandled Rejection at:", promise, "reason:", reason);
34
+ console.trace();
35
+ process.exit(1);
36
+ });
37
+
38
+ const run = async () => {
39
+ try {
40
+ await indexer.setup();
41
+ await indexer.run();
42
+ }
43
+ catch (error) {
44
+ console.error("Error running indexer:", error);
45
+ process.exit(1);
46
+ }
47
+ };
48
+
49
+ run();
@@ -0,0 +1,26 @@
1
+ {
2
+ "include": [
3
+ "src/**/*"
4
+ ],
5
+ "compilerOptions": {
6
+ "target": "es2020",
7
+ "module": "es2020",
8
+ "rootDir": "./src/",
9
+ "moduleResolution": "bundler",
10
+ "types": ["node"],
11
+ "resolveJsonModule": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "emitDeclarationOnly": false,
15
+ "outDir": "./dist/",
16
+ "allowSyntheticDefaultImports": false,
17
+ "esModuleInterop": true,
18
+ "forceConsistentCasingInFileNames": true,
19
+ "strict": true,
20
+ "skipLibCheck": true
21
+ },
22
+ "exclude": [
23
+ "src/**/*.test.ts",
24
+ "dist"
25
+ ]
26
+ }
@@ -0,0 +1,31 @@
1
+ import {
2
+ defineConfig,
3
+ } from "tsdown";
4
+
5
+ export default defineConfig([
6
+ {
7
+ entry: ["./src/index.ts"],
8
+ unbundle: true,
9
+ attw: true,
10
+ platform: "node",
11
+ nodeProtocol: "strip",
12
+ target: "es2020",
13
+ outDir: "./dist",
14
+ clean: true,
15
+ sourcemap: true,
16
+ dts: true,
17
+ format: ["cjs"],
18
+ },
19
+ {
20
+ entry: ["./src/index.ts"],
21
+ unbundle: true,
22
+ attw: true,
23
+ platform: "node",
24
+ target: "es2020",
25
+ outDir: "./dist",
26
+ clean: true,
27
+ sourcemap: true,
28
+ dts: true,
29
+ format: ["esm"],
30
+ },
31
+ ]);