Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let requests = hashes.map(hash => new Promise((resolve, reject) =>{
let statuses = [];
let request = new TxStatusRequest();
request.setTxHash(hash.toString('hex'));
let timer = setTimeout(()=>{
txClient.$channel.close();
reject(new Error('Query txStatus timeout'));
}, timeoutLimit);
let stream = txClient.statusStream(request);
stream.on('data', function (response){
statuses.push(response);
});
stream.on('end', function (end){
clearTimeout(timer);
statuses.length > 0? resolve(statuses[statuses.length - 1].getTxStatus()) : resolve(null);
});
}));
let values = await Promise.all(requests);