funga-eth

Ethereum implementation of the funga keystore and signer
Info | Log | Files | Refs | README | LICENSE

jsonrpc.py (556B)


      1 # local imports
      2 from funga.error import UnknownAccountError
      3 
      4 
      5 def jsonrpc_error(rpc_id, err):
      6     return {
      7             'jsonrpc': '2.0',
      8             'id': rpc_id,
      9             'error': {
     10                 'code': err.CODE,
     11                 'message': err.MESSAGE,
     12                 },
     13             }
     14 
     15 
     16 def jsonrpc_ok(rpc_id, response):
     17     return {
     18             'jsonrpc': '2.0',
     19             'id': rpc_id,
     20             'result': response,
     21             }
     22 
     23 
     24 def is_valid_json(j):
     25     if j.get('id') == 'None':
     26         raise ValueError('id missing')
     27     return True
     28 
     29 
     30