@@ -11,6 +11,7 @@ pub struct SubgraphInfo {
1111 pub deployment : SubgraphDeploymentID ,
1212 pub network : String ,
1313 pub features : Vec < String > ,
14+ pub min_block : u64 ,
1415}
1516
1617pub type SubgraphInfoMap =
@@ -74,21 +75,31 @@ pub async fn fetch_manifest(
7475 . map_err ( |err| ( deployment, err. to_string ( ) ) ) ?;
7576 let manifest = serde_yaml:: from_str :: < SubgraphManifest > ( & payload)
7677 . map_err ( |err| ( deployment, err. to_string ( ) ) ) ?;
78+ let min_block = manifest
79+ . data_sources
80+ . iter ( )
81+ . map ( |data_source| data_source. source . start_block . unwrap_or ( 0 ) )
82+ . min ( )
83+ . unwrap_or ( 0 ) ;
7784 // We are assuming that all `dataSource.network` fields are identical.
7885 // This is guaranteed for now.
7986 let network = manifest
8087 . data_sources
8188 . into_iter ( )
82- . filter_map ( |data_source| data_source. network )
89+ . map ( |data_source| data_source. network )
8390 . next ( )
8491 . ok_or_else ( || ( deployment, "Network not found" . to_string ( ) ) ) ?;
8592 Ok ( SubgraphInfo {
8693 deployment,
8794 network,
95+ min_block,
8896 features : manifest. features ,
8997 } )
9098}
9199
100+ // Subgraph manifest schema:
101+ // https://github.com/graphprotocol/graph-node/blob/master/docs/subgraph-manifest.md
102+
92103#[ derive( Deserialize ) ]
93104#[ serde( rename_all = "camelCase" ) ]
94105pub struct SubgraphManifest {
@@ -98,6 +109,14 @@ pub struct SubgraphManifest {
98109}
99110
100111#[ derive( Deserialize ) ]
112+ #[ serde( rename_all = "camelCase" ) ]
101113pub struct DataSource {
102- pub network : Option < String > ,
114+ pub network : String ,
115+ pub source : EthereumContractSource ,
116+ }
117+
118+ #[ derive( Deserialize ) ]
119+ #[ serde( rename_all = "camelCase" ) ]
120+ pub struct EthereumContractSource {
121+ pub start_block : Option < u64 > ,
103122}
0 commit comments