Skip to content

Commit

Permalink
Catch all the trezor init errors (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobar79 authored and BrodyHughes committed Jul 24, 2023
1 parent b2d3dbb commit f581771
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/entries/popup/handlers/trezor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export async function signTransactionFromTrezor(
transaction: ethers.providers.TransactionRequest,
): Promise<string> {
try {
window.TrezorConnect.init(TREZOR_CONFIG);
try {
window.TrezorConnect.init(TREZOR_CONFIG);
} catch (e) {
// ignore already initialized error
}
const { from: address } = transaction;
const provider = getProvider({
chainId: transaction.chainId,
Expand Down Expand Up @@ -110,7 +114,11 @@ export async function signMessageByTypeFromTrezor(
address: Address,
messageType: string,
): Promise<string> {
window.TrezorConnect.init(TREZOR_CONFIG);
try {
window.TrezorConnect.init(TREZOR_CONFIG);
} catch (e) {
// ignore already initialized error
}
const path = await getPath(address);
// Personal sign
if (messageType === 'personal_sign') {
Expand Down
12 changes: 10 additions & 2 deletions src/entries/popup/handlers/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,11 @@ export const importAccountAtIndex = async (
switch (type) {
case 'Trezor':
{
window.TrezorConnect.init(TREZOR_CONFIG);
try {
window.TrezorConnect.init(TREZOR_CONFIG);
} catch (e) {
// ignore already initialized error
}
const path = `m/${DEFAULT_HD_PATH}/${index}`;
const result = await window.TrezorConnect.ethereumGetAddress({
path,
Expand Down Expand Up @@ -388,7 +392,11 @@ export const connectTrezor = async () => {
// accountsEnabled: 2,
// };
try {
window.TrezorConnect.init(TREZOR_CONFIG);
try {
window.TrezorConnect.init(TREZOR_CONFIG);
} catch (e) {
// ignore already initialized error
}
const path = `m/${DEFAULT_HD_PATH}`;

const result = await window.TrezorConnect.ethereumGetPublicKey({
Expand Down

0 comments on commit f581771

Please sign in to comment.