Skip to content

Commit

Permalink
Keychain logging (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobar79 authored Aug 30, 2023
1 parent 4a4813b commit 25c1eb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/keychain/KeychainManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/core/keychain/keychainTypes/readOnlyKeychain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 25c1eb0

Please sign in to comment.