feat(bond): support anti-abuse bond payout claim flow#595
Conversation
- Parse Payload::BondPayoutRequest and new Action.addBondInvoice (mostro-core 0.11.3); Order.fromJson accepts status: null. - New /add_bond_invoice/:orderId screen with NWC autopay + manual bolt11 fallback; deadline computed from slashed_at + bond_payout_claim_window_days (kind-38385). - Cobra tu parte chip in My Trades and COBRAR button in Trade Detail; FSM preserves trade status so the bond flow doesn't wipe it. - sendBondInvoice service/notifier methods, dedicated stream provider, session navigation, and reusable info-event tag parser. - Localization keys across en/es/it (real) and de/fr (placeholder); unit tests for payload, dispatcher, enum decoding, and info-event parser.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR implements end-to-end support for claiming a slashed anti-abuse bond after winning a dispute. It introduces new data models, service methods, state machine transitions, a complete bond-claim screen with NWC integration, routing infrastructure, and localized UI messaging across five languages. ChangesAnti-Abuse Bond Claim Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
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)
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.
Actionable comments posted: 2
🧹 Nitpick comments (4)
test/data/models/bond_payout_request_test.dart (1)
1-3: ⚡ Quick winUse the aggregated models barrel import.
Switch these model imports to
package:mostro_mobile/data/models.dartto match repository import conventions.♻️ Proposed change
-import 'package:mostro_mobile/data/models/bond_payout_request.dart'; -import 'package:mostro_mobile/data/models/order.dart'; -import 'package:mostro_mobile/data/models/payload.dart'; +import 'package:mostro_mobile/data/models.dart';As per coding guidelines: "Import models through
data/models.dartinstead of importing individual model files".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/data/models/bond_payout_request_test.dart` around lines 1 - 3, Replace the three individual model imports in bond_payout_request_test.dart (imports of bond_payout_request, order, payload) with the aggregated models barrel import by importing package:mostro_mobile/data/models.dart; update any references to BondPayoutRequest, Order, Payload remain unchanged since they are re-exported from the barrel so no other code changes are needed.test/data/models/enums/action_test.dart (1)
1-1: ⚡ Quick winUse
data/models.dartinstead of importing enum files directly.Please replace the direct
Actionimport with the shared models barrel import for consistency with project conventions.♻️ Proposed change
-import 'package:mostro_mobile/data/models/enums/action.dart'; +import 'package:mostro_mobile/data/models.dart';As per coding guidelines: "Import models through
data/models.dartinstead of importing individual model files".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/data/models/enums/action_test.dart` at line 1, Replace the direct enum import of Action with the project's models barrel: in test/data/models/enums/action_test.dart remove the import 'package:mostro_mobile/data/models/enums/action.dart' and import the shared barrel 'package:mostro_mobile/data/models.dart' instead so the test uses Action via the consolidated models export; update any references to Action remain unchanged.lib/features/order/screens/add_bond_invoice_screen.dart (1)
5-5: ⚡ Quick winUse the models barrel import for
BondPayoutRequest.This import bypasses the project’s model import convention.
♻️ Proposed fix
-import 'package:mostro_mobile/data/models/bond_payout_request.dart'; +import 'package:mostro_mobile/data/models.dart';As per coding guidelines: "Import models through
data/models.dartinstead of importing individual model files".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/features/order/screens/add_bond_invoice_screen.dart` at line 5, Replace the direct model import of BondPayoutRequest with the project's models barrel import: remove the import 'package:mostro_mobile/data/models/bond_payout_request.dart' in add_bond_invoice_screen.dart and add the barrel import 'package:mostro_mobile/data/models.dart' so references to BondPayoutRequest continue to resolve via the models.dart export; ensure no other individual model imports remain in that file.lib/features/trades/widgets/trades_list_item.dart (1)
6-6: ⚡ Quick winSwitch this enum import to the
data/models.dartbarrel.This new import bypasses the repository model import convention.
♻️ Proposed fix
-import 'package:mostro_mobile/data/models/enums/action.dart' as mostro_action; +import 'package:mostro_mobile/data/models.dart' as mostro_models;- orderState.action == mostro_action.Action.addBondInvoice + orderState.action == mostro_models.Action.addBondInvoiceAs per coding guidelines: "Import models through
data/models.dartinstead of importing individual model files".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/features/trades/widgets/trades_list_item.dart` at line 6, The file imports the enum directly from action.dart (import 'package:mostro_mobile/data/models/enums/action.dart' as mostro_action;); change this to import the models barrel instead by replacing that direct enum import with a single import from 'package:mostro_mobile/data/models.dart' and update any usages that reference mostro_action to use the same symbol from the barrel (e.g., Action or mostro_action if you keep the alias) so the code follows the repository convention of importing models from data/models.dart.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/features/order/screens/add_bond_invoice_screen.dart`:
- Line 109: Replace the hardcoded error text in the error builder (currently
"Center(child: Text('Error: \$e'))" in add_bond_invoice_screen.dart) with a
localized string: import package:mostro_mobile/generated/l10n.dart, use
S.of(context)! with an appropriate key (e.g. errorWithDetails or genericError)
and pass the error message (e.toString()) to that localized formatter; update or
add the localization key in your ARB/intl resources if it doesn't exist, then
use that S.of(context)!.key in the error branch so the UI is fully localized.
In `@lib/shared/providers/mostro_storage_provider.dart`:
- Around line 2-4: Replace the three individual model imports in
mostro_storage_provider.dart (the imports for bond_payout_request.dart,
mostro_message.dart, and order.dart) with the single barrel import
package:mostro_mobile/data/models.dart; update the import section in the file so
the provider uses the consolidated models.dart export instead of per-model
imports (no code changes needed elsewhere).
---
Nitpick comments:
In `@lib/features/order/screens/add_bond_invoice_screen.dart`:
- Line 5: Replace the direct model import of BondPayoutRequest with the
project's models barrel import: remove the import
'package:mostro_mobile/data/models/bond_payout_request.dart' in
add_bond_invoice_screen.dart and add the barrel import
'package:mostro_mobile/data/models.dart' so references to BondPayoutRequest
continue to resolve via the models.dart export; ensure no other individual model
imports remain in that file.
In `@lib/features/trades/widgets/trades_list_item.dart`:
- Line 6: The file imports the enum directly from action.dart (import
'package:mostro_mobile/data/models/enums/action.dart' as mostro_action;); change
this to import the models barrel instead by replacing that direct enum import
with a single import from 'package:mostro_mobile/data/models.dart' and update
any usages that reference mostro_action to use the same symbol from the barrel
(e.g., Action or mostro_action if you keep the alias) so the code follows the
repository convention of importing models from data/models.dart.
In `@test/data/models/bond_payout_request_test.dart`:
- Around line 1-3: Replace the three individual model imports in
bond_payout_request_test.dart (imports of bond_payout_request, order, payload)
with the aggregated models barrel import by importing
package:mostro_mobile/data/models.dart; update any references to
BondPayoutRequest, Order, Payload remain unchanged since they are re-exported
from the barrel so no other code changes are needed.
In `@test/data/models/enums/action_test.dart`:
- Line 1: Replace the direct enum import of Action with the project's models
barrel: in test/data/models/enums/action_test.dart remove the import
'package:mostro_mobile/data/models/enums/action.dart' and import the shared
barrel 'package:mostro_mobile/data/models.dart' instead so the test uses Action
via the consolidated models export; update any references to Action remain
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6ed9d43c-641a-46dd-a0ce-7be12c66062e
📒 Files selected for processing (28)
integration_test/test_helpers.dartlib/core/app_routes.dartlib/data/models.dartlib/data/models/bond_payout_request.dartlib/data/models/enums/action.dartlib/data/models/order.dartlib/data/models/payload.dartlib/features/mostro/mostro_instance.dartlib/features/notifications/utils/notification_message_mapper.dartlib/features/notifications/widgets/notification_item.dartlib/features/order/models/order_state.dartlib/features/order/notifiers/abstract_mostro_notifier.dartlib/features/order/notifiers/order_notifier.dartlib/features/order/screens/add_bond_invoice_screen.dartlib/features/trades/screens/trade_detail_screen.dartlib/features/trades/widgets/mostro_message_detail_widget.dartlib/features/trades/widgets/trades_list_item.dartlib/l10n/intl_de.arblib/l10n/intl_en.arblib/l10n/intl_es.arblib/l10n/intl_fr.arblib/l10n/intl_it.arblib/services/mostro_service.dartlib/shared/providers/mostro_storage_provider.darttest/data/models/bond_payout_request_test.darttest/data/models/enums/action_test.darttest/features/mostro/mostro_instance_test.darttest/models/order_test.dart
Summary by CodeRabbit
New Features
Localization