-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
query network version when metamask is back on line #3004
Changes from all commits
8900cf4
9f00d0e
d868e01
970c0f5
be83246
5dc02d9
7c81bf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,21 @@ module.exports = class MetamaskController extends EventEmitter { | |
// network store | ||
this.networkController = new NetworkController(initState.NetworkController) | ||
|
||
// setup onLine lister for restarting the provider | ||
if (this.platform.addOnLineListener) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "online" is one word, I'd rather we didn't camel case it into two. Non blocking. |
||
this.platform.addOnLineListener(() => { | ||
// guard against premature firring of the event listener | ||
if (this.provider) { | ||
// start the block tracker up | ||
this.provider.stop() | ||
this.provider.start() | ||
} | ||
// look up the network | ||
this.networkController.lookupNetwork(() => { | ||
this.sendUpdate() | ||
}) | ||
}) | ||
} | ||
// config manager | ||
this.configManager = new ConfigManager({ | ||
store: this.store, | ||
|
@@ -91,6 +106,7 @@ module.exports = class MetamaskController extends EventEmitter { | |
|
||
// rpc provider | ||
this.provider = this.initializeProvider() | ||
|
||
this.blockTracker = this.provider._blockTracker | ||
|
||
this.recentBlocksController = new RecentBlocksController({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,14 @@ class ExtensionPlatform { | |
cb(e) | ||
} | ||
} | ||
|
||
isOnline () { | ||
return navigator.onLine | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sadly, this is the web api's camelization |
||
} | ||
|
||
addOnLineListener (cb) { | ||
window.addEventListener('online', cb) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah camel cased correctly here. Incorrect capitalization kinda driving me nuts, going to change it myself. |
||
} | ||
} | ||
|
||
module.exports = ExtensionPlatform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
log.error
to use ourloglevel
utility.