@@ -6,19 +6,29 @@ use crate::{
66 subgraph:: InstanceDSTemplateInfo ,
77 } ,
88 data:: subgraph:: UnifiedMappingApiVersion ,
9- prelude:: { BlockHash , DataSourceTemplateInfo } ,
9+ prelude:: {
10+ transaction_receipt:: LightTransactionReceipt , BlockHash , ChainStore ,
11+ DataSourceTemplateInfo , StoreError ,
12+ } ,
1013} ;
1114use anyhow:: { Error , Result } ;
1215use async_trait:: async_trait;
1316use serde:: Deserialize ;
17+ use serde_json:: Value ;
1418use slog:: Logger ;
15- use std:: { collections:: HashSet , convert:: TryFrom , sync:: Arc } ;
19+ use std:: {
20+ collections:: { BTreeMap , HashMap , HashSet } ,
21+ convert:: TryFrom ,
22+ sync:: Arc ,
23+ } ;
24+ use web3:: types:: H256 ;
1625
1726use super :: {
1827 block_stream:: { self , BlockStream , FirehoseCursor } ,
1928 client:: ChainClient ,
20- BlockIngestor , BlockTime , EmptyNodeCapabilities , HostFn , IngestorError , MappingTriggerTrait ,
21- NoopDecoderHook , Trigger , TriggerFilterWrapper , TriggerWithHandler ,
29+ BlockIngestor , BlockTime , ChainIdentifier , EmptyNodeCapabilities , ExtendedBlockPtr , HostFn ,
30+ IngestorError , MappingTriggerTrait , NoopDecoderHook , Trigger , TriggerFilterWrapper ,
31+ TriggerWithHandler ,
2232} ;
2333
2434use super :: {
@@ -431,3 +441,105 @@ impl Blockchain for MockBlockchain {
431441 todo ! ( )
432442 }
433443}
444+
445+ // Mock implementation
446+ #[ derive( Default ) ]
447+ pub struct MockChainStore {
448+ pub blocks : BTreeMap < BlockNumber , Vec < ExtendedBlockPtr > > ,
449+ }
450+
451+ #[ async_trait]
452+ impl ChainStore for MockChainStore {
453+ async fn block_ptrs_by_numbers (
454+ self : Arc < Self > ,
455+ numbers : Vec < BlockNumber > ,
456+ ) -> Result < BTreeMap < BlockNumber , Vec < ExtendedBlockPtr > > , Error > {
457+ let mut result = BTreeMap :: new ( ) ;
458+ for num in numbers {
459+ if let Some ( blocks) = self . blocks . get ( & num) {
460+ result. insert ( num, blocks. clone ( ) ) ;
461+ }
462+ }
463+ Ok ( result)
464+ }
465+
466+ // Implement other required methods with minimal implementations
467+ fn genesis_block_ptr ( & self ) -> Result < BlockPtr , Error > {
468+ unimplemented ! ( )
469+ }
470+ async fn upsert_block ( & self , _block : Arc < dyn Block > ) -> Result < ( ) , Error > {
471+ unimplemented ! ( )
472+ }
473+ fn upsert_light_blocks ( & self , _blocks : & [ & dyn Block ] ) -> Result < ( ) , Error > {
474+ unimplemented ! ( )
475+ }
476+ async fn attempt_chain_head_update (
477+ self : Arc < Self > ,
478+ _ancestor_count : BlockNumber ,
479+ ) -> Result < Option < H256 > , Error > {
480+ unimplemented ! ( )
481+ }
482+ async fn chain_head_ptr ( self : Arc < Self > ) -> Result < Option < BlockPtr > , Error > {
483+ unimplemented ! ( )
484+ }
485+ fn chain_head_cursor ( & self ) -> Result < Option < String > , Error > {
486+ unimplemented ! ( )
487+ }
488+ async fn set_chain_head (
489+ self : Arc < Self > ,
490+ _block : Arc < dyn Block > ,
491+ _cursor : String ,
492+ ) -> Result < ( ) , Error > {
493+ unimplemented ! ( )
494+ }
495+ async fn blocks ( self : Arc < Self > , _hashes : Vec < BlockHash > ) -> Result < Vec < Value > , Error > {
496+ unimplemented ! ( )
497+ }
498+ async fn ancestor_block (
499+ self : Arc < Self > ,
500+ _block_ptr : BlockPtr ,
501+ _offset : BlockNumber ,
502+ _root : Option < BlockHash > ,
503+ ) -> Result < Option < ( Value , BlockPtr ) > , Error > {
504+ unimplemented ! ( )
505+ }
506+ fn cleanup_cached_blocks (
507+ & self ,
508+ _ancestor_count : BlockNumber ,
509+ ) -> Result < Option < ( BlockNumber , usize ) > , Error > {
510+ unimplemented ! ( )
511+ }
512+ fn block_hashes_by_block_number ( & self , _number : BlockNumber ) -> Result < Vec < BlockHash > , Error > {
513+ unimplemented ! ( )
514+ }
515+ fn confirm_block_hash ( & self , _number : BlockNumber , _hash : & BlockHash ) -> Result < usize , Error > {
516+ unimplemented ! ( )
517+ }
518+ async fn block_number (
519+ & self ,
520+ _hash : & BlockHash ,
521+ ) -> Result < Option < ( String , BlockNumber , Option < u64 > , Option < BlockHash > ) > , StoreError > {
522+ unimplemented ! ( )
523+ }
524+ async fn block_numbers (
525+ & self ,
526+ _hashes : Vec < BlockHash > ,
527+ ) -> Result < HashMap < BlockHash , BlockNumber > , StoreError > {
528+ unimplemented ! ( )
529+ }
530+ async fn transaction_receipts_in_block (
531+ & self ,
532+ _block_ptr : & H256 ,
533+ ) -> Result < Vec < LightTransactionReceipt > , StoreError > {
534+ unimplemented ! ( )
535+ }
536+ async fn clear_call_cache ( & self , _from : BlockNumber , _to : BlockNumber ) -> Result < ( ) , Error > {
537+ unimplemented ! ( )
538+ }
539+ fn chain_identifier ( & self ) -> Result < ChainIdentifier , Error > {
540+ unimplemented ! ( )
541+ }
542+ fn set_chain_identifier ( & self , _ident : & ChainIdentifier ) -> Result < ( ) , Error > {
543+ unimplemented ! ( )
544+ }
545+ }
0 commit comments