addOriginKey method

Future<String> addOriginKey({
  1. String? originPublicKey,
  2. String? certificate,
})

Add a new origin key @param {String} originPublicKey origin public key to be added @param {String} certificate certificate of the origin public key

Implementation

Future<String> addOriginKey({
  String? originPublicKey,
  String? certificate,
}) async {
  final jsonRPCRequest = {
    'jsonrpc': '2.0',
    'method': 'add_origin_key',
    'params': <String, String>{
      'origin_public_key': originPublicKey!,
      'certificate': certificate!,
    },
    'id': 1,
  };

  log(
    'addOriginKey: requestHttp.body=${json.encode(jsonRPCRequest)}',
    logsActivation: logsActivation,
  );

  final responseHttp = await http.post(
    Uri.parse('$endpoint/api/rpc'),
    body: json.encode(jsonRPCRequest),
    headers: kRequestHeaders,
  );

  log(
    'addOriginKey: responseHttp.body=${responseHttp.body}',
    logsActivation: logsActivation,
  );

  final result = getJsonRPCResult(responseHttp.body);

  return originKeyResponseFromJson(
    json.encode(
      result,
    ),
  ).toString();
}