-
Notifications
You must be signed in to change notification settings - Fork 136
fix: include user reputation in NIP-69 pending event #743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: include user reputation in NIP-69 pending event #743
Conversation
Adds volumeTraded and tradesCompleted fields to the rating tag in NIP-69 events, as requested in lnp2pBot#685. - Respects user privacy: volumeTraded is 0 when show_volume_traded is false - Uses nullish coalescing for safe defaults Closes lnp2pBot#685
WalkthroughThis PR exposes the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@bot/modules/nostr/events.ts`:
- Line 28: The computation of totalRating assigns NaN when maker is null because
Number(maker?.total_rating.toFixed(2)) yields NaN which ?? 0 doesn't catch;
update the expression that sets totalRating (the variable named totalRating) to
use || 0 instead of ?? 0 and guard the toFixed call with optional chaining on
total_rating (e.g., use maker?.total_rating?.toFixed(2)) so that if maker or
maker.total_rating is missing the result falls back to 0 rather than NaN.
- Line 30: The line computing volumeTraded can yield undefined when
maker.show_volume_traded is true but maker.volume_traded is null/undefined;
update the expression that defines volumeTraded (currently referencing
maker.show_volume_traded and maker.volume_traded) to use a nullish-coalescing
fallback (e.g., default to 0) similar to how tradesCompleted is handled so the
tag never contains the string "undefined".
- Use || instead of ?? for totalRating to handle NaN - Add optional chaining on total_rating - Add nullish coalescing for volumeTraded when shown
Summary
This PR adds the user reputation fields to the NIP-69 pending event as requested in #685.
Changes
volumeTradedandtradesCompletedto the rating tag arrayshow_volume_traded)Rating Tag Format (After)
Testing
show_volume_traded: falseCloses #685
Summary by CodeRabbit