From 94949bc4b39529a48761a997b35a9ca3c2681ae5 Mon Sep 17 00:00:00 2001 From: MananTank Date: Fri, 25 Apr 2025 14:57:29 +0000 Subject: [PATCH] Nebula: Fix wallet address not set in context when clicking example prompt on login page (#6856) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR enhances the `ChatPageContent` component by adding the `accountAddress` prop and updates various pages to retrieve and pass this new data. It ensures that both `authToken` and `accountAddress` are validated before proceeding. ### Detailed summary - Added `accountAddress` prop to `ChatPageContent`. - Updated `walletAddress` assignment to prioritize `props.accountAddress`. - Modified `Page` components to fetch `accountAddress` using `getNebulaAuthTokenWalletAddress`. - Updated authentication checks to validate both `authToken` and `accountAddress`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../app/nebula-app/(app)/chat/[session_id]/page.tsx | 9 +++++++-- .../src/app/nebula-app/(app)/chat/page.tsx | 13 ++++++++++--- .../nebula-app/(app)/components/ChatPageContent.tsx | 3 ++- apps/dashboard/src/app/nebula-app/(app)/page.tsx | 11 ++++++++--- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/apps/dashboard/src/app/nebula-app/(app)/chat/[session_id]/page.tsx b/apps/dashboard/src/app/nebula-app/(app)/chat/[session_id]/page.tsx index eed3ca905c3..703f0018778 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/chat/[session_id]/page.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/chat/[session_id]/page.tsx @@ -1,6 +1,9 @@ import { redirect } from "next/navigation"; import { loginRedirect } from "../../../../(app)/login/loginRedirect"; -import { getNebulaAuthToken } from "../../../_utils/authToken"; +import { + getNebulaAuthToken, + getNebulaAuthTokenWalletAddress, +} from "../../../_utils/authToken"; import { getSessionById } from "../../api/session"; import { ChatPageContent } from "../../components/ChatPageContent"; @@ -12,8 +15,9 @@ export default async function Page(props: { const params = await props.params; const pagePath = `/chat/${params.session_id}`; const authToken = await getNebulaAuthToken(); + const accountAddress = await getNebulaAuthTokenWalletAddress(); - if (!authToken) { + if (!authToken || !accountAddress) { loginRedirect(pagePath); } @@ -28,6 +32,7 @@ export default async function Page(props: { return ( x.toString()) || [], - walletAddress: contextRes?.wallet_address || null, + walletAddress: contextRes?.wallet_address || props.accountAddress || null, }; return value; diff --git a/apps/dashboard/src/app/nebula-app/(app)/page.tsx b/apps/dashboard/src/app/nebula-app/(app)/page.tsx index c8cbe7f4a90..1e2bfae7891 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/page.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/page.tsx @@ -1,5 +1,8 @@ import { loginRedirect } from "../../(app)/login/loginRedirect"; -import { getNebulaAuthToken } from "../_utils/authToken"; +import { + getNebulaAuthToken, + getNebulaAuthTokenWalletAddress, +} from "../_utils/authToken"; import { ChatPageContent } from "./components/ChatPageContent"; import { getChains } from "./utils/getChainIds"; @@ -11,17 +14,19 @@ export default async function Page(props: { }) { const searchParams = await props.searchParams; - const [chains, authToken] = await Promise.all([ + const [chains, authToken, accountAddress] = await Promise.all([ getChains(searchParams.chain), getNebulaAuthToken(), + getNebulaAuthTokenWalletAddress(), ]); - if (!authToken) { + if (!authToken || !accountAddress) { loginRedirect(); } return (