11use crate :: blockchain:: SubgraphFilter ;
2- use crate :: data:: store:: scalar;
32use crate :: data_source:: subgraph;
43use crate :: substreams:: Clock ;
54use crate :: substreams_rpc:: response:: Message as SubstreamsMessage ;
@@ -428,16 +427,20 @@ impl<C: Blockchain> TriggersAdapterWrapper<C> {
428427 . into_iter ( )
429428 . map ( |block| {
430429 let key = block. number ( ) ;
431- let entity = match entities. get ( & key) {
432- Some ( e) => e,
433- None => & Self :: create_mock_entity ( & block) ,
434- } ;
435- let trigger_data = vec ! [ Self :: create_subgraph_trigger_from_entity(
436- first_filter,
437- entity,
438- ) ] ;
439- BlockWithTriggers :: new_with_subgraph_triggers ( block, trigger_data, & logger2)
430+ match entities. get ( & key) {
431+ Some ( e) => {
432+ let trigger_data =
433+ vec ! [ Self :: create_subgraph_trigger_from_entity( first_filter, e) ] ;
434+ Some ( BlockWithTriggers :: new_with_subgraph_triggers (
435+ block,
436+ trigger_data,
437+ & logger2,
438+ ) )
439+ }
440+ None => None ,
441+ }
440442 } )
443+ . flatten ( )
441444 . collect ( ) ;
442445
443446 Ok ( ( blocks, to) )
@@ -453,30 +456,6 @@ impl<C: Blockchain> TriggersAdapterWrapper<C> {
453456 entity_type : filter. entities . first ( ) . unwrap ( ) . clone ( ) ,
454457 }
455458 }
456-
457- fn create_mock_entity ( block : & C :: Block ) -> Entity {
458- let id = DeploymentHash :: new ( "test" ) . unwrap ( ) ;
459- let data_schema = InputSchema :: parse_latest (
460- "type Block @entity { id: Bytes!, number: BigInt!, hash: Bytes! }" ,
461- id. clone ( ) ,
462- )
463- . unwrap ( ) ;
464-
465- let block = block. ptr ( ) ;
466- let hash = Value :: Bytes ( scalar:: Bytes :: from ( block. hash_slice ( ) . to_vec ( ) ) ) ;
467- let data = data_schema
468- . make_entity ( vec ! [
469- ( "id" . into( ) , hash. clone( ) ) ,
470- (
471- "number" . into( ) ,
472- Value :: BigInt ( scalar:: BigInt :: from( block. block_number( ) ) ) ,
473- ) ,
474- ( "hash" . into( ) , hash) ,
475- ] )
476- . unwrap ( ) ;
477-
478- data
479- }
480459}
481460
482461#[ async_trait]
0 commit comments