parseQuicksignRequest method

  1. @override
QuicksignRequest parseQuicksignRequest({
  1. required Map<String, dynamic> request,
})
override

Attempts to parse the JSON map "request" into a SigningRequest object. Throws errors on failure. See https://github.com/kadena-io/KIPs/blob/master/kip-0015.md for the Quicksign spec.

Implementation

@override
QuicksignRequest parseQuicksignRequest({
  required Map<String, dynamic> request,
}) {
  QuicksignRequest? quicksignRequest;
  try {
    // If the request is null, try to parse the json request
    quicksignRequest = QuicksignRequest.fromJson(request);
  } catch (e) {
    throw QuicksignResult(
      error: QuicksignError(
        type: QuicksignError.other,
        msg: Constants.quicksignParseFailure,
      ),
    );
  }

  // If the request has an empty list of commands, return an error
  if (quicksignRequest.commandSigDatas.isEmpty) {
    throw QuicksignResult(
      error: QuicksignError(
        type: QuicksignError.emptyList,
      ),
    );
  }

  return quicksignRequest;
}