updateSession method
Update the existing session.
Implementation
Future updateSession(SessionStatus sessionStatus) async {
if (!connected) {
throw WalletConnectException('Session currently disconnected');
}
session.chainId = sessionStatus.chainId;
session.accounts = sessionStatus.accounts;
session.networkId = sessionStatus.networkId ?? 0;
session.rpcUrl = sessionStatus.rpcUrl ?? '';
final params = {
'approved': true,
'chainId': session.chainId,
'networkId': session.networkId,
'accounts': session.accounts,
'rpcUrl': session.rpcUrl,
};
final request = JsonRpcRequest(
id: payloadId,
method: 'wc_sessionUpdate',
params: [params],
);
// Send the request
final response = await _sendRequest(request);
// Notify listeners
await _handleSessionResponse(response);
}