mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 10:30:04 +01:00
2f7d449427
* EIP-1193: Implement new provider API * EIP-1193: Updated implementation * Remove test file * Fix tests * Update ping check * Update logic * PR feedback
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
|
|
}
|