Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/chronik.js
Show First 20 Lines • Show All 315 Lines • ▼ Show 20 Lines | ) => { | ||||
// Now use cachedTokenInfoByTokenId object to finalize token info | // Now use cachedTokenInfoByTokenId object to finalize token info | ||||
// Split this out into a separate function so you can unit test | // Split this out into a separate function so you can unit test | ||||
const finalTokenArray = processPreliminaryTokensArray( | const finalTokenArray = processPreliminaryTokensArray( | ||||
preliminaryTokensArray, | preliminaryTokensArray, | ||||
updatedTokenInfoById, | updatedTokenInfoById, | ||||
); | ); | ||||
return { finalTokenArray, updatedTokenInfoById, newTokensToCache }; | return { tokens: finalTokenArray, updatedTokenInfoById, newTokensToCache }; | ||||
}; | }; | ||||
export const finalizeSlpUtxos = (preliminarySlpUtxos, tokenInfoById) => { | export const finalizeSlpUtxos = (preliminarySlpUtxos, tokenInfoById) => { | ||||
// We need tokenQty in each slpUtxo to support transaction creation | // We need tokenQty in each slpUtxo to support transaction creation | ||||
// Add this info here | // Add this info here | ||||
const finalizedSlpUtxos = []; | const finalizedSlpUtxos = []; | ||||
for (let i = 0; i < preliminarySlpUtxos.length; i += 1) { | for (let i = 0; i < preliminarySlpUtxos.length; i += 1) { | ||||
const thisUtxo = preliminarySlpUtxos[i]; | const thisUtxo = preliminarySlpUtxos[i]; | ||||
▲ Show 20 Lines • Show All 517 Lines • ▼ Show 20 Lines | ) => { | ||||
const txHistoryNewTokensToCache = uncachedTokenIds.length > 0; | const txHistoryNewTokensToCache = uncachedTokenIds.length > 0; | ||||
if (!txHistoryNewTokensToCache) { | if (!txHistoryNewTokensToCache) { | ||||
// This will almost always be the case | // This will almost always be the case | ||||
// Edge case to find uncached token info in tx history that was not caught in processing utxos | // Edge case to find uncached token info in tx history that was not caught in processing utxos | ||||
// Requires performing transactions in one wallet, then loading the same wallet in another browser later | // Requires performing transactions in one wallet, then loading the same wallet in another browser later | ||||
return { | return { | ||||
chronikTxHistory, | parsedTxHistory: chronikTxHistory, | ||||
txHistoryUpdatedTokenInfoById: tokenInfoById, | txHistoryUpdatedTokenInfoById: tokenInfoById, | ||||
txHistoryNewTokensToCache, | txHistoryNewTokensToCache, | ||||
}; | }; | ||||
} | } | ||||
// Iterate over uncachedTokenIds to get genesis info and add to cache | // Iterate over uncachedTokenIds to get genesis info and add to cache | ||||
const getTokenInfoPromises = []; | const getTokenInfoPromises = []; | ||||
for (let i = 0; i < uncachedTokenIds.length; i += 1) { | for (let i = 0; i < uncachedTokenIds.length; i += 1) { | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |