diff --git a/silverback/main.py b/silverback/main.py index eccedd5e..c403c448 100644 --- a/silverback/main.py +++ b/silverback/main.py @@ -125,7 +125,9 @@ def __init__(self, settings: Settings | None = None): ): settings.NEW_BLOCK_TIMEOUT = int(timedelta(days=1).total_seconds()) - settings_str = "\n ".join(f'{key}="{val}"' for key, val in settings.dict().items() if val) + settings_str = "\n ".join( + f'{key}="{val}"' for key, val in settings.model_dump().items() if val + ) logger.info(f"Loading Silverback Bot with settings:\n {settings_str}") self.broker = settings.get_broker() diff --git a/silverback/middlewares.py b/silverback/middlewares.py index ef97206c..37fe5f09 100644 --- a/silverback/middlewares.py +++ b/silverback/middlewares.py @@ -24,12 +24,15 @@ def compute_block_time() -> int: self.block_time = self.chain_manager.provider.network.block_time or compute_block_time() def pre_send(self, message: TaskiqMessage) -> TaskiqMessage: - # TODO: Necessary because bytes/HexBytes doesn't encode/deocde well for some reason + # TODO: Necessary because bytes/HexBytes doesn't encode/decode well for some reason def fix_dict(data: dict, recurse_count: int = 0) -> dict: fixed_data: dict[str, Any] = {} for name, value in data.items(): if isinstance(value, bytes): fixed_data[name] = to_hex(value) + elif name == "transaction_hash" and isinstance(value, list): + # TODO: Why is it a list now? (as of Ape v0.8.19ish) + fixed_data[name] = to_hex(bytearray(value)) elif isinstance(value, dict): if recurse_count > 3: raise RecursionError("Event object is too deep") diff --git a/silverback/state.py b/silverback/state.py index 22591ffe..fe0914a6 100644 --- a/silverback/state.py +++ b/silverback/state.py @@ -46,7 +46,7 @@ async def init(self, bot_id: SilverbackID) -> StateSnapshot | None: self.state_backup_file = data_folder / "state.json" return ( - StateSnapshot.parse_file(self.state_backup_file) + StateSnapshot.model_validate_json(self.state_backup_file.read_text()) if self.state_backup_file.exists() else None )