def middleware(method, params):
     if method != "eth_sign":
         return make_request(method, params)
     account_address, message = params[:2]
     account = address_to_accounts[account_address]
     # We will assume any string which looks like a hex is expected
     # to be converted to hex. Non-hexable strings are forcibly
     # converted by encoding them to utf-8
     try:
         message = HexBytes(message)
     except Exception:  # pylint: disable=broad-except
         message = HexBytes(message.encode("utf-8"))
     msg_hash_hexbytes = messages.defunct_hash_message(message)
     ec_signature = account.signHash(msg_hash_hexbytes)
     return {"result": ec_signature.signature}