approveSession method
Approves the session requested by the peer (dApp), responding with the accounts and client's id and meta. https://docs.walletconnect.com/client-api#approve-session-request-connect
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,
),
));
}