Skip to content

Commit

Permalink
fix: duplicate make_request method causing tracing to not work (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Aug 12, 2022
1 parent f8d9487 commit 983067d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
17 changes: 5 additions & 12 deletions ape_hardhat/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand All @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fork_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 983067d

Please sign in to comment.