From f8662ebc5466b3bb8f418b42c02ad8b9f2e4d106 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt Date: Wed, 13 Feb 2019 01:04:02 -0200 Subject: [PATCH] small fixes --- app/components/TestStatusNetwork.js | 6 +++--- app/components/erc20token.js | 17 +++++++++++------ app/dapp.js | 6 +++--- config/contracts.js | 20 ++++++++++---------- embark.json | 2 +- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/app/components/TestStatusNetwork.js b/app/components/TestStatusNetwork.js index 235b916..e974e51 100644 --- a/app/components/TestStatusNetwork.js +++ b/app/components/TestStatusNetwork.js @@ -1,5 +1,5 @@ import EmbarkJS from 'Embark/EmbarkJS'; -import TestStatusNetwork from 'Embark/contracts/TestStatusNetwork'; +import StatusRoot from 'Embark/contracts/StatusRoot'; import MiniMeToken from 'Embark/contracts/MiniMeToken'; import React from 'react'; import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap'; @@ -22,9 +22,9 @@ class TestTokenUI extends React.Component { e.preventDefault(); await EmbarkJS.enableEthereum(); 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(){ diff --git a/app/components/erc20token.js b/app/components/erc20token.js index 1a859fa..7b8ffdf 100644 --- a/app/components/erc20token.js +++ b/app/components/erc20token.js @@ -28,29 +28,34 @@ class ERC20TokenUI extends React.Component { transfer(e){ var to = this.state.transferTo; var amount = this.state.transferAmount; - var tx = ERC20Token.methods.transfer(to, amount).send({from: web3.eth.defaultAccount}); - this._addToLog(ERC20Token.options.address+".transfer(" + to + ", "+amount+")"); + this._addToLog(ERC20Token.options.address+".methods.transfer(" + to + ", "+amount+").send({from: " + web3.eth.defaultAccount + "})"); + var tx = ERC20Token.methods.transfer(to, amount); + tx.estimateGas().then((r) => { + tx.send({gas: r, from: web3.eth.defaultAccount}); + }); + } approve(e){ var to = this.state.transferTo; 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}); - this._addToLog(ERC20Token.options.address+".approve(" + to + ", "+amount+")"); + } balanceOf(e){ e.preventDefault(); var who = e.target.value; + this._addToLog(ERC20Token.options.address+".methods.balanceOf(" + who + ").call()"); ERC20Token.methods.balanceOf(who).call() .then(_value => this.setState({balanceOf: _value})) - this._addToLog(ERC20Token.options.address+".balanceOf(" + who + ")"); } getDefaultAccountBalance(){ + this._addToLog(ERC20Token.options.address + ".methods.balanceOf(" + web3.eth.defaultAccount + ").call()"); ERC20Token.methods.balanceOf(web3.eth.defaultAccount).call() .then(_value => this.setState({accountBalance: _value})) - this._addToLog(ERC20Token.options.address + ".balanceOf(" + web3.eth.defaultAccount + ")"); } _addToLog(txt){ @@ -103,7 +108,7 @@ class ERC20TokenUI extends React.Component { ); } - } +} export default ERC20TokenUI; diff --git a/app/dapp.js b/app/dapp.js index 801422f..b2473b5 100644 --- a/app/dapp.js +++ b/app/dapp.js @@ -1,7 +1,7 @@ import React from 'react'; import { Tabs, Tab } from 'react-bootstrap'; import EmbarkJS from 'Embark/EmbarkJS'; -import TestTokenUI from './components/TestStatusNetwork'; +import TestStatusNetworkUI from './components/TestStatusNetwork'; import './dapp.css'; @@ -31,8 +31,8 @@ class DApp extends React.Component {
- - + +
); diff --git a/config/contracts.js b/config/contracts.js index ff513a6..3840741 100644 --- a/config/contracts.js +++ b/config/contracts.js @@ -14,22 +14,22 @@ module.exports = { "http://localhost:8545" ], gas: "auto", - contracts: { - "ERC20Receiver": {"deploy": false}, - "SafeMath": {"deploy": false}, - - "MiniMeTokenFactory": {}, + strategy: "explicit", + contracts: { + "MiniMeTokenFactory": { + "deploy": true + }, "MiniMeToken": { + "deploy": true, "args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true], }, - - "StatusNetwork": {"deploy": false}, - "TestStatusNetwork": { + "StatusRoot": { + "instanceOf": "TestStatusNetwork", "deploy": true, "args": ["0x0", "$MiniMeToken"], "onDeploy": [ - "await MiniMeToken.methods.changeController(TestStatusNetwork.address).send()", - "await TestStatusNetwork.methods.setOpen(true).send()", + "await MiniMeToken.methods.changeController(StatusRoot.address).send()", + "await StatusRoot.methods.setOpen(true).send()", ] } } diff --git a/embark.json b/embark.json index b0ce865..a86fd78 100644 --- a/embark.json +++ b/embark.json @@ -10,7 +10,7 @@ "config": "config/", "versions": { "web3": "1.0.0-beta", - "solc": "0.5.0", + "solc": "0.5.4", "ipfs-api": "17.2.4", "p-iteration": "1.1.7" },