Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update uniswap.py
enable caching, will reduce RPC calls for method chainID
  • Loading branch information
PawlowskiAdrian authored Sep 28, 2022
commit 5a548e00727c825aff7e6d183456eda68c7ea482
3 changes: 2 additions & 1 deletion uniswap/uniswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from web3 import Web3
from web3._utils.abi import map_abi_data
from web3._utils.normalizers import BASE_RETURN_NORMALIZERS
from web3.middleware import simple_cache_middleware
from web3.contract import Contract, ContractFunction
from web3.exceptions import BadFunctionCallOutput, ContractLogicError
from web3.types import (
Expand Down Expand Up @@ -115,7 +116,7 @@ def __init__(
provider = os.environ["PROVIDER"]
self.w3 = Web3(Web3.HTTPProvider(provider, request_kwargs={"timeout": 60}))

# Cache netid to avoid extra RPC calls
self.w3.middleware_onion.inject(simple_cache_middleware, layer=0)
self.netid = int(self.w3.net.version)
if self.netid in _netid_to_name:
self.netname = _netid_to_name[self.netid]
Expand Down