Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useWallet.js
Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | const update = async ({ wallet }) => { | ||||
wallet.Path145.publicKey, | wallet.Path145.publicKey, | ||||
wallet.Path245.publicKey, | wallet.Path245.publicKey, | ||||
wallet.Path1899.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 || | |||||
!Array.isArray(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'); | ||||
} | } | ||||
// Need to call with wallet as a parameter rather than trusting it is in state, otherwise can sometimes get wallet=false from haveUtxosChanged | // Need to call with wallet as a parameter rather than trusting it is in state, otherwise can sometimes get wallet=false from haveUtxosChanged | ||||
const utxosHaveChanged = haveUtxosChanged( | const utxosHaveChanged = haveUtxosChanged( | ||||
wallet, | wallet, | ||||
▲ Show 20 Lines • Show All 1,217 Lines • Show Last 20 Lines |