Merge pull request #1011 from embark-framework/bugfix/deployment-interface

Do no show interface on injected web3
This commit is contained in:
Eric Mastro 2018-10-30 20:55:52 +01:00 committed by GitHub
commit 8d33ac6cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -112,26 +112,26 @@ class Web3Contract extends React.Component {
} }
inputsAsArray() { inputsAsArray() {
return findConstructor(this.props.contract.abiDefinition).inputs const constructor = findConstructor(this.props.contract.abiDefinition);
if (!constructor) return [];
return constructor.inputs
.map(input => this.state.inputs[input.name]) .map(input => this.state.inputs[input.name])
.filter(value => value); .filter(value => value);
} }
actionDisabled() { actionDisabled() {
return this.inputsAsArray().length !== findConstructor(this.props.contract.abiDefinition).inputs.length; const constructor = findConstructor(this.props.contract.abiDefinition);
if (!constructor) return false;
return this.inputsAsArray().length !== constructor.inputs.length;
} }
render() { render() {
const abiConstructor = findConstructor(this.props.contract.abiDefinition); const abiConstructor = findConstructor(this.props.contract.abiDefinition);
const isInterface = !abiConstructor;
const argumentsRequired = abiConstructor && abiConstructor.inputs.length > 0; const argumentsRequired = abiConstructor && abiConstructor.inputs.length > 0;
return ( return (
<LayoutContract contract={this.props.contract} cardTitle={ <LayoutContract contract={this.props.contract} cardTitle={this.props.contract.className}>
<React.Fragment>
{isInterface && `${this.props.contract.className} is an interface`}
{!isInterface && this.props.contract.className}
</React.Fragment>
}>
<Row> <Row>
<Col md={6}> <Col md={6}>
{argumentsRequired && {argumentsRequired &&
@ -148,7 +148,7 @@ class Web3Contract extends React.Component {
{!this.props.web3 && <NoWeb3/>} {!this.props.web3 && <NoWeb3/>}
{this.props.web3 && !isInterface && {this.props.web3 &&
<React.Fragment> <React.Fragment>
<Button className="mr-2" <Button className="mr-2"
color="primary" color="primary"

View File

@ -42,7 +42,7 @@ class TextEditorAsideContainer extends Component {
case 'overview': case 'overview':
return ( return (
<React.Fragment> <React.Fragment>
<h2>{contract.className} - Overview</h2> <h2>{contract.className} - Interact</h2>
<ContractOverviewContainer key={index} contract={contract}/> <ContractOverviewContainer key={index} contract={contract}/>
</React.Fragment> </React.Fragment>
); );