Skip to content

Commit 378b8ef

Browse files
committed
web3.py V7 compatibility
1 parent 14a9e57 commit 378b8ef

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

IceCreamSwapWeb3/EthAdvanced.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from web3.datastructures import AttributeDict
77
from web3.eth import Eth
88
from web3.exceptions import ContractLogicError
9-
from web3.types import FilterParams, LogReceipt, CallOverride, BlockIdentifier, TxParams, BlockData, _Hash32
9+
from web3.types import FilterParams, LogReceipt, StateOverride, BlockIdentifier, TxParams, BlockData, _Hash32
1010

1111
from IceCreamSwapWeb3 import Web3Advanced
1212
from IceCreamSwapWeb3.Subsquid import get_filter
@@ -61,13 +61,12 @@ class EthAdvanced(Eth):
6161
'get_code', 'get_transaction_count', 'get_transaction_receipt',
6262
'wait_for_transaction_receipt', 'get_storage_at', 'replace_transaction',
6363
'modify_transaction', 'sign', 'sign_transaction', 'sign_typed_data', 'filter',
64-
'get_filter_changes', 'get_filter_logs', 'uninstall_filter', 'submit_hashrate',
65-
'get_work', 'submit_work',
64+
'get_filter_changes', 'get_filter_logs', 'uninstall_filter'
6665
]
6766

6867
PROPERTIES_TO_RETRY = [
69-
'accounts', 'hashrate', 'block_number', 'coinbase', 'gas_price',
70-
'max_priority_fee', 'mining', 'syncing'
68+
'accounts', 'block_number', 'gas_price',
69+
'max_priority_fee', 'syncing'
7170
]
7271

7372
def __init__(self, w3):
@@ -92,7 +91,7 @@ def call(
9291
self,
9392
transaction: TxParams,
9493
block_identifier: Optional[BlockIdentifier] = None,
95-
state_override: Optional[CallOverride] = None,
94+
state_override: Optional[StateOverride] = None,
9695
ccip_read_enabled: Optional[bool] = None,
9796
no_retry: bool = False,
9897
):
@@ -287,9 +286,6 @@ def get_logs_inner(self, filter_params: FilterParams, no_retry: bool = False):
287286
no_retry = True
288287
return exponential_retry(func_name="get_logs")(self._get_logs)(filter_params, no_retry=no_retry)
289288

290-
def get_block_number_from_identifier(self, block_identifier: BlockIdentifier) -> BlockNumber:
291-
return block_identifier if isinstance(block_identifier, int) else self.get_block(block_identifier)["number"]
292-
293289
def _chain_id(self):
294290
# usually this causes an RPC call and is used in every eth_call. Getting it once in the init and then not again.
295291
return self.chain_id_cached

IceCreamSwapWeb3/Multicall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import eth_utils
77
import rlp
88
from eth_utils import to_checksum_address, to_bytes
9-
from web3._utils.abi import get_abi_output_types, get_abi_input_types
9+
from eth_utils.abi import get_abi_output_types, get_abi_input_types
1010
from web3.contract.contract import ContractFunction, ContractConstructor
1111
from web3.exceptions import ContractLogicError
1212

@@ -45,7 +45,7 @@ def __init__(
4545
self,
4646
w3: Web3Advanced
4747
):
48-
self.w3 = copy.deepcopy(w3)
48+
self.w3 = w3
4949
self.chain_id = self.w3.eth.chain_id
5050

5151
if self.chain_id in self.MULTICALL_DEPLOYMENTS:

IceCreamSwapWeb3/Web3Advanced.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from web3 import Web3
66
from web3.exceptions import ContractLogicError
77
from web3.main import get_default_modules
8-
from web3.middleware import geth_poa_middleware
8+
from web3.middleware import ExtraDataToPOAMiddleware
99

1010
from .EthAdvanced import EthAdvanced
1111
from .Multicall import MultiCall
@@ -51,7 +51,7 @@ def __init__(
5151

5252
super().__init__(provider=provider, modules=modules)
5353

54-
self.middleware_onion.inject(geth_poa_middleware, layer=0, name="poa") # required for pos chains
54+
self.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0, name="poa") # required for pos chains
5555

5656
self.latest_seen_block = self.eth.get_block_number(ignore_latest_seen_block=True)
5757

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
LONG_DESCRIPTION = 'IceCreamSwap Web3.py wrapper with automatic retries, multicall and other advanced functionality'
66

77
requirements = [
8-
'web3',
8+
'web3>=7,<8',
99
'rlp',
1010
]
1111

0 commit comments

Comments
 (0)