diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index 8760096e2..55b0f65e5 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -5,11 +5,13 @@ import { walletConnected } from "../../store/account" import { useRequestEthereumAccount } from "../../hooks/ledger-live-app" import { useIsActive } from "../../hooks/useIsActive" import { useConnectWallet } from "../../hooks/useConnectWallet" +import { useIsEmbed } from "../../hooks/useIsEmbed" const Navbar: FC = () => { const { isActive, account, chainId, deactivate } = useIsActive() const dispatch = useAppDispatch() const connectWallet = useConnectWallet() + const { isEmbed } = useIsEmbed() const { account: ledgerLiveAccount, requestAccount } = useRequestEthereumAccount() @@ -20,10 +22,10 @@ const Navbar: FC = () => { } useEffect(() => { - if (ledgerLiveAccountAddress) { + if (ledgerLiveAccountAddress && isEmbed) { dispatch(walletConnected(ledgerLiveAccountAddress)) } - }, [ledgerLiveAccountAddress, dispatch]) + }, [ledgerLiveAccountAddress, dispatch, isEmbed]) return ( { - setBtcAccount(account || undefined) - }, [account]) + if (isEmbed) setBtcAccount(account || undefined) + }, [account, isEmbed]) const requestBitcoinAccount = useCallback(async () => { const currencyId = supportedChainId === "1" ? "bitcoin" : "bitcoin_testnet" diff --git a/src/hooks/ledger-live-app/useRequestEthereumAccount.ts b/src/hooks/ledger-live-app/useRequestEthereumAccount.ts index daa5de550..a529ef69f 100644 --- a/src/hooks/ledger-live-app/useRequestEthereumAccount.ts +++ b/src/hooks/ledger-live-app/useRequestEthereumAccount.ts @@ -7,6 +7,7 @@ import { useWalletApiReactTransport } from "../../contexts/TransportProvider" import { walletConnected } from "../../store/account" import { supportedChainId } from "../../utils/getEnvVariable" import { useAppDispatch } from "../store/useAppDispatch" +import { useIsEmbed } from "../useIsEmbed" type UseRequestAccountState = { pending: boolean @@ -27,6 +28,7 @@ export function useRequestEthereumAccount(): UseRequestAccountReturn { const { account, requestAccount } = useRequestAccountReturn const dispatch = useAppDispatch() const { setIsSdkInitializing } = useIsTbtcSdkInitializing() + const { isEmbed } = useIsEmbed() useEffect(() => { // Setting the eth account in LedgerLiveAppContext through `setEthAccount` @@ -34,10 +36,12 @@ export function useRequestEthereumAccount(): UseRequestAccountReturn { // reinitialize the lib and tBTC SDK. We can set the is initializing flag // here to indicate as early as as possible that the sdk is in the // initializing process. - setIsSdkInitializing(true) - setEthAccount(account || undefined) - dispatch(walletConnected(account?.address || "")) - }, [account]) + if (isEmbed) { + setIsSdkInitializing(true) + setEthAccount(account || undefined) + dispatch(walletConnected(account?.address || "")) + } + }, [account, isEmbed]) const requestEthereumAccount = useCallback(async () => { const currencyId = supportedChainId === "1" ? "ethereum" : "ethereum_goerli"