File tree Expand file tree Collapse file tree 5 files changed +326
-83
lines changed Expand file tree Collapse file tree 5 files changed +326
-83
lines changed Original file line number Diff line number Diff line change @@ -292,7 +292,7 @@ export function SendTestTransaction(props: {
292
292
293
293
return (
294
294
< div className = "mt-3 w-full rounded-md border bg-background p-6" >
295
- < TryItOut />
295
+ < TryItOut useEngineAPI = { false } />
296
296
< div className = "mt-6 flex flex-col gap-2 md:flex-row md:justify-end md:gap-2" >
297
297
< Dialog open = { isModalOpen } onOpenChange = { setIsModalOpen } >
298
298
< DialogTrigger asChild >
Original file line number Diff line number Diff line change 1
1
"use client" ;
2
2
import { ApiReferenceReact } from "@scalar/api-reference-react" ;
3
3
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" ;
5
22
6
- export function Scalar ( ) {
7
23
return (
8
24
< 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 >
10
28
< ApiReferenceReact
11
29
configuration = { {
12
30
hideModels : true ,
13
31
servers : [
14
32
{
15
- description : "Engine Cloud" ,
16
- url : NEXT_PUBLIC_ENGINE_CLOUD_URL ,
33
+ description : serverDescription ,
34
+ url : apiUrl ,
17
35
} ,
18
36
] ,
19
- url : ` ${ NEXT_PUBLIC_ENGINE_CLOUD_URL } /openapi` ,
37
+ url : openApiUrl ,
20
38
} }
21
39
/>
22
40
</ div >
Original file line number Diff line number Diff line change
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" ;
1
10
import { TryItOut } from "../server-wallets/components/try-it-out" ;
2
11
import { Scalar } from "./components/scalar" ;
3
12
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
+
5
17
return (
6
18
< 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 } />
9
45
</ div >
10
46
) ;
11
47
}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import Link from "next/link";
2
2
import { Badge } from "@/components/ui/badge" ;
3
3
import { Button } from "@/components/ui/button" ;
4
4
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" ;
6
6
7
7
export default async function Page ( props : {
8
8
params : Promise < { team_slug : string ; project_slug : string } > ;
@@ -45,11 +45,11 @@ function TransactionsLayout(props: {
45
45
< div className = "flex items-center gap-2" >
46
46
< Link
47
47
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` }
49
49
rel = "noopener noreferrer"
50
50
target = "_blank"
51
51
>
52
- { NEXT_PUBLIC_ENGINE_CLOUD_URL }
52
+ { NEXT_PUBLIC_THIRDWEB_API_HOST }
53
53
</ Link >
54
54
</ div >
55
55
</ div >
You can’t perform that action at this time.
0 commit comments