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 {
  await dbRdy;

  final box = _objectBox.store.box<DbCashuMintInfo>();

  // return all if no filters provided
  if (mintUrls == null || mintUrls.isEmpty) {
    return box.getAll().map((e) => e.toNdk()).toList();
  }

  // build OR condition
  Condition<DbCashuMintInfo>? cond;
  for (final url in mintUrls) {
    final c = DbCashuMintInfo_.urls.containsElement(url);
    cond = (cond == null) ? c : (cond | c);
  }

  final query = box.query(cond).build();
  try {
    return query.find().map((e) => e.toNdk()).toList();
  } finally {
    query.close();
  }
}