diff --git a/src/ape/api/providers.py b/src/ape/api/providers.py index 49eec322b5..e78391670c 100644 --- a/src/ape/api/providers.py +++ b/src/ape/api/providers.py @@ -120,16 +120,16 @@ class ProviderAPI(BaseInterfaceModel): network: NetworkAPI """A reference to the network this provider provides.""" - provider_settings: dict + provider_settings: Dict """The settings for the provider, as overrides to the configuration.""" data_folder: Path """The path to the ``.ape`` directory.""" - request_header: dict + request_header: Dict """A header to set on HTTP/RPC requests.""" - cached_chain_id: Optional[int] = None + cached_chain_id: Optional[int] = Field(None, exclude=True) """Implementation providers may use this to cache and re-use chain ID.""" block_page_size: int = 100 @@ -1752,7 +1752,10 @@ def disconnect(self): Subclasses override this method to do provider-specific disconnection tasks. """ - self.cached_chain_id = None # type: ignore + # NOTE: Setting it this way mostly because of a mypy issue. + default_value = self.model_fields["cached_chain_id"].default + self.cached_chain_id = default_value + if self.process: self.stop() diff --git a/src/ape_test/provider.py b/src/ape_test/provider.py index 7173079d65..3955d9b832 100644 --- a/src/ape_test/provider.py +++ b/src/ape_test/provider.py @@ -62,7 +62,7 @@ def connect(self): self._web3 = Web3(tester) def disconnect(self): - self.cached_chain_id = None # type: ignore + self.cached_chain_id = None self._web3 = None self._evm_backend = None @@ -111,7 +111,7 @@ def estimate_gas_cost(self, txn: TransactionAPI, **kwargs) -> int: @property def chain_id(self) -> int: - if self.cached_chain_id: + if self.cached_chain_id is not None: return self.cached_chain_id try: