Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/cashMethods.js
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | export const flattenBatchedHydratedUtxos = batchedHydratedUtxoDetails => { | ||||
*/ | */ | ||||
const flattenedBatchedHydratedUtxos = { slpUtxos: [] }; | const flattenedBatchedHydratedUtxos = { slpUtxos: [] }; | ||||
for (let i = 0; i < batchedHydratedUtxoDetails.length; i += 1) { | for (let i = 0; i < batchedHydratedUtxoDetails.length; i += 1) { | ||||
const theseSlpUtxos = batchedHydratedUtxoDetails[i].slpUtxos[0]; | const theseSlpUtxos = batchedHydratedUtxoDetails[i].slpUtxos[0]; | ||||
flattenedBatchedHydratedUtxos.slpUtxos.push(theseSlpUtxos); | flattenedBatchedHydratedUtxos.slpUtxos.push(theseSlpUtxos); | ||||
} | } | ||||
return flattenedBatchedHydratedUtxos; | return flattenedBatchedHydratedUtxos; | ||||
}; | }; | ||||
export const loadStoredWallet = walletStateFromStorage => { | |||||
// Accept cached tokens array that does not save BigNumber type of BigNumbers | |||||
// Return array with BigNumbers converted | |||||
// See BigNumber.js api for how to create a BigNumber object from an object | |||||
// https://mikemcl.github.io/bignumber.js/ | |||||
const liveWalletState = walletStateFromStorage; | |||||
const { tokens } = liveWalletState; | |||||
for (let i = 0; i < tokens.length; i += 1) { | |||||
const thisTokenBalance = tokens[i].balance; | |||||
thisTokenBalance._isBigNumber = true; | |||||
tokens[i].balance = new BigNumber(thisTokenBalance); | |||||
} | |||||
return liveWalletState; | |||||
}; | |||||
export const isValidStoredWallet = walletStateFromStorage => { | |||||
if ( | |||||
walletStateFromStorage && | |||||
walletStateFromStorage.state && | |||||
walletStateFromStorage.state.balances && | |||||
walletStateFromStorage.state.utxos && | |||||
walletStateFromStorage.state.hydratedUtxoDetails && | |||||
walletStateFromStorage.state.parsedTxHistory && | |||||
walletStateFromStorage.state.slpBalancesAndUtxos && | |||||
walletStateFromStorage.state.tokens | |||||
) { | |||||
return true; | |||||
} | |||||
return false; | |||||
Fabien: just return the bool:
```
return walletStateFromStorage &&
walletStateFromStorage.state… | |||||
}; |
just return the bool: