import { fetchBlockchainInfo } from '../http/fetcher' ; import { AppDispatch } from '../../contexts/reducer' ; import { AppActions } from '../../contexts/actions' ; const alertNotEmpty = ( wrapper ) : boolean => wrapper !== null && wrapper !== undefined && wrapper . attributes && wrapper . attributes . blockchainInfo && wrapper . attributes . blockchainInfo . alerts && wrapper . attributes . blockchainInfo . alerts . length > 0 ; export const handleBlockchainAlert = ( dispatch ) => { fetchBlockchainInfo ( ) . then ( ( wrapper ) => { if ( alertNotEmpty ( wrapper ) ) { dispatch ( { type : AppActions . UpdateAppErrors , payload : { appError : { type : 'ChainAlert' , message : wrapper ! . attributes . blockchainInfo . alerts . map ( alert => alert . message ) , } , } , } ) ; } else { dispatch ( { type : AppActions . UpdateAppErrors , payload : { appError : { type : 'ChainAlert' , message : [ ] , } , } , } ) ; } } ) ; } ; export default { handleBlockchainAlert , } ;