2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { addHexPrefix } from '../../../../../../app/scripts/lib/util';
|
2018-09-13 10:47:05 +02:00
|
|
|
import {
|
|
|
|
hideModal,
|
|
|
|
setGasLimit,
|
|
|
|
setGasPrice,
|
2020-03-11 16:07:48 +01:00
|
|
|
createRetryTransaction,
|
2018-10-26 07:50:36 +02:00
|
|
|
createSpeedUpTransaction,
|
|
|
|
hideSidebar,
|
2019-05-20 18:38:08 +02:00
|
|
|
updateSendAmount,
|
|
|
|
setGasTotal,
|
2019-07-03 22:33:44 +02:00
|
|
|
updateTransaction,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../../store/actions';
|
2018-08-02 18:02:22 +02:00
|
|
|
import {
|
|
|
|
setCustomGasPrice,
|
|
|
|
setCustomGasLimit,
|
2018-09-20 18:06:23 +02:00
|
|
|
resetCustomData,
|
2020-12-03 00:25:19 +01:00
|
|
|
fetchBasicGasEstimates,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../../ducks/gas/gas.duck';
|
2018-09-13 14:35:17 +02:00
|
|
|
import {
|
|
|
|
hideGasButtonGroup,
|
2019-05-20 18:38:08 +02:00
|
|
|
updateSendErrors,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../../ducks/send/send.duck';
|
2018-09-13 10:47:05 +02:00
|
|
|
import {
|
|
|
|
conversionRateSelector as getConversionRate,
|
2019-03-22 15:50:12 +01:00
|
|
|
getCurrentCurrency,
|
2018-10-26 07:50:36 +02:00
|
|
|
getCurrentEthBalance,
|
2019-03-22 15:50:12 +01:00
|
|
|
getIsMainnet,
|
2020-05-29 19:46:10 +02:00
|
|
|
getSendToken,
|
2020-05-26 08:11:58 +02:00
|
|
|
getPreferences,
|
2018-10-24 06:22:22 +02:00
|
|
|
getBasicGasEstimateLoadingStatus,
|
|
|
|
getCustomGasLimit,
|
|
|
|
getCustomGasPrice,
|
2018-09-13 10:47:05 +02:00
|
|
|
getDefaultActiveButtonIndex,
|
2018-10-24 06:22:22 +02:00
|
|
|
getRenderableBasicEstimateData,
|
2020-05-02 21:41:17 +02:00
|
|
|
isCustomPriceSafe,
|
2019-05-20 18:38:08 +02:00
|
|
|
getTokenBalance,
|
2020-05-04 17:22:34 +02:00
|
|
|
getSendMaxModeState,
|
2020-12-03 00:25:19 +01:00
|
|
|
getAveragePriceEstimateInHexWEI,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../../selectors';
|
2020-05-04 21:06:28 +02:00
|
|
|
|
2018-09-13 10:47:05 +02:00
|
|
|
import {
|
2020-10-06 20:28:38 +02:00
|
|
|
addHexes,
|
2019-05-20 18:38:08 +02:00
|
|
|
subtractHexWEIsToDec,
|
2018-09-13 10:47:05 +02:00
|
|
|
hexWEIToDecGWEI,
|
2020-10-06 20:28:38 +02:00
|
|
|
getValueFromWeiHex,
|
|
|
|
sumHexWEIsToRenderableFiat,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../../helpers/utils/conversions.util';
|
|
|
|
import { formatETHFee } from '../../../../helpers/utils/formatters';
|
2018-09-13 10:47:05 +02:00
|
|
|
import {
|
|
|
|
calcGasTotal,
|
2018-10-26 07:50:36 +02:00
|
|
|
isBalanceSufficient,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../../pages/send/send.utils';
|
|
|
|
import { MIN_GAS_LIMIT_DEC } from '../../../../pages/send/send.constants';
|
|
|
|
import { calcMaxAmount } from '../../../../pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.utils';
|
|
|
|
import { TRANSACTION_STATUSES } from '../../../../../../shared/constants/transaction';
|
|
|
|
import GasModalPageContainer from './gas-modal-page-container.component';
|
2018-08-02 18:02:22 +02:00
|
|
|
|
2018-10-26 07:50:36 +02:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { currentNetworkTxList, send } = state.metamask;
|
|
|
|
const { modalState: { props: modalProps } = {} } = state.appState.modal || {};
|
|
|
|
const { txData = {} } = modalProps || {};
|
|
|
|
const { transaction = {} } = ownProps;
|
2020-11-04 17:14:08 +01:00
|
|
|
const selectedTransaction = currentNetworkTxList.find(
|
|
|
|
({ id }) => id === (transaction.id || txData.id),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
const buttonDataLoading = getBasicGasEstimateLoadingStatus(state);
|
|
|
|
const sendToken = getSendToken(state);
|
2020-05-28 21:39:33 +02:00
|
|
|
|
|
|
|
// a "default" txParams is used during the send flow, since the transaction doesn't exist yet in that case
|
|
|
|
const txParams = selectedTransaction?.txParams
|
|
|
|
? selectedTransaction.txParams
|
|
|
|
: {
|
2020-11-03 00:41:28 +01:00
|
|
|
gas: send.gasLimit || '0x5208',
|
2020-12-03 00:25:19 +01:00
|
|
|
gasPrice: send.gasPrice || getAveragePriceEstimateInHexWEI(state, true),
|
2020-11-03 00:41:28 +01:00
|
|
|
value: sendToken ? '0x0' : send.amount,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-05-28 21:39:33 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const { gasPrice: currentGasPrice, gas: currentGasLimit, value } = txParams;
|
|
|
|
const customModalGasPriceInHex = getCustomGasPrice(state) || currentGasPrice;
|
2020-11-03 00:41:28 +01:00
|
|
|
const customModalGasLimitInHex =
|
2021-02-04 19:15:23 +01:00
|
|
|
getCustomGasLimit(state) || currentGasLimit || '0x5208';
|
2020-11-03 00:41:28 +01:00
|
|
|
const customGasTotal = calcGasTotal(
|
|
|
|
customModalGasLimitInHex,
|
|
|
|
customModalGasPriceInHex,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-09-13 10:47:05 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const gasButtonInfo = getRenderableBasicEstimateData(
|
|
|
|
state,
|
|
|
|
customModalGasLimitInHex,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-09-13 10:47:05 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const currentCurrency = getCurrentCurrency(state);
|
|
|
|
const conversionRate = getConversionRate(state);
|
2020-10-06 20:28:38 +02:00
|
|
|
const newTotalFiat = sumHexWEIsToRenderableFiat(
|
2020-11-04 17:14:08 +01:00
|
|
|
[value, customGasTotal],
|
2020-10-06 20:28:38 +02:00
|
|
|
currentCurrency,
|
|
|
|
conversionRate,
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-09-13 10:47:05 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const { hideBasic } = state.appState.modal.modalState.props;
|
2018-09-13 14:35:17 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const customGasPrice = calcCustomGasPrice(customModalGasPriceInHex);
|
2018-10-10 18:06:38 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const maxModeOn = getSendMaxModeState(state);
|
2019-05-20 18:38:08 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const balance = getCurrentEthBalance(state);
|
2018-10-26 07:50:36 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const { showFiatInTestnets } = getPreferences(state);
|
|
|
|
const isMainnet = getIsMainnet(state);
|
|
|
|
const showFiat = Boolean(isMainnet || showFiatInTestnets);
|
2019-02-26 19:30:41 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const isSendTokenSet = Boolean(sendToken);
|
2019-05-20 18:38:08 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const newTotalEth =
|
|
|
|
maxModeOn && !isSendTokenSet
|
|
|
|
? sumHexWEIsToRenderableEth([balance, '0x0'])
|
2021-02-04 19:15:23 +01:00
|
|
|
: sumHexWEIsToRenderableEth([value, customGasTotal]);
|
2020-03-11 21:13:48 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const sendAmount =
|
|
|
|
maxModeOn && !isSendTokenSet
|
|
|
|
? subtractHexWEIsFromRenderableEth(balance, customGasTotal)
|
2021-02-04 19:15:23 +01:00
|
|
|
: sumHexWEIsToRenderableEth([value, '0x0']);
|
2019-05-20 18:38:08 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const insufficientBalance = maxModeOn
|
|
|
|
? false
|
|
|
|
: !isBalanceSufficient({
|
|
|
|
amount: value,
|
|
|
|
gasTotal: customGasTotal,
|
|
|
|
balance,
|
|
|
|
conversionRate,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2018-10-23 19:10:27 +02:00
|
|
|
|
2018-08-02 18:02:22 +02:00
|
|
|
return {
|
2018-09-13 14:35:17 +02:00
|
|
|
hideBasic,
|
2018-09-13 10:47:05 +02:00
|
|
|
isConfirm: isConfirm(state),
|
2018-09-20 18:06:23 +02:00
|
|
|
customModalGasPriceInHex,
|
|
|
|
customModalGasLimitInHex,
|
2018-10-10 18:06:38 +02:00
|
|
|
customGasPrice,
|
2018-09-20 18:06:23 +02:00
|
|
|
customGasLimit: calcCustomGasLimit(customModalGasLimitInHex),
|
2019-05-20 18:38:08 +02:00
|
|
|
customGasTotal,
|
2018-09-13 10:47:05 +02:00
|
|
|
newTotalFiat,
|
2020-11-04 17:14:08 +01:00
|
|
|
customPriceIsSafe: isCustomPriceSafe(state),
|
2019-05-20 18:38:08 +02:00
|
|
|
maxModeOn,
|
2018-08-16 14:28:27 +02:00
|
|
|
gasPriceButtonGroupProps: {
|
|
|
|
buttonDataLoading,
|
2020-11-03 00:41:28 +01:00
|
|
|
defaultActiveButtonIndex: getDefaultActiveButtonIndex(
|
|
|
|
gasButtonInfo,
|
|
|
|
customModalGasPriceInHex,
|
|
|
|
),
|
2018-09-13 10:47:05 +02:00
|
|
|
gasButtonInfo,
|
|
|
|
},
|
|
|
|
infoRowProps: {
|
2020-10-06 20:28:38 +02:00
|
|
|
originalTotalFiat: sumHexWEIsToRenderableFiat(
|
2020-11-04 17:14:08 +01:00
|
|
|
[value, customGasTotal],
|
2020-10-06 20:28:38 +02:00
|
|
|
currentCurrency,
|
|
|
|
conversionRate,
|
|
|
|
),
|
2020-11-04 17:14:08 +01:00
|
|
|
originalTotalEth: sumHexWEIsToRenderableEth([value, customGasTotal]),
|
2019-02-26 19:30:41 +01:00
|
|
|
newTotalFiat: showFiat ? newTotalFiat : '',
|
2019-05-20 18:38:08 +02:00
|
|
|
newTotalEth,
|
2020-10-06 20:28:38 +02:00
|
|
|
transactionFee: sumHexWEIsToRenderableEth(['0x0', customGasTotal]),
|
2019-05-20 18:38:08 +02:00
|
|
|
sendAmount,
|
2018-08-16 14:28:27 +02:00
|
|
|
},
|
2019-07-03 22:33:44 +02:00
|
|
|
transaction: txData || transaction,
|
2020-11-07 08:38:12 +01:00
|
|
|
isSpeedUp: transaction.status === TRANSACTION_STATUSES.SUBMITTED,
|
|
|
|
isRetry: transaction.status === TRANSACTION_STATUSES.FAILED,
|
2018-10-26 07:50:36 +02:00
|
|
|
txId: transaction.id,
|
|
|
|
insufficientBalance,
|
2019-03-22 15:50:12 +01:00
|
|
|
isMainnet,
|
2020-05-29 19:46:10 +02:00
|
|
|
sendToken,
|
2019-05-20 18:38:08 +02:00
|
|
|
balance,
|
|
|
|
tokenBalance: getTokenBalance(state),
|
2020-10-06 20:28:38 +02:00
|
|
|
conversionRate,
|
|
|
|
value,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2018-07-31 04:28:05 +02:00
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
const mapDispatchToProps = (dispatch) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const updateCustomGasPrice = (newPrice) =>
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(setCustomGasPrice(addHexPrefix(newPrice)));
|
2018-09-13 10:47:05 +02:00
|
|
|
|
2018-07-31 04:28:05 +02:00
|
|
|
return {
|
2018-09-20 18:06:23 +02:00
|
|
|
cancelAndClose: () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(resetCustomData());
|
|
|
|
dispatch(hideModal());
|
2018-09-20 18:06:23 +02:00
|
|
|
},
|
2018-11-27 18:30:41 +01:00
|
|
|
hideModal: () => dispatch(hideModal()),
|
2018-09-13 10:47:05 +02:00
|
|
|
updateCustomGasPrice,
|
2020-11-03 00:41:28 +01:00
|
|
|
updateCustomGasLimit: (newLimit) =>
|
|
|
|
dispatch(setCustomGasLimit(addHexPrefix(newLimit))),
|
2018-09-13 10:47:05 +02:00
|
|
|
setGasData: (newLimit, newPrice) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(setGasLimit(newLimit));
|
|
|
|
dispatch(setGasPrice(newPrice));
|
2018-09-13 10:47:05 +02:00
|
|
|
},
|
2019-07-03 22:33:44 +02:00
|
|
|
updateConfirmTxGasAndCalculate: (gasLimit, gasPrice, updatedTx) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
updateCustomGasPrice(gasPrice);
|
|
|
|
dispatch(setCustomGasLimit(addHexPrefix(gasLimit.toString(16))));
|
|
|
|
return dispatch(updateTransaction(updatedTx));
|
2018-09-13 10:47:05 +02:00
|
|
|
},
|
2020-03-12 15:33:11 +01:00
|
|
|
createRetryTransaction: (txId, gasPrice, gasLimit) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
return dispatch(createRetryTransaction(txId, gasPrice, gasLimit));
|
2020-03-11 16:07:48 +01:00
|
|
|
},
|
2020-03-12 15:33:11 +01:00
|
|
|
createSpeedUpTransaction: (txId, gasPrice, gasLimit) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
return dispatch(createSpeedUpTransaction(txId, gasPrice, gasLimit));
|
2018-10-26 07:50:36 +02:00
|
|
|
},
|
2018-09-13 14:35:17 +02:00
|
|
|
hideGasButtonGroup: () => dispatch(hideGasButtonGroup()),
|
2018-10-26 07:50:36 +02:00
|
|
|
hideSidebar: () => dispatch(hideSidebar()),
|
2020-12-03 00:25:19 +01:00
|
|
|
fetchBasicGasEstimates: () => dispatch(fetchBasicGasEstimates()),
|
2019-05-20 18:38:08 +02:00
|
|
|
setGasTotal: (total) => dispatch(setGasTotal(total)),
|
|
|
|
setAmountToMax: (maxAmountDataObject) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatch(updateSendErrors({ amount: null }));
|
|
|
|
dispatch(updateSendAmount(calcMaxAmount(maxAmountDataObject)));
|
2019-05-20 18:38:08 +02:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2018-07-31 04:28:05 +02:00
|
|
|
|
2018-09-13 10:47:05 +02:00
|
|
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
2019-05-23 15:56:40 +02:00
|
|
|
const {
|
|
|
|
gasPriceButtonGroupProps,
|
2020-08-18 18:36:45 +02:00
|
|
|
// eslint-disable-next-line no-shadow
|
2019-05-23 15:56:40 +02:00
|
|
|
isConfirm,
|
|
|
|
txId,
|
|
|
|
isSpeedUp,
|
2019-10-28 14:28:46 +01:00
|
|
|
isRetry,
|
2019-05-23 15:56:40 +02:00
|
|
|
insufficientBalance,
|
|
|
|
maxModeOn,
|
|
|
|
customGasPrice,
|
|
|
|
customGasTotal,
|
|
|
|
balance,
|
2020-05-29 19:46:10 +02:00
|
|
|
sendToken,
|
2019-05-23 15:56:40 +02:00
|
|
|
tokenBalance,
|
|
|
|
customGasLimit,
|
2019-07-03 22:33:44 +02:00
|
|
|
transaction,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = stateProps;
|
2018-09-13 10:47:05 +02:00
|
|
|
const {
|
2018-09-13 14:35:17 +02:00
|
|
|
hideGasButtonGroup: dispatchHideGasButtonGroup,
|
2018-09-13 10:47:05 +02:00
|
|
|
setGasData: dispatchSetGasData,
|
|
|
|
updateConfirmTxGasAndCalculate: dispatchUpdateConfirmTxGasAndCalculate,
|
2018-10-26 07:50:36 +02:00
|
|
|
createSpeedUpTransaction: dispatchCreateSpeedUpTransaction,
|
2019-10-28 14:28:46 +01:00
|
|
|
createRetryTransaction: dispatchCreateRetryTransaction,
|
2018-10-26 07:50:36 +02:00
|
|
|
hideSidebar: dispatchHideSidebar,
|
2018-11-27 18:30:41 +01:00
|
|
|
cancelAndClose: dispatchCancelAndClose,
|
|
|
|
hideModal: dispatchHideModal,
|
2019-05-20 18:38:08 +02:00
|
|
|
setAmountToMax: dispatchSetAmountToMax,
|
2018-09-13 10:47:05 +02:00
|
|
|
...otherDispatchProps
|
2021-02-04 19:15:23 +01:00
|
|
|
} = dispatchProps;
|
2018-09-13 10:47:05 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
...stateProps,
|
|
|
|
...otherDispatchProps,
|
|
|
|
...ownProps,
|
2018-10-26 07:50:36 +02:00
|
|
|
onSubmit: (gasLimit, gasPrice) => {
|
2020-11-04 17:14:08 +01:00
|
|
|
if (isConfirm) {
|
2019-07-03 22:33:44 +02:00
|
|
|
const updatedTx = {
|
|
|
|
...transaction,
|
|
|
|
txParams: {
|
|
|
|
...transaction.txParams,
|
|
|
|
gas: gasLimit,
|
|
|
|
gasPrice,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
dispatchUpdateConfirmTxGasAndCalculate(gasLimit, gasPrice, updatedTx);
|
|
|
|
dispatchHideModal();
|
2018-10-26 07:50:36 +02:00
|
|
|
} else if (isSpeedUp) {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatchCreateSpeedUpTransaction(txId, gasPrice, gasLimit);
|
|
|
|
dispatchHideSidebar();
|
|
|
|
dispatchCancelAndClose();
|
2019-10-28 14:28:46 +01:00
|
|
|
} else if (isRetry) {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatchCreateRetryTransaction(txId, gasPrice, gasLimit);
|
|
|
|
dispatchHideSidebar();
|
|
|
|
dispatchCancelAndClose();
|
2018-10-26 07:50:36 +02:00
|
|
|
} else {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatchSetGasData(gasLimit, gasPrice);
|
|
|
|
dispatchHideGasButtonGroup();
|
|
|
|
dispatchCancelAndClose();
|
2018-10-26 07:50:36 +02:00
|
|
|
}
|
2019-05-20 18:38:08 +02:00
|
|
|
if (maxModeOn) {
|
|
|
|
dispatchSetAmountToMax({
|
|
|
|
balance,
|
|
|
|
gasTotal: customGasTotal,
|
2020-05-29 19:46:10 +02:00
|
|
|
sendToken,
|
2019-05-20 18:38:08 +02:00
|
|
|
tokenBalance,
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-05-20 18:38:08 +02:00
|
|
|
}
|
2018-10-26 07:50:36 +02:00
|
|
|
},
|
2018-09-13 10:47:05 +02:00
|
|
|
gasPriceButtonGroupProps: {
|
|
|
|
...gasPriceButtonGroupProps,
|
2020-11-13 01:37:16 +01:00
|
|
|
handleGasPriceSelection: ({ gasPrice }) =>
|
|
|
|
otherDispatchProps.updateCustomGasPrice(gasPrice),
|
2018-09-13 10:47:05 +02:00
|
|
|
},
|
2018-11-27 18:30:41 +01:00
|
|
|
cancelAndClose: () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatchCancelAndClose();
|
2019-10-28 14:28:46 +01:00
|
|
|
if (isSpeedUp || isRetry) {
|
2021-02-04 19:15:23 +01:00
|
|
|
dispatchHideSidebar();
|
2018-11-27 18:30:41 +01:00
|
|
|
}
|
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
disableSave:
|
2020-10-06 20:28:38 +02:00
|
|
|
insufficientBalance ||
|
|
|
|
(isSpeedUp && customGasPrice === 0) ||
|
2020-11-04 17:14:08 +01:00
|
|
|
customGasLimit < Number(MIN_GAS_LIMIT_DEC),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2018-09-13 10:47:05 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps,
|
|
|
|
mergeProps,
|
2021-02-04 19:15:23 +01:00
|
|
|
)(GasModalPageContainer);
|
2018-09-13 10:47:05 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function isConfirm(state) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return Boolean(Object.keys(state.confirmTransaction.txData).length);
|
2018-09-13 10:47:05 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function calcCustomGasPrice(customGasPriceInHex) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return Number(hexWEIToDecGWEI(customGasPriceInHex));
|
2018-09-13 10:47:05 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function calcCustomGasLimit(customGasLimitInHex) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return parseInt(customGasLimitInHex, 16);
|
2018-09-13 10:47:05 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function sumHexWEIsToRenderableEth(hexWEIs) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const hexWEIsSum = hexWEIs.filter(Boolean).reduce(addHexes);
|
2020-11-03 00:41:28 +01:00
|
|
|
return formatETHFee(
|
|
|
|
getValueFromWeiHex({
|
|
|
|
value: hexWEIsSum,
|
|
|
|
toCurrency: 'ETH',
|
|
|
|
numberOfDecimals: 6,
|
|
|
|
}),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-09-13 10:47:05 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function subtractHexWEIsFromRenderableEth(aHexWEI, bHexWEI) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return formatETHFee(subtractHexWEIsToDec(aHexWEI, bHexWEI));
|
2019-05-20 18:38:08 +02:00
|
|
|
}
|