Migrate PaymentMonitorService to dependency injection pattern

- Convert PaymentMonitorService to extend BaseService with proper metadata
- Add invoiceService property to BaseService for payment status checking
- Register PaymentMonitorService in market module with DI container
- Update market store to use injected service instead of singleton import
- Remove exported singleton instance from service file
- Add proper service initialization and cleanup in market module

This completes the third legacy service migration, following InvoiceService
and NostrmarketService. The service now properly integrates with the DI
architecture for better testing, lifecycle management, and loose coupling.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
padreug 2025-09-07 01:42:41 +02:00
parent 14d6bc6329
commit 093846b351
5 changed files with 59 additions and 20 deletions

View file

@ -1,6 +1,6 @@
import { defineStore } from 'pinia'
import { ref, computed, readonly, watch } from 'vue'
import { paymentMonitor } from '../services/paymentMonitor'
import type { PaymentMonitorService } from '../services/paymentMonitor'
import { useAuth } from '@/composables/useAuthService'
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
import type { LightningInvoice, InvoiceService } from '@/core/services/invoiceService'
@ -19,6 +19,7 @@ export const useMarketStore = defineStore('market', () => {
const storageService = injectService(SERVICE_TOKENS.STORAGE_SERVICE) as any
const invoiceService = injectService(SERVICE_TOKENS.INVOICE_SERVICE) as InvoiceService
const nostrmarketService = injectService(SERVICE_TOKENS.NOSTRMARKET_SERVICE) as NostrmarketService
const paymentMonitorService = injectService(SERVICE_TOKENS.PAYMENT_MONITOR) as PaymentMonitorService
// Core market state
const markets = ref<Market[]>([])
const stalls = ref<Stall[]>([])
@ -545,10 +546,10 @@ export const useMarketStore = defineStore('market', () => {
saveOrdersToStorage()
// Start monitoring payment
await paymentMonitor.startMonitoring(order, invoice)
await paymentMonitorService.startMonitoring(order, invoice)
// Set up payment update callback
paymentMonitor.onPaymentUpdate(orderId, (update) => {
paymentMonitorService.onPaymentUpdate(orderId, (update) => {
handlePaymentUpdate(orderId, update)
})