Skip to content

Commit 13c2d27

Browse files
authored
fix(extension): [LW-11506] limit message signing to supported wallet types (#1425)
1 parent 85afb20 commit 13c2d27

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/DropdownMenuOverlay.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ReactNode, useCallback, useState, VFC } from 'react';
1+
import React, { ReactNode, useCallback, useState, VFC, useMemo } from 'react';
22
import { Menu, MenuProps } from 'antd';
33
import {
44
AddNewWalletLink,
@@ -20,7 +20,8 @@ import { WalletAccounts } from './components/WalletAccounts';
2020
import { AddSharedWalletLink } from '@components/MainMenu/DropdownMenuOverlay/components/AddSharedWalletLink';
2121
import { useWalletStore } from '@stores';
2222
import classNames from 'classnames';
23-
import { AnyBip32Wallet } from '@cardano-sdk/web-extension';
23+
import type { AnyBip32Wallet } from '@cardano-sdk/web-extension';
24+
import { WalletType } from '@cardano-sdk/web-extension';
2425
import { Wallet } from '@lace/cardano';
2526

2627
interface Props extends MenuProps {
@@ -39,7 +40,7 @@ export const DropdownMenuOverlay: VFC<Props> = ({
3940
...props
4041
}): React.ReactElement => {
4142
const [currentSection, setCurrentSection] = useState<Sections>(Sections.Main);
42-
const { environmentName, setManageAccountsWallet } = useWalletStore();
43+
const { environmentName, setManageAccountsWallet, walletType } = useWalletStore();
4344

4445
const openWalletAccounts = (wallet: AnyBip32Wallet<Wallet.WalletMetadata, Wallet.AccountMetadata>) => {
4546
setManageAccountsWallet(wallet);
@@ -62,6 +63,14 @@ export const DropdownMenuOverlay: VFC<Props> = ({
6263
</>
6364
);
6465

66+
const shouldShowSignMessage = useMemo(
67+
() =>
68+
process.env.USE_MESSAGE_SIGNING === 'true' &&
69+
!isPopup &&
70+
[WalletType.InMemory, WalletType.Ledger].includes(walletType),
71+
[isPopup, walletType]
72+
);
73+
6574
return (
6675
<Menu {...props} className={styles.menuOverlay} data-testid="header-menu">
6776
{currentSection === Sections.Main && (
@@ -80,7 +89,7 @@ export const DropdownMenuOverlay: VFC<Props> = ({
8089
<AddressBookLink />
8190
<SettingsLink />
8291
<Separator />
83-
{process.env.USE_MESSAGE_SIGNING === 'true' && !isPopup && getSignMessageLink()}
92+
{shouldShowSignMessage && getSignMessageLink()}
8493
<ThemeSwitcher isPopup={isPopup} />
8594
<NetworkChoise onClick={handleNetworkChoise} />
8695
{lockWalletButton && (

0 commit comments

Comments
 (0)