File tree Expand file tree Collapse file tree 6 files changed +71
-0
lines changed Expand file tree Collapse file tree 6 files changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+ build /
2
+ generated /
3
+ node_modules /
4
+
5
+ package-lock.json
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "anonymous" : false ,
4
+ "inputs" : [],
5
+ "name" : " BlockDataSource" ,
6
+ "type" : " event"
7
+ }
8
+ ]
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " block-size-subgraph" ,
3
+ "license" : " MIT" ,
4
+ "scripts" : {
5
+ "codegen" : " graph codegen" ,
6
+ "build" : " graph build" ,
7
+ "create-local" : " graph create --node http://localhost:8020/ block-size-subgraph" ,
8
+ "remove-local" : " graph remove --node http://localhost:8020/ block-size-subgraph" ,
9
+ "deploy-local" : " graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001/ block-size-subgraph"
10
+ },
11
+ "devDependencies" : {
12
+ "@graphprotocol/graph-cli" : " 0.95.0" ,
13
+ "@graphprotocol/graph-ts" : " 0.37.0"
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ type BlockSize @entity (immutable : true ) {
2
+ id : ID !
3
+ number : BigInt !
4
+ size : BigInt !
5
+ }
Original file line number Diff line number Diff line change
1
+ import { ethereum , BigInt } from "@graphprotocol/graph-ts" ;
2
+ import { BlockSize } from "../generated/schema" ;
3
+
4
+ export function handleBlock ( block : ethereum . Block ) : void {
5
+ let blockSize = new BlockSize ( block . hash . toHex ( ) ) ;
6
+
7
+ blockSize . number = block . number ;
8
+ if ( block . size !== null ) {
9
+ blockSize . size = block . size ! ;
10
+ } else {
11
+ blockSize . size = BigInt . fromU64 ( 0 ) ;
12
+ }
13
+ blockSize . save ( ) ;
14
+ }
Original file line number Diff line number Diff line change
1
+ specVersion : 1.3.0
2
+ description : A subgraph that indexes the size of each block.
3
+ schema :
4
+ file : ./schema.graphql
5
+ dataSources :
6
+ - kind : ethereum
7
+ name : BlockDataSource
8
+ network : mainnet
9
+ source :
10
+ address : " 0x0000000000000000000000000000000000000000"
11
+ abi : BlockDataSource
12
+ startBlock : 10000000
13
+ mapping :
14
+ kind : ethereum/events
15
+ apiVersion : 0.0.7
16
+ language : wasm/assemblyscript
17
+ entities :
18
+ - BlockSize
19
+ abis :
20
+ - name : BlockDataSource
21
+ file : ./abis/BlockDataSource.json
22
+ blockHandlers :
23
+ - handler : handleBlock
24
+ file : ./src/mapping.ts
You can’t perform that action at this time.
0 commit comments