rejectSessionAuthenticate method
Future<void>
rejectSessionAuthenticate({
- required int id,
- required WalletConnectError reason,
override
Implementation
@override
Future<void> rejectSessionAuthenticate({
required int id,
required WalletConnectError reason,
}) async {
_checkInitialized();
final pendingSessionAuthRequests = getPendingSessionAuthRequests();
if (!pendingSessionAuthRequests.containsKey(id)) {
throw Errors.getInternalError(
Errors.MISSING_OR_INVALID,
context: 'rejectSessionAuthenticate() '
'Could not find pending auth request with id $id',
);
}
final pendingRequest = pendingSessionAuthRequests[id]!;
if (!pendingRequest.transportType.isLinkMode) {
_confirmOnlineStateOrThrow();
}
final receiverPublicKey = pendingRequest.requester.publicKey;
final senderPublicKey = await core.crypto.generateKeyPair();
final responseTopic = core.crypto.getUtils().hashKey(receiverPublicKey);
final encodeOpts = EncodeOptions(
type: EncodeOptions.TYPE_1,
receiverPublicKey: receiverPublicKey,
senderPublicKey: senderPublicKey,
);
final method = MethodConstants.WC_SESSION_AUTHENTICATE;
final rpcOpts = MethodConstants.RPC_OPTS[method];
await core.pairing.sendError(
id,
responseTopic,
method,
JsonRpcError(code: reason.code, message: reason.message),
encodeOptions: encodeOpts,
rpcOptions: rpcOpts?['reject'],
appLink: _getAppLinkIfEnabled(pendingRequest.requester.metadata),
);
await sessionAuthRequests.delete(id.toString());
await _deleteProposal(id);
}