From d960c937906cde2615548a092b2695274b1519b9 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Thu, 30 Nov 2023 10:50:51 -0600 Subject: [PATCH] feat: even simpler last time maybe --- eip712/messages.py | 6 +++--- tests/test_common.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eip712/messages.py b/eip712/messages.py index b08f352..38223ac 100644 --- a/eip712/messages.py +++ b/eip712/messages.py @@ -149,7 +149,7 @@ def signable_message(self) -> SignableMessage: ) -def eip712_encode(typed_data: Dict[str, Any]) -> List[bytes]: +def encode(typed_data: Dict[str, Any]) -> List[bytes]: encoded_domain = encode_data("EIP712Domain", typed_data["types"], typed_data["domain"]) parts = [bytes.fromhex("1901"), keccak(encoded_domain)] @@ -162,7 +162,7 @@ def eip712_encode(typed_data: Dict[str, Any]) -> List[bytes]: return parts -def eip712_encode_hash(typed_data) -> str: - encoded_data = eip712_encode(typed_data) +def calculate_hash(typed_data) -> str: + encoded_data = encode(typed_data) value = keccak(b"".join(encoded_data)) return add_0x_prefix(cast(HexStr, value.hex())) diff --git a/tests/test_common.py b/tests/test_common.py index a8576cf..47bfc1f 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -3,7 +3,7 @@ from eth_account._utils.structured_data.hashing import hash_message from eip712.common import SAFE_VERSIONS, create_safe_tx_def -from eip712.messages import eip712_encode_hash +from eip712.messages import calculate_hash MAINNET_MSIG_ADDRESS = "0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52" GOERLI_MSIG_ADDRESS = "0x3c59eC3912A6A0c8690ec548D87FB55C3Ba62aBa" @@ -47,6 +47,6 @@ def test_gnosis_goerli_safe_tx(): value=convert("1 ETH", int), ) - actual = eip712_encode_hash(msg) + actual = calculate_hash(msg) expected = "0xbbb1cbed7c3679b5d5764df26af8fab1b15f3a15c084db9082dffb3624ca74ee" assert actual == expected