diff --git a/embark-ui/src/components/Block.js b/embark-ui/src/components/Block.js index 69418a99e..04ab522b1 100644 --- a/embark-ui/src/components/Block.js +++ b/embark-ui/src/components/Block.js @@ -13,7 +13,7 @@ const Block = ({block}) => ( Block {block.number} -
+
diff --git a/embark-ui/src/components/ContractFunctions.js b/embark-ui/src/components/ContractFunctions.js deleted file mode 100644 index 8953ce114..000000000 --- a/embark-ui/src/components/ContractFunctions.js +++ /dev/null @@ -1,183 +0,0 @@ -import PropTypes from "prop-types"; -import React, {Component} from 'react'; -import { - Row, - Col, - Form, - FormGroup, - Label, - Input, - Button, - Card, - CardBody, - CardHeader, - CardTitle, - CardFooter, - Collapse, - ListGroup, - ListGroupItem -} from "reactstrap"; - -class ContractFunction extends Component { - constructor(props) { - super(props); - this.state = {inputs: {}, optionsCollapse: false, functionCollapse: false}; - } - - static isPureCall(method) { - return (method.mutability === 'view' || method.mutability === 'pure'); - } - - static isEvent(method) { - return !this.isPureCall(method) && (method.type === 'event'); - } - - buttonTitle() { - const {method} = this.props; - if (method.name === 'constructor') { - return 'Deploy'; - } - - return ContractFunction.isPureCall(method) ? 'Call' : 'Send'; - } - - inputsAsArray() { - return this.props.method.inputs - .map(input => this.state.inputs[input.name]) - .filter(value => value); - } - - handleChange(e, name) { - let newInputs = this.state.inputs; - newInputs[name] = e.target.value; - this.setState({inputs: newInputs}); - } - - handleCall(e) { - e.preventDefault(); - this.props.postContractFunction(this.props.contractProfile.name, this.props.method.name, this.inputsAsArray(), this.state.inputs.gasPrice * 1000000000); - } - - callDisabled() { - return this.inputsAsArray().length !== this.props.method.inputs.length; - } - - toggleOptions() { - this.setState({ - optionsCollapse: !this.state.optionsCollapse, - }); - } - - toggleFunction() { - this.setState({ - functionCollapse: !this.state.functionCollapse, - }); - } - - render() { - return ( - - - - this.toggleFunction()}> - {ContractFunction.isPureCall(this.props.method) && - - } - {ContractFunction.isEvent(this.props.method) && - - } - {this.props.method.name}({this.props.method.inputs.map(input => input.name).join(', ')}) - - - - -
- {this.props.method.inputs.map(input => ( - - - this.handleChange(e, input.name)}/> - - ))} -
- {!ContractFunction.isPureCall(this.props.method) && - - - this.toggleOptions()}>Advanced Options - -
- - - this.handleChange(e, 'gasPrice')}/> - -
-
-
- - } -
- -
-
-
- {this.props.contractFunctions && this.props.contractFunctions.length > 0 && - - {this.props.contractFunctions.map(contractFunction => ( - - {contractFunction.inputs.length > 0 &&

Inputs: {contractFunction.inputs.join(', ')}

} - Result: {contractFunction.result} -
- ))} -
-
} -
- - ); - } -} - -ContractFunction.propTypes = { - contractProfile: PropTypes.object, - method: PropTypes.object, - contractFunctions: PropTypes.arrayOf(PropTypes.object), - postContractFunction: PropTypes.func -}; - -const filterContractFunctions = (contractFunctions, contractName, method) => { - return contractFunctions.filter((contractFunction) => ( - contractFunction.contractName === contractName && contractFunction.method === method - )); -}; - -const ContractFunctions = (props) => { - const {contractProfile} = props; - - return ( - - {contractProfile.methods - .filter((method) => { - return props.onlyConstructor ? method.type === 'constructor' : method.type !== 'constructor'; - }) - .map(method => )} - - ); -}; - -ContractFunctions.propTypes = { - onlyConstructor: PropTypes.bool, - contractProfile: PropTypes.object, - contractFunctions: PropTypes.arrayOf(PropTypes.object), - postContractFunction: PropTypes.func -}; - -ContractFunctions.defaultProps = { - onlyConstructor: false -}; - -export default ContractFunctions; - diff --git a/embark-ui/src/components/ContractOverview.js b/embark-ui/src/components/ContractOverview.js index 837ced4c7..ed0b9ad36 100644 --- a/embark-ui/src/components/ContractOverview.js +++ b/embark-ui/src/components/ContractOverview.js @@ -79,12 +79,12 @@ class ContractFunction extends Component { return ( - this.toggleFunction()}> + this.toggleFunction()}> {ContractFunction.isPureCall(this.props.method) && - + } {ContractFunction.isEvent(this.props.method) && - + } {this.props.method.name}({this.props.method.inputs.map(input => input.name).join(', ')})