-
Notifications
You must be signed in to change notification settings - Fork 621
[Playground] Refactor Universal Bridge sidebar links and update order #6543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joaquim-verges
merged 3 commits into
main
from
_Playground_Refactor_Universal_Bridge_sidebar_links_and_update_order
Mar 25, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
d24ff14
Revert "[Service-Utils] feat: Add engine-cloud service definition (#6…
joaquim-verges dc6f18e
[Playground] Refactor Universal Bridge sidebar links and update order
joaquim-verges 46476a0
Reapply "[Service-Utils] feat: Add engine-cloud service definition (#…
joaquim-verges File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
apps/playground-web/src/app/connect/pay/backend/layout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import type React from "react"; | ||
| import { APIHeader } from "../../../../components/blocks/APIHeader"; | ||
|
|
||
| export default function Layout(props: { | ||
| children: React.ReactNode; | ||
| }) { | ||
| return ( | ||
| <div> | ||
| <APIHeader | ||
| title="Universal Bridge API" | ||
| description={ | ||
| <>HTTP API to bridge, swap and onramp to and from any currency</> | ||
| } | ||
| docsLink="https://portal.thirdweb.com/connect/pay/overview" | ||
| heroLink="/ub.png" | ||
| /> | ||
|
|
||
| {props.children} | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table"; | ||
| import Link from "next/link"; | ||
| import { getBridgePaths } from "./utils"; | ||
|
|
||
| export default async function Page() { | ||
| try { | ||
| const paths = await getBridgePaths(); | ||
| return ( | ||
| <div className="pb-20"> | ||
| <h2 className="mb-2 font-semibold text-2xl tracking-tight"> | ||
| Universal Bridge REST API | ||
| </h2> | ||
| <p className="mb-5 text-muted-foreground"> | ||
| Directly interact with the Universal Bridge API from your backend, | ||
| using standard REST api. | ||
| </p> | ||
|
|
||
| <div className="flex flex-col gap-8"> | ||
| <BlueprintSection | ||
| title="Available endpoints" | ||
| blueprints={paths.map(([pathName, pathObj]) => { | ||
| if (!pathObj) { | ||
| throw new Error(`Path not found: ${pathName}`); | ||
| } | ||
| return { | ||
| name: pathName, | ||
| description: pathObj.get?.description || "", | ||
| link: `/connect/pay/backend/reference?route=${pathName}`, | ||
| }; | ||
| })} | ||
| /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } catch (error) { | ||
| console.error(error); | ||
| return <div>Error fetching API spec</div>; | ||
| } | ||
| } | ||
|
|
||
| function BlueprintSection(props: { | ||
| title: string; | ||
| blueprints: { name: string; description: string; link: string }[]; | ||
| }) { | ||
| return ( | ||
| <div className="overflow-hidden rounded-lg border bg-card"> | ||
| <div className="flex items-center gap-2 border-b bg-accent/20 px-6 py-4"> | ||
| <h2 className="font-semibold text-lg tracking-tight">{props.title}</h2> | ||
| </div> | ||
| <Table> | ||
| <TableBody> | ||
| {props.blueprints.map((item) => ( | ||
| <TableRow | ||
| key={item.link} | ||
| className="group hover:bg-accent/50" | ||
| linkBox | ||
| > | ||
| <TableCell> | ||
| <span className="flex items-center gap-3"> | ||
| <Link | ||
| href={item.link} | ||
| className="before:absolute before:inset-0" | ||
| > | ||
| <div className="flex flex-col"> | ||
| <p className="font-semibold text-md">{item.name}</p> | ||
| <p className="text-muted-foreground text-sm"> | ||
| {item.description} | ||
| </p> | ||
| </div> | ||
| </Link> | ||
| </span> | ||
| </TableCell> | ||
| </TableRow> | ||
| ))} | ||
| </TableBody> | ||
| </Table> | ||
| </div> | ||
| ); | ||
| } |
70 changes: 70 additions & 0 deletions
70
apps/playground-web/src/app/connect/pay/backend/reference/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { | ||
| Breadcrumb, | ||
| BreadcrumbItem, | ||
| BreadcrumbLink, | ||
| BreadcrumbList, | ||
| BreadcrumbSeparator, | ||
| } from "@/components/ui/breadcrumb"; | ||
| import { redirect } from "next/navigation"; | ||
| import { THIRDWEB_CLIENT } from "../../../../../lib/client"; | ||
| import { isProd } from "../../../../../lib/env"; | ||
| import { BlueprintPlayground } from "../../../../insight/[blueprint_slug]/blueprint-playground.client"; | ||
| import { getBridgePaths } from "../utils"; | ||
|
|
||
| export default async function Page(props: { | ||
| searchParams: Promise<{ | ||
| route: string; | ||
| }>; | ||
| }) { | ||
| const params = await props.searchParams; | ||
|
|
||
| // invalid url | ||
| if (!params.route) { | ||
| redirect("/connect/pay/backend"); | ||
| } | ||
|
|
||
| const thirdwebDomain = !isProd ? "thirdweb-dev" : "thirdweb"; | ||
| const domain = `https://bridge.${thirdwebDomain}.com`; | ||
|
|
||
| const paths = await getBridgePaths(); | ||
| const pathMetadata = paths.find(([path]) => path === params.route)?.[1]?.get; | ||
|
|
||
| // invalid url | ||
| if (!pathMetadata) { | ||
| redirect("/connect/pay/backend"); | ||
| } | ||
|
|
||
| const title = pathMetadata.summary || ""; | ||
| return ( | ||
| <div> | ||
| <Breadcrumbs /> | ||
| <h1 className="mt-3 mb-6 font-semibold text-2xl tracking-tight lg:text-3xl"> | ||
| {title} | ||
| </h1> | ||
| <BlueprintPlayground | ||
| key={params.route} | ||
| metadata={pathMetadata} | ||
| backLink={"/connect/pay/backend"} | ||
| clientId={THIRDWEB_CLIENT.clientId} | ||
| path={params.route} | ||
| supportedChainIds={[]} | ||
| domain={domain} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function Breadcrumbs() { | ||
| return ( | ||
| <Breadcrumb> | ||
| <BreadcrumbList> | ||
| <BreadcrumbItem> | ||
| <BreadcrumbLink href="/connect/pay/backend"> | ||
| Universal Bridge API | ||
| </BreadcrumbLink> | ||
| </BreadcrumbItem> | ||
| <BreadcrumbSeparator /> | ||
| </BreadcrumbList> | ||
| </Breadcrumb> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { OpenAPIV3 } from "openapi-types"; | ||
| import { isProd } from "../../../../lib/env"; | ||
|
|
||
| export async function getBridgePaths() { | ||
| const thirdwebDomain = !isProd ? "thirdweb-dev" : "thirdweb"; | ||
| const res = await fetch(`https://bridge.${thirdwebDomain}.com/openapi.json`); | ||
| const openapiJson = (await res.json()) as OpenAPIV3.Document; | ||
| return Object.entries(openapiJson.paths).filter( | ||
| ([, pathObj]) => | ||
| pathObj?.get?.deprecated === undefined || | ||
| pathObj?.get?.deprecated === false, | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,6 +256,7 @@ export type PayEmbedProps = { | |
| * buyWithFiat: false, | ||
| * }} | ||
| * /> | ||
| * ``` | ||
| * | ||
| * ### Customize the UI | ||
| * | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
searchParamsprop is typed as aPromise<{ route: string }>, but Next.js provides this parameter directly as an object. This causes an unnecessaryawaiton line 19.Consider updating the type signature to:
And then remove the
awaitwhen accessingparams.route. This will align with Next.js's API and simplify the code.Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.