request method

Future request({
  1. required String method,
  2. dynamic params,
})

EIP1193 request to the wallet

Implementation

Future<dynamic> request({required String method, params}) {
  Completer c = Completer();
  if (_loginState != LoginState.connected) {
    c.completeError("User is not logged in!");
    return c.future;
  }
  var r = _createRequest(method, params);
  int id = r.id;
  final listener = EventListener(
    '$id',
    (Map<String, dynamic> data) => _wrapResponseListener(data, c),
    once: true,
  );
  _eventEmitter.addEventListener(listener);
  _injectJavaScript(r.toJSONString());
  return c.future;
}