Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useBCH.js
Show First 20 Lines • Show All 345 Lines • ▼ Show 20 Lines | const getSlpBalancesAndUtxos = hydratedUtxoDetails => { | ||||
// Prevent app from treating slpUtxos as nonSlpUtxos | // Prevent app from treating slpUtxos as nonSlpUtxos | ||||
// Must enforce === false as api will occasionally return utxo.isValid === null | // Must enforce === false as api will occasionally return utxo.isValid === null | ||||
// Do not classify utxos with 546 satoshis as nonSlpUtxos as a precaution | // Do not classify utxos with 546 satoshis as nonSlpUtxos as a precaution | ||||
// Do not classify any utxos that include token information as nonSlpUtxos | // Do not classify any utxos that include token information as nonSlpUtxos | ||||
const nonSlpUtxos = hydratedUtxos.filter( | const nonSlpUtxos = hydratedUtxos.filter( | ||||
utxo => | utxo => | ||||
utxo.isValid === false && utxo.value !== 546 && !utxo.tokenName, | utxo.isValid === false && utxo.value !== 546 && !utxo.tokenName, | ||||
); | ); | ||||
const slpUtxos = hydratedUtxos.filter(utxo => utxo.isValid); | // To be included in slpUtxos, the utxo must | ||||
// have utxo.isValid = true | |||||
// If utxo has a utxo.tokenQty field, i.e. not a minting baton, then utxo.tokenQty !== '0' | |||||
const slpUtxos = hydratedUtxos.filter( | |||||
utxo => utxo.isValid && !(utxo.tokenQty === '0'), | |||||
); | |||||
let tokensById = {}; | let tokensById = {}; | ||||
slpUtxos.forEach(slpUtxo => { | slpUtxos.forEach(slpUtxo => { | ||||
let token = tokensById[slpUtxo.tokenId]; | let token = tokensById[slpUtxo.tokenId]; | ||||
if (token) { | if (token) { | ||||
// Minting baton does nto have a slpUtxo.tokenQty type | // Minting baton does nto have a slpUtxo.tokenQty type | ||||
▲ Show 20 Lines • Show All 462 Lines • Show Last 20 Lines |