Skip to content
Snippets Groups Projects
Commit b247659b authored by Mahdi Yari's avatar Mahdi Yari
Browse files

get transaction status after 3s

parent f94cb9ee
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,16 @@ const debug = newDebug('hive:broadcast');
const noop = function() {}
const formatter = formatterFactory(hiveApi);
function getTransactionStatus(trxId, expiration, time = 3000) {
return new Promise((resolve, reject) => {
setTimeout(() => {
hiveApi.findTransactionAsync(trxId, expiration).then(res => {
resolve(res)
})
}, time)
})
}
const hiveBroadcast = {};
// Base transaction logic -----------------------------------------------------
......@@ -49,8 +59,14 @@ hiveBroadcast.send = function hiveBroadcast$send(tx, privKeys, callback) {
return hiveApi.broadcastTransactionAsync(
signedTransaction
).then((result) => {
// TODO tomorrow: check transaction status then return status
return Object.assign({ id: trxId }, result, signedTransaction);
const expiration = signedTransaction.expiration
return getTransactionStatus(trxId, expiration).then(res => {
const obj = { id: trxId, status: res.status }
if (res.block_num) {
obj.block_num = res.block_num
}
return Object.assign(obj, result, signedTransaction);
})
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment