From 572289e41a6a1f391d75e003fcd1979462ae8284 Mon Sep 17 00:00:00 2001 From: Ilya Vilensky Date: Mon, 20 Apr 2020 20:37:22 +0300 Subject: [PATCH] Added layer id to incoming txs (#493) --- app/redux/wallet/actions.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/redux/wallet/actions.js b/app/redux/wallet/actions.js index 515426c19..599e16747 100644 --- a/app/redux/wallet/actions.js +++ b/app/redux/wallet/actions.js @@ -221,10 +221,10 @@ const mergeTxStatuses = ({ existingList, incomingList, address }: { existingList !hasConfirmedIncomingTxs && existingListMap[tx.txId].tx.status !== TX_STATUSES.CONFIRMED && tx.status === TX_STATUSES.CONFIRMED && tx.receiver === address; hasConfirmedOutgoingTxs = !hasConfirmedOutgoingTxs && existingListMap[tx.txId].tx.status !== TX_STATUSES.CONFIRMED && tx.status === TX_STATUSES.CONFIRMED && tx.sender === address; - unifiedTxList[existingListMap[tx.txId].index] = { ...existingListMap[tx.txId].tx, status: tx.status }; + unifiedTxList[existingListMap[tx.txId].index] = { ...existingListMap[tx.txId].tx, status: tx.status, layerId: tx.layerId || existingListMap[tx.txId].tx.layerId }; } else { hasConfirmedIncomingTxs = !hasConfirmedIncomingTxs && tx.status === TX_STATUSES.CONFIRMED && tx.receiver === address; - unifiedTxList.unshift(tx.timestamp ? tx : { ...tx, timestamp: new Date().getTime() }); + unifiedTxList.unshift(tx.timestamp ? tx : { ...tx, timestamp: tx.timestamp || new Date().getTime() }); } }); return { unifiedTxList, hasConfirmedIncomingTxs, hasConfirmedOutgoingTxs }; @@ -245,12 +245,8 @@ export const getTxList = ({ notify }: { notify: Function }): Action => async (di // get all tx ids for every account, then for each account get full tx data for the list const txListCollector = async () => { - let minValidatedLayer = 0; await asyncForEach(accounts, async (account, index) => { const { txs, validatedLayer } = await httpService.getAccountTxs({ startLayer: transactions[index].layerId, account: account.publicKey }); - if (minValidatedLayer === 0) { - minValidatedLayer = validatedLayer; - } transactions[index].data.forEach((existingTx) => { if (!txs.includes(`0x${existingTx.txId}`) && existingTx.status === TX_STATUSES.PENDING) { txs.push(`0x${existingTx.txId}`); @@ -266,7 +262,7 @@ export const getTxList = ({ notify }: { notify: Function }): Action => async (di if (hasConfirmedIncomingTxs || hasConfirmedOutgoingTxs) { notify({ hasConfirmedIncomingTxs }); } - updatedTransactions = [...transactions.slice(0, index), { layerId: minValidatedLayer, data: unifiedTxList }, ...transactions.slice(index + 1)]; + updatedTransactions = [...transactions.slice(0, index), { layerId: validatedLayer, data: unifiedTxList }, ...transactions.slice(index + 1)]; }); }; await txListCollector();