rejectSession method

  1. @override
Future<void> rejectSession({
  1. required int id,
  2. required WalletConnectError reason,
})
override

Implementation

@override
Future<void> rejectSession({
  required int id,
  required WalletConnectError reason,
}) async {
  _checkInitialized();
  _confirmOnlineStateOrThrow();

  await _isValidReject(id, reason);

  ProposalData? proposal = proposals.get(id.toString());
  if (proposal != null) {
    // Attempt to send a response, if the pairing is not active, this will fail
    // but we don't care
    try {
      final method = MethodConstants.WC_SESSION_PROPOSE;
      final rpcOpts = MethodConstants.RPC_OPTS[method];
      await core.pairing.sendError(
        id,
        proposal.pairingTopic,
        method,
        JsonRpcError(code: reason.code, message: reason.message),
        rpcOptions: rpcOpts?['reject'],
      );
    } catch (_) {
      // print('got here');
    }
  }
  await _deleteProposal(id);
}