Example #1
0
 new Promise((resolve, reject) => {
     const txLocal = localStorage.getItem(txId)
     if (txLocal) {
         resolve(JSON.parse(txLocal))
     } else {
         let txFetched
         let blockFetched
         conn.getTransaction(txId)
             .then(tx => {
                 txFetched = tx
                 return conn.listBlocks(txId)
             })
             .then(block => {
                 blockFetched = block
                 return conn.listVotes(block[0])
             })
             .then(votes => {
                 txFetched = {
                     ...txFetched,
                     block: blockFetched,
                     votes
                 }
                 localStorage.setItem(txId, JSON.stringify(txFetched))
                 resolve(txFetched)
             })
             .catch(reason => reject(reason))
     }
 })