2017-10-17 04:01:28 +00:00
|
|
|
import * as configSelectors from 'selectors/config';
|
|
|
|
import { AppState } from 'reducers';
|
2017-11-12 19:45:52 +00:00
|
|
|
import { toWei, Wei, getDecimal } from 'libs/units';
|
2017-10-17 04:01:28 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { showNotification, TShowNotification } from 'actions/notifications';
|
|
|
|
import { broadcastTx, TBroadcastTx } from 'actions/wallet';
|
|
|
|
import { IWallet } from 'libs/wallet/IWallet';
|
|
|
|
import { RPCNode } from 'libs/nodes';
|
|
|
|
import { NodeConfig, NetworkConfig } from 'config/data';
|
|
|
|
|
|
|
|
export interface IWithTx {
|
|
|
|
wallet: IWallet;
|
2017-11-12 19:45:52 +00:00
|
|
|
balance: Wei;
|
2017-10-17 04:01:28 +00:00
|
|
|
node: NodeConfig;
|
|
|
|
nodeLib: RPCNode;
|
|
|
|
chainId: NetworkConfig['chainId'];
|
|
|
|
networkName: NetworkConfig['name'];
|
|
|
|
gasPrice: Wei;
|
|
|
|
broadcastTx: TBroadcastTx;
|
|
|
|
showNotification: TShowNotification;
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapStateToProps = (state: AppState) => ({
|
|
|
|
wallet: state.wallet.inst,
|
|
|
|
balance: state.wallet.balance,
|
|
|
|
node: configSelectors.getNodeConfig(state),
|
|
|
|
nodeLib: configSelectors.getNodeLib(state),
|
|
|
|
chainId: configSelectors.getNetworkConfig(state).chainId,
|
|
|
|
networkName: configSelectors.getNetworkConfig(state).name,
|
2017-11-12 19:45:52 +00:00
|
|
|
gasPrice: toWei(
|
|
|
|
`${configSelectors.getGasPriceGwei(state)}`,
|
|
|
|
getDecimal('gwei')
|
|
|
|
)
|
2017-10-17 04:01:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export const withTx = passedComponent =>
|
|
|
|
connect(mapStateToProps, {
|
|
|
|
showNotification,
|
|
|
|
broadcastTx
|
|
|
|
})(passedComponent);
|