Skip to content

Commit 7d5e5ad

Browse files
committed
Tighten int_to_bytes32
1 parent d75a4ff commit 7d5e5ad

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

eth/utils/numeric.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from cytoolz import (
88
curry,
99
)
10+
from eth_typing import (
11+
Hash32,
12+
)
1013

1114
from eth.constants import (
1215
UINT_255_MAX,
@@ -15,7 +18,7 @@
1518
)
1619

1720

18-
def int_to_bytes32(value: Union[int, bool]) -> bytes:
21+
def int_to_bytes32(value: Union[int, bool]) -> Hash32:
1922
if not isinstance(value, int) or isinstance(value, bool):
2023
raise ValueError(
2124
"Value must be an integer: Got: {0}".format(
@@ -35,7 +38,7 @@ def int_to_bytes32(value: Union[int, bool]) -> bytes:
3538
)
3639
)
3740
value_bytes = value.to_bytes(32, 'big')
38-
return value_bytes
41+
return Hash32(value_bytes)
3942

4043

4144
def ceilXX(value: int, ceiling: int) -> int:

0 commit comments

Comments
 (0)