2021-11-06 01:59:23 +01:00
|
|
|
import {
|
2023-01-27 19:28:03 +01:00
|
|
|
GasEstimateTypes,
|
2021-11-06 01:59:23 +01:00
|
|
|
CUSTOM_GAS_ESTIMATE,
|
|
|
|
} from '../../../shared/constants/gas';
|
2021-10-22 19:14:28 +02:00
|
|
|
|
|
|
|
export function getGasFeeEstimate(
|
|
|
|
field,
|
|
|
|
gasFeeEstimates,
|
|
|
|
gasEstimateType,
|
|
|
|
estimateToUse,
|
|
|
|
fallback = '0',
|
|
|
|
) {
|
2023-01-27 19:28:03 +01:00
|
|
|
if (gasEstimateType === GasEstimateTypes.feeMarket) {
|
2021-10-22 19:14:28 +02:00
|
|
|
return gasFeeEstimates?.[estimateToUse]?.[field] ?? String(fallback);
|
|
|
|
}
|
|
|
|
return String(fallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
export const feeParamsAreCustom = (transaction) =>
|
2021-11-06 01:59:23 +01:00
|
|
|
!transaction?.userFeeLevel ||
|
|
|
|
transaction?.userFeeLevel === CUSTOM_GAS_ESTIMATE;
|