getTransactionContent method

Future<Map<String, String>> getTransactionContent(
  1. Map<String, String> addresses
)

Query the network to find a transaction from a list of addresses

Implementation

Future<Map<String, String>> getTransactionContent(
  Map<String, String> addresses,
) async {
  if (addresses.isEmpty) {
    return {};
  }

  try {
    final transactionChainMap = await getTransactionChain(
      addresses,
      request: 'data { content }',
    );

    final contentMap = <String, String>{};

    transactionChainMap.forEach((key, value) {
      final transactionList = transactionChainMap[key];
      if (transactionList != null) {
        for (final element in transactionList) {
          if (element.data != null && element.data!.content != null) {
            contentMap[key] = element.data!.content!;
          }
        }
      }
    });

    return removeAliasPrefix<String>(contentMap) ?? {};
  } catch (e) {
    log(
      'getTransactionContent: error=$e',
      logsActivation: logsActivation,
    );
    rethrow;
  }
}