From 983067d22d71932f51c785faf3580167a48b12ff Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Fri, 12 Aug 2022 13:10:56 -0500 Subject: [PATCH] fix: duplicate make_request method causing tracing to not work (#84) --- ape_hardhat/providers.py | 17 +++++------------ setup.py | 2 +- tests/test_fork_provider.py | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/ape_hardhat/providers.py b/ape_hardhat/providers.py index a85da46..eefad2d 100644 --- a/ape_hardhat/providers.py +++ b/ape_hardhat/providers.py @@ -2,7 +2,7 @@ import shutil from pathlib import Path from subprocess import PIPE, call -from typing import Any, Dict, Iterator, List, Optional, Union, cast +from typing import Dict, Iterator, List, Optional, Union, cast from ape._compat import Literal from ape.api import ( @@ -298,12 +298,8 @@ def build_command(self) -> List[str]: str(self.port), ] - def _make_request(self, rpc: str, args: list) -> Any: - return self.web3.provider.make_request(rpc, args) # type: ignore - def set_block_gas_limit(self, gas_limit: int) -> bool: - result = self._make_request("evm_setBlockGasLimit", [hex(gas_limit)]) - return result.get("result") is True + return self._make_request("evm_setBlockGasLimit", [hex(gas_limit)]) is True def set_timestamp(self, new_timestamp: int): pending_timestamp = self.get_block("pending").timestamp @@ -316,23 +312,20 @@ def mine(self, num_blocks: int = 1): self._make_request("hardhat_mine", [num_blocks_arg]) def snapshot(self) -> str: - result = self._make_request("evm_snapshot", []) - return result["result"] + return self._make_request("evm_snapshot", []) def revert(self, snapshot_id: SnapshotID) -> bool: if isinstance(snapshot_id, int): snapshot_id = HexBytes(snapshot_id).hex() - result = self._make_request("evm_revert", [snapshot_id]) - return result.get("result") is True + return self._make_request("evm_revert", [snapshot_id]) is True def unlock_account(self, address: AddressType) -> bool: result = self._make_request("hardhat_impersonateAccount", [address]) - if result: self.unlocked_accounts.append(address) - return result.get("result") is True + return result is True def send_transaction(self, txn: TransactionAPI) -> ReceiptAPI: """ diff --git a/setup.py b/setup.py index e99596d..05580d7 100644 --- a/setup.py +++ b/setup.py @@ -70,7 +70,7 @@ url="https://github.com/ApeWorX/ape-hardhat", include_package_data=True, install_requires=[ - "eth-ape>=0.4.0,<0.5.0", + "eth-ape>=0.4.3,<0.5.0", "importlib-metadata ; python_version<'3.8'", "evm-trace>=0.1.0.a6", "hexbytes", # Use same as eth-ape diff --git a/tests/test_fork_provider.py b/tests/test_fork_provider.py index 479375e..8a9c614 100644 --- a/tests/test_fork_provider.py +++ b/tests/test_fork_provider.py @@ -25,7 +25,7 @@ def fork_contract_instance(owner, contract_container, connected_mainnet_fork_pro def test_fork_config(config, network): plugin_config = config.get_config("hardhat") network_config = plugin_config["fork"].get("ethereum", {}).get(network, {}) - assert network_config["upstream_provider"] == "alchemy", "config not registered" + assert network_config.get("upstream_provider") == "alchemy", "config not registered" @pytest.mark.fork