From d8bba70911ec41460549af4fd9b3ea8bb8783640 Mon Sep 17 00:00:00 2001 From: antazoey Date: Fri, 16 Aug 2024 18:20:30 -0500 Subject: [PATCH] chore: bump eth dependencies (#67) --- .pre-commit-config.yaml | 6 +++--- evm_trace/display.py | 8 ++++---- evm_trace/geth.py | 8 ++++---- setup.cfg | 1 + setup.py | 12 ++++++------ tests/test_geth.py | 4 ++-- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 777f8e0..5a89bd1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,18 +10,18 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black name: black - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + rev: 7.1.1 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.0 + rev: v1.11.1 hooks: - id: mypy additional_dependencies: [types-PyYAML, types-requests, types-setuptools, pydantic] diff --git a/evm_trace/display.py b/evm_trace/display.py index 8fcb9e3..7d3f996 100644 --- a/evm_trace/display.py +++ b/evm_trace/display.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Optional, Union, cast from eth_typing import ChecksumAddress -from eth_utils import to_checksum_address +from eth_utils import to_checksum_address, to_hex from evm_trace.enums import CallType @@ -56,11 +56,11 @@ def title(self) -> str: if hasattr(self.call, "selector"): # Is an Event-node - selector = self.call.selector.hex() if self.call.selector else None + selector = to_hex(self.call.selector) if self.call.selector else None return f"{call_type}: {selector}" # else: Is a CallTreeNode - address_hex_str = self.call.address.hex() if self.call.address else None + address_hex_str = to_hex(self.call.address) if self.call.address else None try: address = to_checksum_address(address_hex_str) if address_hex_str else None except (ImportError, ValueError): @@ -80,7 +80,7 @@ def title(self) -> str: method_id = "" else: - hex_id = self.call.calldata[:4].hex() + hex_id = to_hex(self.call.calldata[:4]) method_id = f"<{hex_id}>" if hex_id else "" sep = "." if call_path and method_id else "" diff --git a/evm_trace/geth.py b/evm_trace/geth.py index c9bb949..bbfbb1a 100644 --- a/evm_trace/geth.py +++ b/evm_trace/geth.py @@ -3,7 +3,7 @@ from typing import Optional from eth_pydantic_types import HashBytes20, HexBytes -from eth_utils import to_int +from eth_utils import to_hex, to_int from pydantic import Field, RootModel, field_validator from evm_trace.base import BaseModel, CallTreeNode, EventNode @@ -188,7 +188,7 @@ def create_call_node_data(frame: TraceFrame) -> dict: data: dict = {"address": frame.address, "depth": frame.depth} if frame.op == CallType.CALL.value: data["call_type"] = CallType.CALL - data["value"] = int(frame.stack[-3].hex(), 16) + data["value"] = int(to_hex(frame.stack[-3]), 16) data["calldata"] = frame.memory.get(frame.stack[-4], frame.stack[-5]) elif frame.op == CallType.DELEGATECALL.value: data["call_type"] = CallType.DELEGATECALL @@ -197,10 +197,10 @@ def create_call_node_data(frame: TraceFrame) -> dict: # `calldata` and `address` are handle in later frames for CREATE and CREATE2. elif frame.op == CallType.CREATE.value: data["call_type"] = CallType.CREATE - data["value"] = int(frame.stack[-1].hex(), 16) + data["value"] = int(to_hex(frame.stack[-1]), 16) elif frame.op == CallType.CREATE2.value: data["call_type"] = CallType.CREATE2 - data["value"] = int(frame.stack[-1].hex(), 16) + data["value"] = int(to_hex(frame.stack[-1]), 16) else: data["call_type"] = CallType.STATICCALL diff --git a/setup.cfg b/setup.cfg index 7121939..aebe88d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,6 +6,7 @@ exclude = docs build evm_trace/version.py +ignore = E704,W503,PYD002 per-file-ignores = # The traces have to be formatted this way for the tests. tests/expected_traces.py: E501 diff --git a/setup.py b/setup.py index 98919c1..a3f9678 100644 --- a/setup.py +++ b/setup.py @@ -10,10 +10,10 @@ "eth-hash[pysha3]", # For eth-utils address checksumming ], "lint": [ - "black>=24.4.2,<25", # Auto-formatter and linter - "mypy>=1.10.0,<2", # Static type analyzer + "black>=24.8.0,<25", # Auto-formatter and linter + "mypy>=1.11.1,<2", # Static type analyzer "types-setuptools", # Needed for mypy type shed - "flake8>=7.0.0,<8", # Style linter + "flake8>=7.1.1,<8", # Style linter "flake8-breakpoint>=1.1.0,<2", # Detect breakpoints left in code "flake8-print>=5.0.0,<6", # Detect print statements left in code "isort>=5.10.1,<6", # Import sorting linter @@ -61,10 +61,10 @@ include_package_data=True, install_requires=[ "pydantic>=2.5.2,<3", - "py-evm>=0.10.0b6,<0.11", - "eth-utils>=2.3.1,<3", + "py-evm>=0.10.1b1,<0.11", + "eth-utils", "msgspec>=0.8", - "eth-pydantic-types>=0.1.0a5", + "eth-pydantic-types>=0.1.1,<0.2", ], python_requires=">=3.9,<4", extras_require=extras_require, diff --git a/tests/test_geth.py b/tests/test_geth.py index dfc95f6..24d1263 100644 --- a/tests/test_geth.py +++ b/tests/test_geth.py @@ -2,7 +2,7 @@ import pytest from eth_pydantic_types import HexBytes -from eth_utils import to_checksum_address +from eth_utils import to_checksum_address, to_hex from pydantic import ValidationError from evm_trace.enums import CallType @@ -240,7 +240,7 @@ def test_create_trace_frames_from_geth_create2_struct_logs( for frame in frames: if frame.op.startswith("CREATE"): assert frame.address - address = frame.address.hex() + address = to_hex(frame.address) assert address.startswith("0x") assert len(address) == 42 create2_found = create2_found or frame.op == "CREATE2"