Skip to content

Commit c137dd6

Browse files
committed
[NEB-190] Set testnet flag on testnet pages in dashboard (#6875)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on adding a `networks` property to various components and functions within the application, enhancing the context management for network-related data across the dashboard. ### Detailed summary - Added `networks` property in `NebulaLoginPage.tsx`. - Updated `NebulaChatButton` components in multiple files to accept `networks`. - Modified context handling to include `networks` in session updates and chat functionalities. - Adjusted `ChatBar` and `ChatPageContent` components to utilize `networks`. - Enhanced API interactions in `session.ts` and `chat.ts` to handle `networks`. - Updated storybook stories to reflect changes in context with `networks`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 65017f6 commit c137dd6

File tree

11 files changed

+28
-0
lines changed

11 files changed

+28
-0
lines changed

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/layout.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ The following is the user's message:
100100
return (
101101
<>
102102
<NebulaChatButton
103+
networks={chain.testnet ? "testnet" : "mainnet"}
103104
isFloating={true}
104105
pageType="chain"
105106
authToken={authToken ?? undefined}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ The following is the user's message:`;
115115
client={client}
116116
>
117117
<NebulaChatButton
118+
networks={info.chainMetadata.testnet ? "testnet" : "mainnet"}
118119
isFloating={true}
119120
pageType="contract"
120121
authToken={authToken ?? undefined}

apps/dashboard/src/app/(app)/(dashboard)/support/page.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export default async function SupportPage() {
158158
</p>
159159
<div className="mt-6 flex w-full flex-col items-center gap-3">
160160
<NebulaChatButton
161+
networks="all"
161162
isFloating={false}
162163
pageType="support"
163164
authToken={authToken ?? undefined}

apps/dashboard/src/app/nebula-app/(app)/api/chat.ts

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { NebulaTxData } from "../components/Chats";
66
export type NebulaContext = {
77
chainIds: string[] | null;
88
walletAddress: string | null;
9+
networks: "mainnet" | "testnet" | "all" | null;
910
};
1011

1112
export async function promptNebula(params: {
@@ -26,6 +27,7 @@ export async function promptNebula(params: {
2627
body.context = {
2728
chain_ids: params.context.chainIds || [],
2829
wallet_address: params.context.walletAddress,
30+
networks: params.context.networks,
2931
};
3032
}
3133

@@ -116,6 +118,7 @@ export async function promptNebula(params: {
116118
const contextData = JSON.parse(data.data) as {
117119
wallet_address: string;
118120
chain_ids: number[];
121+
networks: NebulaContext["networks"];
119122
};
120123

121124
params.handleStream({
@@ -165,6 +168,7 @@ type ChatStreamedResponse =
165168
data: {
166169
wallet_address: string;
167170
chain_ids: number[];
171+
networks: NebulaContext["networks"];
168172
};
169173
};
170174

apps/dashboard/src/app/nebula-app/(app)/api/session.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export async function createSession(params: {
1818
body.context = {
1919
chain_ids: params.context.chainIds || [],
2020
wallet_address: params.context.walletAddress,
21+
networks: params.context.networks,
2122
};
2223
}
2324

@@ -47,6 +48,7 @@ export async function updateSession(params: {
4748
body.context = {
4849
chain_ids: params.contextFilters.chainIds || [],
4950
wallet_address: params.contextFilters.walletAddress,
51+
networks: params.contextFilters.networks,
5052
};
5153
}
5254

apps/dashboard/src/app/nebula-app/(app)/components/ChatBar.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export function ChatBar(props: {
130130
props.setContext({
131131
walletAddress: props.context?.walletAddress || null,
132132
chainIds: values.map((x) => x.toString()),
133+
networks: props.context?.networks || null,
133134
});
134135
}}
135136
priorityChains={[
@@ -156,6 +157,7 @@ export function ChatBar(props: {
156157
props.setContext({
157158
walletAddress: walletMeta.address,
158159
chainIds: props.context?.chainIds || [],
160+
networks: props.context?.networks || null,
159161
});
160162
}}
161163
/>

apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export function ChatPageContent(props: {
101101
props.initialParams?.chainIds.map((x) => x.toString()) ||
102102
[],
103103
walletAddress: contextRes?.wallet_address || props.accountAddress || null,
104+
networks: "mainnet",
104105
};
105106

106107
return value;
@@ -131,6 +132,7 @@ export function ChatPageContent(props: {
131132
: {
132133
chainIds: [],
133134
walletAddress: null,
135+
networks: null,
134136
};
135137

136138
if (!updatedContextFilters.walletAddress && address) {
@@ -594,6 +596,7 @@ export async function handleNebulaPrompt(params: {
594596
setContextFilters({
595597
chainIds: res.data.chain_ids.map((x) => x.toString()),
596598
walletAddress: res.data.wallet_address,
599+
networks: res.data.networks,
597600
});
598601
}
599602
},

apps/dashboard/src/app/nebula-app/(app)/components/Chatbar.stories.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function Story() {
4848
isStreaming={false}
4949
context={{
5050
chainIds: ["1"],
51+
networks: null,
5152
walletAddress: null,
5253
}}
5354
showContextSelector={true}
@@ -60,6 +61,7 @@ function Story() {
6061
isStreaming={false}
6162
context={{
6263
chainIds: ["1", "137", "10"],
64+
networks: null,
6365
walletAddress: null,
6466
}}
6567
showContextSelector={true}
@@ -72,6 +74,7 @@ function Story() {
7274
isStreaming={false}
7375
context={{
7476
chainIds: ["1", "137", "10", "146", "80094"],
77+
networks: null,
7578
walletAddress: null,
7679
}}
7780
showContextSelector={true}
@@ -89,6 +92,7 @@ function Story() {
8992
isStreaming={false}
9093
context={{
9194
chainIds: ["1", "137", "10", "146", "80094"],
95+
networks: null,
9296
walletAddress: null,
9397
}}
9498
showContextSelector={true}

apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChat.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
useState,
1717
} from "react";
1818
import type { ThirdwebClient } from "thirdweb";
19+
import type { NebulaContext } from "../../api/chat";
1920
import type { ExamplePrompt } from "../../data/examplePrompts";
2021
import { NebulaIcon } from "../../icons/NebulaIcon";
2122

@@ -25,6 +26,7 @@ export function NebulaChatButton(props: {
2526
pageType: "chain" | "contract" | "support";
2627
authToken: string | undefined;
2728
examplePrompts: ExamplePrompt[];
29+
networks: NebulaContext["networks"];
2830
label: string;
2931
client: ThirdwebClient;
3032
isFloating: boolean;
@@ -91,6 +93,7 @@ export function NebulaChatButton(props: {
9193
</div>
9294

9395
<NebulaChatUIContainer
96+
networks={props.networks}
9497
onClose={closeModal}
9598
isOpen={isOpen}
9699
hasBeenOpened={hasBeenOpened}
@@ -112,6 +115,7 @@ function NebulaChatUIContainer(props: {
112115
examplePrompts: ExamplePrompt[];
113116
pageType: "chain" | "contract" | "support";
114117
client: ThirdwebClient;
118+
networks: NebulaContext["networks"];
115119
nebulaParams:
116120
| {
117121
messagePrefix: string;
@@ -187,6 +191,7 @@ function NebulaChatUIContainer(props: {
187191
}
188192
>
189193
<LazyFloatingChatContent
194+
networks={props.networks}
190195
authToken={props.authToken}
191196
client={props.client}
192197
nebulaParams={props.nebulaParams}

apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChatContent.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default function FloatingChatContent(props: {
2626
client: ThirdwebClient;
2727
examplePrompts: ExamplePrompt[];
2828
pageType: "chain" | "contract" | "support";
29+
networks: NebulaContext["networks"];
2930
nebulaParams:
3031
| {
3132
messagePrefix: string;
@@ -40,6 +41,7 @@ export default function FloatingChatContent(props: {
4041

4142
return (
4243
<FloatingChatContentLoggedIn
44+
networks={props.networks}
4345
authToken={props.authToken}
4446
client={props.client}
4547
nebulaParams={props.nebulaParams}
@@ -54,6 +56,7 @@ function FloatingChatContentLoggedIn(props: {
5456
client: ThirdwebClient;
5557
pageType: "chain" | "contract" | "support";
5658
examplePrompts: ExamplePrompt[];
59+
networks: NebulaContext["networks"];
5760
nebulaParams:
5861
| {
5962
messagePrefix: string;
@@ -82,6 +85,7 @@ function FloatingChatContentLoggedIn(props: {
8285
props.nebulaParams?.chainIds.map((chainId) => chainId.toString()) ||
8386
null,
8487
walletAddress: props.nebulaParams?.wallet || null,
88+
networks: props.networks,
8589
};
8690
});
8791

apps/dashboard/src/app/nebula-app/login/NebulaLoginPage.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export function NebulaLoggedOutStatePage(props: {
9393
context={{
9494
walletAddress: null,
9595
chainIds: chainIds.map((x) => x.toString()),
96+
networks: null,
9697
}}
9798
setContext={(v) => {
9899
if (v?.chainIds) {

0 commit comments

Comments
 (0)