@@ -486,12 +486,19 @@ mod data {
486
486
) -> Result < Vec < json:: Value > , Error > {
487
487
use diesel:: dsl:: any;
488
488
489
+ // We need to deal with chain stores where some entries have a
490
+ // toplevel 'block' field and others directly contain what would
491
+ // be in the 'block' field. Make sure we return the contents of
492
+ // the 'block' field if it exists, otherwise assume the whole
493
+ // Json object is what should be in 'block'
494
+ //
495
+ // see also 7736e440-4c6b-11ec-8c4d-b42e99f52061
489
496
match self {
490
497
Storage :: Shared => {
491
498
use public:: ethereum_blocks as b;
492
499
493
500
b:: table
494
- . select ( sql :: < Jsonb > ( "data -> 'block'" ) )
501
+ . select ( sql :: < Jsonb > ( "coalesce( data -> 'block', data) " ) )
495
502
. filter ( b:: network_name. eq ( chain) )
496
503
. filter ( b:: hash. eq ( any ( Vec :: from_iter (
497
504
hashes. into_iter ( ) . map ( |h| format ! ( "{:x}" , h) ) ,
@@ -500,7 +507,7 @@ mod data {
500
507
}
501
508
Storage :: Private ( Schema { blocks, .. } ) => blocks
502
509
. table ( )
503
- . select ( sql :: < Jsonb > ( "data -> 'block'" ) )
510
+ . select ( sql :: < Jsonb > ( "coalesce( data -> 'block', data) " ) )
504
511
. filter (
505
512
blocks
506
513
. hash ( )
@@ -835,6 +842,20 @@ mod data {
835
842
}
836
843
} ;
837
844
845
+ // We need to deal with chain stores where some entries have a
846
+ // toplevel 'blocks' field and others directly contain what
847
+ // would be in the 'blocks' field. Make sure the value we return
848
+ // has a 'block' entry
849
+ //
850
+ // see also 7736e440-4c6b-11ec-8c4d-b42e99f52061
851
+ let data = {
852
+ use graph:: prelude:: serde_json:: json;
853
+
854
+ data. map ( |data| match data. get ( "block" ) {
855
+ Some ( _) => data,
856
+ None => json ! ( { "block" : data, "transaction_receipts" : [ ] } ) ,
857
+ } )
858
+ } ;
838
859
Ok ( data)
839
860
}
840
861
0 commit comments