diff --git a/schemas/blocks.py b/schemas/blocks.py index 66851b9..35aa340 100644 --- a/schemas/blocks.py +++ b/schemas/blocks.py @@ -1,6 +1,9 @@ +import json from typing import Dict, List, Optional +from hexbytes import HexBytes from pydantic import BaseModel +from web3.datastructures import AttributeDict class Block(BaseModel): @@ -12,6 +15,12 @@ class Block(BaseModel): transaction_hashes: List[str] txs_gas_data: Dict[str, dict] + class Config: + json_encoders = { + AttributeDict: dict, + HexBytes: lambda h: h.hex(), + } + def get_filtered_calls(self, hash: str) -> List[dict]: return [ call for call in self.calls