call method

  1. @override
Future<RPCResponse> call(
  1. String function, [
  2. List? params
])
override

Performs an RPC request, asking the server to execute the function with the given name and the associated parameters, which need to be encodable with the json class of dart:convert.

When the request is successful, an RPCResponse with the request id and the data from the server will be returned. If not, an RPCError will be thrown. Other errors might be thrown if an IO-Error occurs.

Implementation

@override
Future<RPCResponse> call(String function, [List? params]) {
  params ??= [];

  var request = MagicRPCRequest(method: function, params: params);

  /* Send the RPCRequest to Magic Relayer and decode it by using RPCResponse from web3dart */
  return send(request: request, completer: Completer<JavaScriptMessage>())
      .then((jsMsg) {
    var relayerResponse = RelayerResponse<dynamic>.fromJson(
        json.decode(jsMsg.message), (json) => json as dynamic);
    return relayerResponse.response;
  });
}