mirror of https://github.com/embarklabs/embark.git
Verifying if contract can be deployed or not
This commit is contained in:
parent
56afed906a
commit
92f1ac7576
|
@ -84,14 +84,21 @@ class ContractUI extends React.Component {
|
|||
</div>
|
||||
<AccountList accountUpdate={this.updateAccounts} />
|
||||
<h5>Deploy</h5>
|
||||
<FunctionArea contractName={this.props.name} contract={this.props.contract} type="constructor" />
|
||||
{
|
||||
this.props.definition.code == "" ? <p>Interface or set to not deploy</p>: ""
|
||||
}
|
||||
<FunctionArea definition={this.props.definition} contractName={this.props.name} contract={this.props.contract} type="constructor" />
|
||||
</Tab>
|
||||
|
||||
<Tab id="functions" selectedTab={this.state.selectedTab}>
|
||||
<h4 className="mb-5">Functions</h4>
|
||||
<InstanceSelector selectedInstance={this.state.selectedInstance} instanceUpdate={this.handleInstanceSelection} />
|
||||
<FunctionArea contractName={this.props.name} contract={this.props.contract} type="function" />
|
||||
<FunctionArea contractName={this.props.name} contract={this.props.contract} type="fallback" />
|
||||
{
|
||||
this.props.definition.code != "" ?
|
||||
<InstanceSelector selectedInstance={this.state.selectedInstance} instanceUpdate={this.handleInstanceSelection} />
|
||||
: ""
|
||||
}
|
||||
<FunctionArea definition={this.props.definition} contractName={this.props.name} contract={this.props.contract} type="function" />
|
||||
<FunctionArea definition={this.props.definition} contractName={this.props.name} contract={this.props.contract} type="fallback" />
|
||||
</Tab>
|
||||
|
||||
<Tab id="contract" selectedTab={this.state.selectedTab}>
|
||||
|
|
|
@ -13,7 +13,7 @@ class FunctionArea extends React.Component {
|
|||
{
|
||||
this.props.contract.options.jsonInterface
|
||||
.filter(item => item.type == type)
|
||||
.map((item, i) => <FunctionForm key={i} contract={contract} contractName={contractName} abi={item} instanceUpdate={this.props.instanceUpdate} />)
|
||||
.map((item, i) => <FunctionForm definition={this.props.definition} key={i} contract={contract} contractName={contractName} abi={item} instanceUpdate={this.props.instanceUpdate} />)
|
||||
}
|
||||
</React.Fragment>;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class FunctionForm extends React.Component {
|
|||
<CardAlert show={this.state.error} message={this.state.message} />
|
||||
|
||||
<div className="card-body row">
|
||||
<Function contract={this.props.contract} contractName={this.props.contractName} duplicated={isDuplicated} abi={this.props.abi} resultHandler={this.showResults} />
|
||||
<Function definition={this.props.definition} contract={this.props.contract} contractName={this.props.contractName} duplicated={isDuplicated} abi={this.props.abi} resultHandler={this.showResults} />
|
||||
</div>
|
||||
{
|
||||
receipt != null || !this.state.error && this.state.message != null
|
||||
|
|
|
@ -194,6 +194,21 @@ class Function extends React.Component {
|
|||
}
|
||||
|
||||
render(){
|
||||
|
||||
let btnClass = "btn ml-auto ";
|
||||
let disabled = false;
|
||||
|
||||
if(this.state.onRequest){
|
||||
disabled = true;
|
||||
}
|
||||
|
||||
if(this.props.definition.code == ""){
|
||||
btnClass += "btn-secondary";
|
||||
disabled = true;
|
||||
} else {
|
||||
btnClass += "btn-primary";
|
||||
}
|
||||
|
||||
return <ContractContext.Consumer>
|
||||
{ (context) => (
|
||||
<React.Fragment>
|
||||
|
@ -208,11 +223,18 @@ class Function extends React.Component {
|
|||
</code>
|
||||
</div>
|
||||
<div className="col-md-1">
|
||||
<button className="btn btn-primary ml-auto" onClick={event => this.handleClick(event, context.updateInstances)} disabled={this.state.onRequest}>
|
||||
<button className={btnClass} title={this.props.definition.code == "" ? "Can't execute function" : "Execute function"} onClick={event => this.handleClick(event, context.updateInstances)} disabled={disabled}>
|
||||
{ this.state.onRequest ?
|
||||
<img src="../assets/images/loading.gif" className="loading" alt="" />
|
||||
:
|
||||
<React.Fragment>⏎</React.Fragment>
|
||||
(
|
||||
this.props.definition.code == ""
|
||||
?
|
||||
<React.Fragment>_</React.Fragment>
|
||||
:
|
||||
<React.Fragment>⏎</React.Fragment>
|
||||
)
|
||||
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue