Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/keyring-controller/src/KeyringController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
stripHexPrefix,
getBinarySize,
} from 'ethereumjs-util';
import {
isValidHexAddress,
toChecksumHexAddress,
} from '@metamask/controller-utils';
import {
normalize as normalizeAddress,
signTypedData,
Expand All @@ -28,7 +32,6 @@ import {
PersonalMessageParams,
TypedMessageParams,
} from '@metamask/message-manager';
import { toChecksumHexAddress } from '@metamask/controller-utils';

/**
* Available keyring types
Expand Down Expand Up @@ -493,6 +496,11 @@ export class KeyringController extends BaseController<
) {
try {
const address = normalizeAddress(messageParams.from);
if (!address || !isValidHexAddress(address)) {
throw new Error(
`Missing or invalid address ${JSON.stringify(messageParams.from)}`,
);
}
const qrKeyring = await this.getOrAddQRKeyring();
const qrAccounts = await qrKeyring.getAccounts();
if (
Expand Down Expand Up @@ -751,6 +759,8 @@ export class KeyringController extends BaseController<
};
});
} catch (e) {
// TODO: Add test case for when keyring throws
/* istanbul ignore next */
throw new Error(`Unspecified error when connect QR Hardware, ${e}`);
}
}
Expand Down