From 26f4f83843649fa32b7f9741e52a107f398544c1 Mon Sep 17 00:00:00 2001 From: Bruno Barbieri Date: Tue, 18 Jul 2023 13:12:59 +0200 Subject: [PATCH] ignore trezor init --- src/entries/popup/handlers/trezor.ts | 12 ++++++++++-- src/entries/popup/handlers/wallet.ts | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/entries/popup/handlers/trezor.ts b/src/entries/popup/handlers/trezor.ts index 221184915b..8b141029c1 100644 --- a/src/entries/popup/handlers/trezor.ts +++ b/src/entries/popup/handlers/trezor.ts @@ -27,7 +27,11 @@ export async function signTransactionFromTrezor( transaction: ethers.providers.TransactionRequest, ): Promise { 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, @@ -110,7 +114,11 @@ export async function signMessageByTypeFromTrezor( address: Address, messageType: string, ): Promise { - 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') { diff --git a/src/entries/popup/handlers/wallet.ts b/src/entries/popup/handlers/wallet.ts index 98c79076a8..2dcf958eb6 100644 --- a/src/entries/popup/handlers/wallet.ts +++ b/src/entries/popup/handlers/wallet.ts @@ -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, @@ -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({