Skip to content

Commit cf401be

Browse files
[Dashboard] Add thirdweb API option alongside Engine API (#7734)
1 parent c178d3a commit cf401be

File tree

5 files changed

+326
-83
lines changed

5 files changed

+326
-83
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/analytics/send-test-tx.client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export function SendTestTransaction(props: {
292292

293293
return (
294294
<div className="mt-3 w-full rounded-md border bg-background p-6">
295-
<TryItOut />
295+
<TryItOut useEngineAPI={false} />
296296
<div className="mt-6 flex flex-col gap-2 md:flex-row md:justify-end md:gap-2">
297297
<Dialog open={isModalOpen} onOpenChange={setIsModalOpen}>
298298
<DialogTrigger asChild>

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/explorer/components/scalar.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
"use client";
22
import { ApiReferenceReact } from "@scalar/api-reference-react";
33
import "@scalar/api-reference-react/style.css";
4-
import { NEXT_PUBLIC_ENGINE_CLOUD_URL } from "@/constants/public-envs";
4+
import {
5+
NEXT_PUBLIC_ENGINE_CLOUD_URL,
6+
NEXT_PUBLIC_THIRDWEB_API_HOST,
7+
} from "@/constants/public-envs";
8+
9+
interface ScalarProps {
10+
useEngineAPI: boolean;
11+
}
12+
13+
export function Scalar({ useEngineAPI }: ScalarProps) {
14+
const apiUrl = useEngineAPI
15+
? NEXT_PUBLIC_ENGINE_CLOUD_URL
16+
: NEXT_PUBLIC_THIRDWEB_API_HOST;
17+
const openApiUrl = useEngineAPI
18+
? `${apiUrl}/openapi`
19+
: `${apiUrl}/openapi.json`;
20+
const apiName = useEngineAPI ? "Engine API (advanced)" : "thirdweb API";
21+
const serverDescription = useEngineAPI ? "Engine Cloud" : "thirdweb API";
522

6-
export function Scalar() {
723
return (
824
<div className="flex flex-col gap-4">
9-
<h2 className="font-bold text-2xl tracking-tight">Full API Reference</h2>
25+
<h2 className="font-bold text-2xl tracking-tight">
26+
Full API Reference - {apiName}
27+
</h2>
1028
<ApiReferenceReact
1129
configuration={{
1230
hideModels: true,
1331
servers: [
1432
{
15-
description: "Engine Cloud",
16-
url: NEXT_PUBLIC_ENGINE_CLOUD_URL,
33+
description: serverDescription,
34+
url: apiUrl,
1735
},
1836
],
19-
url: `${NEXT_PUBLIC_ENGINE_CLOUD_URL}/openapi`,
37+
url: openApiUrl,
2038
}}
2139
/>
2240
</div>
Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
1+
"use client";
2+
import { useState } from "react";
3+
import {
4+
Select,
5+
SelectContent,
6+
SelectItem,
7+
SelectTrigger,
8+
SelectValue,
9+
} from "@/components/ui/select";
110
import { TryItOut } from "../server-wallets/components/try-it-out";
211
import { Scalar } from "./components/scalar";
312

4-
export default async function TransactionsExplorerPage() {
13+
export default function TransactionsExplorerPage() {
14+
const [apiMode, setApiMode] = useState<"thirdweb" | "engine">("thirdweb");
15+
const useEngineAPI = apiMode === "engine";
16+
517
return (
618
<div className="flex flex-col gap-4">
7-
<TryItOut />
8-
<Scalar />
19+
<div className="flex items-center justify-between rounded-lg border bg-card p-4">
20+
<div className="flex flex-col gap-1">
21+
<h3 className="font-medium text-sm">Select API Mode</h3>
22+
<p className="text-muted-foreground text-xs">
23+
Choose between thirdweb API (recommended) or Engine API (advanced)
24+
</p>
25+
</div>
26+
<div className="flex items-center gap-3">
27+
<Select
28+
value={apiMode}
29+
onValueChange={(value: "thirdweb" | "engine") => setApiMode(value)}
30+
>
31+
<SelectTrigger>
32+
<SelectValue />
33+
</SelectTrigger>
34+
<SelectContent>
35+
<SelectItem value="thirdweb">
36+
thirdweb API (recommended)
37+
</SelectItem>
38+
<SelectItem value="engine">Engine API (advanced)</SelectItem>
39+
</SelectContent>
40+
</Select>
41+
</div>
42+
</div>
43+
<TryItOut useEngineAPI={useEngineAPI} />
44+
<Scalar useEngineAPI={useEngineAPI} />
945
</div>
1046
);
1147
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Link from "next/link";
22
import { Badge } from "@/components/ui/badge";
33
import { Button } from "@/components/ui/button";
44
import { TabPathLinks } from "@/components/ui/tabs";
5-
import { NEXT_PUBLIC_ENGINE_CLOUD_URL } from "@/constants/public-envs";
5+
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "@/constants/public-envs";
66

77
export default async function Page(props: {
88
params: Promise<{ team_slug: string; project_slug: string }>;
@@ -45,11 +45,11 @@ function TransactionsLayout(props: {
4545
<div className="flex items-center gap-2">
4646
<Link
4747
className="max-w-full truncate text-muted-foreground text-sm hover:text-foreground" // TODO: change this
48-
href={`${NEXT_PUBLIC_ENGINE_CLOUD_URL}/reference`}
48+
href={`${NEXT_PUBLIC_THIRDWEB_API_HOST}/reference`}
4949
rel="noopener noreferrer"
5050
target="_blank"
5151
>
52-
{NEXT_PUBLIC_ENGINE_CLOUD_URL}
52+
{NEXT_PUBLIC_THIRDWEB_API_HOST}
5353
</Link>
5454
</div>
5555
</div>

0 commit comments

Comments
 (0)