diff --git a/embark-ui/src/components/ContractFunctions.js b/embark-ui/src/components/ContractFunctions.js new file mode 100644 index 000000000..762ae6f3d --- /dev/null +++ b/embark-ui/src/components/ContractFunctions.js @@ -0,0 +1,48 @@ +import PropTypes from "prop-types"; +import React from 'react'; +import { + Page, + Grid, + Form, + Button, + Card +} from "tabler-react"; + +const ContractFunction = ({method}) => ( + + + + + {method.name} + + {method.inputs.length > 0 && + + {method.inputs.map(input => ( + + + + ))} + + } + + + + + + +); + +const ContractFunctions = ({contractProfile}) => ( + + {contractProfile.methods + .filter(method => method.name !== 'constructor') + .map(method => )} + +); + +ContractFunctions.propTypes = { + contractProfile: PropTypes.object +}; + +export default ContractFunctions; + diff --git a/embark-ui/src/components/ContractLayout.js b/embark-ui/src/components/ContractLayout.js index 71b838a7e..edd8882fc 100644 --- a/embark-ui/src/components/ContractLayout.js +++ b/embark-ui/src/components/ContractLayout.js @@ -9,6 +9,7 @@ import { import ContractContainer from '../containers/ContractContainer'; import ContractLoggerContainer from '../containers/ContractLoggerContainer'; +import ContractFunctionsContainer from '../containers/ContractFunctionsContainer'; import ContractProfileContainer from '../containers/ContractProfileContainer'; import ContractSourceContainer from '../containers/ContractSourceContainer'; @@ -72,6 +73,7 @@ const ContractLayout = ({match}) => ( + diff --git a/embark-ui/src/containers/ContractContainer.js b/embark-ui/src/containers/ContractContainer.js index 925135e8a..3389abf85 100644 --- a/embark-ui/src/containers/ContractContainer.js +++ b/embark-ui/src/containers/ContractContainer.js @@ -3,7 +3,6 @@ import {connect} from 'react-redux'; import PropTypes from 'prop-types'; import {withRouter} from 'react-router-dom'; -import {contract as contractAction} from '../actions'; import Contract from '../components/Contract'; import DataWrapper from "../components/DataWrapper"; import {getContract} from "../reducers/selectors"; @@ -27,14 +26,10 @@ function mapStateToProps(state, props) { } ContractContainer.propTypes = { - match: PropTypes.object, contract: PropTypes.object, error: PropTypes.string }; export default withRouter(connect( - mapStateToProps, - { - fetchContract: contractAction.request - } + mapStateToProps )(ContractContainer)); diff --git a/embark-ui/src/containers/ContractFunctionsContainer.js b/embark-ui/src/containers/ContractFunctionsContainer.js new file mode 100644 index 000000000..adc2859f2 --- /dev/null +++ b/embark-ui/src/containers/ContractFunctionsContainer.js @@ -0,0 +1,45 @@ +import React, {Component} from 'react'; +import {connect} from 'react-redux'; +import PropTypes from 'prop-types'; +import {withRouter} from 'react-router-dom'; + +import {contractProfile as contractProfileAction} from '../actions'; +import ContractFunctions from '../components/ContractFunctions'; +import DataWrapper from "../components/DataWrapper"; +import {getContractProfile} from "../reducers/selectors"; + +class ContractFunctionsContainer extends Component { + componentDidMount() { + this.props.fetchContractProfile(this.props.match.params.contractName); + } + + render() { + return ( + ( + + )} /> + ); + } +} + +function mapStateToProps(state, props) { + return { + contractProfile: getContractProfile(state, props.match.params.contractName), + error: state.errorMessage, + loading: state.loading + }; +} + +ContractFunctionsContainer.propTypes = { + match: PropTypes.object, + contractProfile: PropTypes.object, + fetchContractProfile: PropTypes.func, + error: PropTypes.string +}; + +export default withRouter(connect( + mapStateToProps, + { + fetchContractProfile: contractProfileAction.request + } +)(ContractFunctionsContainer));