import { convert } from '@emeraldplatform/core' ; import { BlockchainCode , Currency } from '@emeraldwallet/core' ; import { Wei , WEIS } from '@emeraldpay/bigamount-crypto' ; export function txFeeFiat ( gasPrice , gasLimit , rate ) { if ( typeof rate == 'undefined' ) { return '--' ; } const wei = new Wei ( gasPrice ) . multiply ( convert . toBigNumber ( gasLimit ) ) ; const ether = wei . number . dividedBy ( WEIS . top . multiplier ) ; return Currency . convert ( ether . toFixed ( ) , rate ) ; } export const traceValidate = ( chain , tx , dispatch , estimateGas ) : Promise < number > => { return new Promise ( ( resolve , reject ) => { dispatch ( estimateGas ( chain , tx ) ) . then ( ( gasEst ) => { if ( ! gasEst ) { reject ( 'Invalid Transaction' ) ; } else if ( gasEst > tx . gas . toNumber ( ) ) { reject ( `Insufficient Gas. Expected ${ gasEst }` ) ; } else { resolve ( gasEst ) ; } } ) . catch ( ( error ) => { reject ( error ) ; } ) ; } ) ; } ;