Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/LN_ADDRESS_CONFIRMATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ All three receiving methods follow the same confirm-then-send pattern:
|------|--------|
| `lib/shared/widgets/ln_address_confirmation_widget.dart` | Confirmation widget with address display and confirm/fallback buttons |
| `lib/features/order/screens/add_lightning_invoice_screen.dart` | Shows confirmation when `lnAddress` param present |
| `lib/features/order/notfiers/abstract_mostro_notifier.dart` | Navigates to confirmation screen instead of auto-sending |
| `lib/features/order/notifiers/abstract_mostro_notifier.dart` | Navigates to confirmation screen instead of auto-sending |
| `lib/core/app_routes.dart` | Passes `lnAddress` query parameter to the screen |

## Design Decisions
Expand Down
16 changes: 8 additions & 8 deletions docs/architecture/ORDER_CREATION_PROCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ This document provides a detailed explanation of how order creation works in the
### Key Files and Classes

- **`lib/services/mostro_service.dart`** - Main service for Mostro communication
- **`lib/features/order/notfiers/order_notifier.dart`** - Manages order state and lifecycle
- **`lib/features/order/notfiers/abstract_mostro_notifier.dart`** - Base class for Mostro message handling
- **`lib/features/order/notifiers/order_notifier.dart`** - Manages order state and lifecycle
- **`lib/features/order/notifiers/abstract_mostro_notifier.dart`** - Base class for Mostro message handling
- **`lib/data/repositories/mostro_storage.dart`** - Local storage for Mostro messages
- **`lib/features/order/models/order_state.dart`** - Order state management
- **`lib/shared/providers/mostro_storage_provider.dart`** - Riverpod providers for message streams
Expand All @@ -33,7 +33,7 @@ The user creates an order through the UI (sell or buy order). This typically hap
When the user submits the order, the `AddOrderNotifier` handles the complete flow:

```dart
// lib/features/order/notfiers/add_order_notifier.dart:71-85
// lib/features/order/notifiers/add_order_notifier.dart:71-85
Future<void> submitOrder(Order order) async {
// 1. Create MostroMessage with new-order action
final message = MostroMessage<Order>(
Expand Down Expand Up @@ -191,7 +191,7 @@ Future<void> _onData(NostrEvent event) async {
When Mostro sends the confirmation message back with the order ID, the `AddOrderNotifier` processes it:

```dart
// lib/features/order/notfiers/add_order_notifier.dart:28-58
// lib/features/order/notifiers/add_order_notifier.dart:28-58
@override
void subscribe() {
subscription = ref.listen(
Expand Down Expand Up @@ -227,7 +227,7 @@ void subscribe() {

**Confirmation Processing**:
```dart
// lib/features/order/notfiers/add_order_notifier.dart:60-69
// lib/features/order/notifiers/add_order_notifier.dart:60-69
Future<void> _confirmOrder(MostroMessage message) async {
// 1. Update state with confirmed order
state = state.updateWith(message);
Expand Down Expand Up @@ -320,7 +320,7 @@ Future<void> addMessage(String key, MostroMessage message) async {
After confirmation, the `OrderNotifier` takes over for ongoing trade management:

```dart
// lib/features/order/notfiers/order_notifier.dart:15-25
// lib/features/order/notifiers/order_notifier.dart:15-25
class OrderNotifier extends AbstractMostroNotifier {
late final MostroService mostroService;

Expand All @@ -344,7 +344,7 @@ class OrderNotifier extends AbstractMostroNotifier {
The notifier subscribes to message streams using Riverpod providers:

```dart
// lib/features/order/notfiers/abstract_mostro_notifier.dart:35-55
// lib/features/order/notifiers/abstract_mostro_notifier.dart:35-55
void subscribe() {
subscription = ref.listen(
mostroMessageStreamProvider(orderId),
Expand Down Expand Up @@ -470,7 +470,7 @@ OrderState updateWith(MostroMessage message) {
The `new-order` action is handled in the `AbstractMostroNotifier`:

```dart
// lib/features/order/notfiers/abstract_mostro_notifier.dart lines 75-77
// lib/features/order/notifiers/abstract_mostro_notifier.dart lines 75-77
switch (event.action) {
case Action.newOrder:
break; // No special handling needed, state is already updated
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This directory contains comprehensive technical documentation for the Mostro Mob

### **Code Example Standards**
- Use actual code from the codebase, not pseudo-code
- Include file paths: `lib/features/order/notfiers/order_notifier.dart`
- Include file paths: `lib/features/order/notifiers/order_notifier.dart`
- Add line numbers for specific references: `// Line 45-67`
- Show complete context, not just isolated snippets
- Validate examples still compile and work
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/REQUEST_ID_ANALYSIS.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Similarly:

### Primary Files

#### A. `lib/features/order/notfiers/add_order_notifier.dart`
#### A. `lib/features/order/notifiers/add_order_notifier.dart`
```dart
class AddOrderNotifier extends AbstractMostroNotifier {
late int requestId; // Line 13
Expand Down
6 changes: 3 additions & 3 deletions docs/architecture/SESSION_AND_KEY_MANAGEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ The orphan session prevention system uses static timer storage with differentiat
### Complete Order Creation Process

#### 1. Order Submission
When a user creates a new order, the flow starts in `AddOrderNotifier.submitOrder()` (`lib/features/order/notfiers/add_order_notifier.dart:71-85`):
When a user creates a new order, the flow starts in `AddOrderNotifier.submitOrder()` (`lib/features/order/notifiers/add_order_notifier.dart:71-85`):

```dart
Future<void> submitOrder(Order order) async {
Expand Down Expand Up @@ -377,7 +377,7 @@ Future<void> publishOrder(MostroMessage order) async {
```

#### 3. Order Confirmation
When mostrod confirms the order, `AddOrderNotifier._confirmOrder()` is called (`lib/features/order/notfiers/add_order_notifier.dart:60-69`):
When mostrod confirms the order, `AddOrderNotifier._confirmOrder()` is called (`lib/features/order/notifiers/add_order_notifier.dart:60-69`):

```dart
Future<void> _confirmOrder(MostroMessage message) async {
Expand Down Expand Up @@ -1119,7 +1119,7 @@ final childSession = Session(
### Complete Order Creation Flow with Key Logging

```dart
// File: lib/features/order/notfiers/add_order_notifier.dart:71-85
// File: lib/features/order/notifiers/add_order_notifier.dart:71-85
Future<void> submitOrder(Order order) async {
logger.d('=== ORDER CREATION START ===');

Expand Down
18 changes: 9 additions & 9 deletions docs/architecture/TIMEOUT_DETECTION_AND_SESSION_CLEANUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The timeout detection system receives direct instructions from Mostro via encryp
#### **OrderNotifier Implementation**

```dart
// lib/features/order/notfiers/order_notifier.dart
// lib/features/order/notifiers/order_notifier.dart
class OrderNotifier extends AbstractMostroNotifier {
// Simplified implementation - timeout/cancellation logic moved to AbstractMostroNotifier
@override
Expand All @@ -69,7 +69,7 @@ The system processes timeout and cancellation instructions directly from Mostro
#### **AbstractMostroNotifier Gift Wrap Processing**

```dart
// lib/features/order/notfiers/abstract_mostro_notifier.dart
// lib/features/order/notifiers/abstract_mostro_notifier.dart
Future<void> handleEvent(MostroMessage event, {bool bypassTimestampGate = false}) async {
switch (event.action) {
case Action.newOrder:
Expand Down Expand Up @@ -773,7 +773,7 @@ final session = ref.read(sessionNotifierProvider.notifier).getSessionByOrderId(o
## Related Documentation

### Implementation Files
- **`lib/features/order/notfiers/order_notifier.dart`** - Core timeout detection and synthetic event creation
- **`lib/features/order/notifiers/order_notifier.dart`** - Core timeout detection and synthetic event creation
- **`lib/data/models/mostro_message.dart`** - MostroMessage.createTimeoutReversal() factory
- **`lib/shared/providers/time_provider.dart`** - Countdown timer system
- **`lib/shared/notifiers/session_notifier.dart`** - Session management
Expand All @@ -797,7 +797,7 @@ The system automatically starts cleanup timers for both order creation and order
When users take orders, a cleanup timer is automatically started to prevent sessions from becoming orphaned if Mostro doesn't respond:

```dart
// lib/features/order/notfiers/abstract_mostro_notifier.dart - startSessionTimeoutCleanup method
// lib/features/order/notifiers/abstract_mostro_notifier.dart - startSessionTimeoutCleanup method
static void startSessionTimeoutCleanup(String orderId, Ref ref) {
// Cancel existing timer if any
_sessionTimeouts[orderId]?.cancel();
Expand All @@ -824,7 +824,7 @@ static void startSessionTimeoutCleanup(String orderId, Ref ref) {
The cleanup timer is automatically cancelled when any response is received from Mostro:

```dart
// lib/features/order/notfiers/abstract_mostro_notifier.dart:92-93
// lib/features/order/notifiers/abstract_mostro_notifier.dart:92-93
void handleEvent(MostroMessage event) {
// Cancel timer on ANY response from Mostro for this order
_cancelSessionTimeoutCleanup(orderId);
Expand All @@ -836,7 +836,7 @@ void handleEvent(MostroMessage event) {
When users create new orders, a similar cleanup timer prevents orphan sessions if Mostro doesn't respond to the order creation request:

```dart
// lib/features/order/notfiers/abstract_mostro_notifier.dart
// lib/features/order/notifiers/abstract_mostro_notifier.dart
static void startSessionTimeoutCleanupForRequestId(int requestId, Ref ref) {
final key = 'request:$requestId';
// Cancel existing timer if any
Expand Down Expand Up @@ -865,7 +865,7 @@ static void startSessionTimeoutCleanupForRequestId(int requestId, Ref ref) {
The cleanup timer is started automatically when users take orders:

```dart
// lib/features/order/notfiers/order_notifier.dart:107-108
// lib/features/order/notifiers/order_notifier.dart:107-108
Future<void> takeSellOrder(String orderId, int? amount, String? lnAddress) async {
// ... session creation

Expand All @@ -880,7 +880,7 @@ Future<void> takeSellOrder(String orderId, int? amount, String? lnAddress) async
The cleanup timer is started automatically when users create orders:

```dart
// lib/features/order/notfiers/add_order_notifier.dart
// lib/features/order/notifiers/add_order_notifier.dart
Future<void> submitOrder(Order order) async {
// ... session creation

Expand All @@ -898,7 +898,7 @@ Future<void> submitOrder(Order order) async {
When the 10-second timer expires, users receive a localized notification and are automatically navigated back to the order book:

```dart
// lib/features/order/notfiers/abstract_mostro_notifier.dart:381-393
// lib/features/order/notifiers/abstract_mostro_notifier.dart:381-393
static void _showTimeoutNotificationAndNavigate(Ref ref) {
try {
// Show snackbar with localized timeout message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mostro_mobile/data/enums.dart';
import 'package:mostro_mobile/data/models.dart';
import 'package:mostro_mobile/shared/providers.dart';
import 'package:mostro_mobile/features/order/notfiers/abstract_mostro_notifier.dart';
import 'package:mostro_mobile/features/order/notifiers/abstract_mostro_notifier.dart';
import 'package:mostro_mobile/features/order/providers/order_notifier_provider.dart';
import 'package:mostro_mobile/features/order/models/order_state.dart';
import 'package:mostro_mobile/services/logger_service.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:mostro_mobile/data/models.dart';
import 'package:mostro_mobile/features/order/models/order_state.dart';
import 'package:mostro_mobile/features/notifications/providers/notifications_provider.dart';
import 'package:mostro_mobile/shared/providers.dart';
import 'package:mostro_mobile/features/order/notfiers/abstract_mostro_notifier.dart';
import 'package:mostro_mobile/features/order/notifiers/abstract_mostro_notifier.dart';
import 'package:mostro_mobile/services/logger_service.dart';
import 'package:mostro_mobile/services/mostro_service.dart';

Expand Down
4 changes: 2 additions & 2 deletions lib/features/order/providers/order_notifier_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mostro_mobile/data/models/enums/order_type.dart';
import 'package:mostro_mobile/data/models/mostro_message.dart';
import 'package:mostro_mobile/features/order/models/order_state.dart';
import 'package:mostro_mobile/features/order/notfiers/add_order_notifier.dart';
import 'package:mostro_mobile/features/order/notfiers/order_notifier.dart';
import 'package:mostro_mobile/features/order/notifiers/add_order_notifier.dart';
import 'package:mostro_mobile/features/order/notifiers/order_notifier.dart';
import 'package:mostro_mobile/shared/providers/mostro_storage_provider.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'order_notifier_provider.g.dart';
Expand Down
2 changes: 1 addition & 1 deletion test/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'package:mostro_mobile/services/mostro_service.dart';
import 'package:mostro_mobile/services/nostr_service.dart';
import 'package:mostro_mobile/shared/notifiers/session_notifier.dart';
import 'package:mostro_mobile/features/order/models/order_state.dart';
import 'package:mostro_mobile/features/order/notfiers/order_notifier.dart';
import 'package:mostro_mobile/features/order/notifiers/order_notifier.dart';
import 'package:mostro_mobile/services/blossom_client.dart';
import 'package:mostro_mobile/services/encrypted_file_upload_service.dart';
import 'package:mostro_mobile/services/encrypted_image_upload_service.dart';
Expand Down
Loading