From 60c75e173a56fc52275bc8ea4c16cf2c3aa9d2e1 Mon Sep 17 00:00:00 2001 From: JonathanAmenechi <7217608+JonathanAmenechi@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:31:48 -0400 Subject: [PATCH] chore: ensure 0x is always prepended --- py_order_utils/builders/base_builder.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/py_order_utils/builders/base_builder.py b/py_order_utils/builders/base_builder.py index 16e0577..79e4e72 100644 --- a/py_order_utils/builders/base_builder.py +++ b/py_order_utils/builders/base_builder.py @@ -29,7 +29,10 @@ def _create_struct_hash(self, order: EIP712Struct): """ Creates an EIP712 compliant struct hash for the Order """ - return "0x" + keccak(order.signable_bytes(domain=self.domain_separator)).hex() + struct_hash = keccak(order.signable_bytes(domain=self.domain_separator)).hex() + if len(struct_hash) > 2 and struct_hash[:2] != "0x": + struct_hash = f"0x{struct_hash}" + return struct_hash def sign(self, struct_hash): """