diff --git a/silverback/middlewares.py b/silverback/middlewares.py index 31215653..b25efdb3 100644 --- a/silverback/middlewares.py +++ b/silverback/middlewares.py @@ -6,7 +6,7 @@ from taskiq import TaskiqMessage, TaskiqMiddleware, TaskiqResult from silverback.persistence import HandlerResult -from silverback.types import SilverbackIdent, handler_id_block, handler_id_event +from silverback.types import SilverbackID, handler_id_block, handler_id_event from silverback.utils import hexbytes_dict @@ -40,7 +40,7 @@ def compute_block_time() -> int: settings = kwargs.pop("silverback_settings") self.block_time = self.chain_manager.provider.network.block_time or compute_block_time() - self.ident = SilverbackIdent.from_settings(settings) + self.ident = SilverbackID.from_settings(settings) self.persistence = settings.get_persistent_store() def pre_send(self, message: TaskiqMessage) -> TaskiqMessage: diff --git a/silverback/persistence.py b/silverback/persistence.py index a673d34e..2c2b4e80 100644 --- a/silverback/persistence.py +++ b/silverback/persistence.py @@ -9,7 +9,7 @@ from taskiq import TaskiqResult from typing_extensions import Self # Introduced 3.11 -from .types import SilverbackIdent +from .types import SilverbackID _HandlerReturnType = TypeVar("_HandlerReturnType") @@ -35,7 +35,7 @@ class HandlerResult(TaskiqResult): @classmethod def from_taskiq( cls, - ident: SilverbackIdent, + ident: SilverbackID, handler_id: str, block_number: Optional[int], log_index: Optional[int], @@ -59,20 +59,20 @@ async def init(self): ... @abstractmethod - async def get_state(self, ident: SilverbackIdent) -> Optional[SilverbackState]: + async def get_state(self, ident: SilverbackID) -> Optional[SilverbackState]: """Return the stored state for a Silverback instance""" ... @abstractmethod async def set_state( - self, ident: SilverbackIdent, last_block_seen: int, last_block_processed: int + self, ident: SilverbackID, last_block_seen: int, last_block_processed: int ) -> Optional[SilverbackState]: """Set the stored state for a Silverback instance""" ... @abstractmethod async def get_latest_result( - self, ident: SilverbackIdent, handler: Optional[str] = None + self, ident: SilverbackID, handler: Optional[str] = None ) -> Optional[HandlerResult]: """Return the latest result for a Silverback instance's handler""" ... @@ -182,7 +182,7 @@ async def init(self): self.initialized = True - async def get_state(self, ident: SilverbackIdent) -> Optional[SilverbackState]: + async def get_state(self, ident: SilverbackID) -> Optional[SilverbackState]: if not self.initialized: await self.init() @@ -209,7 +209,7 @@ async def get_state(self, ident: SilverbackIdent) -> Optional[SilverbackState]: ) async def set_state( - self, ident: SilverbackIdent, last_block_seen: int, last_block_processed: int + self, ident: SilverbackID, last_block_seen: int, last_block_processed: int ) -> Optional[SilverbackState]: if not self.initialized: await self.init() @@ -261,7 +261,7 @@ async def set_state( ) async def get_latest_result( - self, ident: SilverbackIdent, handler: Optional[str] = None + self, ident: SilverbackID, handler: Optional[str] = None ) -> Optional[HandlerResult]: if not self.initialized: await self.init() diff --git a/silverback/runner.py b/silverback/runner.py index da5a93f1..49580586 100644 --- a/silverback/runner.py +++ b/silverback/runner.py @@ -14,7 +14,7 @@ from .persistence import BasePersistentStore from .settings import Settings from .subscriptions import SubscriptionType, Web3SubscriptionsManager -from .types import SilverbackIdent, SilverbackStartupState +from .types import SilverbackID, SilverbackStartupState from .utils import async_wrap_iter, hexbytes_dict settings = Settings() @@ -29,7 +29,7 @@ def __init__(self, app: SilverbackApp, *args, max_exceptions: int = 3, **kwargs) self.last_block_seen = 0 self.last_block_processed = 0 self.persistence: Optional[BasePersistentStore] = None - self.ident = SilverbackIdent.from_settings(settings) + self.ident = SilverbackID.from_settings(settings) def _handle_result(self, result: TaskiqResult): if result.is_err: diff --git a/silverback/types.py b/silverback/types.py index 954e4134..571a5c87 100644 --- a/silverback/types.py +++ b/silverback/types.py @@ -15,7 +15,7 @@ def get_network_choice(self) -> str: ... -class SilverbackIdent(BaseModel): +class SilverbackID(BaseModel): identifier: str network_choice: str