Skip to content

Commit

Permalink
Change signature parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
hweawer committed Sep 3, 2024
1 parent 8db867a commit c6cb01b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/transport/msg_providers/onchain_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def mock_receipts(w3: Web3) -> list[EventData]:
40,
2,
'0x42eef33d13c4440627c3fab6e3abee85af796ae6f77dcade628b183640b519d0',
'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
3,
('0x0000000000000000000000000000000000000000000000000000000000000000',),
)
Expand Down

0 comments on commit c6cb01b

Please sign in to comment.