Add boolean to encoder

This commit is contained in:
nolash 2021-05-08 08:41:48 +02:00
parent 3f3a2e7af4
commit 2591a73950
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 16 additions and 1 deletions

View File

@ -61,6 +61,10 @@ class ABIContractDecoder:
return bool(self.uint256(v))
def boolean(self, v):
return bool(self.uint256(v))
def address(self, v):
a = strip_0x(v)[64-40:]
return to_checksum_address(a)
@ -143,6 +147,16 @@ class ABIContractEncoder:
self.__log_latest(v)
def bool(self, v):
return self.boolean(v)
def boolean(self, v):
if bool(v):
return self.uint256(1)
return self.uint256(0)
def address(self, v):
self.bytes_fixed(32, v, 20)
self.types.append(ABIContractType.ADDRESS)
@ -161,6 +175,7 @@ class ABIContractEncoder:
self.__log_latest(v)
def string(self, v):
b = v.encode('utf-8')
l = len(b)

View File

@ -1,6 +1,6 @@
[metadata]
name = chainlib
version = 0.0.3a2
version = 0.0.3a3
description = Generic blockchain access library and tooling
author = Louis Holbrook
author_email = dev@holbrook.no