Skip to content

Commit 0c29f2c

Browse files
committed
actually fix address bug
1 parent 65bed5b commit 0c29f2c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

populus/contracts/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ def decode_single(typ, data):
99
base, sub, _ = abi.process_type(typ)
1010

1111
if base == 'address':
12-
return '0x' + data[-40:]
12+
if data == "0x":
13+
return "0x" + "0" * 40
14+
return '0x' + strip_0x_prefix(data[-40:])
1315
elif base == 'string' or base == 'bytes' or base == 'hash':
1416
if sub:
1517
bytes = ethereum_utils.int_to_32bytearray(int(data, 16))

tests/contracts/test_decode_single_type.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ def test_decode_bytes():
7676
@pytest.mark.parametrize(
7777
'input,expected',
7878
(
79+
(
80+
'0x',
81+
'0x0000000000000000000000000000000000000000',
82+
),
83+
(
84+
'0x0000000000000000000000000000000000000000000000000000000000000000',
85+
'0x0000000000000000000000000000000000000000',
86+
),
7987
(
8088
'0x000000000000000000000000c305c901078781c232a2a521c2af7980f8385ee9',
8189
'0xc305c901078781c232a2a521c2af7980f8385ee9',

0 commit comments

Comments
 (0)