From 7e3d9630ceaa980b165eb581b69687a956eb41c2 Mon Sep 17 00:00:00 2001 From: nolash Date: Sat, 28 Aug 2021 03:10:21 +0200 Subject: [PATCH] Add missing encode module --- chainqueue/encode.py | 48 ++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 chainqueue/encode.py diff --git a/chainqueue/encode.py b/chainqueue/encode.py new file mode 100644 index 0000000..c9397a2 --- /dev/null +++ b/chainqueue/encode.py @@ -0,0 +1,48 @@ +# standard imports +import logging + +# external imports +from hexathon import ( + add_0x, + strip_0x, + uniform as hex_uniform, + ) + +logg = logging.getLogger(__name__) + + +class TxHexNormalize: + + def tx_hash(self, tx_hash): + return self.__hex_normalize(tx_hash) + + + def tx_wire(self, tx_wire): + return self.__hex_normalize(tx_wire) + + + def wallet_address(self, address): + return self.__hex_normalize(address) + + + def executable_address(self, address): + return self.__hex_normalize(address) + + + def __hex_normalize(self, data): + r = add_0x(hex_uniform(strip_0x(data))) + logg.debug('tx hex normalize {} -> {}'.format(data, r)) + return r + + +class NoopNormalize: + + def __init__(self): + self.tx_hash = self.__noop + self.tx_wire = self.__noop + self.wallet_address = self.__noop + self.executable_address = self.__noop + + + def __noop(self, data): + return data diff --git a/setup.cfg b/setup.cfg index aa7e10e..2cc1095 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainqueue -version = 0.0.4a7 +version = 0.0.4a8 description = Generic blockchain transaction queue control author = Louis Holbrook author_email = dev@holbrook.no