chainlib

Generic blockchain access library and tooling
Log | Files | Refs | README | LICENSE

commit 2591a73950699e7d6553522747fa4bd4a0a1a486
parent 3f3a2e7af4eb986bb5d8d1e02e3ef229f4293547
Author: nolash <dev@holbrook.no>
Date:   Sat,  8 May 2021 08:41:48 +0200

Add boolean to encoder

Diffstat:
Mchainlib/eth/contract.py | 15+++++++++++++++
Msetup.cfg | 2+-
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/chainlib/eth/contract.py b/chainlib/eth/contract.py @@ -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) diff --git a/setup.cfg b/setup.cfg @@ -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