1- import { useMemo } from 'react' ;
1+ import { ElementType , useMemo } from 'react' ;
22
33import { BonsaiCore } from '@/bonsai/ontology' ;
4- // import { useMfaEnrollment } from '@privy-io/react-auth';
4+ import { useMfaEnrollment , usePrivy } from '@privy-io/react-auth' ;
55import { LAMPORTS_PER_SOL } from '@solana/web3.js' ;
66import styled , { css } from 'styled-components' ;
77import tw from 'twin.macro' ;
@@ -13,20 +13,21 @@ import { STRING_KEYS } from '@/constants/localization';
1313import { isDev } from '@/constants/networks' ;
1414import { SMALL_USD_DECIMALS , USD_DECIMALS } from '@/constants/numbers' ;
1515import { StatsigFlags } from '@/constants/statsig' ;
16- import { DydxChainAsset , WalletType } from '@/constants/wallets' ;
16+ import { ConnectorType , DydxChainAsset , wallets , WalletType } from '@/constants/wallets' ;
1717
1818import { useAccountBalance } from '@/hooks/useAccountBalance' ;
1919import { useAccounts } from '@/hooks/useAccounts' ;
2020import { useBreakpoints } from '@/hooks/useBreakpoints' ;
2121import { useEnableSpot } from '@/hooks/useEnableSpot' ;
2222import { useEnvFeatures } from '@/hooks/useEnvFeatures' ;
23+ import { useMobileAppUrl } from '@/hooks/useMobileAppUrl' ;
2324import { usePerpetualsComplianceState } from '@/hooks/usePerpetualsComplianceState' ;
2425import { useStatsigGateValue } from '@/hooks/useStatsig' ;
2526import { useStringGetter } from '@/hooks/useStringGetter' ;
2627import { useSubaccount } from '@/hooks/useSubaccount' ;
2728import { useTokenConfigs } from '@/hooks/useTokenConfigs' ;
2829
29- // import { AppleIcon, AppleLightIcon, DiscordIcon, GoogleIcon, TwitterIcon } from '@/icons';
30+ import { AppleIcon , AppleLightIcon , DiscordIcon , GoogleIcon , TwitterIcon } from '@/icons' ;
3031import { headerMixins } from '@/styles/headerMixins' ;
3132import { layoutMixins } from '@/styles/layoutMixins' ;
3233
@@ -87,12 +88,12 @@ export const AccountMenu = () => {
8788 } = useAccounts ( ) ;
8889 const { registerAffiliate } = useSubaccount ( ) ;
8990
90- // const privy = usePrivy();
91- // const { google, discord, twitter } = privy.user ?? {};
91+ const privy = usePrivy ( ) ;
92+ const { google, discord, twitter } = privy . user ?? { } ;
9293
93- // const { showMfaEnrollmentModal } = useMfaEnrollment();
94+ const { showMfaEnrollmentModal } = useMfaEnrollment ( ) ;
9495
95- // const { appleAppStoreUrl, googlePlayStoreUrl } = useMobileAppUrl();
96+ const { appleAppStoreUrl, googlePlayStoreUrl } = useMobileAppUrl ( ) ;
9697
9798 const usedBalanceBN = MustBigNumber ( usdcBalance ) ;
9899
@@ -119,55 +120,55 @@ export const AccountMenu = () => {
119120 return null ;
120121 }
121122
122- // if (
123- // onboardingState === OnboardingState.AccountConnected &&
124- // walletInfo.name === WalletType.Privy
125- // ) {
126- // if (google) {
127- // return <Icon iconComponent={GoogleIcon as ElementType} />;
128- // }
129-
130- // if (discord) {
131- // return <Icon iconComponent={DiscordIcon as ElementType} />;
132- // }
133-
134- // if (twitter) {
135- // return <Icon iconComponent={TwitterIcon as ElementType} />;
136- // }
137-
138- // return (
139- // <Icon
140- // tw="rounded-[0.25rem]"
141- // iconComponent={wallets[WalletType.Privy].icon as ElementType}
142- // />
143- // );
144- // }
145-
146- // if (
147- // onboardingState === OnboardingState.AccountConnected &&
148- // walletInfo.connectorType === ConnectorType.Turnkey
149- // ) {
150- // if (walletInfo.providerName === 'google') {
151- // return <Icon iconComponent={GoogleIcon as ElementType} />;
152- // }
153-
154- // if (walletInfo.providerName === 'apple') {
155- // return (
156- // <Icon
157- // iconComponent={
158- // theme === AppTheme.Light
159- // ? (AppleIcon as ElementType)
160- // : (AppleLightIcon as ElementType)
161- // }
162- // />
163- // );
164- // }
165-
166- // return <Icon iconComponent={wallets[WalletType.Turnkey].icon as ElementType} />;
167- // }
123+ if (
124+ onboardingState === OnboardingState . AccountConnected &&
125+ walletInfo . name === WalletType . Privy
126+ ) {
127+ if ( google ) {
128+ return < Icon iconComponent = { GoogleIcon as ElementType } /> ;
129+ }
130+
131+ if ( discord ) {
132+ return < Icon iconComponent = { DiscordIcon as ElementType } /> ;
133+ }
134+
135+ if ( twitter ) {
136+ return < Icon iconComponent = { TwitterIcon as ElementType } /> ;
137+ }
138+
139+ return (
140+ < Icon
141+ tw = "rounded-[0.25rem]"
142+ iconComponent = { wallets [ WalletType . Privy ] . icon as ElementType }
143+ />
144+ ) ;
145+ }
146+
147+ if (
148+ onboardingState === OnboardingState . AccountConnected &&
149+ walletInfo . connectorType === ConnectorType . Turnkey
150+ ) {
151+ if ( walletInfo . providerName === 'google' ) {
152+ return < Icon iconComponent = { GoogleIcon as ElementType } /> ;
153+ }
154+
155+ if ( walletInfo . providerName === 'apple' ) {
156+ return (
157+ < Icon
158+ iconComponent = {
159+ theme === AppTheme . Light
160+ ? ( AppleIcon as ElementType )
161+ : ( AppleLightIcon as ElementType )
162+ }
163+ />
164+ ) ;
165+ }
166+
167+ return < Icon iconComponent = { wallets [ WalletType . Turnkey ] . icon as ElementType } /> ;
168+ }
168169
169170 return < WalletIcon wallet = { walletInfo } /> ;
170- } , [ onboardingState , walletInfo , theme ] ) ;
171+ } , [ onboardingState , walletInfo , google , discord , twitter , theme ] ) ;
171172
172173 return onboardingState === OnboardingState . Disconnected ? (
173174 < OnboardingTriggerButton size = { ButtonSize . XSmall } />
@@ -397,24 +398,24 @@ export const AccountMenu = () => {
397398 } ,
398399 ]
399400 : [ ] ) ,
400- // ...((appleAppStoreUrl ?? googlePlayStoreUrl)
401- // ? [
402- // {
403- // value: 'MobileDownload',
404- // icon: <Icon iconName={IconName.Qr} />,
405- // label: stringGetter({ key: STRING_KEYS.DOWNLOAD_MOBILE_APP }),
406- // onSelect: () => {
407- // dispatch(
408- // openDialog(
409- // DialogTypes.MobileDownload({
410- // mobileAppUrl: (appleAppStoreUrl ?? googlePlayStoreUrl)!,
411- // })
412- // )
413- // );
414- // },
415- // },
416- // ]
417- // : []),
401+ ...( ( appleAppStoreUrl ?? googlePlayStoreUrl )
402+ ? [
403+ {
404+ value : 'MobileDownload' ,
405+ icon : < Icon iconName = { IconName . Qr } /> ,
406+ label : stringGetter ( { key : STRING_KEYS . DOWNLOAD_MOBILE_APP } ) ,
407+ onSelect : ( ) => {
408+ dispatch (
409+ openDialog (
410+ DialogTypes . MobileDownload ( {
411+ mobileAppUrl : ( appleAppStoreUrl ?? googlePlayStoreUrl ) ! ,
412+ } )
413+ )
414+ ) ;
415+ } ,
416+ } ,
417+ ]
418+ : [ ] ) ,
418419 onboardingState === OnboardingState . AccountConnected &&
419420 hdKey && {
420421 value : 'MobileQrSignIn' ,
@@ -431,16 +432,16 @@ export const AccountMenu = () => {
431432 highlightColor : 'destroy' as const ,
432433 onSelect : ( ) => dispatch ( openDialog ( DialogTypes . MnemonicExport ( ) ) ) ,
433434 } ,
434- // ...(privy.ready && privy.authenticated
435- // ? [
436- // {
437- // value: 'MFA',
438- // icon: <Icon iconName={IconName.Lock} />,
439- // label: stringGetter({ key: STRING_KEYS.MULTI_FACTOR_AUTH }),
440- // onSelect: () => showMfaEnrollmentModal(),
441- // },
442- // ]
443- // : []),
435+ ...( privy . ready && privy . authenticated
436+ ? [
437+ {
438+ value : 'MFA' ,
439+ icon : < Icon iconName = { IconName . Lock } /> ,
440+ label : stringGetter ( { key : STRING_KEYS . MULTI_FACTOR_AUTH } ) ,
441+ onSelect : ( ) => showMfaEnrollmentModal ( ) ,
442+ } ,
443+ ]
444+ : [ ] ) ,
444445 {
445446 value : 'Disconnect' ,
446447 icon : < Icon iconName = { IconName . BoxClose } /> ,
0 commit comments