Skip to content

Commit a76933c

Browse files
authored
Merge pull request #28 from turadg/ta/ci
set up CI with linting
2 parents 6d29d5d + 43a967e commit a76933c

File tree

11 files changed

+10894
-126
lines changed

11 files changed

+10894
-126
lines changed

.github/workflows/pr.yaml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,50 @@
11
name: PR
2-
# on:
3-
# pull_request:
4-
# paths-ignore:
5-
# - ".github/workflows/**"
2+
on:
3+
pull_request:
4+
65
jobs:
76
pr:
8-
name: pr
97
runs-on: ubuntu-latest
8+
services:
9+
postgres:
10+
image: postgres:16-alpine
11+
ports:
12+
- 5432:5432
13+
env:
14+
POSTGRES_PASSWORD: postgres
15+
options: >-
16+
--health-cmd pg_isready
17+
--health-interval 10s
18+
--health-timeout 5s
19+
--health-retries 5
20+
env:
21+
DB_USER: postgres
22+
DB_PASS: postgres
23+
DB_DATABASE: postgres
24+
DB_HOST: localhost
25+
DB_PORT: 5432
1026
steps:
11-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
28+
# Before setup-node because that action runs `yarn cache dir`. See https://github.com/actions/setup-node/issues/480#issuecomment-1915448139
29+
- run: corepack enable
30+
shell: bash
1231
- name: Setup Node.js environment
13-
uses: actions/setup-node@v2
32+
uses: actions/setup-node@v4
1433
with:
1534
node-version: 18
16-
- run: yarn
35+
cache: yarn
36+
- run: yarn install
37+
- run: yarn prettier:check
1738
- name: Codegen
1839
run: yarn codegen
40+
# After codegen because that makes src/types/
41+
- run: yarn tsc
1942
- name: Build
2043
run: yarn build
21-
- name: Install subql-node-cosmos
22-
run: yarn global add @subql/node-cosmos
23-
- name: Run tests with Subquery Node
24-
run: subql-node-cosmos test -f ${{ github.workspace }}
44+
# TODO: https://github.com/Agoric/agoric-subql/issues/8
45+
- name: Enable btree btree_gist
46+
run: psql "postgresql://$DB_USER:$DB_PASS@$DB_HOST:$DB_PORT/$DB_DATABASE" -c "CREATE EXTENSION IF NOT EXISTS btree_gist;"
47+
# - name: Install subql-node-cosmos
48+
# run: yarn global add @subql/node-cosmos
49+
# - name: Run tests with Subquery Node
50+
# run: subql-node-cosmos test -f ${{ github.workspace }}

.gitignore

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
node_modules/
88
dist/
99

10-
# lock files
11-
yarn.lock
12-
package-lock.json
13-
1410
# Compiled Java class files
1511
*.class
1612

@@ -55,6 +51,14 @@ Thumbs.db
5551
*.wmv
5652

5753
.data
58-
.yarn
5954

6055
.DS_Store
56+
57+
# Yarn (https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored)
58+
.pnp.*
59+
.yarn/*
60+
!.yarn/patches
61+
!.yarn/plugins
62+
!.yarn/releases
63+
!.yarn/sdks
64+
!.yarn/versions

.yarnrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# UNTIL https://github.com/subquery/subql/issues/2621 is fixed
2+
nodeLinker: node-modules

docker-compose.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3"
1+
version: '3'
22

33
services:
44
postgres:
@@ -12,15 +12,15 @@ services:
1212
environment:
1313
POSTGRES_PASSWORD: postgres
1414
healthcheck:
15-
test: ["CMD-SHELL", "pg_isready -U postgres"]
15+
test: ['CMD-SHELL', 'pg_isready -U postgres']
1616
interval: 5s
1717
timeout: 5s
1818
retries: 5
1919

2020
subquery-node:
2121
image: subquerynetwork/subql-node-cosmos:latest
2222
depends_on:
23-
"postgres":
23+
'postgres':
2424
condition: service_healthy
2525
restart: always
2626
environment:
@@ -40,7 +40,7 @@ services:
4040
# - --log-level=debug
4141
# - --unfinalized-blocks=true
4242
healthcheck:
43-
test: ["CMD", "curl", "-f", "http://subquery-node:3000/ready"]
43+
test: ['CMD', 'curl', '-f', 'http://subquery-node:3000/ready']
4444
interval: 3s
4545
timeout: 5s
4646
retries: 10
@@ -50,9 +50,9 @@ services:
5050
ports:
5151
- 3000:3000
5252
depends_on:
53-
"postgres":
53+
'postgres':
5454
condition: service_healthy
55-
"subquery-node":
55+
'subquery-node':
5656
condition: service_healthy
5757
restart: always
5858
environment:

package.json

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,45 @@
11
{
2-
"name": "agoric-starter",
2+
"name": "agoric-indexer",
33
"version": "0.0.1",
4-
"description": "This project can be use as a starting point for developing your Agoric based SubQuery project",
4+
"description": "This is the SubQuery project for indexing the Agoric chain",
55
"main": "dist/index.js",
66
"scripts": {
77
"build": "subql build",
8-
"pub": "subql publish",
98
"codegen": "subql codegen",
109
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
1110
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
1211
"prepack": "rm -rf dist && npm run build",
13-
"test": "jest",
14-
"subql": "subql codegen --help",
12+
"test": "subql build && subql-node-cosmos test",
1513
"prettier:check": "prettier --list-different . --print-width 120",
1614
"prettier:write": "prettier --write . --print-width 120"
1715
},
18-
"homepage": "https://github.com/subquery/cosmos-subql-starter",
19-
"repository": "github:subquery/cosmos-subql-starter",
16+
"homepage": "https://github.com/Agoric/agoric-subql",
17+
"repository": "github:Agoric/agoric-subql",
2018
"files": [
2119
"dist",
2220
"schema.graphql",
2321
"project.yaml"
2422
],
25-
"jest": {
26-
"preset": "ts-jest",
27-
"testEnvironment": "node",
28-
"modulePathIgnorePatterns": [
29-
"/dist/"
30-
]
31-
},
32-
"author": "SubQuery Team",
33-
"license": "MIT",
23+
"author": "Agoric OpCo",
24+
"license": "Apache-2.0",
3425
"devDependencies": {
35-
"@babel/preset-typescript": "^7.23.2",
3626
"@cosmjs/stargate": "^0.28.9",
37-
"@subql/cli": "^4.2.6",
38-
"@subql/node-cosmos": "^3.9.2",
27+
"@subql/cli": "^5.3.3",
28+
"@subql/node-cosmos": "^4.2.1",
3929
"@subql/testing": "latest",
40-
"@types/jest": "^29.5.7",
41-
"jest": "^29.7.0",
42-
"prettier": "^3.2.5",
43-
"ts-jest": "^29.1.2",
44-
"typescript": "^5.2.2"
30+
"prettier": "^3.4.2",
31+
"starknet": "6.11.0",
32+
"typescript": "^5.7.2"
4533
},
4634
"dependencies": {
47-
"@subql/types-cosmos": "^3.2.3",
35+
"@subql/types-cosmos": "^4.0.0",
36+
"@subql/utils": "^2.16.0",
4837
"@types/node": "^17.0.21",
4938
"bech32": "^2.0.0",
5039
"js-sha256": "^0.11.0",
5140
"pino": "^7.8.0",
5241
"ts-proto": "^1.112.1",
5342
"tslib": "^2.3.1"
54-
}
43+
},
44+
"packageManager": "yarn@4.5.3"
5545
}

project.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
import { CosmosDatasourceKind, CosmosHandlerKind, CosmosProject } from "@subql/types-cosmos";
1+
import { CosmosDatasourceKind, CosmosHandlerKind, CosmosProject } from '@subql/types-cosmos';
22

33
// Can expand the Datasource processor types via the genreic param
44
const project: CosmosProject = {
5-
specVersion: "1.0.0",
6-
version: "0.0.1",
7-
name: "agoric-starter",
8-
description: "This project can be use as a starting point for developing your Cosmos agoric based SubQuery project",
5+
specVersion: '1.0.0',
6+
version: '0.0.1',
7+
name: 'agoric-starter',
8+
description: 'This project can be use as a starting point for developing your Cosmos agoric based SubQuery project',
99
runner: {
1010
node: {
11-
name: "@subql/node-cosmos",
12-
version: ">=3.0.0",
11+
name: '@subql/node-cosmos',
12+
version: '>=3.0.0',
1313
},
1414
query: {
15-
name: "@subql/query",
16-
version: "*",
15+
name: '@subql/query',
16+
version: '*',
1717
},
1818
},
1919
schema: {
20-
file: "./schema.graphql",
20+
file: './schema.graphql',
2121
},
2222
network: {
2323
// chainId: "agoriclocal",
2424
// endpoint: ["http://host.docker.internal:26657/"],
25-
chainId: "agoric-3",
26-
endpoint: ["https://main-a.rpc.agoric.net:443"],
25+
chainId: 'agoric-3',
26+
endpoint: ['https://main-a.rpc.agoric.net:443'],
2727

2828
chaintypes: new Map([
2929
[
30-
"cosmos.slashing.v1beta1",
30+
'cosmos.slashing.v1beta1',
3131
{
32-
file: "./proto/cosmos/slashing/v1beta1/tx.proto",
33-
messages: ["MsgUnjail"],
32+
file: './proto/cosmos/slashing/v1beta1/tx.proto',
33+
messages: ['MsgUnjail'],
3434
},
3535
],
3636
[
37-
"cosmos.gov.v1beta1",
37+
'cosmos.gov.v1beta1',
3838
{
39-
file: "./proto/cosmos/gov/v1beta1/tx.proto",
40-
messages: ["MsgVoteWeighted"],
39+
file: './proto/cosmos/gov/v1beta1/tx.proto',
40+
messages: ['MsgVoteWeighted'],
4141
},
4242
],
4343
[
44-
"cosmos.gov.v1beta1.gov",
44+
'cosmos.gov.v1beta1.gov',
4545
{
46-
file: "./proto/cosmos/gov/v1beta1/gov.proto",
47-
messages: ["WeightedVoteOption"],
46+
file: './proto/cosmos/gov/v1beta1/gov.proto',
47+
messages: ['WeightedVoteOption'],
4848
},
49-
],
49+
],
5050
[
51-
"/agoric.swingset.MsgInstallBundle",
51+
'/agoric.swingset.MsgInstallBundle',
5252
{
53-
file: "./proto/agoric/swingset/msgs.proto",
54-
messages: ["MsgInstallBundle"],
53+
file: './proto/agoric/swingset/msgs.proto',
54+
messages: ['MsgInstallBundle'],
5555
},
5656
],
5757
]),
@@ -69,7 +69,7 @@ const project: CosmosProject = {
6969
startBlock: 7179262,
7070

7171
mapping: {
72-
file: "./dist/index.js",
72+
file: './dist/index.js',
7373
handlers: [
7474
// {
7575
// Using block handlers slows your project down as they can be executed with each and every block.
@@ -108,10 +108,10 @@ const project: CosmosProject = {
108108
// },
109109
// },
110110
{
111-
handler: "handleStateChangeEvent",
111+
handler: 'handleStateChangeEvent',
112112
kind: CosmosHandlerKind.Event,
113113
filter: {
114-
type: "state_change",
114+
type: 'state_change',
115115
},
116116
},
117117
{

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
//Exports all handler functions
2-
export * from "./mappings/mappingHandlers";
2+
export * from './mappings/mappingHandlers';

src/mappings/mappingHandlers.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import type { tendermint37 } from '@cosmjs/tendermint-rpc';
12
import { StateChangeEvent, IBCChannel, IBCTransfer, TransferType, BundleInstall } from '../types';
2-
import { CosmosEvent, CosmosMessage } from '@subql/types-cosmos';
3+
import { CosmosEvent, CosmosMessage, type CosmosBlock } from '@subql/types-cosmos';
34
import {
45
b64decode,
56
extractStoragePath,
@@ -44,7 +45,7 @@ async function saveIbcChannel(channelName: string) {
4445
}
4546

4647
export async function handleIbcSendPacketEvent(cosmosEvent: CosmosEvent): Promise<void> {
47-
const { event, block, tx } = cosmosEvent;
48+
const { event, block, tx } = cosmosEvent as CosmosEvent & { event: tendermint37.Event };
4849
if (event.type != EVENT_TYPES.SEND_PACKET) {
4950
logger.warn('Not valid send_packet event.');
5051
return;
@@ -86,7 +87,7 @@ export async function handleIbcSendPacketEvent(cosmosEvent: CosmosEvent): Promis
8687
}
8788

8889
export async function handleIbcReceivePacketEvent(cosmosEvent: CosmosEvent): Promise<void> {
89-
const { event, block, tx } = cosmosEvent;
90+
const { event, block, tx } = cosmosEvent as CosmosEvent & { event: tendermint37.Event };
9091
if (event.type != EVENT_TYPES.RECEIVE_PACKET) {
9192
logger.warn('Not valid recv_packet event.');
9293
return;
@@ -153,7 +154,7 @@ export async function handleBundleInstallMessage(message: CosmosMessage): Promis
153154
}
154155

155156
export async function handleStateChangeEvent(cosmosEvent: CosmosEvent): Promise<void> {
156-
const { event, block } = cosmosEvent;
157+
const { event, block } = cosmosEvent as CosmosEvent & { event: tendermint37.Event };
157158

158159
if (event.type != EVENT_TYPES.STATE_CHANGE) {
159160
logger.warn('Not valid state_change event.');

0 commit comments

Comments
 (0)