Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useBCH.js
Show First 20 Lines • Show All 286 Lines • ▼ Show 20 Lines | const parseTokenInfoForTxHistory = (BCH, parsedTx, tokenInfo) => { | ||||
cashtabTokenInfo.tokenTicker = tokenInfo.tokenTicker; | cashtabTokenInfo.tokenTicker = tokenInfo.tokenTicker; | ||||
cashtabTokenInfo.transactionType = transactionType; | cashtabTokenInfo.transactionType = transactionType; | ||||
return cashtabTokenInfo; | return cashtabTokenInfo; | ||||
}; | }; | ||||
const addTokenTxDataToSingleTx = async (BCH, parsedTx) => { | const addTokenTxDataToSingleTx = async (BCH, parsedTx) => { | ||||
// Accept one parsedTx | // Accept one parsedTx | ||||
// If it's a token tx, do an API call to get token info and return it | |||||
// If it's not a token tx, just return it | // If it's not a token tx, just return it as is and do not parse for token data | ||||
if (!parsedTx.tokenTx) { | if (!parsedTx.tokenTx) { | ||||
return parsedTx; | return parsedTx; | ||||
} | } | ||||
const tokenData = await BCH.SLP.Utils.txDetails(parsedTx.txid); | |||||
// If it could be a token tx, do an API call to get token info and return it | |||||
let tokenData; | |||||
try { | |||||
tokenData = await BCH.SLP.Utils.txDetails(parsedTx.txid); | |||||
} catch (err) { | |||||
console.log( | |||||
`Error in parsing BCH.SLP.Utils.txDetails(${parsedTx.txid})`, | |||||
); | |||||
console.log(err); | |||||
// This is not a token tx | |||||
parsedTx.tokenTx = false; | |||||
return parsedTx; | |||||
} | |||||
const { tokenInfo } = tokenData; | const { tokenInfo } = tokenData; | ||||
parsedTx.tokenInfo = parseTokenInfoForTxHistory( | parsedTx.tokenInfo = parseTokenInfoForTxHistory( | ||||
BCH, | BCH, | ||||
parsedTx, | parsedTx, | ||||
tokenInfo, | tokenInfo, | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 725 Lines • Show Last 20 Lines |