Skip to content

Commit

Permalink
fix: Init wallet device.
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu committed Feb 4, 2023
1 parent b9aa2c9 commit 3806557
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/neuron-ui/src/services/localCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ export const currentWallet = {
window.localStorage.setItem(LocalCacheKey.CurrentWallet, walletStr)
return true
},
load: (): { [index: string]: string } => {
load: (): State.WalletIdentity | undefined => {
const walletStr = window.localStorage.getItem(LocalCacheKey.CurrentWallet) || '{}'
try {
return JSON.parse(walletStr)
return JSON.parse(walletStr) as State.WalletIdentity
} catch (err) {
console.error(`Cannot parse current wallet`)
return {}
return undefined
}
},
}
Expand Down
7 changes: 5 additions & 2 deletions packages/neuron-ui/src/states/init/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ export const emptyWallet: State.Wallet = {
const wallet = currentWallet.load()

export const walletState: State.Wallet = {
name: wallet.name || '',
id: wallet.id || '',
name: wallet?.name || '',
id: wallet?.id || '',
balance: '0',
addresses: addresses.load(),
device: wallet?.device,
isHD: wallet?.isHD,
isWatchOnly: wallet?.isWatchOnly,
}

export default walletState

0 comments on commit 3806557

Please sign in to comment.