Add missing encode module

This commit is contained in:
nolash 2021-08-28 03:10:21 +02:00
parent faa9988d53
commit 7e3d9630ce
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 49 additions and 1 deletions

48
chainqueue/encode.py Normal file
View File

@ -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

View File

@ -1,6 +1,6 @@
[metadata] [metadata]
name = chainqueue name = chainqueue
version = 0.0.4a7 version = 0.0.4a8
description = Generic blockchain transaction queue control description = Generic blockchain transaction queue control
author = Louis Holbrook author = Louis Holbrook
author_email = dev@holbrook.no author_email = dev@holbrook.no