Skip to content

Commit

Permalink
fix: window.ethereum
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Feb 13, 2023
1 parent 0b67f15 commit ab059fe
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/utils/wallets/getBrowserWalletLabelAndIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ import { defaultWallet } from './wallets/defaultWallet';

export function getBrowserWalletLabelAndIcon() {
if (typeof window !== 'undefined') {
const userBrowserWallets = wallets.filter(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
(wallet) => !!window.ethereum[wallet.identityFlag]
);
if (userBrowserWallets.length > 1 || userBrowserWallets.length === 0) {
return {
label: defaultWallet.label,
icon: defaultWallet.icon,
};
if (!!window.ethereum) {
const userBrowserWallets = wallets.filter(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
(wallet) => !!window.ethereum[wallet.identityFlag]
);
if (userBrowserWallets.length > 1 || userBrowserWallets.length === 0) {
return {
label: defaultWallet.label,
icon: defaultWallet.icon,
};
} else {
return {
label: userBrowserWallets[0].label,
icon: userBrowserWallets[0].icon,
};
}
} else {
return {
label: userBrowserWallets[0].label,
icon: userBrowserWallets[0].icon,
};
return undefined;
}
} else {
return undefined;
Expand Down

0 comments on commit ab059fe

Please sign in to comment.