diff --git a/lib/modules/scaffolding-react/templates/dapp.js.tpl b/lib/modules/scaffolding-react/templates/dapp.js.tpl index 6482b9ead..5a2554a9b 100644 --- a/lib/modules/scaffolding-react/templates/dapp.js.tpl +++ b/lib/modules/scaffolding-react/templates/dapp.js.tpl @@ -21,7 +21,8 @@ class {{capitalize name}}_{{@index}}_Form extends React.Component { {{#ifview stateMutability}} output: null, {{/ifview}} - error: null + error: null, + mined: null }; } @@ -37,10 +38,10 @@ class {{capitalize name}}_{{@index}}_Form extends React.Component { async handleClick(e){ e.preventDefault(); - this.setState({output: null, error: null}); + this.setState({output: null, error: null, receipt: null}); - {{#ifview stateMutability}} try { + {{#ifview stateMutability}} {{../contractName}}.methods{{methodname ../functions name inputs}}({{#each inputs}}this.state.input.{{name}}{{#unless @last}}, {{/unless}}{{/each}}) .call() .then((result) => { @@ -57,44 +58,56 @@ class {{capitalize name}}_{{@index}}_Form extends React.Component { .catch((err) => { this.setState({error: err.message}); }); + {{else}} + {{../contractName}}.methods{{methodname ../functions name inputs}}({{#each inputs}}this.state.input.{{name}}{{#unless @last}}, {{/unless}}{{/each}}) + .send({ + from: web3.eth.defaultAccount + }) + .then((_receipt) => { + console.log(_receipt); + this.setState({receipt: _receipt}) + }) + .catch((err) => { + console.log(err); + this.setState({error: err.message}); + }); + // TODO payable + {{/ifview}} } catch(err) { this.setState({error: err.message}); } - - // TODO show on screen - {{/ifview}} - + // TODO validate } render(){ return