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>
|
</div>
|
||||||
<AccountList accountUpdate={this.updateAccounts} />
|
<AccountList accountUpdate={this.updateAccounts} />
|
||||||
<h5>Deploy</h5>
|
<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>
|
||||||
|
|
||||||
<Tab id="functions" selectedTab={this.state.selectedTab}>
|
<Tab id="functions" selectedTab={this.state.selectedTab}>
|
||||||
<h4 className="mb-5">Functions</h4>
|
<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" />
|
this.props.definition.code != "" ?
|
||||||
<FunctionArea contractName={this.props.name} contract={this.props.contract} type="fallback" />
|
<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>
|
||||||
|
|
||||||
<Tab id="contract" selectedTab={this.state.selectedTab}>
|
<Tab id="contract" selectedTab={this.state.selectedTab}>
|
||||||
|
|
|
@ -13,7 +13,7 @@ class FunctionArea extends React.Component {
|
||||||
{
|
{
|
||||||
this.props.contract.options.jsonInterface
|
this.props.contract.options.jsonInterface
|
||||||
.filter(item => item.type == type)
|
.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>;
|
</React.Fragment>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class FunctionForm extends React.Component {
|
||||||
<CardAlert show={this.state.error} message={this.state.message} />
|
<CardAlert show={this.state.error} message={this.state.message} />
|
||||||
|
|
||||||
<div className="card-body row">
|
<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>
|
</div>
|
||||||
{
|
{
|
||||||
receipt != null || !this.state.error && this.state.message != null
|
receipt != null || !this.state.error && this.state.message != null
|
||||||
|
|
|
@ -194,6 +194,21 @@ class Function extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
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>
|
return <ContractContext.Consumer>
|
||||||
{ (context) => (
|
{ (context) => (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
@ -208,11 +223,18 @@ class Function extends React.Component {
|
||||||
</code>
|
</code>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-1">
|
<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 ?
|
{ this.state.onRequest ?
|
||||||
<img src="../assets/images/loading.gif" className="loading" alt="" />
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue