chaind-eth

Queue server for ethereum
Log | Files | Refs | README | LICENSE

commit 8f86e9c97025d72ae1ae598143536afb6d10acd3
parent abc619d7b24493d76e4f89b78a18c88bbd07b1ac
Author: lash <dev@holbrook.no>
Date:   Wed,  4 May 2022 07:26:17 +0000

Implement unsafe address for send

Diffstat:
Mchaind/eth/runnable/send.py | 2+-
Mchaind/eth/token/process.py | 19++++++++++++++-----
Msetup.cfg | 2+-
3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/chaind/eth/runnable/send.py b/chaind/eth/runnable/send.py @@ -118,7 +118,7 @@ def main(): m = GasTokenResolver token_resolver = m(chain_spec, rpc.get_sender_address(), rpc.get_signer(), rpc.get_gas_oracle(), rpc.get_nonce_oracle()) - processor = Processor(token_resolver, config.get('_SOURCE')) + processor = Processor(token_resolver, config.get('_SOURCE'), use_checksum=not config.get('_UNSAFE')) processor.add_processor(CSVProcessor()) sends = None diff --git a/chaind/eth/token/process.py b/chaind/eth/token/process.py @@ -3,7 +3,10 @@ import logging # external imports from chaind.error import TxSourceError -from chainlib.eth.address import is_checksum_address +from chainlib.eth.address import ( + is_checksum_address, + to_checksum_address, + ) from chainlib.eth.tx import unpack from chainlib.eth.gas import Gas from hexathon import ( @@ -17,10 +20,11 @@ logg = logging.getLogger(__name__) class Processor: - def __init__(self, resolver, source): + def __init__(self, resolver, source, use_checksum=True): self.resolver = resolver self.source = source self.processor = [] + self.safe = use_checksum self.conn = None @@ -50,9 +54,14 @@ class Processor: txs = [] for i, r in enumerate(self.content): logg.debug('processing {}'.format(r)) - if not is_checksum_address(r[0]): - raise ValueError('invalid checksum address {} in record {}'.format(r[0], i)) - self.content[i][0] = add_0x(r[0]) + address = r[0] + if self.safe: + if not is_checksum_address(address): + raise ValueError('invalid checksum address {} in record {}'.format(address, i)) + else: + address = to_checksum_address(address) + + self.content[i][0] = add_0x(address) try: self.content[i][1] = int(r[1]) except ValueError: diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chaind-eth -version = 0.2.2 +version = 0.2.3 description = Queue server for ethereum author = Louis Holbrook author_email = dev@holbrook.no