示例#1
0
 def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes:
     rpc_dict = {
         "jsonrpc": "2.0",
         "method": method,
         "params": params or [],
         "id": next(self.request_counter),
     }
     encoded = FriendlyJsonSerde().json_encode(rpc_dict)
     return to_bytes(text=encoded)
示例#2
0
 def decode_rpc_response(self, raw_response: bytes) -> RPCResponse:
     text_response = to_text(raw_response)
     return cast(RPCResponse,
                 FriendlyJsonSerde().json_decode(text_response))
示例#3
0
 def decode_rpc_response(self, response):
     text_response = to_text(response)
     return FriendlyJsonSerde().json_decode(text_response)