mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
20 lines
577 B
JavaScript
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
|
||
|
}
|