Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch all the trezor init errors #770

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
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: 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