From cf43c15f4b75fd0f40fe9feb2d0e310284c86d49 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 14 Sep 2018 18:39:47 -0400 Subject: [PATCH] simplify embark_demo, use web3.js 1.0 only --- templates/demo/app/components/blockchain.js | 21 ++++---------------- templates/demo/app/dapp.js | 22 ++++++--------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/templates/demo/app/components/blockchain.js b/templates/demo/app/components/blockchain.js index 3b5ec984c..a8fe4b7e3 100644 --- a/templates/demo/app/components/blockchain.js +++ b/templates/demo/app/components/blockchain.js @@ -32,28 +32,15 @@ class Blockchain extends React.Component { var value = parseInt(this.state.valueSet, 10); - // If web3.js 1.0 is being used - if (EmbarkJS.isNewWeb3()) { - SimpleStorage.methods.set(value).send({ from: web3.eth.defaultAccount }); - this._addToLog("SimpleStorage.methods.set(value).send({from: web3.eth.defaultAccount})"); - } else { - SimpleStorage.set(value); - this._addToLog("#blockchain", "SimpleStorage.set(" + value + ")"); - } + SimpleStorage.methods.set(value).send({ from: web3.eth.defaultAccount }); + this._addToLog("SimpleStorage.methods.set(value).send({from: web3.eth.defaultAccount})"); } getValue(e) { e.preventDefault(); - if (EmbarkJS.isNewWeb3()) { - SimpleStorage.methods.get().call() - .then(_value => this.setState({ valueGet: _value })); - this._addToLog("SimpleStorage.methods.get(console.log)"); - } else { - SimpleStorage.get() - .then(_value => this.setState({ valueGet: _value })); - this._addToLog("SimpleStorage.get()"); - } + SimpleStorage.methods.get().call().then(_value => this.setState({ valueGet: _value })); + this._addToLog("SimpleStorage.methods.get(console.log)"); } _addToLog(txt) { diff --git a/templates/demo/app/dapp.js b/templates/demo/app/dapp.js index d350c169c..999e40550 100644 --- a/templates/demo/app/dapp.js +++ b/templates/demo/app/dapp.js @@ -34,23 +34,13 @@ class App extends React.Component { // you can use this to ask the user to enable metamask for e.g return this.setState({error: err.message || err}); } - if (EmbarkJS.isNewWeb3()) { - EmbarkJS.Messages.Providers.whisper.getWhisperVersion((err, _version) => { - if (err) { - return console.log(err); - } - this.setState({whisperEnabled: true}); - }); - } else { - if (EmbarkJS.Messages.providerName === 'whisper') { - EmbarkJS.Messages.getWhisperVersion((err, _version) => { - if (err) { - return console.log(err); - } - this.setState({whisperEnabled: true}); - }); + + EmbarkJS.Messages.Providers.whisper.getWhisperVersion((err, _version) => { + if (err) { + return console.log(err); } - } + this.setState({whisperEnabled: true}); + }); EmbarkJS.Storage.isAvailable().then((result) => { this.setState({storageEnabled: result});