resolveAttachments function

Future<List<Result<void, String>>> resolveAttachments(
  1. DidcommPlaintextMessage message
)

Will resolve all attachments inside a DidcommPlaintextMessage results will be reported as appropriate as Result for each attachment

Implementation

Future<List<Result<void, String>>> resolveAttachments(
    DidcommPlaintextMessage message) async {
  var results = <Result<void, String>>[];
  if (message.attachments != null && message.attachments!.isNotEmpty) {
    for (var a in message.attachments!) {
      try {
        await a.data.resolveData();
        results.add(Result.Ok(null));
      } catch (e) {
        results.add(Result.Error(e.toString()));
      }
    }
  }

  return results;
}