From 1065d3eae1b10a06ce0519bd33eeec5e81733d8b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 23 Aug 2018 15:53:33 -0400 Subject: [PATCH 1/4] fix configs --- templates/boilerplate/config/communication.js | 2 +- templates/boilerplate/config/namesystem.js | 2 +- templates/demo/config/communication.js | 2 +- templates/demo/config/namesystem.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/boilerplate/config/communication.js b/templates/boilerplate/config/communication.js index 9a7ee8db2..641c0cd4d 100644 --- a/templates/boilerplate/config/communication.js +++ b/templates/boilerplate/config/communication.js @@ -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" diff --git a/templates/boilerplate/config/namesystem.js b/templates/boilerplate/config/namesystem.js index 09a6e3f78..35ef7e9a9 100644 --- a/templates/boilerplate/config/namesystem.js +++ b/templates/boilerplate/config/namesystem.js @@ -14,7 +14,7 @@ module.exports = { 'status': '0x1a2f3b98e434c02363f3dac3174af93c1d690914' } } - } + }, // merges with the settings in default // used with "embark run privatenet" diff --git a/templates/demo/config/communication.js b/templates/demo/config/communication.js index b776b339e..e8998cf29 100644 --- a/templates/demo/config/communication.js +++ b/templates/demo/config/communication.js @@ -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" diff --git a/templates/demo/config/namesystem.js b/templates/demo/config/namesystem.js index 09a6e3f78..35ef7e9a9 100644 --- a/templates/demo/config/namesystem.js +++ b/templates/demo/config/namesystem.js @@ -14,7 +14,7 @@ module.exports = { 'status': '0x1a2f3b98e434c02363f3dac3174af93c1d690914' } } - } + }, // merges with the settings in default // used with "embark run privatenet" From 65d3d5c1e93a518380baf5b0ef13be9f87cae203 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 23 Aug 2018 16:09:47 -0400 Subject: [PATCH 2/4] display error message when there is a connection error --- templates/demo/app/dapp.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/templates/demo/app/dapp.js b/templates/demo/app/dapp.js index 77a837fbd..50b305e3c 100644 --- a/templates/demo/app/dapp.js +++ b/templates/demo/app/dapp.js @@ -18,6 +18,7 @@ class App extends React.Component { this.handleSelect = this.handleSelect.bind(this); this.state = { + error: false, 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 (

Embark - Usage Example

+ if (this.state.error) { + return (
+
Something went wrong connecting to ethereum. Please make sure you have a node running or are using metamask to connect to the ethereum network:
+
{this.state.error}
+
); + } else { + return (
+

Embark - Usage Example

@@ -86,6 +99,7 @@ class App extends React.Component {
); + } } } From ba4510fa173a1e0679aa52f4547932e59ed1300d Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 23 Aug 2018 16:23:00 -0400 Subject: [PATCH 3/4] remove unneded else --- templates/demo/app/dapp.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/demo/app/dapp.js b/templates/demo/app/dapp.js index 50b305e3c..ecba52f0d 100644 --- a/templates/demo/app/dapp.js +++ b/templates/demo/app/dapp.js @@ -81,7 +81,7 @@ class App extends React.Component {
Something went wrong connecting to ethereum. Please make sure you have a node running or are using metamask to connect to the ethereum network:
{this.state.error}
); - } else { + } return (

Embark - Usage Example

@@ -99,7 +99,6 @@ class App extends React.Component {
); - } } } From c5a65177c3b65eb064c57a2859623738e05a74f0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 24 Aug 2018 10:05:48 -0400 Subject: [PATCH 4/4] use null instead of false --- templates/demo/app/dapp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/demo/app/dapp.js b/templates/demo/app/dapp.js index ecba52f0d..2117558b3 100644 --- a/templates/demo/app/dapp.js +++ b/templates/demo/app/dapp.js @@ -18,7 +18,7 @@ class App extends React.Component { this.handleSelect = this.handleSelect.bind(this); this.state = { - error: false, + error: null, activeKey: 1, whisperEnabled: false, storageEnabled: false,