@@ -85,7 +85,7 @@ def _process_storage(self, storage_type: Type[StorageType], storage: Dict, prefi
8585 if field .alias :
8686 key = field .alias
8787
88- bigmap_name = key if prefix is None else '.' . join ([ prefix , key ])
88+ bigmap_name = key if prefix is None else f' { prefix } . { key } '
8989
9090 # NOTE: TzKT could return bigmaps as object or as array of key-value objects. We need to guess this from storage.
9191 # TODO: This code should be a part of datasource module.
@@ -96,17 +96,23 @@ def _process_storage(self, storage_type: Type[StorageType], storage: Dict, prefi
9696 continue
9797 raise ConfigurationError (f'Type `{ storage_type .__name__ } ` is invalid: `{ key } ` field does not exists' ) from e
9898
99- if field .type_ not in (int , bool ) and isinstance (value , int ):
100- if hasattr (field .type_ , '__fields__' ) and 'key' in field .type_ .__fields__ and 'value' in field .type_ .__fields__ :
99+ # FIXME: Pydantic bug. `BaseModel.type_` returns incorrect value when annotation is Dict[str, bool]
100+ if field .type_ != field .outer_type_ and field .type_ == bool :
101+ annotation = field .outer_type_
102+ else :
103+ annotation = field .type_
104+
105+ if annotation not in (int , bool ) and isinstance (value , int ):
106+ if hasattr (annotation , '__fields__' ) and 'key' in annotation .__fields__ and 'value' in annotation .__fields__ :
101107 storage [key ] = []
102108 if self .diffs :
103109 self ._merge_bigmapdiffs (storage , bigmap_name , array = True )
104110 else :
105111 storage [key ] = {}
106112 if self .diffs :
107113 self ._merge_bigmapdiffs (storage , bigmap_name , array = False )
108- elif hasattr (field . type_ , '__fields__' ) and isinstance (storage [key ], dict ):
109- storage [key ] = self ._process_storage (field . type_ , storage [key ], bigmap_name )
114+ elif hasattr (annotation , '__fields__' ) and isinstance (storage [key ], dict ):
115+ storage [key ] = self ._process_storage (annotation , storage [key ], bigmap_name )
110116
111117 return storage
112118
0 commit comments