From 8dd7647da56c015486e3b7a5272a63a152cfeba3 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Tue, 22 Mar 2022 12:27:52 +0100 Subject: [PATCH] Make adjustments for EIP1559 (default on web3 > 5.24) --- .github/workflows/python.yml | 2 +- gnosis/eth/tests/test_ethereum_client.py | 1 - gnosis/eth/tests/utils.py | 5 +++-- gnosis/safe/safe_tx.py | 2 +- gnosis/safe/tests/test_real_nodes.py | 2 +- run_tests.sh | 2 +- setup.py | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 5790fada8..f76a1d469 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -21,7 +21,7 @@ jobs: - 5432:5432 steps: - name: Setup and run ganache - run: docker run --detach --publish 8545:8545 --network-alias ganache -e DOCKER=true trufflesuite/ganache:latest --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -k berlin -d + run: docker run --detach --publish 8545:8545 --network-alias ganache -e DOCKER=true trufflesuite/ganache:latest --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 diff --git a/gnosis/eth/tests/test_ethereum_client.py b/gnosis/eth/tests/test_ethereum_client.py index 23993c60f..91980263b 100644 --- a/gnosis/eth/tests/test_ethereum_client.py +++ b/gnosis/eth/tests/test_ethereum_client.py @@ -1022,7 +1022,6 @@ def test_send_unsigned_transaction(self): "to": to, "value": value, "gas": 23000, - "gasPrice": 1, } with self.assertRaisesMessage( diff --git a/gnosis/eth/tests/utils.py b/gnosis/eth/tests/utils.py index d076868a2..40e0815a0 100644 --- a/gnosis/eth/tests/utils.py +++ b/gnosis/eth/tests/utils.py @@ -5,6 +5,7 @@ from eth_account.signers.local import LocalAccount from web3 import Web3 from web3.contract import Contract +from web3.types import TxParams from ..contracts import get_example_erc20_contract @@ -39,14 +40,14 @@ def just_test_if_mainnet_node() -> str: return mainnet_node_url -def send_tx(w3: Web3, tx, account: LocalAccount) -> bytes: +def send_tx(w3: Web3, tx: TxParams, account: LocalAccount) -> bytes: tx["from"] = account.address if "nonce" not in tx: tx["nonce"] = w3.eth.get_transaction_count( account.address, block_identifier="pending" ) - if "gasPrice" not in tx: + if "gasPrice" not in tx and "maxFeePerGas" not in tx: tx["gasPrice"] = w3.eth.gas_price if "gas" not in tx: diff --git a/gnosis/safe/safe_tx.py b/gnosis/safe/safe_tx.py index 6caad16a3..e98f55927 100644 --- a/gnosis/safe/safe_tx.py +++ b/gnosis/safe/safe_tx.py @@ -386,7 +386,7 @@ def execute( else: tx_parameters = { "from": sender_account.address, - "gasPrice": tx_gas_price or self.gas_price or self.w3.eth.gas_price, + "gasPrice": tx_gas_price or self.w3.eth.gas_price, } if tx_gas: diff --git a/gnosis/safe/tests/test_real_nodes.py b/gnosis/safe/tests/test_real_nodes.py index 60101b462..2b1a048bd 100644 --- a/gnosis/safe/tests/test_real_nodes.py +++ b/gnosis/safe/tests/test_real_nodes.py @@ -20,7 +20,7 @@ def test_node_exceptions(self): "value": 0, "data": b"", "gas": 25000, - "gasPrice": 1, + "gasPrice": ethereum_service.w3.eth.gas_price, }, private_key=random_sender_account.key, ) diff --git a/run_tests.sh b/run_tests.sh index 4d3b1a58e..ea5d15807 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -4,7 +4,7 @@ ps aux | grep ganache-cli | grep -v grep > /dev/null if [ $? -eq 1 ]; then echo 'Running Ganache-Cli' - ganache-cli --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d -k berlin > /dev/null & + ganache-cli --defaultBalanceEther 10000 --gasLimit 10000000 -a 30 --chain.chainId 1337 --chain.networkId 1337 -d > /dev/null & GANACHE_PID=$! sleep 3 fi diff --git a/setup.py b/setup.py index f8a988b31..b389dc975 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( name="gnosis-py", - version="3.8.3", + version="3.9.0", packages=find_packages(), package_data={"gnosis": ["py.typed"]}, install_requires=requirements,