Merge pull request #741 from embark-framework/add_error_on_demo

fix configs + handle connection error in demo
This commit is contained in:
Iuri Matias 2018-08-24 10:06:09 -04:00 committed by GitHub
commit 04925604fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 6 deletions

View File

@ -14,7 +14,7 @@ module.exports = {
port: 8546, // Port of the blockchain node
type: "ws" // Type of connection (ws or rpc)
}
}
},
// merges with the settings in default
// used with "embark run privatenet"

View File

@ -14,7 +14,7 @@ module.exports = {
'status': '0x1a2f3b98e434c02363f3dac3174af93c1d690914'
}
}
}
},
// merges with the settings in default
// used with "embark run privatenet"

View File

@ -18,6 +18,7 @@ class App extends React.Component {
this.handleSelect = this.handleSelect.bind(this);
this.state = {
error: null,
activeKey: 1,
whisperEnabled: false,
storageEnabled: false,
@ -26,7 +27,12 @@ class App extends React.Component {
}
componentDidMount() {
EmbarkJS.onReady(() => {
EmbarkJS.onReady((err) => {
if (err) {
// If err is not null then it means something went wrong connecting to ethereum
// you can use this to ask the user to enable metamask for e.g
return this.setState({error: err});
}
if (EmbarkJS.isNewWeb3()) {
EmbarkJS.Messages.Providers.whisper.getWhisperVersion((err, _version) => {
if (err) {
@ -70,7 +76,14 @@ class App extends React.Component {
}
render() {
return (<div><h3>Embark - Usage Example</h3>
if (this.state.error) {
return (<div>
<div>Something went wrong connecting to ethereum. Please make sure you have a node running or are using metamask to connect to the ethereum network:</div>
<div>{this.state.error}</div>
</div>);
}
return (<div>
<h3>Embark - Usage Example</h3>
<Tabs onSelect={this.handleSelect} activeKey={this.state.activeKey} id="uncontrolled-tab-example">
<Tab eventKey={1} title="Blockchain">
<Blockchain/>

View File

@ -14,7 +14,7 @@ module.exports = {
port: 8546, // Port of the blockchain node
type: "ws" // Type of connection (ws or rpc)
}
}
},
// merges with the settings in default
// used with "embark run privatenet"

View File

@ -14,7 +14,7 @@ module.exports = {
'status': '0x1a2f3b98e434c02363f3dac3174af93c1d690914'
}
}
}
},
// merges with the settings in default
// used with "embark run privatenet"