Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useWallet.js
Show First 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | const update = async ({ wallet }) => { | ||||
}); | }); | ||||
} | } | ||||
// If you were missing any token info for tokens in this tx history, get it | // If you were missing any token info for tokens in this tx history, get it | ||||
const newState = { | const newState = { | ||||
balances: getWalletBalanceFromUtxos(nonSlpUtxos), | balances: getWalletBalanceFromUtxos(nonSlpUtxos), | ||||
tokens: finalTokenArray, | tokens: finalTokenArray, | ||||
slpBalancesAndUtxos: { | |||||
slpUtxos: finalizedSlpUtxos, | slpUtxos: finalizedSlpUtxos, | ||||
nonSlpUtxos, | nonSlpUtxos, | ||||
}, | |||||
parsedTxHistory: chronikTxHistory, | parsedTxHistory: chronikTxHistory, | ||||
}; | }; | ||||
const walletStateAfterThisStack = { | const walletStateAfterThisStack = { | ||||
balances: getWalletBalanceFromUtxos(nonSlpUtxos), | balances: getWalletBalanceFromUtxos(nonSlpUtxos), | ||||
slpUtxos: finalizedSlpUtxos, | slpUtxos: finalizedSlpUtxos, | ||||
nonSlpUtxos, | nonSlpUtxos, | ||||
tokens: finalTokenArray, | tokens: finalTokenArray, | ||||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | const useWallet = () => { | ||||
}; | }; | ||||
const writeWalletState = async (wallet, newState) => { | const writeWalletState = async (wallet, newState) => { | ||||
// Add new state as an object on the active wallet | // Add new state as an object on the active wallet | ||||
wallet.state = newState; | wallet.state = newState; | ||||
try { | try { | ||||
await localforage.setItem('wallet', wallet); | await localforage.setItem('wallet', wallet); | ||||
console.log( | console.log( | ||||
`Wallet ${wallet.name} saved without duplicate token object`, | `Wallet ${wallet.name} saved without slpBalancesAndUtxos parent object`, | ||||
); | ); | ||||
} catch (err) { | } catch (err) { | ||||
console.log(`Error in writeWalletState()`); | console.log(`Error in writeWalletState()`); | ||||
console.log(err); | console.log(err); | ||||
} | } | ||||
}; | }; | ||||
const getWalletDetails = async wallet => { | const getWalletDetails = async wallet => { | ||||
▲ Show 20 Lines • Show All 1,034 Lines • Show Last 20 Lines |