1- import { ok , err , Result } from '@synonymdev/result' ;
1+ import { IOnchainFees } from 'beignet' ;
2+ import { Result , err , ok } from '@synonymdev/result' ;
23
4+ import { getOnChainWalletAsync } from '../../utils/wallet' ;
35import { dispatch , getFeesStore } from '../helpers' ;
46import { updateOnchainFees } from '../slices/fees' ;
5- import { getFeeEstimates } from '../../utils/wallet/transactions' ;
6- import { EAvailableNetwork } from '../../utils/networks' ;
7- import { getOnChainWalletAsync , getSelectedNetwork } from '../../utils/wallet' ;
8- import { IOnchainFees } from 'beignet' ;
9-
10- export const REFRESH_INTERVAL = 60 * 30 ; // in seconds, 30 minutes
117
128export const updateOnchainFeeEstimates = async ( {
13- selectedNetwork = getSelectedNetwork ( ) ,
149 forceUpdate = false ,
1510 feeEstimates,
1611} : {
17- selectedNetwork : EAvailableNetwork ;
1812 forceUpdate ?: boolean ;
1913 feeEstimates ?: IOnchainFees ;
2014} ) : Promise < Result < string > > => {
@@ -24,12 +18,7 @@ export const updateOnchainFeeEstimates = async ({
2418 }
2519
2620 if ( ! feeEstimates ) {
27- const timestamp = feesStore . onchain . timestamp ;
28- const difference = Math . floor ( ( Date . now ( ) - timestamp ) / 1000 ) ;
29- if ( ! forceUpdate && difference < REFRESH_INTERVAL ) {
30- return ok ( 'On-chain fee estimates are up to date.' ) ;
31- }
32- const feeEstimatesRes = await getFeeEstimates ( selectedNetwork ) ;
21+ const feeEstimatesRes = await refreshOnchainFeeEstimates ( { forceUpdate } ) ;
3322 if ( feeEstimatesRes . isErr ( ) ) {
3423 return err ( feeEstimatesRes . error ) ;
3524 }
0 commit comments