Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useWallet.js
Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | const update = async ({ wallet }) => { | ||||
return; | return; | ||||
} | } | ||||
const cashAddresses = [ | const cashAddresses = [ | ||||
wallet.Path245.cashAddress, | wallet.Path245.cashAddress, | ||||
wallet.Path145.cashAddress, | wallet.Path145.cashAddress, | ||||
wallet.Path1899.cashAddress, | wallet.Path1899.cashAddress, | ||||
]; | ]; | ||||
const publicKeys = [ | |||||
wallet.Path145.publicKey, | |||||
wallet.Path245.publicKey, | |||||
wallet.Path1899.publicKey, | |||||
]; | |||||
const utxos = await getUtxos(BCH, cashAddresses); | const utxos = await getUtxos(BCH, cashAddresses); | ||||
// If an error is returned or utxos from only 1 address are returned | // If an error is returned or utxos from only 1 address are returned | ||||
if (!utxos || isEmpty(utxos) || utxos.error || utxos.length < 2) { | if (!utxos || isEmpty(utxos) || utxos.error || utxos.length < 2) { | ||||
// Throw error here to prevent more attempted api calls | // Throw error here to prevent more attempted api calls | ||||
// as you are likely already at rate limits | // as you are likely already at rate limits | ||||
throw new Error('Error fetching utxos'); | throw new Error('Error fetching utxos'); | ||||
} | } | ||||
Show All 20 Lines | const update = async ({ wallet }) => { | ||||
utxos, | utxos, | ||||
); | ); | ||||
const slpBalancesAndUtxos = await getSlpBalancesAndUtxos( | const slpBalancesAndUtxos = await getSlpBalancesAndUtxos( | ||||
BCH, | BCH, | ||||
hydratedUtxoDetails, | hydratedUtxoDetails, | ||||
); | ); | ||||
const txHistory = await getTxHistory(BCH, cashAddresses); | const txHistory = await getTxHistory(BCH, cashAddresses); | ||||
const parsedTxHistory = await getTxData(BCH, txHistory); | |||||
// public keys are used to determined if a tx is incoming outgoing | |||||
const parsedTxHistory = await getTxData(BCH, txHistory, publicKeys); | |||||
const parsedWithTokens = await addTokenTxData(BCH, parsedTxHistory); | const parsedWithTokens = await addTokenTxData(BCH, parsedTxHistory); | ||||
console.log(`slpBalancesAndUtxos`, slpBalancesAndUtxos); | console.log(`slpBalancesAndUtxos`, slpBalancesAndUtxos); | ||||
if (typeof slpBalancesAndUtxos === 'undefined') { | if (typeof slpBalancesAndUtxos === 'undefined') { | ||||
console.log(`slpBalancesAndUtxos is undefined`); | console.log(`slpBalancesAndUtxos is undefined`); | ||||
throw new Error('slpBalancesAndUtxos is undefined'); | throw new Error('slpBalancesAndUtxos is undefined'); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 879 Lines • Show Last 20 Lines |