Skip to content

Conversation

@ocbentonita
Copy link

@ocbentonita ocbentonita commented Feb 11, 2026

Summary

This PR adds the user reputation fields to the NIP-69 pending event as requested in #685.

Changes

  • Added volumeTraded and tradesCompleted to the rating tag array
  • Respects user privacy settings (show_volume_traded)

Rating Tag Format (After)

['rating', totalRating, days, totalReviews, volumeTraded, tradesCompleted]

Testing

  • All existing tests pass (106/106)
  • Verified rating tag output includes new fields
  • Confirmed volumeTraded is 0 when user has show_volume_traded: false

Closes #685

Summary by CodeRabbit

  • New Features
    • Enhanced rating metrics to include volume traded and completed trades for clearer trading performance insights.
  • Bug Fixes
    • Improved handling of missing or unavailable rating data to prevent gaps and ensure consistent display.

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
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Walkthrough

This PR exposes the orderToTags function by converting it from a private const to an exported function, and extends the rating tuple to include two additional maker metrics: volumeTraded and tradesCompleted, each defaulting to 0 when unavailable.

Changes

Cohort / File(s) Summary
NOSTR Events Enhancement
bot/modules/nostr/events.ts
Exported orderToTags function and extended the rating tuple from 3 to 5 elements by appending volumeTraded and tradesCompleted fields with default values of 0; updated totalRating extraction to handle missing values safely.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops with glee and cheer,
Functions now exposed, loud and clear!
Five metrics dance in tuple's song,
Trades and volumes, steady and strong.
NOSTR tags hum — the code moves along! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding user reputation (volumeTraded and tradesCompleted fields) to the NIP-69 pending event's rating tag.
Linked Issues check ✅ Passed The PR successfully implements the requirement from issue #685 by adding reputation fields (volumeTraded, tradesCompleted) to the rating tag and respecting user privacy settings.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing reputation inclusion in NIP-69 events; exposing orderToTags publicly is a necessary supporting change for the feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NIP-69 event is not sending the user reputation

1 participant