From 070c41be3edb4154750c64fd207f1ad126ba29a1 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Wed, 3 Jul 2024 15:05:29 -0500 Subject: [PATCH] refactor: this is better --- ape_alchemy/provider.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ape_alchemy/provider.py b/ape_alchemy/provider.py index bfeb6e9..f92fd09 100644 --- a/ape_alchemy/provider.py +++ b/ape_alchemy/provider.py @@ -10,8 +10,10 @@ VirtualMachineError, ) from ape.logging import logger +from ape.types import BlockID from ape_ethereum.provider import Web3Provider from ape_ethereum.trace import TransactionTrace +from ape_ethereum.transactions import AccessList from eth_pydantic_types import HexBytes from eth_typing import HexStr from requests import HTTPError @@ -98,11 +100,11 @@ def ws_uri(self) -> str: @property def priority_fee(self) -> int: - try: - return super().priority_fee - except Exception as err: - # Raise this error to avoid uncaught 404 from Alchemy. - raise APINotImplementedError() from err + if self.network.ecosystem.name == "polygon-zkevm": + # The error is only 400 with no info otherwise. + raise APINotImplementedError() + + return super().priority_fee @property def connection_str(self) -> str: @@ -170,15 +172,16 @@ def get_virtual_machine_error(self, exception: Exception, **kwargs) -> VirtualMa return VirtualMachineError(message=message, txn=txn) - def make_request(self, rpc: str, parameters: Optional[Iterable] = None) -> Any: - # There is no clue whatsoever from not-implemented errors from polygon-zkevm, - # so we have to hardcode this. - if self.network.ecosystem.name == "polygon-zkevm" and rpc in ( - "eth_createAccessList", - "eth_priorityFee", - ): + def create_access_list( + self, transaction: TransactionAPI, block_id: Optional[BlockID] = None + ) -> list[AccessList]: + if self.network.ecosystem.name == "polygon-zkevm": + # The error is only 400 with no info otherwise. raise APINotImplementedError() + return super().create_access_list(transaction, block_id=block_id) + + def make_request(self, rpc: str, parameters: Optional[Iterable] = None) -> Any: parameters = parameters or [] try: return self.web3.provider.make_request(RPCEndpoint(rpc), parameters)