Skip to content

Commit

Permalink
chanege fetchZappedReceipts to Stream<ZapReceipt>
Browse files Browse the repository at this point in the history
  • Loading branch information
frnandu committed Dec 22, 2024
1 parent 4f83859 commit cdced08
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/ndk/example/zaps/receipts_for_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void main() async {
pubKey:
"787338757fc25d65cd929394d5e7713cf43638e8d259e8dcf5c73b834eb851f2",
eventId:
"906a0c5920b59e5754d0df5164bfea2a8d48ce5d73beaa1e854b3e6725e3288a");
"906a0c5920b59e5754d0df5164bfea2a8d48ce5d73beaa1e854b3e6725e3288a").toList();

// Sort eventReceipts by amountSats in descending order
receipts
Expand Down
2 changes: 1 addition & 1 deletion packages/ndk/example/zaps/receipts_for_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void main() async {
print("fetching zap receipts for profile ");
final profileReceipts = await ndk.zaps.fetchZappedReceipts(
pubKey: "30782a8323b7c98b172c5a2af7206bb8283c655be6ddce11133611a03d5f1177",
);
).toList();

// Sort profileReceipts by amountSats in descending order
profileReceipts
Expand Down
9 changes: 5 additions & 4 deletions packages/ndk/lib/domain_layer/usecases/zaps/zaps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,17 @@ class Zaps {
}

/// fetch all zap receipts matching given pubKey and optional event id, in sats
Future<List<ZapReceipt>> fetchZappedReceipts(
{required String pubKey, String? eventId, Duration? timeout}) async {
Stream<ZapReceipt> fetchZappedReceipts(
{required String pubKey, String? eventId, Duration? timeout}) {
NdkResponse? response = _requests.query(timeout: timeout??Duration(seconds:10), filters: [
eventId != null
? Filter(kinds: [ZapReceipt.KIND], eTags: [eventId], pTags: [pubKey])
: Filter(kinds: [ZapReceipt.KIND], pTags: [pubKey])
]);
List<Nip01Event> events = await response.future;
// TODO how to check validity of zap receipts without nostrPubKey and recipientLnurl????
return events.map((event) => ZapReceipt.fromEvent(event)).toList();
return response.stream.map((event) => ZapReceipt.fromEvent(event));
// List<Nip01Event> events = await response.future;
// return events.map((event) => ZapReceipt.fromEvent(event)).toList();
}

/// fetch all zap receipts matching given pubKey and optional event id, in sats
Expand Down

0 comments on commit cdced08

Please sign in to comment.