Skip to content

Commit

Permalink
Fix problems introduced by update to web3 v6
Browse files Browse the repository at this point in the history
  • Loading branch information
karlb committed Oct 13, 2022
1 parent bcf1b7f commit 05e53b8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog

## 0.1.8 (2022-10-13)
* Fix problems introduced by update to web3 v6

## 0.1.7 (2022-10-13)
* Update dependencies

Expand Down
2 changes: 1 addition & 1 deletion raiden_common/network/proxies/token_network_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def filter_token_added_events(self) -> List[Dict[str, Any]]:
)
events = filter_.get_all_entries()
if filter_.filter_id:
self.proxy.web3.eth.uninstallFilter(filter_.filter_id)
self.proxy.w3.eth.uninstall_filter(filter_.filter_id)

return events

Expand Down
21 changes: 12 additions & 9 deletions raiden_common/network/rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def get_transaction_data(
abi=abi, abi_codec=web3.codec, fn_identifier=function_name, args=args, kwargs=kwargs
)
return encode_transaction_data(
web3=web3,
w3=web3,
fn_identifier=function_name,
contract_abi=abi,
fn_abi=fn_abi,
Expand Down Expand Up @@ -640,8 +640,8 @@ def estimate_gas_for_function(
) -> int:
"""Temporary workaround until next web3.py release (5.X.X)"""
estimate_transaction = prepare_transaction(
w3=web3,
address=to_checksum_address(address),
web3=web3,
fn_identifier=fn_identifier,
contract_abi=contract_abi,
fn_abi=fn_abi,
Expand Down Expand Up @@ -924,10 +924,10 @@ def estimate_gas(
if not expected_error:
raise err

block = self.data.contract.web3.eth.get_block(BLOCK_ID_LATEST)
block = self.data.contract.w3.eth.get_block(BLOCK_ID_LATEST)

if estimated_gas is not None:
gas_price = gas_price_for_fast_transaction(self.data.contract.web3)
gas_price = gas_price_for_fast_transaction(self.data.contract.w3)

transaction_estimated = TransactionEstimated(
from_address=self.from_address,
Expand All @@ -942,7 +942,7 @@ def estimate_gas(
log.debug(
"Transaction gas estimated",
**transaction_estimated.to_log_details(),
node_gas_price=self.data.contract.web3.eth.gas_price,
node_gas_price=self.data.contract.w3.eth.gas_price,
)

return transaction_estimated
Expand Down Expand Up @@ -1296,7 +1296,7 @@ def to_log_details(self) -> Dict[str, Any]:
if isinstance(slot.data, SmartContractCall):
function_call = slot.data
data = get_transaction_data(
web3=function_call.contract.web3,
web3=function_call.contract.w3,
abi=function_call.contract.abi,
function_name=function_call.function,
args=function_call.args,
Expand Down Expand Up @@ -1412,7 +1412,9 @@ def to_log_details(self) -> Dict[str, Any]:
def new_contract_proxy(
self, abi: ABI, contract_address: Union[Address, ChecksumAddress]
) -> Contract:
return self.web3.eth.contract(abi=abi, address=contract_address)
contract = self.web3.eth.contract(abi=abi, address=contract_address)
assert isinstance(contract, Contract)
return contract

def deploy_single_contract(
self,
Expand All @@ -1431,8 +1433,9 @@ def deploy_single_contract(

ctor_parameters = constructor_parameters or ()

contract_object = self.web3.eth.contract(abi=contract["abi"], bytecode=contract["bin"])
contract_transaction = contract_object.constructor(*ctor_parameters).buildTransaction()
contract_object = self.web3.eth.contract(abi=contract["abi"], bytecode=contract["bin"])()
assert isinstance(contract_object, Contract)
contract_transaction = contract_object.constructor(*ctor_parameters).build_transaction()
constructor_call = ByteCode(contract_name, contract_transaction["data"])

block = self.get_block(BLOCK_ID_LATEST)
Expand Down
2 changes: 1 addition & 1 deletion raiden_common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def check_gas_reserve(raiden: "RaidenService") -> None: # pragma: no unittest
has_enough_balance, estimated_required_balance = gas_reserve.has_enough_gas_reserve(
raiden, channels_to_open=1
)
estimated_required_balance_eth = Web3.fromWei(estimated_required_balance, "ether")
estimated_required_balance_eth = Web3.from_wei(estimated_required_balance, "ether")

if not has_enough_balance:
notification_body = (
Expand Down

0 comments on commit 05e53b8

Please sign in to comment.