Skip to content

Commit 1e3aa7d

Browse files
committed
fixup! Cache and restore wallets
1 parent ac72065 commit 1e3aa7d

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

src/core/account/account-pixie.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const accountPixie: TamePixie<AccountProps> = combinePixies({
112112
async update() {
113113
const ai = toApiInput(input)
114114
const { accountId, accountState, log } = input.props
115-
const { accountWalletInfos } = accountState
115+
const { accountWalletInfo, accountWalletInfos } = accountState
116116

117117
async function loadAllFiles(): Promise<void> {
118118
await Promise.all([
@@ -127,12 +127,7 @@ const accountPixie: TamePixie<AccountProps> = combinePixies({
127127
// Assumes storage wallets are already initialized.
128128
async function tryLoadCache(): Promise<WalletCacheSetup | undefined> {
129129
try {
130-
const storageWalletId = accountWalletInfos[0]?.id
131-
if (storageWalletId == null) {
132-
return undefined
133-
}
134-
135-
const cachePath = getWalletCachePath(storageWalletId)
130+
const cachePath = getWalletCachePath(accountWalletInfo.id)
136131
const cacheJson = await ai.props.io.disklet.getText(cachePath)
137132

138133
// Build currency info map from loaded plugins.
@@ -358,18 +353,17 @@ const accountPixie: TamePixie<AccountProps> = combinePixies({
358353

359354
// Initialize cache saver once account API exists
360355
if (accountApi != null && cacheSaver == null) {
361-
const storageWalletId = accountState.accountWalletInfos[0]?.id
362-
if (storageWalletId != null) {
363-
const cachePath = getWalletCachePath(storageWalletId)
364-
365-
cacheSaver = makeWalletCacheSaver(
366-
accountApi,
367-
ai.props.io.disklet,
368-
cachePath,
369-
input.props.log.warn.bind(input.props.log)
370-
)
371-
input.props.log('[WalletCache] Cache saver initialized')
372-
}
356+
const cachePath = getWalletCachePath(
357+
accountState.accountWalletInfo.id
358+
)
359+
360+
cacheSaver = makeWalletCacheSaver(
361+
accountApi,
362+
ai.props.io.disklet,
363+
cachePath,
364+
input.props.log.warn.bind(input.props.log)
365+
)
366+
input.props.log('[WalletCache] Cache saver initialized')
373367
}
374368

375369
if (cacheSaver == null) return

0 commit comments

Comments
 (0)