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 ;
@@ -425,16 +424,20 @@ impl<C: Blockchain> TriggersAdapterWrapper<C> {
425424 . into_iter ( )
426425 . map ( |block| {
427426 let key = block. number ( ) ;
428- let entity = match entities. get ( & key) {
429- Some ( e) => e,
430- None => & Self :: create_mock_entity ( & block) ,
431- } ;
432- let trigger_data = vec ! [ Self :: create_subgraph_trigger_from_entity(
433- first_filter,
434- entity,
435- ) ] ;
436- BlockWithTriggers :: new_with_subgraph_triggers ( block, trigger_data, & logger2)
427+ match entities. get ( & key) {
428+ Some ( e) => {
429+ let trigger_data =
430+ vec ! [ Self :: create_subgraph_trigger_from_entity( first_filter, e) ] ;
431+ Some ( BlockWithTriggers :: new_with_subgraph_triggers (
432+ block,
433+ trigger_data,
434+ & logger2,
435+ ) )
436+ }
437+ None => None ,
438+ }
437439 } )
440+ . flatten ( )
438441 . collect ( ) ;
439442
440443 Ok ( ( blocks, to) )
@@ -450,30 +453,6 @@ impl<C: Blockchain> TriggersAdapterWrapper<C> {
450453 entity_type : filter. entities . first ( ) . unwrap ( ) . clone ( ) ,
451454 }
452455 }
453-
454- fn create_mock_entity ( block : & C :: Block ) -> Entity {
455- let id = DeploymentHash :: new ( "test" ) . unwrap ( ) ;
456- let data_schema = InputSchema :: parse_latest (
457- "type Block @entity { id: Bytes!, number: BigInt!, hash: Bytes! }" ,
458- id. clone ( ) ,
459- )
460- . unwrap ( ) ;
461-
462- let block = block. ptr ( ) ;
463- let hash = Value :: Bytes ( scalar:: Bytes :: from ( block. hash_slice ( ) . to_vec ( ) ) ) ;
464- let data = data_schema
465- . make_entity ( vec ! [
466- ( "id" . into( ) , hash. clone( ) ) ,
467- (
468- "number" . into( ) ,
469- Value :: BigInt ( scalar:: BigInt :: from( block. block_number( ) ) ) ,
470- ) ,
471- ( "hash" . into( ) , hash) ,
472- ] )
473- . unwrap ( ) ;
474-
475- data
476- }
477456}
478457
479458#[ async_trait]
0 commit comments