getMintInfos method

  1. @override
Future<List<CashuMintInfo>?> getMintInfos({
  1. List<String>? mintUrls,
})
override

return all if no mintUrls are provided

Implementation

@override
Future<List<CashuMintInfo>?> getMintInfos({List<String>? mintUrls}) async {
  if (mintUrls == null || mintUrls.isEmpty) {
    // Return all mint infos
    final records = await _mintInfoStore.find(_database);
    return records
        .map((record) => CashuMintInfoExtension.fromJsonStorage(record.value))
        .toList();
  }

  // For Sembast, we need to filter in memory since we can't do complex array operations
  final allRecords = await _mintInfoStore.find(_database);
  final allMintInfos = allRecords
      .map((record) => CashuMintInfoExtension.fromJsonStorage(record.value))
      .toList();

  // Filter by URLs
  return allMintInfos.where((mintInfo) {
    return mintUrls.any((url) => mintInfo.urls.contains(url));
  }).toList();
}