Skip to content

Commit

Permalink
actually fix address bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pipermerriam committed Dec 23, 2015
1 parent 65bed5b commit 0c29f2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion populus/contracts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def decode_single(typ, data):
base, sub, _ = abi.process_type(typ)

if base == 'address':
return '0x' + data[-40:]
if data == "0x":
return "0x" + "0" * 40
return '0x' + strip_0x_prefix(data[-40:])
elif base == 'string' or base == 'bytes' or base == 'hash':
if sub:
bytes = ethereum_utils.int_to_32bytearray(int(data, 16))
Expand Down
8 changes: 8 additions & 0 deletions tests/contracts/test_decode_single_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ def test_decode_bytes():
@pytest.mark.parametrize(
'input,expected',
(
(
'0x',
'0x0000000000000000000000000000000000000000',
),
(
'0x0000000000000000000000000000000000000000000000000000000000000000',
'0x0000000000000000000000000000000000000000',
),
(
'0x000000000000000000000000c305c901078781c232a2a521c2af7980f8385ee9',
'0xc305c901078781c232a2a521c2af7980f8385ee9',
Expand Down

0 comments on commit 0c29f2c

Please sign in to comment.