-
Notifications
You must be signed in to change notification settings - Fork 1
[ENG-274] Add landing page, market pages, and header toolbar to frontend #99
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
Draft
xbtmatt
wants to merge
27
commits into
main
Choose a base branch
from
ENG-274
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
95f3440
Add landing page, market pages, and header toolbar to frontend
xbtmatt d8e3940
Format
xbtmatt 9686402
wip
xbtmatt b7b7971
wip2
xbtmatt ce00e20
Add price libs and unit tests
xbtmatt 541b10c
Remove `workspaces` entry from package.json
xbtmatt 405c337
Add real market data for everything but daily volume on the market la…
xbtmatt a062924
Add proper env setup with RPC URLs with private/public split
xbtmatt 22fef6a
Handle slug properly
xbtmatt 8862687
Add icon.svg to pubilc/ and add it to layout.tsx
xbtmatt d9a16de
Conditionally render react query dev tools
xbtmatt 2a8b4c1
sort + neightbor comparison for slug prefixes
xbtmatt b8c83a2
Memoize prefix map
xbtmatt f2c1171
Format and add `useSortedClasses` import rule
xbtmatt e12a4a0
Add a `lint:ts:fix:unsafe` option
xbtmatt d069759
Only return random volume values in development
xbtmatt 1cd009d
Don't early truncate bigints in format number
xbtmatt 7771b89
Fix typo
xbtmatt d95a573
do BigInt(Number.MAX_SAFE_INTEGER) instead of Number.isSafeInteger(n)…
xbtmatt acea3e6
Dynamic import the react query dev tools
xbtmatt 6c70c44
Use stable rpcClient value
xbtmatt ef598d9
Fix buildPrefixMap types
xbtmatt 8862814
Remove useless ternary in use-all-markets
xbtmatt de5fe29
Remove TODO comment since it's done now
xbtmatt 2bfe6db
Add e2e tests for single dropset market account + view path
xbtmatt ebd6410
Add couldn't load market error display
xbtmatt cc6bf8f
Fix address type
xbtmatt 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
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Required: which Solana cluster to connect to. | ||
| # Valid values: localnet, devnet, testnet, mainnet | ||
| NEXT_PUBLIC_CLUSTER=localnet | ||
|
|
||
| # Optional: private/paid RPC URLs (server-side only, never exposed to the browser). | ||
| # Falls back to the public RPC URL for the selected cluster if not set. | ||
| # SERVER_LOCALNET_RPC_URL=http://localhost:8899 | ||
| # SERVER_DEVNET_RPC_URL=https://your-paid-rpc.example.com | ||
| # SERVER_TESTNET_RPC_URL=https://your-paid-rpc.example.com | ||
| # SERVER_MAINNET_RPC_URL=https://your-paid-rpc.example.com |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export default function InfoPage() { | ||
| return ( | ||
| <div className="mx-auto max-w-6xl px-6 py-8"> | ||
| <div className="mb-8"> | ||
| <h1 className="font-semibold text-2xl tracking-tight">Info</h1> | ||
| <p className="mt-1 text-muted-fg">Coming soon.</p> | ||
| </div> | ||
| </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
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,51 @@ | ||
| "use client"; | ||
|
|
||
| import type { Address } from "@solana/addresses"; | ||
| import { useMarket } from "@/lib/hooks/use-market"; | ||
|
|
||
| export function MarketView({ address }: { address: Address }) { | ||
| const { data: market, isLoading } = useMarket(address); | ||
|
|
||
| return ( | ||
| <div className="mx-auto max-w-6xl px-6 py-8"> | ||
| <div className="mb-8"> | ||
| <h1 className="font-semibold text-2xl tracking-tight">Market</h1> | ||
| <p className="mt-1 break-all font-mono text-muted-fg text-sm"> | ||
| {address} | ||
| </p> | ||
| </div> | ||
|
|
||
| {isLoading && <p className="text-zinc-500">Loading…</p>} | ||
| {!isLoading && !market && <p className="text-red-500">Couldn't load market</p>} | ||
|
|
||
| {market && ( | ||
| <div className="grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-4"> | ||
| <div className="flex flex-col gap-1 rounded-lg border border-border p-4"> | ||
| <span className="text-muted-fg text-xs uppercase tracking-[0.05em]"> | ||
| Traders | ||
| </span> | ||
| <span className="font-semibold text-xl tabular-nums"> | ||
| {market.traders} | ||
| </span> | ||
| </div> | ||
| <div className="flex flex-col gap-1 rounded-lg border border-border p-4"> | ||
| <span className="text-muted-fg text-xs uppercase tracking-[0.05em]"> | ||
| Liquidity | ||
| </span> | ||
| <span className="font-semibold text-xl tabular-nums"> | ||
| ${market.liquidity.toLocaleString()} | ||
| </span> | ||
| </div> | ||
| <div className="flex flex-col gap-1 rounded-lg border border-border p-4"> | ||
| <span className="text-muted-fg text-xs uppercase tracking-[0.05em]"> | ||
| 24h Volume | ||
| </span> | ||
| <span className="font-semibold text-xl tabular-nums"> | ||
| ${market.volume24h.toLocaleString()} | ||
| </span> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </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,37 @@ | ||
| import type { Metadata } from "next"; | ||
| import { notFound } from "next/navigation"; | ||
| import { fetchAllMarkets } from "@/lib/queries/fetch-all-markets"; | ||
| import { resolveSlug } from "@/lib/slug"; | ||
| import { MarketView } from "./market-view"; | ||
|
|
||
| type Props = { | ||
| params: Promise<{ slug: string }>; | ||
| }; | ||
|
|
||
| export async function generateMetadata({ params }: Props): Promise<Metadata> { | ||
| const { slug } = await params; | ||
| const markets = await fetchAllMarkets(); | ||
xbtmatt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const address = | ||
| resolveSlug( | ||
| slug, | ||
| markets.map((m) => m.address), | ||
| ) ?? slug; | ||
xbtmatt marked this conversation as resolved.
Show resolved
Hide resolved
xbtmatt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return { | ||
| title: `dropset – market ${address}`, | ||
| description: `A dropset alpha market at address ${address}`, | ||
| }; | ||
| } | ||
|
|
||
| export default async function MarketPage({ params }: Props) { | ||
| const { slug } = await params; | ||
| const markets = await fetchAllMarkets(); | ||
| const address = resolveSlug( | ||
| slug, | ||
| markets.map((m) => m.address), | ||
| ); | ||
|
|
||
| if (!address) notFound(); | ||
|
|
||
| return <MarketView address={address} />; | ||
| } | ||
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 |
|---|---|---|
| @@ -1,8 +1,96 @@ | ||
| "use client"; | ||
|
|
||
| import Link from "next/link"; | ||
| import { useMemo } from "react"; | ||
| import { useAllMarkets } from "@/lib/hooks/use-all-markets"; | ||
| import { buildPrefixMap } from "@/lib/slug"; | ||
| import { ensureU64 } from "@/ts-sdk/rust-types"; | ||
|
|
||
| function formatNumber(input: number | bigint): string { | ||
| const n = ensureU64(input); | ||
| if (n <= BigInt(Number.MAX_SAFE_INTEGER)) { | ||
| const val = Number(n); | ||
| if (val >= 1_000_000) return `${(val / 1_000_000).toFixed(1)}M`; | ||
| if (val >= 1_000) return `${(val / 1_000).toFixed(1)}K`; | ||
| } else { | ||
| if (n >= 1_000_000n) return `${(Number(n / 1_000_000n)).toFixed(1)}M`; | ||
| if (n >= 1_000n) return `${(Number(n / 1_000n)).toFixed(1)}K`; | ||
| } | ||
xbtmatt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return n.toString(); | ||
| } | ||
|
|
||
| export default function Home() { | ||
| const { data: markets, isLoading, error } = useAllMarkets(); | ||
|
|
||
| const addresses = useMemo( | ||
| () => markets?.map((m) => m.address) ?? [], | ||
| [markets], | ||
| ); | ||
|
|
||
| const prefixMap = useMemo(() => buildPrefixMap(addresses), [addresses]); | ||
|
|
||
| return ( | ||
| <div className="flex flex-1 flex-col items-center justify-center gap-4 font-sans"> | ||
| <h1 className="text-3xl font-semibold tracking-tight">Dropset</h1> | ||
| <p className="text-zinc-500 dark:text-zinc-400">Alpha prototype</p> | ||
| <div className="mx-auto max-w-6xl px-6 py-8"> | ||
| <div className="mb-8"> | ||
| <h1 className="font-semibold text-2xl tracking-tight">Markets</h1> | ||
| <p className="mt-1 text-muted-fg">Browse active Dropset markets</p> | ||
| </div> | ||
|
|
||
| {isLoading && <p className="text-zinc-500">Loading markets…</p>} | ||
| {error && <p className="text-red-500">Failed to load markets.</p>} | ||
|
|
||
| {markets && ( | ||
| <div className="overflow-x-auto rounded-lg border border-border"> | ||
| <table className="w-full border-collapse text-sm"> | ||
| <thead className="bg-muted"> | ||
| <tr> | ||
| <th className="px-4 py-2.5 text-left font-medium text-muted-fg text-xs uppercase tracking-[0.05em]"> | ||
| Address | ||
| </th> | ||
| <th className="px-4 py-2.5 text-right font-medium font-mono text-muted-fg text-xs uppercase tabular-nums tracking-[0.05em]"> | ||
| Traders | ||
| </th> | ||
| <th className="px-4 py-2.5 text-right font-medium font-mono text-muted-fg text-xs uppercase tabular-nums tracking-[0.05em]"> | ||
| Liquidity | ||
| </th> | ||
| <th className="px-4 py-2.5 text-right font-medium font-mono text-muted-fg text-xs uppercase tabular-nums tracking-[0.05em]"> | ||
| 24h Volume | ||
| </th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {markets.map((market) => { | ||
| const shortSlug = | ||
| prefixMap.get(market.address) ?? market.address; | ||
| return ( | ||
| <tr key={market.address} className="hover:bg-muted"> | ||
| <td className="border-border border-t px-4 py-3"> | ||
| <Link | ||
xbtmatt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| href={`/market/${shortSlug}`} | ||
| className="text-accent no-underline transition-colors hover:text-accent-hover hover:underline" | ||
| title={market.address} | ||
| > | ||
| <code className="font-mono text-[0.8125rem]"> | ||
| {market.address} | ||
| </code> | ||
| </Link> | ||
| </td> | ||
| <td className="border-border border-t px-4 py-3 text-right font-mono tabular-nums"> | ||
| {market.traders} | ||
| </td> | ||
| <td className="border-border border-t px-4 py-3 text-right font-mono tabular-nums"> | ||
| ${formatNumber(market.liquidity)} | ||
| </td> | ||
| <td className="border-border border-t px-4 py-3 text-right font-mono tabular-nums"> | ||
| ${formatNumber(market.volume24h)} | ||
| </td> | ||
| </tr> | ||
| ); | ||
| })} | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
| )} | ||
| </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,10 @@ | ||
| export default function RepoPage() { | ||
| return ( | ||
| <div className="mx-auto max-w-6xl px-6 py-8"> | ||
| <div className="mb-8"> | ||
| <h1 className="font-semibold text-2xl tracking-tight">Repo</h1> | ||
| <p className="mt-1 text-muted-fg">Coming soon.</p> | ||
| </div> | ||
| </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,10 @@ | ||
| export default function TeamPage() { | ||
| return ( | ||
| <div className="mx-auto max-w-6xl px-6 py-8"> | ||
| <div className="mb-8"> | ||
| <h1 className="font-semibold text-2xl tracking-tight">Team</h1> | ||
| <p className="mt-1 text-muted-fg">Coming soon.</p> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.