Skip to content

Commit

Permalink
remove trx validation for eth_call to prevent unnecessary eth_chainId…
Browse files Browse the repository at this point in the history
… requests
  • Loading branch information
Elnaril committed Oct 22, 2024
1 parent 14f3cec commit eb39995
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions uniswap_smart_path/smart_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
from web3.contract import AsyncContract
from web3.contract.async_contract import AsyncContractFunctions
from web3.exceptions import BadFunctionCallOutput
from web3.middleware import validation
from web3.types import (
ChecksumAddress,
RPCEndpoint,
Wei,
)

Expand Down Expand Up @@ -68,6 +70,9 @@
logger = logging.getLogger(__name__)


NO_VALIDATION_METHODS = [RPCEndpoint("eth_call")] # to avoid unnecessary eth_chainId requests


def _rate_limit(method_name: Literal["eth_call"]) -> Callable[[Callable[..., Any]], Any]:
def decorator(func: DecoratedSignature) -> Any:
@wraps(func)
Expand Down Expand Up @@ -99,6 +104,10 @@ def __init__(
if with_gas_estimate:
raise NotImplementedError("Gas is not yet estimated")
self.w3 = w3
for method in NO_VALIDATION_METHODS:
if method in validation.METHODS_TO_VALIDATE:
logger.debug(f"Removing {method} from web3.middleware.validation.METHODS_TO_VALIDATE")
validation.METHODS_TO_VALIDATE.remove(method)
self.chain_id = chain_id
self.with_v2 = with_v2
self.with_v3 = with_v3
Expand Down

0 comments on commit eb39995

Please sign in to comment.