@@ -17,7 +17,7 @@ import {
17
17
UnsignedTransaction ,
18
18
SmartTransactionsStatus ,
19
19
SmartTransactionStatuses ,
20
- Fee ,
20
+ Fees ,
21
21
} from './types' ;
22
22
import {
23
23
getAPIRequestURL ,
@@ -51,6 +51,8 @@ export interface SmartTransactionsControllerState extends BaseState {
51
51
smartTransactionsState : {
52
52
smartTransactions : Record < string , SmartTransaction [ ] > ;
53
53
userOptIn : boolean | undefined ;
54
+ liveness : boolean | undefined ;
55
+ fees : Fees | undefined ;
54
56
} ;
55
57
}
56
58
@@ -118,6 +120,8 @@ export default class SmartTransactionsController extends BaseController<
118
120
smartTransactionsState : {
119
121
smartTransactions : { } ,
120
122
userOptIn : undefined ,
123
+ fees : undefined ,
124
+ liveness : true ,
121
125
} ,
122
126
} ;
123
127
@@ -446,15 +450,7 @@ export default class SmartTransactionsController extends BaseController<
446
450
} ;
447
451
}
448
452
449
- async getFees (
450
- unsignedTransaction : UnsignedTransaction ,
451
- ) : Promise < {
452
- fees : Fee [ ] ;
453
- cancelFees : Fee [ ] ;
454
- feeEstimate : number ;
455
- gasLimit : number ;
456
- gasUsed : number ;
457
- } > {
453
+ async getFees ( unsignedTransaction : UnsignedTransaction ) : Promise < Fees > {
458
454
const { chainId } = this . config ;
459
455
460
456
const unsignedTransactionWithNonce = await this . addNonceToTransaction (
@@ -464,6 +460,12 @@ export default class SmartTransactionsController extends BaseController<
464
460
method : 'POST' ,
465
461
body : JSON . stringify ( { tx : unsignedTransactionWithNonce } ) ,
466
462
} ) ;
463
+ this . update ( {
464
+ smartTransactionsState : {
465
+ ...this . state . smartTransactionsState ,
466
+ fees : data ,
467
+ } ,
468
+ } ) ;
467
469
468
470
return data ;
469
471
}
@@ -549,10 +551,23 @@ export default class SmartTransactionsController extends BaseController<
549
551
550
552
async fetchLiveness ( ) : Promise < boolean > {
551
553
const { chainId } = this . config ;
552
- const response = await this . fetch (
553
- getAPIRequestURL ( APIType . LIVENESS , chainId ) ,
554
- ) ;
555
- return Boolean ( response . lastBlock ) ;
554
+ let liveness = false ;
555
+ try {
556
+ const response = await this . fetch (
557
+ getAPIRequestURL ( APIType . LIVENESS , chainId ) ,
558
+ ) ;
559
+ liveness = Boolean ( response . lastBlock ) ;
560
+ } catch ( e ) {
561
+ console . log ( '"fetchLiveness" API call failed' ) ;
562
+ }
563
+
564
+ this . update ( {
565
+ smartTransactionsState : {
566
+ ...this . state . smartTransactionsState ,
567
+ liveness,
568
+ } ,
569
+ } ) ;
570
+ return liveness ;
556
571
}
557
572
558
573
async setStatusRefreshInterval ( interval : number ) : Promise < void > {
0 commit comments