@@ -17,20 +17,11 @@ import {
1717} from '@/background/services/openPayments' ;
1818import { bigIntMax , convert , getNextSendableAmount } from '@/background/utils' ;
1919import type {
20- EventsService ,
21- OpenPaymentsService ,
22- OutgoingPaymentGrantService ,
23- StorageService ,
24- TabState ,
25- } from '.' ;
26- import type {
27- BackgroundToContentMessage ,
28- MessageManager ,
2920 MonetizationEventDetails ,
3021 MonetizationEventPayload ,
3122} from '@/shared/messages' ;
3223import type { AmountValue } from '@/shared/types' ;
33- import type { Logger } from '@/shared/logger ' ;
24+ import type { Cradle as Cradle_ } from '@/background/container ' ;
3425import {
3526 OUTGOING_PAYMENT_POLLING_INITIAL_DELAY ,
3627 OUTGOING_PAYMENT_POLLING_INTERVAL ,
@@ -47,17 +38,35 @@ interface CreateOutgoingPaymentParams {
4738 incomingPaymentId : IncomingPayment [ 'id' ] ;
4839 amount : string ;
4940}
41+ type Cradle = Pick <
42+ Cradle_ ,
43+ | 'storage'
44+ | 'openPaymentsService'
45+ | 'outgoingPaymentGrantService'
46+ | 'events'
47+ | 'tabState'
48+ | 'logger'
49+ | 'message'
50+ > ;
5051
5152export 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+
5361 private active = false ;
5462 /** Invalid receiver (providers not peered or other reasons) */
5563 private isInvalid = false ;
5664 private countInvalidReceiver = 0 ;
5765 private isDisabled = false ;
5866 private incomingPaymentUrl : string ;
5967 private incomingPaymentExpiresAt : number ;
60- private amount : string ;
68+ private rate : AmountValue ;
69+ private amount : AmountValue ;
6170 private intervalInMs : number ;
6271 private shouldRetryImmediately = false ;
6372
@@ -69,15 +78,11 @@ export class PaymentSession {
6978 private requestId : string ,
7079 private tabId : number ,
7180 private frameId : number ,
72- private storage : StorageService ,
73- private openPaymentsService : OpenPaymentsService ,
74- private outgoingPaymentGrantService : OutgoingPaymentGrantService ,
75- private events : EventsService ,
76- private tabState : TabState ,
7781 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+ }
8186
8287 #adjustAmountLastRate: AmountValue ;
8388 #adjustAmountController = new AbortController ( ) ;
0 commit comments