saveMintInfo method

  1. @override
Future<void> saveMintInfo({
  1. required CashuMintInfo mintInfo,
})
override

Implementation

@override
Future<void> saveMintInfo({required CashuMintInfo mintInfo}) async {
  // Use the first URL as the key for upsert logic
  final key = mintInfo.urls.first;

  // Remove existing mint info with the same URL
  final allRecords = await _mintInfoStore.find(_database);
  for (final record in allRecords) {
    final existingMintInfo =
        CashuMintInfoExtension.fromJsonStorage(record.value);
    if (existingMintInfo.urls.contains(mintInfo.urls.first)) {
      await _mintInfoStore.record(record.key).delete(_database);
    }
  }

  // Insert new mint info
  await _mintInfoStore
      .record(key)
      .put(_database, mintInfo.toJsonForStorage());
}