diff --git a/READMEs/setup-remote.md b/READMEs/setup-remote.md index ebf4b3dd6..bd132274b 100644 --- a/READMEs/setup-remote.md +++ b/READMEs/setup-remote.md @@ -202,9 +202,6 @@ ocean = Ocean(config) OCEAN = ocean.OCEAN_token # Create Alice's wallet -from brownie.network import accounts -accounts.clear() - alice_private_key = os.getenv('REMOTE_TEST_PRIVATE_KEY1') alice = accounts.add(alice_private_key) assert alice.balance() > 0, "Alice needs MATIC" diff --git a/conftest_ganache.py b/conftest_ganache.py index 8bee2baf0..481400988 100644 --- a/conftest_ganache.py +++ b/conftest_ganache.py @@ -55,7 +55,7 @@ def setup_all(request, config, ocean_token): assert balance >= to_wei(10), "Need more ETH" amt_distribute = to_wei(1000) - ocean_token.mint(wallet, to_wei(2000), {"from": wallet.address}) + ocean_token.mint(wallet, to_wei(2000), {"from": wallet}) for w in (get_publisher_wallet(), get_consumer_wallet()): balance = config["web3_instance"].eth.get_balance(w.address) diff --git a/ocean_lib/ocean/util.py b/ocean_lib/ocean/util.py index e5a842e55..32546e619 100644 --- a/ocean_lib/ocean/util.py +++ b/ocean_lib/ocean/util.py @@ -63,11 +63,7 @@ def str_with_wei(amt_wei: int) -> str: @enforce_types def get_from_address(tx_dict: dict) -> str: - address = ( - tx_dict["from"].address - if hasattr(tx_dict["from"], "address") - else tx_dict["from"] - ) + address = tx_dict["from"].address return Web3.toChecksumAddress(address.lower()) diff --git a/ocean_lib/web3_internal/contract_base.py b/ocean_lib/web3_internal/contract_base.py index e2aac0a73..93f025f48 100644 --- a/ocean_lib/web3_internal/contract_base.py +++ b/ocean_lib/web3_internal/contract_base.py @@ -17,6 +17,7 @@ logger = logging.getLogger(__name__) +# TODO: cleanup def function_wrapper(contract, web3, contract_functions, func_name): if hasattr(contract, func_name): return getattr(contract, func_name) @@ -49,14 +50,17 @@ def wrap(*args, **kwargs): return result.call() else: wallet = tx_dict["from"] - tx_dict["nonce"] = web3.eth.get_transaction_count(wallet.address) - tx_dict["from"] = ( - tx_dict["from"].address - if hasattr(tx_dict["from"], "address") - else tx_dict["from"] - ) + tx_dict2 = tx_dict.copy() + tx_dict2["nonce"] = web3.eth.get_transaction_count(wallet.address) + + tx_dict2["from"] = tx_dict["from"].address + + if "gasPrice" in tx_dict: + tx_dict2["gasPrice"] = tx_dict["gasPrice"] + else: + tx_dict2["gasPrice"] = int(web3.eth.gas_price * 1.1) - result = result.build_transaction(tx_dict) + result = result.build_transaction(tx_dict2) signed_tx = web3.eth.account.sign_transaction(result, wallet.privateKey) receipt = web3.eth.send_raw_transaction(signed_tx.rawTransaction) diff --git a/tests/integration/remote/test_mumbai_main.py b/tests/integration/remote/test_mumbai_main.py index 15c61c204..425060b00 100644 --- a/tests/integration/remote/test_mumbai_main.py +++ b/tests/integration/remote/test_mumbai_main.py @@ -2,7 +2,6 @@ # Copyright 2023 Ocean Protocol Foundation # SPDX-License-Identifier: Apache-2.0 # -from brownie.network import accounts from ocean_lib.example_config import get_config_dict from ocean_lib.ocean.ocean import Ocean @@ -17,7 +16,6 @@ def test_nonocean_tx(tmp_path, monkeypatch): config = get_config_dict("mumbai") ocean = Ocean(config) - accounts.clear() (alice_wallet, bob_wallet) = util.get_wallets() # Do a simple-as-possible test that uses ocean stack, while accounting for gotchas @@ -32,7 +30,6 @@ def test_ocean_tx__create(tmp_path, monkeypatch): config = get_config_dict("mumbai") ocean = Ocean(config) - accounts.clear() (alice_wallet, _) = util.get_wallets() # Do a simple-as-possible test that uses ocean stack, while accounting for gotchas diff --git a/tests/integration/remote/test_mumbai_readme.py b/tests/integration/remote/test_mumbai_readme.py index 9d92998cf..e93379904 100644 --- a/tests/integration/remote/test_mumbai_readme.py +++ b/tests/integration/remote/test_mumbai_readme.py @@ -5,14 +5,11 @@ import pathlib import runpy -from brownie.network import accounts - from . import util def test_simple_remote_readme(monkeypatch): monkeypatch.delenv("ADDRESS_FILE") - accounts.clear() (ref_alice_wallet, _) = util.get_wallets() # README generation command: @@ -27,6 +24,7 @@ def test_simple_remote_readme(monkeypatch): if "Alice needs MATIC" in str(e) or "Bob needs MATIC" in str(e): return raise (e) + ocean = result["ocean"] alice = result["alice"] diff --git a/tests/integration/remote/test_polygon.py b/tests/integration/remote/test_polygon.py index 06ee407eb..77d82138d 100644 --- a/tests/integration/remote/test_polygon.py +++ b/tests/integration/remote/test_polygon.py @@ -3,7 +3,6 @@ # SPDX-License-Identifier: Apache-2.0 # import pytest -from brownie.network import accounts from ocean_lib.example_config import get_config_dict from ocean_lib.ocean.ocean import Ocean @@ -20,7 +19,6 @@ def test_ocean_tx__create(tmp_path, monkeypatch): config = get_config_dict("polygon") ocean = Ocean(config) - accounts.clear() (alice_wallet, _) = util.get_wallets() # Do a simple-as-possible test that uses ocean stack, while accounting for gotchas