Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useWallet.js
Show All 12 Lines | import { | ||||
addNewHydratedUtxos, | addNewHydratedUtxos, | ||||
removeConsumedUtxos, | removeConsumedUtxos, | ||||
areAllUtxosIncludedInIncrementallyHydratedUtxos, | areAllUtxosIncludedInIncrementallyHydratedUtxos, | ||||
getHashArrayFromWallet, | getHashArrayFromWallet, | ||||
parseChronikTx, | parseChronikTx, | ||||
checkWalletForTokenInfo, | checkWalletForTokenInfo, | ||||
isActiveWebsocket, | isActiveWebsocket, | ||||
} from 'utils/cashMethods'; | } from 'utils/cashMethods'; | ||||
import { getUtxosChronik } from 'utils/chronik'; | import { | ||||
getUtxosChronik, | |||||
getSlpBalancesAndUtxosFromChronik, | |||||
addTokenInfo, | |||||
} from 'utils/chronik'; | |||||
import { | import { | ||||
isValidCashtabSettings, | isValidCashtabSettings, | ||||
isValidContactList, | isValidContactList, | ||||
parseInvalidSettingsForMigration, | parseInvalidSettingsForMigration, | ||||
} from 'utils/validation'; | } from 'utils/validation'; | ||||
import localforage from 'localforage'; | import localforage from 'localforage'; | ||||
import { currency } from 'components/Common/Ticker'; | import { currency } from 'components/Common/Ticker'; | ||||
import isEmpty from 'lodash.isempty'; | import isEmpty from 'lodash.isempty'; | ||||
▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | const update = async ({ wallet }) => { | ||||
console.log(`bchApiUtxos`, utxos); | console.log(`bchApiUtxos`, utxos); | ||||
const chronikUtxos = await getUtxosChronik( | const chronikUtxos = await getUtxosChronik( | ||||
chronik, | chronik, | ||||
hash160AndAddressObjArray, | hash160AndAddressObjArray, | ||||
); | ); | ||||
console.log(`chronikUtxos`, chronikUtxos); | console.log(`chronikUtxos`, chronikUtxos); | ||||
const chronikSlpBalancesAndUtxos = | |||||
getSlpBalancesAndUtxosFromChronik(chronikUtxos); | |||||
console.log( | |||||
`chronikSlpBalancesAndUtxos without token info`, | |||||
chronikSlpBalancesAndUtxos, | |||||
); | |||||
const tokensWithGenesisInfo = await addTokenInfo( | |||||
chronik, | |||||
chronikSlpBalancesAndUtxos.tokens, | |||||
); | |||||
chronikSlpBalancesAndUtxos.tokens = tokensWithGenesisInfo; | |||||
console.log( | |||||
`chronikSlpBalancesAndUtxos`, | |||||
chronikSlpBalancesAndUtxos, | |||||
); | |||||
// 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 ( | if ( | ||||
!utxos || | !utxos || | ||||
!Array.isArray(utxos) || | !Array.isArray(utxos) || | ||||
isEmpty(utxos) || | isEmpty(utxos) || | ||||
utxos.error || | utxos.error || | ||||
utxos.length < 2 | utxos.length < 2 | ||||
) { | ) { | ||||
▲ Show 20 Lines • Show All 1,251 Lines • Show Last 20 Lines |