commit 0714791b9a135d3d626231d17fee198cd7c5497c
parent 8833e2e7b8afdf57a503b8961830d342ffd56cbc
Author: nolash <dev@holbrook.no>
Date: Thu, 9 Sep 2021 09:05:59 +0200
Allow unsafe addresses in input
Diffstat:
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/chaind_eth/cli/resolver.py b/chaind_eth/cli/resolver.py
@@ -12,12 +12,21 @@ logg = logging.getLogger(__name__)
class LookNoop:
+ def __init__(self, check=True):
+ self.check = check
+
+
def get(self, k, rpc=None):
- try:
- if not is_checksum_address(k):
+ if not self.check:
+ address_bytes = bytes.fromhex(strip_0x(k))
+ if len(address_bytes) != 20:
+ raise ValueError('{} is not a valid address'.format(k))
+ else:
+ try:
+ if not is_checksum_address(k):
+ raise ValueError('not valid checksum address {}'.format(k))
+ except ValueError:
raise ValueError('not valid checksum address {}'.format(k))
- except ValueError:
- raise ValueError('not valid checksum address {}'.format(k))
return strip_0x(k)
diff --git a/chaind_eth/runnable/send.py b/chaind_eth/runnable/send.py
@@ -118,7 +118,7 @@ def main():
# TODO: make resolvers pluggable
token_resolver = DefaultResolver(chain_spec, conn, sender_address=rpc.get_sender_address())
- noop_lookup = LookNoop()
+ noop_lookup = LookNoop(check=not config.true('_UNSAFE'))
token_resolver.add_lookup(noop_lookup, 'noop')
if config.get('_TOKEN_INDEX') != None: