Allow unsafe addresses in input

This commit is contained in:
nolash 2021-09-09 09:05:59 +02:00
parent 8833e2e7b8
commit 0714791b9a
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 14 additions and 5 deletions

View File

@ -12,7 +12,16 @@ logg = logging.getLogger(__name__)
class LookNoop: class LookNoop:
def __init__(self, check=True):
self.check = check
def get(self, k, rpc=None): def get(self, k, rpc=None):
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: try:
if not is_checksum_address(k): if not is_checksum_address(k):
raise ValueError('not valid checksum address {}'.format(k)) raise ValueError('not valid checksum address {}'.format(k))

View File

@ -118,7 +118,7 @@ def main():
# TODO: make resolvers pluggable # TODO: make resolvers pluggable
token_resolver = DefaultResolver(chain_spec, conn, sender_address=rpc.get_sender_address()) 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') token_resolver.add_lookup(noop_lookup, 'noop')
if config.get('_TOKEN_INDEX') != None: if config.get('_TOKEN_INDEX') != None: