approveSession method

Future approveSession({
  1. required List<String> accounts,
  2. required int chainId,
})

Approve the session.

Implementation

Future approveSession({
  required List<String> accounts,
  required int chainId,
}) async {
  if (connected) {
    throw WalletConnectException('Session currently connected');
  }

  final params = {
    'approved': true,
    'chainId': chainId,
    'networkId': 0,
    'accounts': accounts,
    'rpcUrl': '',
    'peerId': session.clientId,
    'peerMeta': session.clientMeta,
  };

  final response = JsonRpcResponse(
    id: session.handshakeId,
    result: params,
  );

  await _sendResponse(response);
  session.connected = true;

  // Notify listeners
  _eventBus.fire(Event<SessionStatus>(
    'connect',
    SessionStatus(
      chainId: chainId,
      accounts: accounts,
    ),
  ));
}