add gas station to Contract functions

This commit is contained in:
Jonathan Rainville 2018-08-28 15:11:16 -04:00 committed by Pascal Precht
parent 8ff13b09f1
commit 636431d338
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
3 changed files with 29 additions and 12 deletions

View File

@ -75,7 +75,7 @@ class GasStation extends Component {
<Card.Header> <Card.Header>
<Card.Title>Gas Price Estimator (for Mainnet)</Card.Title> <Card.Title>Gas Price Estimator (for Mainnet)</Card.Title>
<Card.Options> <Card.Options>
<CopyToClipboard text={currentGasStep.price} <CopyToClipboard text={currentGasStep.price / 10}
onCopy={() => this.setState({copied: true})} onCopy={() => this.setState({copied: true})}
title="Copy gas price to clipboard"> title="Copy gas price to clipboard">
<span><Stamp color="blue" icon="copy"/></span> <span><Stamp color="blue" icon="copy"/></span>

View File

@ -36,7 +36,6 @@ class ContractDeploymentContainer extends Component {
render={({gasStats}) => ( render={({gasStats}) => (
<GasStation gasStats={gasStats}/> <GasStation gasStats={gasStats}/>
)}/> )}/>
</React.Fragment> </React.Fragment>
); );
} }
@ -58,6 +57,7 @@ ContractDeploymentContainer.propTypes = {
contractFunctions: PropTypes.arrayOf(PropTypes.object), contractFunctions: PropTypes.arrayOf(PropTypes.object),
postContractDeploy: PropTypes.func, postContractDeploy: PropTypes.func,
fetchContractProfile: PropTypes.func, fetchContractProfile: PropTypes.func,
fetchEthGas: PropTypes.func,
error: PropTypes.string error: PropTypes.string
}; };

View File

@ -3,25 +3,39 @@ import {connect} from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import {withRouter} from 'react-router-dom'; import {withRouter} from 'react-router-dom';
import {contractProfile as contractProfileAction, contractFunction as contractFunctionAction} from '../actions'; import {
contractProfile as contractProfileAction,
contractFunction as contractFunctionAction,
ethGas as ethGasAction
} from '../actions';
import ContractFunctions from '../components/ContractFunctions'; import ContractFunctions from '../components/ContractFunctions';
import DataWrapper from "../components/DataWrapper"; import DataWrapper from "../components/DataWrapper";
import {getContractProfile, getContractFunctions} from "../reducers/selectors"; import GasStation from "../components/GasStation";
import {getContractProfile, getContractFunctions, getGasStats} from "../reducers/selectors";
class ContractFunctionsContainer extends Component { class ContractFunctionsContainer extends Component {
componentDidMount() { componentDidMount() {
this.props.fetchContractProfile(this.props.match.params.contractName); this.props.fetchContractProfile(this.props.match.params.contractName);
this.props.fetchEthGas();
} }
render() { render() {
return ( return (
<DataWrapper shouldRender={this.props.contractProfile !== undefined } <React.Fragment>
{...this.props} <DataWrapper shouldRender={this.props.contractProfile !== undefined}
render={({contractProfile, contractFunctions, postContractFunction}) => ( {...this.props}
<ContractFunctions contractProfile={contractProfile} render={({contractProfile, contractFunctions, postContractFunction}) => (
contractFunctions={contractFunctions} <ContractFunctions contractProfile={contractProfile}
postContractFunction={postContractFunction}/> contractFunctions={contractFunctions}
)} /> postContractFunction={postContractFunction}/>
)}/>
<DataWrapper shouldRender={this.props.gasStats !== undefined}
{...this.props}
render={({gasStats}) => (
<GasStation gasStats={gasStats}/>
)}/>
</React.Fragment>
); );
} }
} }
@ -30,6 +44,7 @@ function mapStateToProps(state, props) {
return { return {
contractProfile: getContractProfile(state, props.match.params.contractName), contractProfile: getContractProfile(state, props.match.params.contractName),
contractFunctions: getContractFunctions(state, props.match.params.contractName), contractFunctions: getContractFunctions(state, props.match.params.contractName),
gasStats: getGasStats(state),
error: state.errorMessage, error: state.errorMessage,
loading: state.loading loading: state.loading
}; };
@ -41,6 +56,7 @@ ContractFunctionsContainer.propTypes = {
contractFunctions: PropTypes.arrayOf(PropTypes.object), contractFunctions: PropTypes.arrayOf(PropTypes.object),
postContractFunction: PropTypes.func, postContractFunction: PropTypes.func,
fetchContractProfile: PropTypes.func, fetchContractProfile: PropTypes.func,
fetchEthGas: PropTypes.func,
error: PropTypes.string error: PropTypes.string
}; };
@ -48,6 +64,7 @@ export default withRouter(connect(
mapStateToProps, mapStateToProps,
{ {
fetchContractProfile: contractProfileAction.request, fetchContractProfile: contractProfileAction.request,
postContractFunction: contractFunctionAction.post postContractFunction: contractFunctionAction.post,
fetchEthGas: ethGasAction.request
} }
)(ContractFunctionsContainer)); )(ContractFunctionsContainer));