Skip to content

Commit 6a7ba52

Browse files
authored
Merge pull request #221 from threefoldtech/master-standardize-npm
chore: standardize on npm, remove yarn.lock
2 parents be49aed + 358881f commit 6a7ba52

9 files changed

Lines changed: 1596 additions & 28394 deletions

File tree

.github/workflows/CI.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ jobs:
1414
uses: actions/setup-node@v3
1515
with:
1616
node-version: 20
17-
cache: "yarn"
18-
cache-dependency-path: "**/yarn.lock"
17+
cache: "npm"
1918
- name: Install dependencies
20-
run: yarn install
19+
run: npm ci
2120
- name: Build
22-
run: yarn build
21+
run: npm run build

LICENSE

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
1-
Apache License
2-
Version 2.0, January 2004
3-
http://www.apache.org/licenses/
1+
The software contained in this repository and all rights, title, and interest
2+
3+
Copyright © TF TECH NV
4+
Belgian Enterprise Number: BE 0712.845.674
5+
6+
Authored and maintained by TF TECH NV.
7+
8+
TF TECH NV retains ownership of its contributions to this software.
9+
10+
11+
This software is Licensed under the Apache License, Version 2.0 (the "License");
12+
you may not use this file except in compliance with the License.
13+
You may obtain a copy of the License at
14+
15+
http://www.apache.org/licenses/LICENSE-2.0
16+
17+
Unless required by applicable law or agreed to in writing, software
18+
distributed under the License is distributed on an "AS IS" BASIS,
19+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
See the License for the specific language governing permissions and
21+
limitations under the License.
22+
423

524
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
625

@@ -175,27 +194,3 @@
175194

176195
END OF TERMS AND CONDITIONS
177196

178-
APPENDIX: How to apply the Apache License to your work.
179-
180-
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
182-
replaced with your own identifying information. (Don't include
183-
the brackets!) The text should be enclosed in the appropriate
184-
comment syntax for the file format. We also recommend that a
185-
file or class name and description of purpose be included on the
186-
same "printed page" as the copyright notice for easier
187-
identification within third-party archives.
188-
189-
Copyright TF TECH NV (Belgium)
190-
191-
Licensed under the Apache License, Version 2.0 (the "License");
192-
you may not use this file except in compliance with the License.
193-
You may obtain a copy of the License at
194-
195-
http://www.apache.org/licenses/LICENSE-2.0
196-
197-
Unless required by applicable law or agreed to in writing, software
198-
distributed under the License is distributed on an "AS IS" BASIS,
199-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200-
See the License for the specific language governing permissions and
201-
limitations under the License.

README.md

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,73 @@
1-
# TFChain GraphQL
1+
# Ledger GraphQL
22

3-
[Subsquid](https://docs.subsquid.io) is used to index and provide a GraphQL interface on top of TFChain.
3+
A high-performance indexing layer with a queryable GraphQL API over Ledger Chain on-chain data. It enables efficient data access for dashboards, applications, and analytics tools without directly querying the blockchain.
44

5-
## Concept
5+
## What this is
66

7-
The substrate events are processed in a multi-step pipeline:
7+
This project provides a [Subsquid](https://docs.subsquid.io)-based indexer that consumes raw blockchain events from Ledger Chain, transforms them into a structured schema, and exposes them through a GraphQL endpoint. It replaces direct chain queries with a fast, developer-friendly API suitable for front-end applications and data analytics.
88

9-
TFChain => Squid Indexer => Indexer GraphQL gateway => Squid Processor => Database => Query Node GraphQL endpoint
9+
## What this repository contains
1010

11-
![Bird eye overview](https://gblobscdn.gitbook.com/assets%2F-MdI-MAyz-csivC8mmdb%2Fsync%2Fe587479ff22ad79886861487b2734b6556302d10.png?alt=media)
11+
- **Indexer** — Docker Compose setup for the Squid indexer that ingests on-chain events
12+
- **Processor** — Event processing pipeline that maps raw chain data to database models
13+
- **GraphQL schema**`schema.graphql` defining the queryable data model
14+
- **Database migrations** — Migration files for the processor database
15+
- **Type definitions** — Chain-specific type files for decoding events
16+
- **Mapping functions** — Logic for transforming events into indexed entities
17+
- **Scripts** — Utility scripts for generating initial state and development workflows
18+
19+
## Role in the stack
20+
21+
The indexer sits between the blockchain and consumer applications. It decouples data access from the chain, allowing complex queries, aggregations, and historical lookups that would be inefficient or impossible via direct RPC calls. Dashboards, explorers, and third-party integrations rely on this layer for real-time and historical data.
22+
23+
The data pipeline is:
24+
25+
```
26+
Ledger Chain => Squid Indexer => Indexer GraphQL gateway => Squid Processor => Database => Query Node GraphQL endpoint
27+
```
28+
29+
## Relation to ThreeFold
30+
31+
This technology is used within the ThreeFold ecosystem and was first deployed on the ThreeFold Grid. The component itself is designed as reusable infrastructure technology and should be understood by its technical function first, independent of any specific deployment.
32+
33+
## Ownership
34+
35+
This repository is owned and maintained by TF-Tech NV, a Belgian company responsible for the development and maintenance of this technology.
1236

1337
## Prerequisites
1438

15-
* Node v20+
16-
* Docker
17-
* Docker Compose
39+
- Node v20+
40+
- Docker
41+
- Docker Compose
1842

1943
## Running
2044

21-
See [docs](./docs/readme.md)
45+
See [docs](./docs/readme.md) for detailed running instructions.
2246

2347
## Project layout
2448

25-
- `indexer/` - Docker Compose setup for the indexer (archive)
26-
- `db/` - Processor database migration files
27-
- `scripts/` - Utility scripts (see [scripts/readme.md](./scripts/readme.md))
28-
- `src/` - Processor source code
29-
- `mappings/` - Event handler functions that map chain events to database entities
30-
- `model/` - Generated TypeORM models from `schema.graphql`
31-
- `types/` - Auto-generated type definitions (do not edit manually — run `make typegen`)
32-
- `processor.ts` - Processor entrypoint: event subscription and dispatch
33-
- `typegen/` - Type generation infrastructure
34-
- `tfchainVersions.jsonl` - Append-only log of runtime metadata from all TFChain networks
35-
- `typegen.json` - Typegen config: which events to generate types for
36-
- `typesBundle.json` - Frozen pre-V14 type mappings (do not edit for new runtime versions)
37-
- `docs/` - Documentation
38-
- [typeChanges.md](./docs/typeChanges.md) - How to handle type changes on chain (adding new runtime versions, resync guidance)
39-
- [development.md](./docs/development.md) - Local development setup
40-
- [production.md](./docs/production.md) - Production deployment
41-
- [release_process.md](./docs/release_process.md) - Release workflow
42-
- `schema.graphql` - GraphQL schema — changes here regenerate `src/model/` via `yarn codegen`
43-
- `Makefile` - Common tasks: `typegen`, `typegen-add`, `typegen-seed`, `version-bump`
44-
- `processor-chart/` - Helm chart for processor + query node deployment
45-
- `indexer/chart/` - Helm chart for indexer stack deployment
49+
- `indexer/` — Docker Compose setup for the indexer (archive)
50+
- `db/` — Processor database migration files
51+
- `scripts/` — Utility scripts (see [scripts/readme.md](./scripts/readme.md))
52+
- `src/` — Processor source code
53+
- `mappings/` — Event handler functions that map chain events to database entities
54+
- `model/` — Generated TypeORM models from `schema.graphql`
55+
- `types/` — Auto-generated type definitions (do not edit manually — run `make typegen`)
56+
- `processor.ts` — Processor entrypoint: event subscription and dispatch
57+
- `typegen/` — Type generation infrastructure
58+
- `tfchainVersions.jsonl` — Append-only log of runtime metadata from all Ledger Chain networks
59+
- `typegen.json` — Typegen config: which events to generate types for
60+
- `typesBundle.json` — Frozen pre-V14 type mappings (do not edit for new runtime versions)
61+
- `docs/` — Documentation
62+
- [typeChanges.md](./docs/typeChanges.md) — How to handle type changes on chain (adding new runtime versions, resync guidance)
63+
- [development.md](./docs/development.md) — Local development setup
64+
- [production.md](./docs/production.md) — Production deployment
65+
- [release_process.md](./docs/release_process.md) — Release workflow
66+
- `schema.graphql` — GraphQL schema — changes here regenerate `src/model/` via `npm run codegen`
67+
- `Makefile` — Common tasks: `typegen`, `typegen-add`, `typegen-seed`, `version-bump`
68+
- `processor-chart/` — Helm chart for processor + query node deployment
69+
- `indexer/chart/` — Helm chart for indexer stack deployment
70+
71+
## License
72+
73+
This project is licensed under the Apache License 2.0 — see the [LICENSE](LICENSE) file for details.

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
- TYPEORM_LOGGING=error
3333
ports:
3434
- 44233:44233
35-
command: ["yarn", "process"]
35+
command: ["npm", "run", "process"]
3636

3737
query-node:
3838
image: ghcr.io/threefoldtech/tfchain_graphql_query-node:latest

docs/development.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
## Install
44

55
```bash
6-
yarn
7-
yarn build
6+
npm install
7+
npm run build
88
```
99

1010
## Local Network
@@ -55,9 +55,9 @@ INDEXER_ENDPOINT_URL=http://localhost:8888/graphql
5555
Start the local PostgreSQL container and run the processor:
5656

5757
```bash
58-
yarn build
59-
yarn db:up
60-
yarn process
58+
npm run build
59+
npm run db:up
60+
npm run process
6161
```
6262

6363
You should see TFChain blocks being processed by the processor:
@@ -79,7 +79,7 @@ At this step, running `docker ps` should show the indexer containers running:
7979
Start the query node:
8080

8181
```bash
82-
yarn api
82+
npm run api
8383
```
8484

8585
Now you can use the GraphQL playground at http://localhost:4000/graphql
@@ -93,7 +93,7 @@ When TFChain has a new spec version with type changes, see [typeChanges.md](./ty
9393
make typegen-add
9494

9595
# Check what changed in src/types/, add handler branches if needed
96-
yarn build
96+
npm run build
9797
```
9898

9999
## Modifying the GraphQL Schema
@@ -103,17 +103,17 @@ If you need to add new entities or fields to the GraphQL API:
103103
1. Edit `schema.graphql`
104104
2. Regenerate models and create a migration:
105105
```bash
106-
yarn codegen
107-
yarn build
108-
yarn db:create-migration
106+
npm run codegen
107+
npm run build
108+
npm run db:create-migration
109109
```
110110
3. Add or update event handlers in `src/mappings/`
111111
4. Register new events in `src/processor.ts` if needed
112112
5. Test locally:
113113
```bash
114-
yarn db:up
115-
yarn db:migrate
116-
yarn process
114+
npm run db:up
115+
npm run db:migrate
116+
npm run process
117117
```
118118

119119
## Resetting the Processor Database
@@ -137,7 +137,7 @@ docker compose up -d
137137

138138
```bash
139139
./scripts/reset-db.sh
140-
yarn process
140+
npm run process
141141
```
142142

143143
## Debugging

0 commit comments

Comments
 (0)