Skip to content

Commit 11d7515

Browse files
authored
chore: bring in graph-ts (#1037)
* chore: bring in graph-ts * ci test and lint fix * ci split up lint * fix lint issues * fix lint issues * fix test * prettier: * hopefully works now
1 parent c295d66 commit 11d7515

26 files changed

+4363
-15
lines changed

Diff for: .eslintrc.cjs

+17
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,21 @@ module.exports = {
1414
// TODO: not ready yet
1515
'unicorn/prefer-node-protocol': 'off',
1616
},
17+
overrides: [
18+
{
19+
files: ['packages/ts/**'],
20+
rules: {
21+
// TODO: want to avoid any structural change so fix it later
22+
'@typescript-eslint/no-namespace': 'off',
23+
// TODO: warning for now, clean up
24+
'unicorn/filename-case': 'warn',
25+
// TODO: warning for now, clean up
26+
'sonarjs/no-inverted-boolean-check': 'warn',
27+
// TODO: warning for now, clean up
28+
'@typescript-eslint/no-loss-of-precision': 'warn',
29+
// AssemblyScript types are different from TS and in cases we want to use what TS may think we should not
30+
'@typescript-eslint/ban-types': 'off',
31+
},
32+
},
33+
],
1734
};

Diff for: .github/workflows/ci.yml

+84-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,47 @@ on:
88
pull_request:
99

1010
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v3
17+
18+
- name: Install Node
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: 16
22+
23+
- name: Install pnpm
24+
uses: pnpm/[email protected]
25+
with:
26+
version: 7
27+
28+
- name: Get pnpm store path
29+
id: pnpm-store
30+
run: echo "PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
31+
32+
- name: Cache pnpm
33+
uses: actions/cache@v3
34+
with:
35+
path: ${{ steps.pnpm-store.outputs.PATH }}
36+
key:
37+
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{
38+
hashFiles('**/pnpm-lock.yaml') }}
39+
restore-keys: |
40+
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-
41+
42+
- name: Install Dependencies
43+
run: pnpm i
44+
45+
- name: Lint
46+
run: pnpm lint
47+
1148
cli:
1249
name: CLI / nodejs v${{ matrix.node-version }}
1350
runs-on: ubuntu-latest
51+
needs: [lint]
1452
strategy:
1553
fail-fast: false
1654
matrix:
@@ -52,9 +90,6 @@ jobs:
5290
- name: Install Dependencies
5391
run: pnpm i
5492

55-
- name: Lint
56-
run: pnpm lint
57-
5893
- name: Build Packages
5994
run: pnpm build # will also check types
6095

@@ -67,6 +102,7 @@ jobs:
67102

68103
event-handler:
69104
name: Basic Event Handlers
105+
needs: [lint]
70106
runs-on: ubuntu-latest
71107
steps:
72108
- name: Checkout Repository
@@ -108,3 +144,48 @@ jobs:
108144
timeout_minutes: 10
109145
max_attempts: 3
110146
command: pnpm run --filter="basic-event-handlers" test
147+
148+
ts:
149+
name: Graph TS
150+
needs: [lint]
151+
runs-on: ubuntu-latest
152+
steps:
153+
- name: Checkout Repository
154+
uses: actions/checkout@v3
155+
156+
- name: Install Node
157+
uses: actions/setup-node@v3
158+
with:
159+
node-version: 16
160+
161+
- name: Install pnpm
162+
uses: pnpm/[email protected]
163+
with:
164+
version: 7
165+
166+
- name: Get pnpm store path
167+
id: pnpm-store
168+
run: echo "PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
169+
170+
- name: Cache pnpm
171+
uses: actions/cache@v3
172+
with:
173+
path: ${{ steps.pnpm-store.outputs.PATH }}
174+
key:
175+
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{
176+
hashFiles('**/pnpm-lock.yaml') }}
177+
restore-keys: |
178+
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-
179+
180+
- name: Install Dependencies
181+
run: pnpm i
182+
183+
- name: Build Packages
184+
run: pnpm build # will also check types
185+
186+
- name: Run Tests
187+
uses: nick-fields/retry@v2
188+
with:
189+
timeout_minutes: 10
190+
max_attempts: 3
191+
command: pnpm run test:ts -- --forceExit

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
"pnpm": ">=7.14.2"
1515
},
1616
"scripts": {
17-
"build": "pnpm --filter=@graphprotocol/graph-cli build",
17+
"build": "pnpm --filter=@graphprotocol/graph-* build",
1818
"lint": "pnpm lint:prettier && pnpm lint:eslint",
1919
"lint:eslint": "eslint .",
2020
"lint:prettier": "prettier -c .",
2121
"release": "pnpm build && changeset publish",
2222
"test:cli": "pnpm --filter @graphprotocol/graph-cli test",
23+
"test:ts": "pnpm --filter @graphprotocol/graph-ts test",
2324
"type-check": "pnpm --filter=@graphprotocol/graph-cli type-check"
2425
},
2526
"devDependencies": {

Diff for: packages/ts/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# build files
2+
*.wasm

Diff for: packages/ts/chain/arweave.ts

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import '../common/eager_offset';
2+
import { Bytes } from '../common/collections';
3+
4+
// Most types from this namespace are direct mappings or adaptations from:
5+
// https://github.com/ChainSafe/firehose-arweave/blob/master/proto/sf/arweave/type/v1/type.proto
6+
export namespace arweave {
7+
/**
8+
* A key-value pair for arbitrary metadata
9+
*/
10+
export class Tag {
11+
constructor(public name: Bytes, public value: Bytes) {}
12+
}
13+
14+
export class ProofOfAccess {
15+
constructor(
16+
public option: string,
17+
public txPath: Bytes,
18+
public dataPath: Bytes,
19+
public chunk: Bytes,
20+
) {}
21+
}
22+
23+
/**
24+
* An Arweave block.
25+
*/
26+
export class Block {
27+
constructor(
28+
public timestamp: u64,
29+
public lastRetarget: u64,
30+
public height: u64,
31+
public indepHash: Bytes,
32+
public nonce: Bytes,
33+
public previousBlock: Bytes,
34+
public diff: Bytes,
35+
public hash: Bytes,
36+
public txRoot: Bytes,
37+
public txs: Bytes[],
38+
public walletList: Bytes,
39+
public rewardAddr: Bytes,
40+
public tags: Tag[],
41+
public rewardPool: Bytes,
42+
public weaveSize: Bytes,
43+
public blockSize: Bytes,
44+
public cumulativeDiff: Bytes,
45+
public hashListMerkle: Bytes,
46+
public poa: ProofOfAccess,
47+
) {}
48+
}
49+
50+
/**
51+
* An Arweave transaction
52+
*/
53+
export class Transaction {
54+
constructor(
55+
public format: u32,
56+
public id: Bytes,
57+
public lastTx: Bytes,
58+
public owner: Bytes,
59+
public tags: Tag[],
60+
public target: Bytes,
61+
public quantity: Bytes,
62+
public data: Bytes,
63+
public dataSize: Bytes,
64+
public dataRoot: Bytes,
65+
public signature: Bytes,
66+
public reward: Bytes,
67+
) {}
68+
}
69+
70+
/**
71+
* An Arweave transaction with block ptr
72+
*/
73+
export class TransactionWithBlockPtr {
74+
constructor(public tx: Transaction, public block: Block) {}
75+
}
76+
}

0 commit comments

Comments
 (0)