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({