Skip to content

Commit c81fed3

Browse files
MananTankd4mrjoaquim-verges
authored
[TOOL-3337] Dashboard: Engine cloud - DO NOT MERGE (#6639)
Co-authored-by: Prithvish Baidya <deformercoding@gmail.com> Co-authored-by: Joaquim Verges <joaquim.verges@gmail.com>
1 parent ec50f8c commit c81fed3

File tree

193 files changed

+11514
-268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+11514
-268
lines changed

.changeset/big-cases-wish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/vault-sdk": patch
3+
---
4+
5+
Introducing vault sdk

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ packages/*/typedoc/*
3030
storybook-static
3131
.aider*
3232

33-
tsconfig.tsbuildinfo
33+
tsconfig.tsbuildinfo
34+
.cursor

apps/dashboard/.env.example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,8 @@ ANALYTICS_SERVICE_URL=""
104104
NEXT_PUBLIC_NEBULA_URL=""
105105

106106
# required for billing parts of the dashboard (team -> settings -> billing / invoices)
107-
STRIPE_SECRET_KEY=""
107+
STRIPE_SECRET_KEY=""
108+
109+
# required for server wallet management
110+
NEXT_PUBLIC_THIRDWEB_VAULT_URL=""
111+
NEXT_PUBLIC_ENGINE_CLOUD_URL=""

apps/dashboard/knip.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"ignoreDependencies": [
1313
"@storybook/blocks",
1414
"@thirdweb-dev/service-utils",
15+
"@thirdweb-dev/vault-sdk",
1516
"@types/color",
1617
"fast-xml-parser"
1718
]

apps/dashboard/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@
4545
"@radix-ui/react-slot": "^1.2.0",
4646
"@radix-ui/react-switch": "^1.2.2",
4747
"@radix-ui/react-tooltip": "1.2.3",
48+
"@scalar/api-reference-react": "^0.6.19",
4849
"@sentry/nextjs": "9.13.0",
4950
"@shazow/whatsabi": "0.21.0",
5051
"@tanstack/react-query": "5.74.4",
5152
"@tanstack/react-table": "^8.21.3",
5253
"@thirdweb-dev/service-utils": "workspace:*",
54+
"@thirdweb-dev/vault-sdk": "workspace:*",
5355
"@vercel/functions": "2.0.0",
5456
"@vercel/og": "^0.6.8",
5557
"abitype": "1.0.8",

apps/dashboard/src/@/actions/proxies.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use server";
22

33
import { getAuthToken } from "../../app/(app)/api/lib/getAuthToken";
4-
import { API_SERVER_URL } from "../constants/env";
4+
import { API_SERVER_URL, THIRDWEB_ENGINE_CLOUD_URL } from "../constants/env";
55

66
type ProxyActionParams = {
77
pathname: string;
@@ -79,6 +79,10 @@ export async function apiServerProxy<T>(params: ProxyActionParams) {
7979
return proxy<T>(API_SERVER_URL, params);
8080
}
8181

82+
export async function engineCloudProxy<T>(params: ProxyActionParams) {
83+
return proxy<T>(THIRDWEB_ENGINE_CLOUD_URL, params);
84+
}
85+
8286
export async function payServerProxy<T>(params: ProxyActionParams) {
8387
return proxy<T>(
8488
process.env.NEXT_PUBLIC_PAY_URL

apps/dashboard/src/@/components/blocks/SidebarLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function FullWidthSidebarLayout(props: {
9595
links={[...contentSidebarLinks, ...(footerSidebarLinks || [])]}
9696
/>
9797

98-
<main className="z-0 flex min-w-0 grow flex-col max-sm:w-full">
98+
<main className="flex min-w-0 grow flex-col max-sm:w-full">
9999
{children}
100100
</main>
101101
<AppFooter containerClassName="max-w-7xl" />

apps/dashboard/src/@/components/blocks/select-with-search.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ export const SelectWithSearch = React.forwardRef<
129129
selectedOption && "text-foreground",
130130
)}
131131
>
132-
{selectedOption?.label || placeholder}
132+
{renderOption && selectedOption
133+
? renderOption(selectedOption)
134+
: selectedOption?.label || placeholder}
133135
</span>
134136
<ChevronDownIcon className="size-4 cursor-pointer text-muted-foreground" />
135137
</div>

apps/dashboard/src/@/components/ui/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const buttonVariants = cva(
2222
link: "text-primary underline-offset-4 hover:underline text-semibold",
2323
pink: "border border-nebula-pink-foreground !text-nebula-pink-foreground bg-[hsl(var(--nebula-pink-foreground)/5%)] hover:bg-nebula-pink-foreground/10 dark:!text-foreground dark:bg-nebula-pink-foreground/10 dark:hover:bg-nebula-pink-foreground/20",
2424
upsell:
25-
"bg-gradient-to-r from-purple-500 to-pink-500 text-white hover:from-purple-600 hover:to-pink-600 shadow-lg hover:shadow-xl transform hover:-translate-y-0.5 transition-all duration-200",
25+
"bg-green-600 text-white hover:bg-green-700 shadow-lg hover:shadow-xl transform hover:-translate-y-0.5 transition-all duration-200",
2626
},
2727
size: {
2828
default: "h-10 px-4 py-2",

apps/dashboard/src/@/components/ui/tabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Button } from "./button";
1010
import { ToolTipLabel } from "./tooltip";
1111

1212
export type TabLink = {
13-
name: string;
13+
name: React.ReactNode;
1414
href: string;
1515
isActive: boolean;
1616
isDisabled?: boolean;
@@ -43,7 +43,7 @@ export function TabLinks(props: {
4343
return (
4444
<Button
4545
asChild
46-
key={tab.name}
46+
key={tab.href}
4747
disabled={tab.isDisabled}
4848
variant="ghost"
4949
>
@@ -206,7 +206,7 @@ function useUnderline<El extends HTMLElement>() {
206206

207207
export function TabPathLinks(props: {
208208
links: {
209-
name: string;
209+
name: React.ReactNode;
210210
path: string;
211211
exactMatch?: boolean;
212212
isDisabled?: boolean;

apps/dashboard/src/@/constants/env.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ export const NEXT_PUBLIC_NEBULA_APP_CLIENT_ID =
99

1010
export const NEBULA_APP_SECRET_KEY = process.env.NEBULA_APP_SECRET_KEY || "";
1111

12+
export const THIRDWEB_VAULT_URL =
13+
process.env.NEXT_PUBLIC_THIRDWEB_VAULT_URL || "";
14+
15+
export const THIRDWEB_ENGINE_CLOUD_URL =
16+
process.env.NEXT_PUBLIC_ENGINE_CLOUD_URL || "";
17+
1218
export const THIRDWEB_API_SECRET = process.env.API_SERVER_SECRET || "";
1319

1420
export const IPFS_GATEWAY_URL =

apps/dashboard/src/@/lib/time.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { differenceInCalendarDays } from "date-fns";
2+
import {
3+
type DurationId,
4+
type Range,
5+
getLastNDaysRange,
6+
} from "../../components/analytics/date-range-selector";
7+
8+
export function normalizeTime(date: Date) {
9+
const newDate = new Date(date);
10+
newDate.setHours(1, 0, 0, 0);
11+
return newDate;
12+
}
13+
14+
export function normalizeTimeISOString(date: Date) {
15+
return normalizeTime(date).toISOString();
16+
}
17+
18+
export function getFiltersFromSearchParams(params: {
19+
from: string | undefined | string[];
20+
to: string | undefined | string[];
21+
interval: string | undefined | string[];
22+
defaultRange: DurationId;
23+
}) {
24+
const fromStr = params.from;
25+
const toStr = params.to;
26+
const defaultRange = getLastNDaysRange(params.defaultRange);
27+
28+
const range: Range =
29+
fromStr && toStr && typeof fromStr === "string" && typeof toStr === "string"
30+
? {
31+
from: normalizeTime(new Date(fromStr)),
32+
to: normalizeTime(new Date(toStr)),
33+
type: "custom",
34+
}
35+
: {
36+
from: normalizeTime(defaultRange.from),
37+
to: normalizeTime(defaultRange.to),
38+
type: defaultRange.type,
39+
};
40+
41+
const defaultInterval =
42+
differenceInCalendarDays(range.to, range.from) > 30
43+
? "week"
44+
: ("day" as const);
45+
46+
return {
47+
range,
48+
interval:
49+
params.interval === "day"
50+
? ("day" as const)
51+
: params.interval === "week"
52+
? ("week" as const)
53+
: defaultInterval,
54+
};
55+
}

apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import {
77
useQuery,
88
useQueryClient,
99
} from "@tanstack/react-query";
10-
import type { ResultItem } from "app/(app)/team/[team_slug]/(team)/~/engine/(instance)/[engineId]/metrics/components/StatusCodes";
1110
import type { EngineBackendWalletType } from "lib/engine";
1211
import { useState } from "react";
1312
import { useActiveAccount } from "thirdweb/react";
1413
import invariant from "tiny-invariant";
15-
import type { EngineStatus } from "../../../app/(app)/team/[team_slug]/(team)/~/engine/(instance)/[engineId]/overview/components/transactions-table";
14+
import type { ResultItem } from "../../../app/(app)/team/[team_slug]/[project_slug]/engine/dedicated/(instance)/[engineId]/metrics/components/StatusCodes";
15+
import type { EngineStatus } from "../../../app/(app)/team/[team_slug]/[project_slug]/engine/dedicated/(instance)/[engineId]/overview/components/transactions-table";
1616
import { engineKeys } from "../cache-keys";
1717

1818
// Engine instances
@@ -1641,15 +1641,19 @@ interface EngineResourceMetrics {
16411641
};
16421642
}
16431643

1644-
export function useEngineSystemMetrics(engineId: string, teamIdOrSlug: string) {
1644+
export function useEngineSystemMetrics(
1645+
engineId: string,
1646+
teamIdOrSlug: string,
1647+
projectSlug: string,
1648+
) {
16451649
const [enabled, setEnabled] = useState(true);
16461650

16471651
return useQuery({
16481652
queryKey: engineKeys.systemMetrics(engineId),
16491653
queryFn: async () => {
16501654
const res = await apiServerProxy({
16511655
method: "GET",
1652-
pathname: `/v1/teams/${teamIdOrSlug}/engine/${engineId}/metrics`,
1656+
pathname: `/v1/teams/${teamIdOrSlug}/${projectSlug}/engine/dedicated/${engineId}/metrics`,
16531657
});
16541658

16551659
if (!res.ok) {

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ export default async function TeamLayout(props: {
7474
path: `/team/${params.team_slug}/~/analytics`,
7575
name: "Analytics",
7676
},
77-
{
78-
path: `/team/${params.team_slug}/~/engine`,
79-
name: "Engines",
80-
},
8177
{
8278
path: `/team/${params.team_slug}/~/ecosystem`,
8379
name: "Ecosystems",

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/engine/(general)/layout.tsx

Lines changed: 0 additions & 46 deletions
This file was deleted.

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getTeamBySlug } from "@/api/team";
33
import { getTeamSubscriptions } from "@/api/team-subscription";
44
import { fetchRPCUsage } from "@/api/usage/rpc";
55
import { getThirdwebClient } from "@/constants/thirdweb.server";
6-
import { normalizeTimeISOString } from "lib/time";
6+
import { normalizeTimeISOString } from "@/lib/time";
77
import { redirect } from "next/navigation";
88
import { getValidAccount } from "../../../../../account/settings/getAccount";
99
import { getAuthToken } from "../../../../../api/lib/getAuthToken";

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/ProjectFTUX.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function ProductsSection(props: {
234234
title: "Engine",
235235
description:
236236
"Scale your application with a backend server to read, write, and deploy contracts at production-grade.",
237-
href: `/team/${props.teamSlug}/~/engine`,
237+
href: `/team/${props.teamSlug}/${props.projectSlug}/engine`,
238238
icon: EngineIcon,
239239
trackingLabel: "engine",
240240
},

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectSidebarLayout.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import {
88
WalletIcon,
99
} from "lucide-react";
1010
import { ContractIcon } from "../../../../(dashboard)/(chain)/components/server/icons/ContractIcon";
11+
import { EngineIcon } from "../../../../(dashboard)/(chain)/components/server/icons/EngineIcon";
1112
import { InsightIcon } from "../../../../(dashboard)/(chain)/components/server/icons/InsightIcon";
1213
import { PayIcon } from "../../../../(dashboard)/(chain)/components/server/icons/PayIcon";
1314
import { SmartAccountIcon } from "../../../../(dashboard)/(chain)/components/server/icons/SmartAccountIcon";
15+
import { Badge } from "../../../../../../@/components/ui/badge";
1416
import { NebulaIcon } from "../../../../../nebula-app/(app)/icons/NebulaIcon";
1517

1618
export function ProjectSidebarLayout(props: {
@@ -60,17 +62,27 @@ export function ProjectSidebarLayout(props: {
6062
tracking: tracking("contracts"),
6163
},
6264
{
63-
href: `${layoutPath}/nebula`,
64-
label: "Nebula",
65-
icon: NebulaIcon,
66-
tracking: tracking("nebula"),
65+
href: `${layoutPath}/engine`,
66+
label: (
67+
<span className="flex items-center gap-2">
68+
Engine <Badge>New</Badge>
69+
</span>
70+
),
71+
icon: EngineIcon,
72+
tracking: tracking("engine"),
6773
},
6874
{
6975
href: `${layoutPath}/insight`,
7076
label: "Insight",
7177
icon: InsightIcon,
7278
tracking: tracking("insight"),
7379
},
80+
{
81+
href: `${layoutPath}/nebula`,
82+
label: "Nebula",
83+
icon: NebulaIcon,
84+
tracking: tracking("nebula"),
85+
},
7486
]}
7587
footerSidebarLinks={[
7688
{

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/connect/account-abstraction/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default async function Page(props: {
7575
});
7676

7777
return (
78-
<div>
78+
<div className="flex grow flex-col">
7979
<AccountAbstractionSummary
8080
teamId={project.teamId}
8181
projectId={project.id}

0 commit comments

Comments
 (0)