From 6200fd0a2c39a3e4feffc4ea3d0a5e8c390ace07 Mon Sep 17 00:00:00 2001 From: Keri Date: Wed, 18 Sep 2019 14:12:19 -0600 Subject: [PATCH] Add padding back to StrictByteStringEncoder --- web3/_utils/abi.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web3/_utils/abi.py b/web3/_utils/abi.py index 6b66d93ed1..176009464f 100644 --- a/web3/_utils/abi.py +++ b/web3/_utils/abi.py @@ -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):