ekzyis faa26ec68f
Add wallet debug page (#2301)
* Add wallet debug page

* Show key hash information

* Show last key update

* Show last wallet update

* Show last device key update
2025-07-21 15:39:09 -05:00

65 lines
1.6 KiB
JavaScript

import { isTemplate, isWallet } from '@/wallets/lib/util'
export const KeyStatus = {
KEY_STORAGE_UNAVAILABLE: 'KEY_STORAGE_UNAVAILABLE',
WRONG_KEY: 'WRONG_KEY'
}
// wallet actions
export const SET_WALLETS = 'SET_WALLETS'
export const SET_KEY = 'SET_KEY'
export const WRONG_KEY = 'WRONG_KEY'
export const KEY_MATCH = 'KEY_MATCH'
export const KEY_STORAGE_UNAVAILABLE = 'KEY_STORAGE_UNAVAILABLE'
export const WALLETS_QUERY_ERROR = 'WALLETS_QUERY_ERROR'
export default function reducer (state, action) {
switch (action.type) {
case SET_WALLETS: {
const wallets = action.wallets
.filter(isWallet)
.sort((a, b) => a.priority === b.priority ? a.id - b.id : a.priority - b.priority)
const templates = action.wallets
.filter(isTemplate)
.sort((a, b) => a.name.localeCompare(b.name))
return {
...state,
walletsLoading: false,
walletsError: null,
wallets,
templates
}
}
case WALLETS_QUERY_ERROR:
return {
...state,
walletsLoading: false,
walletsError: action.error
}
case SET_KEY:
return {
...state,
key: action.key,
keyHash: action.hash,
keyUpdatedAt: action.updatedAt
}
case WRONG_KEY:
return {
...state,
keyError: KeyStatus.WRONG_KEY
}
case KEY_MATCH:
return {
...state,
keyError: null
}
case KEY_STORAGE_UNAVAILABLE:
return {
...state,
keyError: KeyStatus.KEY_STORAGE_UNAVAILABLE
}
default:
return state
}
}