Ejemplo n.º 1
0
 def _address_rxp(self, addr):
     """ Create a regex string for addresses, that matches several representations:
         - with(out) '0x' prefix
         - `pex` version
         This function takes care of maintaining additional lookup keys for substring matches.
         In case the given string is no address, it returns the original string.
     """
     try:
         addr = to_checksum_address(addr)
         rxp = '(?:0x)?' + pex(address_checksum_and_decode(addr)) + f'(?:{addr.lower()[10:]})?'
         self._extra_keys[pex(address_checksum_and_decode(addr))] = addr.lower()
         self._extra_keys[addr[2:].lower()] = addr.lower()
     except ValueError:
         rxp = addr
     return rxp
Ejemplo n.º 2
0
 def _address_rxp(self, addr):
     """ Create a regex string for addresses, that matches several representations:
         - with(out) '0x' prefix
         - `pex` version
         This function takes care of maintaining additional lookup keys for substring matches.
         In case the given string is no address, it returns the original string.
     """
     try:
         addr = to_checksum_address(addr)
         rxp = '(?:0x)?' + pex(address_checksum_and_decode(addr)) + f'(?:{addr.lower()[10:]})?'
         self._extra_keys[pex(address_checksum_and_decode(addr))] = addr.lower()
         self._extra_keys[addr[2:].lower()] = addr.lower()
     except ValueError:
         rxp = addr
     return rxp