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)
def decode_rpc_response(self, raw_response: bytes) -> RPCResponse: text_response = to_text(raw_response) return cast(RPCResponse, FriendlyJsonSerde().json_decode(text_response))
def decode_rpc_response(self, response): text_response = to_text(response) return FriendlyJsonSerde().json_decode(text_response)