Skip to content

Commit a20c43f

Browse files
committed
Introduce VRS type
1 parent dd1614f commit a20c43f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

eth/typing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Dict,
33
Iterable,
44
List,
5+
NewType,
56
Tuple,
67
Union,
78
)
@@ -30,3 +31,5 @@
3031
AccountState,
3132
List[Tuple[Address, Dict[str, Union[int, bytes, Dict[int, int]]]]]
3233
]
34+
35+
VRS = NewType("VRS", Tuple[int, int, int])

eth/utils/transactions.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import rlp
22

3-
from typing import (
4-
Tuple,
5-
)
6-
73
from eth_keys import keys
84
from eth_keys import datatypes
95
from eth_keys.exceptions import (
@@ -14,6 +10,9 @@
1410
int_to_big_endian,
1511
ValidationError,
1612
)
13+
from eth.typing import (
14+
VRS,
15+
)
1716
from eth.utils.numeric import (
1817
is_even,
1918
)
@@ -49,7 +48,7 @@ def extract_signature_v(v: int) -> int:
4948

5049
def create_transaction_signature(unsigned_txn: BaseTransaction,
5150
private_key: datatypes.PrivateKey,
52-
chain_id: int=None) -> Tuple[int, int, int]:
51+
chain_id: int=None) -> VRS:
5352

5453
transaction_parts = rlp.decode(rlp.encode(unsigned_txn))
5554

@@ -70,7 +69,7 @@ def create_transaction_signature(unsigned_txn: BaseTransaction,
7069
else:
7170
v = canonical_v + V_OFFSET
7271

73-
return v, r, s
72+
return VRS((v, r, s))
7473

7574

7675
def validate_transaction_signature(transaction: BaseTransaction) -> None:

0 commit comments

Comments
 (0)