@@ -17,20 +17,11 @@ import {
17
17
} from '@/background/services/openPayments' ;
18
18
import { bigIntMax , convert , getNextSendableAmount } from '@/background/utils' ;
19
19
import type {
20
- EventsService ,
21
- OpenPaymentsService ,
22
- OutgoingPaymentGrantService ,
23
- StorageService ,
24
- TabState ,
25
- } from '.' ;
26
- import type {
27
- BackgroundToContentMessage ,
28
- MessageManager ,
29
20
MonetizationEventDetails ,
30
21
MonetizationEventPayload ,
31
22
} from '@/shared/messages' ;
32
23
import type { AmountValue } from '@/shared/types' ;
33
- import type { Logger } from '@/shared/logger ' ;
24
+ import type { Cradle as Cradle_ } from '@/background/container ' ;
34
25
import {
35
26
OUTGOING_PAYMENT_POLLING_INITIAL_DELAY ,
36
27
OUTGOING_PAYMENT_POLLING_INTERVAL ,
@@ -47,17 +38,35 @@ interface CreateOutgoingPaymentParams {
47
38
incomingPaymentId : IncomingPayment [ 'id' ] ;
48
39
amount : string ;
49
40
}
41
+ type Cradle = Pick <
42
+ Cradle_ ,
43
+ | 'storage'
44
+ | 'openPaymentsService'
45
+ | 'outgoingPaymentGrantService'
46
+ | 'events'
47
+ | 'tabState'
48
+ | 'logger'
49
+ | 'message'
50
+ > ;
50
51
51
52
export class PaymentSession {
52
- private rate : string ;
53
+ private storage : Cradle [ 'storage' ] ;
54
+ private openPaymentsService : Cradle [ 'openPaymentsService' ] ;
55
+ private outgoingPaymentGrantService : Cradle [ 'outgoingPaymentGrantService' ] ;
56
+ private events : Cradle [ 'events' ] ;
57
+ private tabState : Cradle [ 'tabState' ] ;
58
+ private logger : Cradle [ 'logger' ] ;
59
+ private message : Cradle [ 'message' ] ;
60
+
53
61
private active = false ;
54
62
/** Invalid receiver (providers not peered or other reasons) */
55
63
private isInvalid = false ;
56
64
private countInvalidReceiver = 0 ;
57
65
private isDisabled = false ;
58
66
private incomingPaymentUrl : string ;
59
67
private incomingPaymentExpiresAt : number ;
60
- private amount : string ;
68
+ private rate : AmountValue ;
69
+ private amount : AmountValue ;
61
70
private intervalInMs : number ;
62
71
private shouldRetryImmediately = false ;
63
72
@@ -69,15 +78,11 @@ export class PaymentSession {
69
78
private requestId : string ,
70
79
private tabId : number ,
71
80
private frameId : number ,
72
- private storage : StorageService ,
73
- private openPaymentsService : OpenPaymentsService ,
74
- private outgoingPaymentGrantService : OutgoingPaymentGrantService ,
75
- private events : EventsService ,
76
- private tabState : TabState ,
77
81
private url : string ,
78
- private logger : Logger ,
79
- private message : MessageManager < BackgroundToContentMessage > ,
80
- ) { }
82
+ private deps : Cradle ,
83
+ ) {
84
+ Object . assign ( this , this . deps ) ;
85
+ }
81
86
82
87
#adjustAmountLastRate: AmountValue ;
83
88
#adjustAmountController = new AbortController ( ) ;
0 commit comments