Skip to content

Commit

Permalink
Fix types in signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
hweawer committed Sep 16, 2024
1 parent ef2d312 commit ed1449b
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/transport/msg_providers/onchain_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
from enum import StrEnum
from typing import List, Optional

from cryptography.verify_signature import compute_vs
from eth_account.account import VRS
from eth_typing import ChecksumAddress, HexStr
from eth_typing import ChecksumAddress
from schema import Schema
from transport.msg_providers.common import BaseMessageProvider
from transport.msg_providers.rabbit import MessageType
Expand Down Expand Up @@ -44,12 +42,6 @@
PAUSE_V3_DATA_SCHEMA = '(uint256,bytes32,(bytes32,bytes32),(bytes32))'


def signature_to_r_vs(signature: bytes) -> tuple[VRS, VRS]:
r, s, v = signature[:32], signature[32:64], int.from_bytes(signature[64:])
_vs = compute_vs(v, HexStr(bytes_to_hex_string(s)))
return HexStr(bytes_to_hex_string(r)), HexStr(_vs)


class EventParser(abc.ABC):
def __init__(self, w3: Web3, schema: str):
self._w3 = w3
Expand Down Expand Up @@ -88,8 +80,8 @@ def _create_message(self, parsed_data: tuple, guardian: str) -> dict:
guardianAddress=guardian,
stakingModuleId=staking_module_id,
signature={
'r': r,
'_vs': vs,
'r': bytes_to_hex_string(r),
'_vs': bytes_to_hex_string(vs),
},
)

Expand All @@ -109,8 +101,8 @@ def _create_message(self, parsed_data: tuple, guardian: str) -> dict:
guardianAddress=guardian,
stakingModuleId=staking_module_id,
signature={
'r': r,
'_vs': vs,
'r': bytes_to_hex_string(r),
'_vs': bytes_to_hex_string(vs),
},
operatorIds=operator_ids,
vettedKeysByOperator=vetted_keys_by_operator,
Expand Down Expand Up @@ -145,8 +137,8 @@ def _create_message(self, parsed_data: tuple, guardian: str) -> dict:
guardianAddress=guardian,
stakingModuleId=staking_module_id,
signature={
'r': r,
'_vs': vs,
'r': bytes_to_hex_string(r),
'_vs': bytes_to_hex_string(vs),
},
)

Expand Down

0 comments on commit ed1449b

Please sign in to comment.