William O'Beirne d1a2c885a2 Performance Improvements (Pure components, debounced gas slider) (#899)
* PureComponent a ton of non-connected components.

* Debounce gas price slider. Keep gas price in state to reflect changes immediately.

* PureComponent balance sidebar and swap unconnected components.

* Import correct component.

* Move debouncing of gas slider to sagas via gasPriceInputIntent action.

* Remove console log.

* Remove leftover file from merge.
2018-01-29 13:13:46 -06:00

40 lines
1.2 KiB
TypeScript

import { AppState } from 'reducers';
import { getTransactionState, getGasCost } from 'selectors/transaction';
import { getEtherBalance } from 'selectors/wallet';
import { getOffline } from 'selectors/config';
const getFields = (state: AppState) => getTransactionState(state).fields;
const getTo = (state: AppState) => getFields(state).to;
const getData = (state: AppState) => getFields(state).data;
const getGasLimit = (state: AppState) => getFields(state).gasLimit;
const getGasPrice = (state: AppState) => getFields(state).gasPrice;
const getValue = (state: AppState) => getFields(state).value;
const getNonce = (state: AppState) => getFields(state).nonce;
const getDataExists = (state: AppState) => {
const { value } = getData(state);
return !!value && value.length > 0;
};
const getValidGasCost = (state: AppState) => {
const gasCost = getGasCost(state);
const etherBalance = getEtherBalance(state);
const isOffline = getOffline(state);
if (isOffline || !etherBalance) {
return true;
}
return gasCost.lte(etherBalance);
};
export {
getData,
getFields,
getGasLimit,
getValue,
getTo,
getNonce,
getGasPrice,
getDataExists,
getValidGasCost
};