diff --git a/src/core/keychain/KeychainManager.ts b/src/core/keychain/KeychainManager.ts index 57006490ee..3b5d26827f 100644 --- a/src/core/keychain/KeychainManager.ts +++ b/src/core/keychain/KeychainManager.ts @@ -168,14 +168,16 @@ class KeychainManager { }, persist: async () => { - // Remove any potential empty keychains // Serialize all the keychains - const serializedKeychains = this.state.keychains?.length + let serializedKeychains = this.state.keychains?.length ? await Promise.all( - this.state.keychains?.map((keychain) => keychain.serialize()), + this.state.keychains?.map((keychain) => keychain?.serialize()), ) : []; + // Remove any potential empty keychains + serializedKeychains = serializedKeychains.filter((k) => !!k); + // Encrypt the serialized keychains const pwd = privates.get(this).password; const { encryptionKey } = await privates.get(this).getEncryptionKey(); diff --git a/src/core/keychain/keychainTypes/readOnlyKeychain.ts b/src/core/keychain/keychainTypes/readOnlyKeychain.ts index 7ce3e8c302..165eae8d46 100644 --- a/src/core/keychain/keychainTypes/readOnlyKeychain.ts +++ b/src/core/keychain/keychainTypes/readOnlyKeychain.ts @@ -6,6 +6,7 @@ import { Wallet } from '@ethersproject/wallet'; import { Address } from 'wagmi'; import { KeychainType } from '~/core/types/keychainTypes'; +import { logger } from '~/logger'; import { IKeychain, PrivateKey } from '../IKeychain'; @@ -46,6 +47,7 @@ export class ReadOnlyKeychain implements IKeychain { async deserialize(opts: SerializedReadOnlyKeychain) { if (!isAddress(opts.address)) { + logger.info('Invalid address:', { address: opts.address }); throw new Error('Invalid address'); } this.address = opts.address;