From a575bb1346da36407d9f06e7cc64cc52a13c73ef Mon Sep 17 00:00:00 2001 From: chambaz Date: Sat, 19 Oct 2024 20:58:31 -0400 Subject: [PATCH 1/3] fix: check mrgnlend store initialized before fetching points data --- apps/marginfi-v2-ui/src/hooks/useFirebaseAccount.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/marginfi-v2-ui/src/hooks/useFirebaseAccount.tsx b/apps/marginfi-v2-ui/src/hooks/useFirebaseAccount.tsx index 64581a1eaa..74fb99f233 100644 --- a/apps/marginfi-v2-ui/src/hooks/useFirebaseAccount.tsx +++ b/apps/marginfi-v2-ui/src/hooks/useFirebaseAccount.tsx @@ -6,6 +6,7 @@ import { useRouter } from "next/router"; import { toast } from "react-toastify"; import { useUserProfileStore } from "~/store"; +import { useMrgnlendStore } from "~/store"; import { useWallet } from "~/components/wallet-v2/hooks/use-wallet.hook"; import React from "react"; @@ -16,6 +17,8 @@ const useFirebaseAccount = () => { const [isLogged, setIsLogged] = React.useState(false); const referralCode = React.useMemo(() => routerQuery.referralCode as string | undefined, [routerQuery.referralCode]); + const [initialized] = useMrgnlendStore((state) => [state.initialized]); + const [checkForFirebaseUser, setFirebaseUser, signoutFirebaseUser, fetchPoints, resetPoints, hasUser] = useUserProfileStore((state) => [ state.checkForFirebaseUser, @@ -30,6 +33,7 @@ const useFirebaseAccount = () => { const walletId = walletInfo && walletInfo?.name ? walletInfo.name : ""; useEffect(() => { + if (!initialized) return; // NOTE: if more point-specific logic is added, move this to a separate hook const unsubscribe = onAuthStateChanged(firebaseApi.auth, (newUser) => { if (newUser) { @@ -41,7 +45,7 @@ const useFirebaseAccount = () => { } }); return () => unsubscribe(); - }, [fetchPoints, setFirebaseUser, resetPoints]); + }, [fetchPoints, setFirebaseUser, resetPoints, initialized]); // Wallet connection side effect (auto-login attempt) useEffect(() => { From 18c74663ef71aecd10cde68ab3b9b818764ce17a Mon Sep 17 00:00:00 2001 From: chambaz Date: Sat, 19 Oct 2024 21:28:27 -0400 Subject: [PATCH 2/3] chore: remove sentry exception if user exists --- apps/marginfi-v2-ui/src/pages/api/user/signup.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/marginfi-v2-ui/src/pages/api/user/signup.ts b/apps/marginfi-v2-ui/src/pages/api/user/signup.ts index 4993681850..271dd93470 100644 --- a/apps/marginfi-v2-ui/src/pages/api/user/signup.ts +++ b/apps/marginfi-v2-ui/src/pages/api/user/signup.ts @@ -35,11 +35,9 @@ export default async function handler(req: NextApiRequest, res: a try { const user = await getFirebaseUserByWallet(walletAddress); if (user) { - Sentry.captureException({ message: "User already exists" }); return res.status(STATUS_BAD_REQUEST).json({ error: "User already exists" }); } } catch (error: any) { - Sentry.captureException(error); return res.status(STATUS_INTERNAL_ERROR).json({ error: error.message }); // An unexpected error occurred } From cab90ab3df91a763c83140af4e073aa11dec755e Mon Sep 17 00:00:00 2001 From: chambaz Date: Sat, 19 Oct 2024 21:28:42 -0400 Subject: [PATCH 3/3] fix: change ref code link --- packages/mrgn-ui/src/components/wallet-v2/wallet.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mrgn-ui/src/components/wallet-v2/wallet.tsx b/packages/mrgn-ui/src/components/wallet-v2/wallet.tsx index db168ce91c..aab30756c3 100644 --- a/packages/mrgn-ui/src/components/wallet-v2/wallet.tsx +++ b/packages/mrgn-ui/src/components/wallet-v2/wallet.tsx @@ -538,7 +538,7 @@ const Wallet = ({
  • { if (userPointsData.referralLink && userPointsData.referralLink.length > 0) { setIsReferralCopied(true);