Skip to content

Commit 03d0d3d

Browse files
[FIX] MM Dropdown bug (#634)
* [FIX] MM Dropdown bug * i18n: change text when not connected * fix: Pr comments * fix: show metamask links only for mm wallets * fix mm portfolio page for non mm extension wallets (#650) * chore: delete sdk file --------- Co-authored-by: Flavio F Lima <flavioislima@users.noreply.github.com> Co-authored-by: Brett <27568879+BrettCleary@users.noreply.github.com>
1 parent 16ffa4e commit 03d0d3d

File tree

3 files changed

+52
-36
lines changed

3 files changed

+52
-36
lines changed

public/locales/en/translation.json

+1
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@
310310
"noThanks": "No Thanks"
311311
},
312312
"changeWallet": "Change wallet",
313+
"connectWallet": "Connect wallet",
313314
"copyUrl": "Copy URL",
314315
"currentWallet": "Current wallet",
315316
"discordApp": "Discord",
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
11
import { Menu } from '@mantine/core'
2-
import React, { useContext } from 'react'
2+
import React from 'react'
3+
import walletState from 'frontend/state/WalletState'
4+
import { observer } from 'mobx-react-lite'
5+
36
import Wallet from 'frontend/components/UI/Wallet'
47
import styles from './index.module.scss'
58
import { NavLink } from 'react-router-dom'
69
import onboardingStore from 'frontend/store/OnboardingStore'
710
import { useTranslation } from 'react-i18next'
8-
import ContextProvider from 'frontend/state/ContextProvider'
11+
import { PROVIDERS } from 'common/types/proxy-types'
912

10-
function NavigationMenuItem({ label, to }: { label: string; to: string }) {
11-
const { showMetaMaskBrowserSidebarLinks } = useContext(ContextProvider)
13+
function NavigationMenuItem({
14+
label,
15+
to,
16+
showMetaMaskExtensionLinks
17+
}: {
18+
label: string
19+
to: string
20+
showMetaMaskExtensionLinks: boolean
21+
}) {
1222
return (
1323
<Menu.Item
1424
className={styles.menuItem}
15-
id={
16-
showMetaMaskBrowserSidebarLinks
17-
? 'topMenuItemWalletDropdown'
18-
: undefined
19-
}
25+
id={showMetaMaskExtensionLinks ? 'topMenuItemWalletDropdown' : undefined}
2026
>
2127
<NavLink
2228
to={to}
23-
id={
24-
showMetaMaskBrowserSidebarLinks
25-
? 'topElementWalletDropdown'
26-
: undefined
27-
}
29+
id={showMetaMaskExtensionLinks ? 'topElementWalletDropdown' : undefined}
2830
>
2931
<div className={`body ${styles.itemContents}`}>{label}</div>
3032
</NavLink>
3133
</Menu.Item>
3234
)
3335
}
3436

35-
export default function AccountDropdown() {
37+
const WalletDropdown: React.FC = observer(() => {
3638
const { t } = useTranslation()
37-
const { showMetaMaskBrowserSidebarLinks } = useContext(ContextProvider)
39+
const showWalletConnectedLinks = walletState.isConnected
40+
const showMetaMaskExtensionLinks =
41+
walletState.isConnected &&
42+
walletState.provider === PROVIDERS.METAMASK_EXTENSION
43+
3844
return (
3945
<Menu position="bottom" trigger="hover">
4046
<Menu.Target>
@@ -50,48 +56,54 @@ export default function AccountDropdown() {
5056
<Menu.Label className={styles.menuLabel}>
5157
{t('hyperplay.currentWallet', `Current wallet`)}
5258
</Menu.Label>
53-
{showMetaMaskBrowserSidebarLinks && (
59+
{showMetaMaskExtensionLinks && (
5460
<>
5561
<NavigationMenuItem
5662
label={t('hyperplay.viewFullscreen', `View fullscreen`)}
5763
to={'/metamaskHome'}
64+
showMetaMaskExtensionLinks={showMetaMaskExtensionLinks}
5865
></NavigationMenuItem>
5966
<NavigationMenuItem
6067
label={t('hyperplay.viewItem', {
6168
defaultValue: 'View {{item}}',
6269
item: 'Snaps'
6370
})}
71+
showMetaMaskExtensionLinks={showMetaMaskExtensionLinks}
6472
to={'/metamaskSnaps'}
6573
></NavigationMenuItem>
6674
</>
6775
)}
68-
<Menu.Item
69-
className={`${styles.menuItem} `}
70-
id={
71-
!showMetaMaskBrowserSidebarLinks
72-
? 'topMenuItemWalletDropdown'
73-
: undefined
74-
}
75-
>
76-
<NavLink
77-
to={'/metamaskPortfolio'}
76+
{showWalletConnectedLinks && (
77+
<Menu.Item
78+
className={`${styles.menuItem} `}
7879
id={
79-
!showMetaMaskBrowserSidebarLinks
80-
? 'topElementWalletDropdown'
80+
!showWalletConnectedLinks
81+
? 'topMenuItemWalletDropdown'
8182
: undefined
8283
}
8384
>
84-
<div className={`body ${styles.itemContents}`}>
85-
{t('hyperplay.viewPortfolio', `View portfolio`)}
86-
</div>
87-
</NavLink>
88-
</Menu.Item>
85+
<NavLink
86+
to={'/metamaskPortfolio'}
87+
id={
88+
!showWalletConnectedLinks
89+
? 'topElementWalletDropdown'
90+
: undefined
91+
}
92+
>
93+
<div className={`body ${styles.itemContents}`}>
94+
{t('hyperplay.viewPortfolio', `View portfolio`)}
95+
</div>
96+
</NavLink>
97+
</Menu.Item>
98+
)}
8999
<Menu.Item
90100
className={`${styles.menuItem} `}
91101
onClick={() => onboardingStore.openOnboarding()}
92102
>
93103
<div className={`body ${styles.itemContents}`}>
94-
{t('hyperplay.changeWallet', `Change wallet`)}
104+
{showWalletConnectedLinks
105+
? t('hyperplay.changeWallet', `Change wallet`)
106+
: t('hyperplay.connectWallet', `Connect wallet`)}
95107
</div>
96108
</Menu.Item>
97109
<Menu.Label className={styles.menuLabel}>
@@ -107,4 +119,6 @@ export default function AccountDropdown() {
107119
</Menu.Dropdown>
108120
</Menu>
109121
)
110-
}
122+
})
123+
124+
export default WalletDropdown

src/frontend/screens/MetaMaskPortfolio/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const MetaMaskPortfolio = function () {
1313
className={MetaMaskPortfolioStyles.homeWebview}
1414
src={`https://portfolio.metamask.io/${page}`}
1515
allowpopups={trueAsStr}
16+
partition={'persist:InPageWindowEthereumExternalWallet'}
1617
/>
1718
</div>
1819
</>

0 commit comments

Comments
 (0)