transformRequest method

  1. @override
Future transformRequest(
  1. HttpAgentRequest request
)
override

Transform a request into a signed version of the request. This is done last after the transforms on the body of a request. The returned object can be anything, but must be serializable to CBOR. @param request - internet computer request to transform

Implementation

@override
Future<dynamic> transformRequest(HttpAgentRequest request) async {
  final body = request.body;
  final requestId = requestIdOf(body.toJson());
  return {
    ...request.toJson(),
    'body': {
      'content': request.body.toJson(),
      'sender_pubkey': getPublicKey().toDer(),
      'sender_sig': await sign(
        u8aConcat([
          '\x0Aic-request'.plainToU8a(), // Domain separator
          requestId.buffer,
        ]),
      ),
    },
  };
}