feat: add blockchain status getter to all daemons

This commit is contained in:
Sérgio Salgado 2022-01-21 17:44:53 +00:00
parent 75cb094476
commit 2819b8a519
11 changed files with 107 additions and 16 deletions

View file

@ -32,7 +32,8 @@ module.exports = {
privateKey,
isStrictAddress,
connect,
supportsBatching
supportsBatching,
checkBlockchainStatus
}
function connect (url) {
@ -230,3 +231,9 @@ function supportsBatching (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(pify(web3.eth.isSyncing))
.then(res => _.isObject(res) ? 'syncing' : 'ready')
}