Skip to content

Conversation

@AndreaDiazCorreia
Copy link
Member

@AndreaDiazCorreia AndreaDiazCorreia commented Sep 9, 2025

All references to the dispute token were removed because it is no longer used.

Summary by CodeRabbit

  • Refactor
    • Removed dispute token from the data model and standardized on dispute ID across notifications and UI.
  • Bug Fix
    • Notification details now only show a dispute identifier when present.
    • Order export now always includes the expiry field (may be empty).
  • Chores
    • Removed obsolete token-related localization strings in English, Spanish, and Italian.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 9, 2025

Walkthrough

DisputeToken was removed from the Dispute model and its (de)serialization. Notification payloads for dispute events now use dispute_id instead of user_token, the notification UI reads dispute_id, and three localization keys related to token verification were removed from EN/ES/IT ARB files.

Changes

Cohort / File(s) Summary
Dispute model cleanup
lib/data/models/dispute.dart
Removed disputeToken field and all references: constructor, copyWith, toJson/fromJson parsing (including oid extraction), operator ==, hashCode, and toString.
Notification payload + UI consumption
lib/features/order/notfiers/abstract_mostro_notifier.dart, lib/features/notifications/widgets/notification_details.dart
Renamed payload key user_tokendispute_id for disputeInitiatedByYou/disputeInitiatedByPeer; UI now checks dispute_id and displays notificationDisputeId only when present.
Order serialization tweak
lib/data/models/order.dart
expires_at is always emitted in toJson() (previously conditional on non-null).
Localization removals
lib/l10n/intl_en.arb, lib/l10n/intl_es.arb, lib/l10n/intl_it.arb
Removed keys: tokenVerified, awaitingTokenVerification, askAdminQuoteToken across EN/ES/IT.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Notifier as AbstractMostroNotifier
  participant System as Notification System
  participant UI as NotificationDetails
  participant Model as Dispute Model

  Note over Model: disputeToken removed from model and (de)serialization

  Notifier->>System: sendNotification(eventId, data: { dispute_id: dispute.disputeId })
  System-->>UI: deliver payload (includes dispute_id)
  UI->>UI: if data.dispute_id present -> render "notificationDisputeId" row
  UI-->>User: display dispute_id
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • grunch
  • Catrya
  • chebizarro

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and succinctly summarizes the primary change of the refactor by indicating the removal of dispute token functionality along with its associated translations, which aligns directly with the main modifications made in the changeset.
Description Check ✅ Passed The description directly references the removal of all dispute token references, which is the central theme of the pull request and thus is clearly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

A rabbit hops with nimble code,
Tokens gone — new id on the road.
Notifications clearer, ARB trimmed light,
Models leaner, everything's right. 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/token-error

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: 0

🧹 Nitpick comments (1)
lib/features/notifications/widgets/notification_details.dart (1)

88-94: Switch to dispute_id looks correct; consider a legacy-safe fallback to 'dispute'

If older backends/clients might still send 'dispute', you can show it without reintroducing tokens.

-        if (data.containsKey('dispute_id')) {
+        final disputeId = data['dispute_id'] ?? data['dispute'];
+        if (disputeId != null && disputeId.toString().isNotEmpty) {
           widgets.add(DetailRow(
             label: S.of(context)!.notificationDisputeId,
-            value: _formatHashOrId(context, data['dispute_id']),
+            value: _formatHashOrId(context, disputeId),
             icon: HeroIcons.exclamationTriangle,
           ));
         }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0631cb0 and 45a8876.

📒 Files selected for processing (6)
  • lib/data/models/dispute.dart (1 hunks)
  • lib/features/notifications/widgets/notification_details.dart (1 hunks)
  • lib/features/order/notfiers/abstract_mostro_notifier.dart (2 hunks)
  • lib/l10n/intl_en.arb (0 hunks)
  • lib/l10n/intl_es.arb (0 hunks)
  • lib/l10n/intl_it.arb (0 hunks)
💤 Files with no reviewable changes (3)
  • lib/l10n/intl_en.arb
  • lib/l10n/intl_it.arb
  • lib/l10n/intl_es.arb
🧰 Additional context used
📓 Path-based instructions (3)
{lib/*.dart,lib/!(generated)/**/*.dart}

📄 CodeRabbit inference engine (CLAUDE.md)

{lib/*.dart,lib/!(generated)/**/*.dart}: Use localized strings; replace hardcoded user-facing text with S.of(context).keyName
Prefer const constructors and const where possible
Use latest Flutter/Dart APIs (e.g., withValues() instead of deprecated withOpacity())

Files:

  • lib/features/notifications/widgets/notification_details.dart
  • lib/features/order/notfiers/abstract_mostro_notifier.dart
  • lib/data/models/dispute.dart
{lib/*.dart,lib/!(generated)/**/*.dart,test/**/*.dart}

📄 CodeRabbit inference engine (CLAUDE.md)

{lib/*.dart,lib/!(generated)/**/*.dart,test/**/*.dart}: Check mounted before using BuildContext after await (async gaps)
Remove unused imports and dependencies

Files:

  • lib/features/notifications/widgets/notification_details.dart
  • lib/features/order/notfiers/abstract_mostro_notifier.dart
  • lib/data/models/dispute.dart
**/*.dart

📄 CodeRabbit inference engine (CLAUDE.md)

All code comments, variable names, and function names must be in English

Files:

  • lib/features/notifications/widgets/notification_details.dart
  • lib/features/order/notfiers/abstract_mostro_notifier.dart
  • lib/data/models/dispute.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (2)
lib/data/models/dispute.dart (1)

304-305: hashCode/toString updated to drop the token — LGTM

Both now reflect the current fields only; no stale references to the removed token remain.

Also applies to: 307-308

lib/features/order/notfiers/abstract_mostro_notifier.dart (1)

282-284: Approve: notifier emits dispute_id with no leftover token or i18n keys
All token-based keys/fields and obsolete ARB entries have been removed; dispute_id usage is consistent.

@grunch
Copy link
Member

grunch commented Sep 9, 2025

@AndreaDiazCorreia Please update this PR with the latest changes from main. The current branch is based on an older commit of main that still had a bug, which is causing the issue here. Rebasing main should fix it.

mostrod expect a message with expires_at: null
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/data/models/order.dart (1)

199-217: Data loss risk in DB mapping: trade pubkeys not persisted by toMap

fromMap reads buyerTradePubkey/sellerTradePubkey, but toMap never writes them. Round-tripping through storage drops these fields.

   Map<String, dynamic> toMap() {
     return {
@@
       'masterSellerPubkey': masterSellerPubkey,
+      'buyerTradePubkey': buyerTradePubkey,
+      'sellerTradePubkey': sellerTradePubkey,
       'buyerInvoice': buyerInvoice,
       'createdAt': createdAt,
       'expiresAt': expiresAt,
     };
   }

Also applies to: 219-238

🧹 Nitpick comments (4)
lib/data/models/order.dart (4)

67-67: Out-of-scope wire-format change: avoid emitting expires_at: null unless API requires it

This PR is about dispute token removal; always including expires_at (possibly null) changes the payload. If the backend rejects nulls or treats them differently, this can break requests. Prefer the prior conditional emit unless you’ve validated the contract.

-    data[type]['expires_at'] = expiresAt;
+    if (expiresAt != null) {
+      data[type]['expires_at'] = expiresAt;
+    }

48-62: Round-trip mismatch: toJson nests under type ("order"), fromJson reads flat

toJson returns { "order": { ... } } while fromJson expects top-level fields. Objects you serialize with toJson won’t parse with fromJson as-is.

   factory Order.fromJson(Map<String, dynamic> json) {
     try {
+      // Support both nested `{ "order": { ... } }` and flat payloads
+      final Map<String, dynamic> payload =
+          (json['order'] is Map<String, dynamic>)
+              ? (json['order'] as Map<String, dynamic>)
+              : json;
       // Validate required fields
-      void validateField(String field) {
-        if (!json.containsKey(field) || json[field] == null) {
+      void validateField(String field) {
+        if (!payload.containsKey(field) || payload[field] == null) {
           throw FormatException('Missing required field: $field');
         }
       }
@@
-      int parseIntField(String field, {int defaultValue = 0}) {
-        final value = json[field];
+      int parseIntField(String field, {int defaultValue = 0}) {
+        final value = payload[field];
@@
-      String parseStringField(String field) {
-        final value = json[field];
+      String parseStringField(String field) {
+        final value = payload[field];
@@
-      String? parseOptionalStringField(String field) {
-        final value = json[field];
+      String? parseOptionalStringField(String field) {
+        final value = payload[field];
@@
-      int? parseOptionalIntField(String field) {
-        final value = json[field];
+      int? parseOptionalIntField(String field) {
+        final value = payload[field];

Also applies to: 78-83


1-1: Remove unused import

dart_nostr/nostr/model/event/event.dart isn’t referenced in this file.

-import 'package:dart_nostr/nostr/model/event/event.dart';

189-196: Safer numeric casts from NostrEvent

Cast via num to avoid TypeError when values are double or other numeric types.

-      amount: event.amount as int,
+      amount: (event.amount as num).toInt(),
@@
-      premium: event.premium as int,
+      premium: (event.premium as num).toInt(),
@@
-      createdAt: event.createdAt as int,
-      expiresAt: event.expiration as int?,
+      createdAt: (event.createdAt as num).toInt(),
+      expiresAt: (event.expiration as num?)?.toInt(),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 45a8876 and 12ff3cb.

📒 Files selected for processing (1)
  • lib/data/models/order.dart (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
{lib/*.dart,lib/!(generated)/**/*.dart}

📄 CodeRabbit inference engine (CLAUDE.md)

{lib/*.dart,lib/!(generated)/**/*.dart}: Use localized strings; replace hardcoded user-facing text with S.of(context).keyName
Prefer const constructors and const where possible
Use latest Flutter/Dart APIs (e.g., withValues() instead of deprecated withOpacity())

Files:

  • lib/data/models/order.dart
{lib/*.dart,lib/!(generated)/**/*.dart,test/**/*.dart}

📄 CodeRabbit inference engine (CLAUDE.md)

{lib/*.dart,lib/!(generated)/**/*.dart,test/**/*.dart}: Check mounted before using BuildContext after await (async gaps)
Remove unused imports and dependencies

Files:

  • lib/data/models/order.dart
**/*.dart

📄 CodeRabbit inference engine (CLAUDE.md)

All code comments, variable names, and function names must be in English

Files:

  • lib/data/models/order.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

Copy link
Member

@grunch grunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@grunch grunch merged commit 09f1c24 into main Sep 11, 2025
2 checks passed
@grunch grunch deleted the fix/token-error branch September 11, 2025 15:28
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.

3 participants