File tree Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,9 @@ type Block2 @entity(immutable: true) {
10
10
hash : Bytes !
11
11
testMessage : String
12
12
}
13
+
14
+ type Block3 @entity (immutable : true ) {
15
+ id : Bytes !
16
+ number : BigInt !
17
+ testMessage : String
18
+ }
Original file line number Diff line number Diff line change 1
1
import { ethereum , log , store } from '@graphprotocol/graph-ts' ;
2
- import { Block , Block2 } from '../generated/schema' ;
2
+ import { Block , Block2 , Block3 } from '../generated/schema' ;
3
3
4
4
export function handleBlock ( block : ethereum . Block ) : void {
5
5
log . info ( 'handleBlock {}' , [ block . number . toString ( ) ] ) ;
@@ -22,4 +22,10 @@ export function handleBlock(block: ethereum.Block): void {
22
22
blockEntity3 . hash = block . hash ;
23
23
blockEntity3 . testMessage = block . number . toString ( ) . concat ( '-message' ) ;
24
24
blockEntity3 . save ( ) ;
25
+
26
+ let id4 = block . hash ;
27
+ let blockEntity4 = new Block3 ( id4 ) ;
28
+ blockEntity4 . number = block . number ;
29
+ blockEntity4 . testMessage = block . number . toString ( ) . concat ( '-message' ) ;
30
+ blockEntity4 . save ( ) ;
25
31
}
Original file line number Diff line number Diff line change @@ -4,3 +4,9 @@ type MirrorBlock @entity {
4
4
hash : Bytes !
5
5
testMessage : String
6
6
}
7
+
8
+ type MirrorBlockBytes @entity {
9
+ id : Bytes !
10
+ number : BigInt !
11
+ testMessage : String
12
+ }
Original file line number Diff line number Diff line change 1
1
import { log , store } from '@graphprotocol/graph-ts' ;
2
- import { Block , Block2 } from '../generated/subgraph-QmWi3H11QFE2PiWx6WcQkZYZdA5UasaBptUJqGn54MFux5 ' ;
3
- import { MirrorBlock } from '../generated/schema' ;
2
+ import { Block , Block2 , Block3 } from '../generated/subgraph-QmRWTEejPDDwALaquFGm6X2GBbbh5osYDXwCRRkoZ6KQhb ' ;
3
+ import { MirrorBlock , MirrorBlockBytes } from '../generated/schema' ;
4
4
5
5
export function handleEntity ( block : Block ) : void {
6
6
let id = block . id ;
@@ -23,6 +23,16 @@ export function handleEntity2(block: Block2): void {
23
23
blockEntity . save ( ) ;
24
24
}
25
25
26
+ export function handleEntity3 ( block : Block3 ) : void {
27
+ let id = block . id ;
28
+
29
+ let blockEntity = new MirrorBlockBytes ( id ) ;
30
+ blockEntity . number = block . number ;
31
+ blockEntity . testMessage = block . testMessage ;
32
+
33
+ blockEntity . save ( ) ;
34
+ }
35
+
26
36
export function loadOrCreateMirrorBlock ( id : string ) : MirrorBlock {
27
37
let block = MirrorBlock . load ( id ) ;
28
38
if ( ! block ) {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ dataSources:
6
6
name : Contract
7
7
network : test
8
8
source :
9
- address : ' QmWi3H11QFE2PiWx6WcQkZYZdA5UasaBptUJqGn54MFux5 '
9
+ address : ' QmRWTEejPDDwALaquFGm6X2GBbbh5osYDXwCRRkoZ6KQhb '
10
10
startBlock : 0
11
11
mapping :
12
12
apiVersion : 0.0.7
@@ -18,4 +18,6 @@ dataSources:
18
18
entity : Block
19
19
- handler : handleEntity2
20
20
entity : Block2
21
+ - handler : handleEntity3
22
+ entity : Block3
21
23
file : ./src/mapping.ts
You can’t perform that action at this time.
0 commit comments