From c6cb01b9a7e5a8179328d00e26cfa4070362d53b Mon Sep 17 00:00:00 2001 From: hweawer Date: Tue, 3 Sep 2024 09:30:00 +0200 Subject: [PATCH] Change signature parsing --- src/transport/msg_providers/onchain_transport.py | 7 ++++--- .../{test_onchain_transport.py => test_data_bus.py} | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) rename tests/transport/{test_onchain_transport.py => test_data_bus.py} (99%) diff --git a/src/transport/msg_providers/onchain_transport.py b/src/transport/msg_providers/onchain_transport.py index fa70c7d..1993329 100644 --- a/src/transport/msg_providers/onchain_transport.py +++ b/src/transport/msg_providers/onchain_transport.py @@ -4,6 +4,7 @@ from enum import StrEnum from typing import Any, List, Optional +from cryptography.verify_signature import compute_vs from eth_account.account import VRS from eth_typing import ChecksumAddress, HexStr from schema import Schema @@ -45,8 +46,9 @@ def signature_to_r_vs(signature: bytes) -> tuple[VRS, VRS]: - r, _vs = signature[:32], signature[32:] - return HexStr(bytes_to_hex_string(r)), HexStr(bytes_to_hex_string(_vs)) + r, s, v = signature[:32], signature[32:64], signature[64:] + _vs = compute_vs(v, HexStr(s)) + return HexStr(bytes_to_hex_string(r)), HexStr(_vs) class EventParser(abc.ABC): @@ -231,7 +233,6 @@ def _fetch_messages(self) -> List[Any]: filter_params = FilterParams( fromBlock=from_block, - toBlock=latest_block_number, address=self._onchain_address, topics=[self._topics], ) diff --git a/tests/transport/test_onchain_transport.py b/tests/transport/test_data_bus.py similarity index 99% rename from tests/transport/test_onchain_transport.py rename to tests/transport/test_data_bus.py index 7026df9..fd73492 100644 --- a/tests/transport/test_onchain_transport.py +++ b/tests/transport/test_data_bus.py @@ -106,7 +106,7 @@ def mock_receipts(w3: Web3) -> list[EventData]: 40, 2, '0x42eef33d13c4440627c3fab6e3abee85af796ae6f77dcade628b183640b519d0', - '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 3, ('0x0000000000000000000000000000000000000000000000000000000000000000',), )