Skip to content

Commit

Permalink
Add padding back to StrictByteStringEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Sep 18, 2019
1 parent 1b98224 commit 6200fd0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion web3/_utils/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,15 @@ def validate(self):

def encode(self, value):
normalized_value = self.validate_value(value)
return self.encode_fn(normalized_value)

base_encoded_value = self.encode_fn(normalized_value)

if self.is_big_endian:
padded_encoded_value = base_encoded_value.rjust(32, b'\x00')
else:
padded_encoded_value = base_encoded_value.ljust(32, b'\x00')

return padded_encoded_value

def validate_value(self, value):
if not is_bytes(value) and not is_text(value):
Expand Down

0 comments on commit 6200fd0

Please sign in to comment.