Merge pull request #838 from embark-framework/embark_demo_1_0
simplify embark_demo, use web3.js 1.0 only
This commit is contained in:
commit
73fcda1ed2
|
@ -32,28 +32,15 @@ class Blockchain extends React.Component {
|
||||||
|
|
||||||
var value = parseInt(this.state.valueSet, 10);
|
var value = parseInt(this.state.valueSet, 10);
|
||||||
|
|
||||||
// If web3.js 1.0 is being used
|
SimpleStorage.methods.set(value).send();
|
||||||
if (EmbarkJS.isNewWeb3()) {
|
this._addToLog("SimpleStorage.methods.set(value).send()");
|
||||||
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 + ")");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getValue(e) {
|
getValue(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (EmbarkJS.isNewWeb3()) {
|
SimpleStorage.methods.get().call().then(_value => this.setState({ valueGet: _value }));
|
||||||
SimpleStorage.methods.get().call()
|
this._addToLog("SimpleStorage.methods.get(console.log)");
|
||||||
.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()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_addToLog(txt) {
|
_addToLog(txt) {
|
||||||
|
|
|
@ -34,23 +34,13 @@ class App extends React.Component {
|
||||||
// you can use this to ask the user to enable metamask for e.g
|
// you can use this to ask the user to enable metamask for e.g
|
||||||
return this.setState({error: err.message || err});
|
return this.setState({error: err.message || err});
|
||||||
}
|
}
|
||||||
if (EmbarkJS.isNewWeb3()) {
|
|
||||||
EmbarkJS.Messages.Providers.whisper.getWhisperVersion((err, _version) => {
|
EmbarkJS.Messages.Providers.whisper.getWhisperVersion((err, _version) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return console.log(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});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
this.setState({whisperEnabled: true});
|
||||||
|
});
|
||||||
|
|
||||||
EmbarkJS.Storage.isAvailable().then((result) => {
|
EmbarkJS.Storage.isAvailable().then((result) => {
|
||||||
this.setState({storageEnabled: result});
|
this.setState({storageEnabled: result});
|
||||||
|
|
Loading…
Reference in New Issue