1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 16:18:07 +01:00
metamask-extension/app/scripts/controllers/network/createBlockTracker.js
Paul Bouchon 2f7d449427 EIP-1193: standard provider API (#6170)
* EIP-1193: Implement new provider API

* EIP-1193: Updated implementation

* Remove test file

* Fix tests

* Update ping check

* Update logic

* PR feedback
2019-02-19 16:42:08 -08:00

20 lines
577 B
JavaScript

const BlockTracker = require('eth-block-tracker')
/**
* Creates a block tracker that sends platform events on success and failure
*/
module.exports = function createBlockTracker (args, platform) {
const blockTracker = new BlockTracker(args)
blockTracker.on('latest', () => {
if (platform && platform.sendMessage) {
platform.sendMessage({ action: 'ethereum-ping-success' })
}
})
blockTracker.on('error', () => {
if (platform && platform.sendMessage) {
platform.sendMessage({ action: 'ethereum-ping-error' })
}
})
return blockTracker
}