contracts/app/components/TestStatusNetwork.js

51 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2018-05-13 01:31:01 -03:00
import EmbarkJS from 'Embark/EmbarkJS';
2019-02-13 01:04:02 -02:00
import StatusRoot from 'Embark/contracts/StatusRoot';
import MiniMeToken from 'Embark/contracts/MiniMeToken';
2018-05-13 01:31:01 -03:00
import React from 'react';
import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap';
2018-05-31 20:38:21 -03:00
import ERC20TokenUI from './erc20token';
2019-01-16 09:10:47 -02:00
class TestStatusNetworkUI extends React.Component {
2018-05-13 01:31:01 -03:00
constructor(props) {
super(props);
this.state = {
amountToMint: 100,
}
}
handleMintAmountChange(e){
this.setState({amountToMint: e.target.value});
}
2019-01-12 11:42:31 -02:00
async mint(e){
2018-05-13 01:31:01 -03:00
e.preventDefault();
2019-01-12 11:42:31 -02:00
await EmbarkJS.enableEthereum();
2018-05-13 01:31:01 -03:00
var value = parseInt(this.state.amountToMint, 10);
2019-02-13 01:04:02 -02:00
StatusRoot.methods.mint(value).send({ gas: 1000000 })
2019-02-13 01:04:02 -02:00
console.log(StatusRoot.options.address +".mint("+value+").send({from: " + web3.eth.defaultAccount + "})");
2018-05-13 01:31:01 -03:00
}
2018-05-31 20:38:21 -03:00
2018-05-13 01:31:01 -03:00
render(){
return (<React.Fragment>
2019-01-12 11:42:31 -02:00
<h3> Test Status Network</h3>
2018-05-13 01:31:01 -03:00
<Form inline>
<FormGroup>
<FormControl
type="text"
defaultValue={this.state.amountToMint}
onChange={(e) => this.handleMintAmountChange(e)} />
<Button bsStyle="primary" onClick={(e) => this.mint(e)}>Mint</Button>
</FormGroup>
</Form>
<ERC20TokenUI address={ MiniMeToken.options.address } />
2018-05-31 20:38:21 -03:00
2018-05-13 01:31:01 -03:00
</React.Fragment>
);
}
}
2019-01-16 09:10:47 -02:00
export default TestStatusNetworkUI;