From 6044a647e2c764e5cc6f13a1b34279ad2f580383 Mon Sep 17 00:00:00 2001 From: slush Date: Mon, 14 Oct 2024 11:03:10 -0500 Subject: [PATCH] chore: updates HashBytes to HexBytes --- evm_trace/geth.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/evm_trace/geth.py b/evm_trace/geth.py index bbfbb1a..4f5e499 100644 --- a/evm_trace/geth.py +++ b/evm_trace/geth.py @@ -2,7 +2,7 @@ from collections.abc import Iterator from typing import Optional -from eth_pydantic_types import HashBytes20, HexBytes +from eth_pydantic_types import HexBytes20, HexBytes from eth_utils import to_hex, to_int from pydantic import Field, RootModel, field_validator @@ -49,7 +49,7 @@ class TraceFrame(BaseModel): storage: dict[HexBytes, HexBytes] = {} """Contract storage.""" - contract_address: Optional[HashBytes20] = None + contract_address: Optional[HexBytes20] = None """The address producing the frame.""" @field_validator("pc", "gas", "gas_cost", "depth", mode="before") @@ -57,7 +57,7 @@ def validate_ints(cls, value): return int(value, 16) if isinstance(value, str) else value @property - def address(self) -> Optional[HashBytes20]: + def address(self) -> Optional[HexBytes20]: """ The address of this CALL frame. Only returns a value if this frame's opcode is a call-based opcode. @@ -66,7 +66,7 @@ def address(self) -> Optional[HashBytes20]: if not self.contract_address and ( self.op in CALL_OPCODES and CallType.CREATE.value not in self.op ): - self.contract_address = HashBytes20.__eth_pydantic_validate__(self.stack[-2][-20:]) + self.contract_address = HexBytes20.__eth_pydantic_validate__(self.stack[-2][-20:]) return self.contract_address @@ -116,7 +116,7 @@ def _get_create_frames(frame: TraceFrame, frames: Iterator[dict]) -> list[TraceF # the first frame after the CREATE with an equal depth. if len(next_frame_obj.stack) > 0: raw_addr = HexBytes(next_frame_obj.stack[-1][-40:]) - frame.contract_address = HashBytes20.__eth_pydantic_validate__(raw_addr) + frame.contract_address = HexBytes20.__eth_pydantic_validate__(raw_addr) create_frames.append(next_frame_obj) break @@ -274,7 +274,7 @@ def _create_node( node_kwargs["last_create_depth"].pop() for subcall in node_kwargs.get("calls", [])[::-1]: if subcall.call_type in (CallType.CREATE, CallType.CREATE2): - subcall.address = HashBytes20.__eth_pydantic_validate__(frame.stack[-1][-40:]) + subcall.address = HexBytes20.__eth_pydantic_validate__(frame.stack[-1][-40:]) if len(frame.stack) >= 5: subcall.calldata = frame.memory.get(frame.stack[-4], frame.stack[-5])