Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 03dbe91

Browse files
vubvub
authored andcommitted
Changes to normalize address
1 parent 0c77c40 commit 03dbe91

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

ethereum/abi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ def encode_single(typ, arg):
236236
return zpad(arg, 32)
237237
elif len(arg) == 40:
238238
return zpad(decode_hex(arg), 32)
239+
elif len(arg) == 42 and arg[2:] == '0x':
240+
return zpad(decode_hex(arg[2:]), 32)
239241
else:
240242
raise EncodingError("Could not parse address: %r" % arg)
241243
raise EncodingError("Unhandled type: %r %r" % (base, sub))

ethereum/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ def check_and_strip_checksum(x):
128128
return x[:20]
129129

130130

131-
def normalize_address(x):
131+
def normalize_address(x, allow_blank=False):
132+
if allow_blank and x == '':
133+
return ''
132134
if len(x) in (42, 50) and x[:2] == '0x':
133135
x = x[2:]
134136
if len(x) in (40, 48):

0 commit comments

Comments
 (0)