fix array display and setting

This commit is contained in:
Jonathan Rainville 2018-10-18 11:51:37 -04:00 committed by Pascal Precht
parent a1c33a23a2
commit 551d1e209b
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 6 additions and 3 deletions

View File

@ -5,6 +5,9 @@ import React, { Component, Fragment } from 'react';
import ReactDOM from 'react-dom';
import { FormGroup, ControlLabel, FormControl, Checkbox, Button, Alert, InputGroup } from 'react-bootstrap';
function isSuccess(status) {
return status === "0x1" || status === true;
}
{{#each functions}}
class {{capitalize name}}Form{{@index}} extends Component {
@ -50,7 +53,7 @@ class {{capitalize name}}Form{{@index}} extends Component {
try {
{{#ifview stateMutability}}
const result = await {{../contractName}}.methods{{methodname ../functions name inputs}}({{#each inputs}}input.{{#ifeq name ''}}field{{else}}{{trim name}}{{/ifeq}}{{#unless @last}}, {{/unless}}{{/each}}).call()
const result = await {{../contractName}}.methods{{methodname ../functions name inputs}}({{#each inputs}}input.{{#ifeq name ''}}field{{else}}{{trim name}}{{/ifeq}}{{#unless @last}}, {{/unless}}{{/each}}).call();
{{#iflengthgt outputs 1}}
this.setState({output: {
{{#each outputs}}
@ -141,7 +144,7 @@ class {{capitalize name}}Form{{@index}} extends Component {
{{#iflengthgt outputs 1}}
<ul>
{{#each outputs}}
<li>{{emptyname name @index}}: { output.{{emptyname name @index}} }</li>
<li>{{emptyname name @index}}: { JSON.stringify(output.{{emptyname name @index}}) }</li>
{{/each}}
</ul>
{{else}}
@ -154,7 +157,7 @@ class {{capitalize name}}Form{{@index}} extends Component {
{
receipt &&
<Fragment>
<Alert bsStyle={receipt.status === "0x1" ? 'success' : 'danger'}>{receipt.status === "0x1" ? 'Success' : 'Failure / Revert'} - Transaction Hash: {receipt.transactionHash}</Alert>
<Alert bsStyle={isSuccess(receipt.status) ? 'success' : 'danger'}>{isSuccess(receipt.status) ? 'Success' : 'Failure / Revert'} - Transaction Hash: {receipt.transactionHash}</Alert>
</Fragment>
}