small fixes

This commit is contained in:
Ricardo Guilherme Schmidt 2019-02-13 01:04:02 -02:00
parent eebb8b352b
commit f8662ebc54
No known key found for this signature in database
GPG Key ID: BFB3F5C8ED618A94
5 changed files with 28 additions and 23 deletions

View File

@ -1,5 +1,5 @@
import EmbarkJS from 'Embark/EmbarkJS'; import EmbarkJS from 'Embark/EmbarkJS';
import TestStatusNetwork from 'Embark/contracts/TestStatusNetwork'; import StatusRoot from 'Embark/contracts/StatusRoot';
import MiniMeToken from 'Embark/contracts/MiniMeToken'; import MiniMeToken from 'Embark/contracts/MiniMeToken';
import React from 'react'; import React from 'react';
import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap'; import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap';
@ -22,9 +22,9 @@ class TestTokenUI extends React.Component {
e.preventDefault(); e.preventDefault();
await EmbarkJS.enableEthereum(); await EmbarkJS.enableEthereum();
var value = parseInt(this.state.amountToMint, 10); var value = parseInt(this.state.amountToMint, 10);
TestStatusNetwork.methods.mint(value).send({ gas: 1000000 }) StatusRoot.methods.mint(value).send({ gas: 1000000 })
console.log(TestStatusNetwork.options.address +".mint("+value+").send({from: " + web3.eth.defaultAccount + "})"); console.log(StatusRoot.options.address +".mint("+value+").send({from: " + web3.eth.defaultAccount + "})");
} }
render(){ render(){

View File

@ -28,29 +28,34 @@ class ERC20TokenUI extends React.Component {
transfer(e){ transfer(e){
var to = this.state.transferTo; var to = this.state.transferTo;
var amount = this.state.transferAmount; var amount = this.state.transferAmount;
var tx = ERC20Token.methods.transfer(to, amount).send({from: web3.eth.defaultAccount}); this._addToLog(ERC20Token.options.address+".methods.transfer(" + to + ", "+amount+").send({from: " + web3.eth.defaultAccount + "})");
this._addToLog(ERC20Token.options.address+".transfer(" + to + ", "+amount+")"); var tx = ERC20Token.methods.transfer(to, amount);
tx.estimateGas().then((r) => {
tx.send({gas: r, from: web3.eth.defaultAccount});
});
} }
approve(e){ approve(e){
var to = this.state.transferTo; var to = this.state.transferTo;
var amount = this.state.transferAmount; var amount = this.state.transferAmount;
this._addToLog(ERC20Token.options.address+".methods.approve(" + to + ", "+amount+").send({from: " + web3.eth.defaultAccount + "})");
var tx = ERC20Token.methods.approve(to, amount).send({from: web3.eth.defaultAccount}); var tx = ERC20Token.methods.approve(to, amount).send({from: web3.eth.defaultAccount});
this._addToLog(ERC20Token.options.address+".approve(" + to + ", "+amount+")");
} }
balanceOf(e){ balanceOf(e){
e.preventDefault(); e.preventDefault();
var who = e.target.value; var who = e.target.value;
this._addToLog(ERC20Token.options.address+".methods.balanceOf(" + who + ").call()");
ERC20Token.methods.balanceOf(who).call() ERC20Token.methods.balanceOf(who).call()
.then(_value => this.setState({balanceOf: _value})) .then(_value => this.setState({balanceOf: _value}))
this._addToLog(ERC20Token.options.address+".balanceOf(" + who + ")");
} }
getDefaultAccountBalance(){ getDefaultAccountBalance(){
this._addToLog(ERC20Token.options.address + ".methods.balanceOf(" + web3.eth.defaultAccount + ").call()");
ERC20Token.methods.balanceOf(web3.eth.defaultAccount).call() ERC20Token.methods.balanceOf(web3.eth.defaultAccount).call()
.then(_value => this.setState({accountBalance: _value})) .then(_value => this.setState({accountBalance: _value}))
this._addToLog(ERC20Token.options.address + ".balanceOf(" + web3.eth.defaultAccount + ")");
} }
_addToLog(txt){ _addToLog(txt){

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Tabs, Tab } from 'react-bootstrap'; import { Tabs, Tab } from 'react-bootstrap';
import EmbarkJS from 'Embark/EmbarkJS'; import EmbarkJS from 'Embark/EmbarkJS';
import TestTokenUI from './components/TestStatusNetwork'; import TestStatusNetworkUI from './components/TestStatusNetwork';
import './dapp.css'; import './dapp.css';
@ -31,8 +31,8 @@ class DApp extends React.Component {
<div> <div>
<Tabs defaultActiveKey={1} id="uncontrolled-tab-example"> <Tabs defaultActiveKey={1} id="uncontrolled-tab-example">
<Tab eventKey={1} title="TestToken"> <Tab eventKey={1} title="TestStatusNetwork">
<TestTokenUI /> <TestStatusNetworkUI />
</Tab> </Tab>
</Tabs> </Tabs>
</div>); </div>);

View File

@ -14,22 +14,22 @@ module.exports = {
"http://localhost:8545" "http://localhost:8545"
], ],
gas: "auto", gas: "auto",
strategy: "explicit",
contracts: { contracts: {
"ERC20Receiver": {"deploy": false}, "MiniMeTokenFactory": {
"SafeMath": {"deploy": false}, "deploy": true
},
"MiniMeTokenFactory": {},
"MiniMeToken": { "MiniMeToken": {
"deploy": true,
"args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true], "args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true],
}, },
"StatusRoot": {
"StatusNetwork": {"deploy": false}, "instanceOf": "TestStatusNetwork",
"TestStatusNetwork": {
"deploy": true, "deploy": true,
"args": ["0x0", "$MiniMeToken"], "args": ["0x0", "$MiniMeToken"],
"onDeploy": [ "onDeploy": [
"await MiniMeToken.methods.changeController(TestStatusNetwork.address).send()", "await MiniMeToken.methods.changeController(StatusRoot.address).send()",
"await TestStatusNetwork.methods.setOpen(true).send()", "await StatusRoot.methods.setOpen(true).send()",
] ]
} }
} }

View File

@ -10,7 +10,7 @@
"config": "config/", "config": "config/",
"versions": { "versions": {
"web3": "1.0.0-beta", "web3": "1.0.0-beta",
"solc": "0.5.0", "solc": "0.5.4",
"ipfs-api": "17.2.4", "ipfs-api": "17.2.4",
"p-iteration": "1.1.7" "p-iteration": "1.1.7"
}, },