diff --git a/packages/explorer/src/app/Providers.tsx b/packages/explorer/src/app/(explorer)/Providers.tsx similarity index 94% rename from packages/explorer/src/app/Providers.tsx rename to packages/explorer/src/app/(explorer)/Providers.tsx index d930de1dba..cf3ea465e4 100644 --- a/packages/explorer/src/app/Providers.tsx +++ b/packages/explorer/src/app/(explorer)/Providers.tsx @@ -6,7 +6,7 @@ import { ReactNode } from "react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { createConfig, http } from "@wagmi/core"; import { localhost } from "@wagmi/core/chains"; -import { AppStoreProvider } from "../store"; +import { AppStoreProvider } from "../../store"; const queryClient = new QueryClient(); diff --git a/packages/explorer/src/app/error.tsx b/packages/explorer/src/app/(explorer)/error.tsx similarity index 91% rename from packages/explorer/src/app/error.tsx rename to packages/explorer/src/app/(explorer)/error.tsx index 08d42ee6ce..08c77d587a 100644 --- a/packages/explorer/src/app/error.tsx +++ b/packages/explorer/src/app/(explorer)/error.tsx @@ -2,8 +2,8 @@ import { ExternalLink, RefreshCwIcon } from "lucide-react"; import Link from "next/link"; -import { Button } from "../components/ui/Button"; -import { useWorldUrl } from "../hooks/useWorldUrl"; +import { Button } from "../../components/ui/Button"; +import { useWorldUrl } from "../../hooks/useWorldUrl"; type Props = { error: Error & { digest?: string }; diff --git a/packages/explorer/src/app/globals.css b/packages/explorer/src/app/(explorer)/globals.css similarity index 100% rename from packages/explorer/src/app/globals.css rename to packages/explorer/src/app/(explorer)/globals.css diff --git a/packages/explorer/src/app/layout.tsx b/packages/explorer/src/app/(explorer)/layout.tsx similarity index 100% rename from packages/explorer/src/app/layout.tsx rename to packages/explorer/src/app/(explorer)/layout.tsx diff --git a/packages/explorer/src/app/not-found.tsx b/packages/explorer/src/app/(explorer)/not-found.tsx similarity index 90% rename from packages/explorer/src/app/not-found.tsx rename to packages/explorer/src/app/(explorer)/not-found.tsx index 85030ebf80..dc83993eea 100644 --- a/packages/explorer/src/app/not-found.tsx +++ b/packages/explorer/src/app/(explorer)/not-found.tsx @@ -2,8 +2,8 @@ import { ExternalLink } from "lucide-react"; import Link from "next/link"; -import { Button } from "../components/ui/Button"; -import { useWorldUrl } from "../hooks/useWorldUrl"; +import { Button } from "../../components/ui/Button"; +import { useWorldUrl } from "../../hooks/useWorldUrl"; export default function NotFound() { const getUrl = useWorldUrl(); diff --git a/packages/explorer/src/app/(explorer)/page.tsx b/packages/explorer/src/app/(explorer)/page.tsx new file mode 100644 index 0000000000..cd0a8af1d8 --- /dev/null +++ b/packages/explorer/src/app/(explorer)/page.tsx @@ -0,0 +1,5 @@ +import { redirect } from "next/navigation"; + +export default async function IndexPage() { + redirect("/worlds"); +} diff --git a/packages/explorer/src/app/worlds/[worldAddress]/explorer/DataExplorer.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/DataExplorer.tsx similarity index 100% rename from packages/explorer/src/app/worlds/[worldAddress]/explorer/DataExplorer.tsx rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/DataExplorer.tsx diff --git a/packages/explorer/src/app/worlds/[worldAddress]/explorer/EditableTableCell.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/EditableTableCell.tsx similarity index 93% rename from packages/explorer/src/app/worlds/[worldAddress]/explorer/EditableTableCell.tsx rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/EditableTableCell.tsx index 15822d6c74..4b3a058a62 100644 --- a/packages/explorer/src/app/worlds/[worldAddress]/explorer/EditableTableCell.tsx +++ b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/EditableTableCell.tsx @@ -10,12 +10,12 @@ import { SchemaAbiType } from "@latticexyz/schema-type/internal"; import IBaseWorldAbi from "@latticexyz/world/out/IBaseWorld.sol/IBaseWorld.abi.json"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { waitForTransactionReceipt, writeContract } from "@wagmi/core"; -import { Checkbox } from "../../../../components/ui/Checkbox"; -import { ACCOUNT_PRIVATE_KEYS } from "../../../../consts"; -import { camelCase, cn } from "../../../../lib/utils"; -import { useAppStore } from "../../../../store"; +import { Checkbox } from "../../../../../components/ui/Checkbox"; +import { ACCOUNT_PRIVATE_KEYS } from "../../../../../consts"; +import { camelCase, cn } from "../../../../../lib/utils"; +import { useAppStore } from "../../../../../store"; +import { TableConfig } from "../../../../api/table/route"; import { wagmiConfig } from "../../../Providers"; -import { TableConfig } from "../../../api/table/route"; type Props = { name: string; diff --git a/packages/explorer/src/app/worlds/[worldAddress]/explorer/TableSelector.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/TableSelector.tsx similarity index 96% rename from packages/explorer/src/app/worlds/[worldAddress]/explorer/TableSelector.tsx rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/TableSelector.tsx index 7fe71a6c55..7bd6a8a05c 100644 --- a/packages/explorer/src/app/worlds/[worldAddress]/explorer/TableSelector.tsx +++ b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/TableSelector.tsx @@ -1,7 +1,7 @@ import { Lock } from "lucide-react"; import { useParams } from "next/navigation"; import { internalTableNames } from "@latticexyz/store-sync/sqlite"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../../../components/ui/Select"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../../../../components/ui/Select"; type Props = { value: string | undefined; diff --git a/packages/explorer/src/app/worlds/[worldAddress]/explorer/TablesViewer.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/TablesViewer.tsx similarity index 97% rename from packages/explorer/src/app/worlds/[worldAddress]/explorer/TablesViewer.tsx rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/TablesViewer.tsx index 5de665d0e3..d12254ae82 100644 --- a/packages/explorer/src/app/worlds/[worldAddress]/explorer/TablesViewer.tsx +++ b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/TablesViewer.tsx @@ -14,10 +14,10 @@ import { getSortedRowModel, useReactTable, } from "@tanstack/react-table"; -import { Button } from "../../../../components/ui/Button"; -import { Checkbox } from "../../../../components/ui/Checkbox"; -import { Input } from "../../../../components/ui/Input"; -import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../../../../components/ui/Table"; +import { Button } from "../../../../../components/ui/Button"; +import { Checkbox } from "../../../../../components/ui/Checkbox"; +import { Input } from "../../../../../components/ui/Input"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../../../../../components/ui/Table"; import { bufferToBigInt } from "../utils/bufferToBigInt"; import { EditableTableCell } from "./EditableTableCell"; diff --git a/packages/explorer/src/app/worlds/[worldAddress]/explorer/page.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/page.tsx similarity index 100% rename from packages/explorer/src/app/worlds/[worldAddress]/explorer/page.tsx rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/explorer/page.tsx diff --git a/packages/explorer/src/app/worlds/[worldAddress]/interact/Form.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/Form.tsx similarity index 89% rename from packages/explorer/src/app/worlds/[worldAddress]/interact/Form.tsx rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/Form.tsx index e38d40734c..3c78302d5d 100644 --- a/packages/explorer/src/app/worlds/[worldAddress]/interact/Form.tsx +++ b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/Form.tsx @@ -3,12 +3,12 @@ import { Coins, Eye, Send } from "lucide-react"; import { AbiFunction } from "viem"; import { useDeferredValue, useState } from "react"; -import { Input } from "../../../../components/ui/Input"; -import { Separator } from "../../../../components/ui/Separator"; -import { Skeleton } from "../../../../components/ui/Skeleton"; -import { useHashState } from "../../../../hooks/useHashState"; -import { cn } from "../../../../lib/utils"; -import { useAbiQuery } from "../../../../queries/useAbiQuery"; +import { Input } from "../../../../../components/ui/Input"; +import { Separator } from "../../../../../components/ui/Separator"; +import { Skeleton } from "../../../../../components/ui/Skeleton"; +import { useHashState } from "../../../../../hooks/useHashState"; +import { cn } from "../../../../../lib/utils"; +import { useAbiQuery } from "../../../../../queries/useAbiQuery"; import { FunctionField } from "./FunctionField"; export function Form() { diff --git a/packages/explorer/src/app/worlds/[worldAddress]/interact/FunctionField.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/FunctionField.tsx similarity index 93% rename from packages/explorer/src/app/worlds/[worldAddress]/interact/FunctionField.tsx rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/FunctionField.tsx index 3134127c10..ecb6affad2 100644 --- a/packages/explorer/src/app/worlds/[worldAddress]/interact/FunctionField.tsx +++ b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/FunctionField.tsx @@ -6,10 +6,10 @@ import { z } from "zod"; import { useState } from "react"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; -import { Button } from "../../../../components/ui/Button"; -import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "../../../../components/ui/Form"; -import { Input } from "../../../../components/ui/Input"; -import { Separator } from "../../../../components/ui/Separator"; +import { Button } from "../../../../../components/ui/Button"; +import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "../../../../../components/ui/Form"; +import { Input } from "../../../../../components/ui/Input"; +import { Separator } from "../../../../../components/ui/Separator"; import { useContractMutation } from "./useContractMutation"; export enum FunctionType { diff --git a/packages/explorer/src/app/worlds/[worldAddress]/interact/page.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/page.tsx similarity index 100% rename from packages/explorer/src/app/worlds/[worldAddress]/interact/page.tsx rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/page.tsx diff --git a/packages/explorer/src/app/worlds/[worldAddress]/interact/useContractMutation.ts b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/useContractMutation.ts similarity index 95% rename from packages/explorer/src/app/worlds/[worldAddress]/interact/useContractMutation.ts rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/useContractMutation.ts index 720fe207c4..74e24845e0 100644 --- a/packages/explorer/src/app/worlds/[worldAddress]/interact/useContractMutation.ts +++ b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/interact/useContractMutation.ts @@ -5,8 +5,8 @@ import { privateKeyToAccount } from "viem/accounts"; import { useChainId } from "wagmi"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { readContract, waitForTransactionReceipt, writeContract } from "@wagmi/core"; -import { ACCOUNT_PRIVATE_KEYS } from "../../../../consts"; -import { useAppStore } from "../../../../store"; +import { ACCOUNT_PRIVATE_KEYS } from "../../../../../consts"; +import { useAppStore } from "../../../../../store"; import { wagmiConfig } from "../../../Providers"; import { FunctionType } from "./FunctionField"; diff --git a/packages/explorer/src/app/worlds/[worldAddress]/layout.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/layout.tsx similarity index 73% rename from packages/explorer/src/app/worlds/[worldAddress]/layout.tsx rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/layout.tsx index 30e9291148..c13476dcf2 100644 --- a/packages/explorer/src/app/worlds/[worldAddress]/layout.tsx +++ b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/layout.tsx @@ -1,6 +1,6 @@ "use client"; -import { Navigation } from "../../../components/Navigation"; +import { Navigation } from "../../../../components/Navigation"; export default function WorldLayout({ children }: { children: React.ReactNode }) { return ( diff --git a/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/page.tsx b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/page.tsx new file mode 100644 index 0000000000..bd72da2c84 --- /dev/null +++ b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/page.tsx @@ -0,0 +1,5 @@ +import { redirect } from "next/navigation"; + +export default async function WorldPage({ params }: { params: { worldAddress: string } }) { + return redirect(`/worlds/${params.worldAddress}/explorer`); +} diff --git a/packages/explorer/src/app/worlds/[worldAddress]/utils/bufferToBigInt.ts b/packages/explorer/src/app/(explorer)/worlds/[worldAddress]/utils/bufferToBigInt.ts similarity index 100% rename from packages/explorer/src/app/worlds/[worldAddress]/utils/bufferToBigInt.ts rename to packages/explorer/src/app/(explorer)/worlds/[worldAddress]/utils/bufferToBigInt.ts diff --git a/packages/explorer/src/app/(explorer)/worlds/page.tsx b/packages/explorer/src/app/(explorer)/worlds/page.tsx new file mode 100644 index 0000000000..86e55b18f3 --- /dev/null +++ b/packages/explorer/src/app/(explorer)/worlds/page.tsx @@ -0,0 +1,7 @@ +import { notFound, redirect } from "next/navigation"; + +export default async function WorldsPage() { + const worldAddress = process.env.WORLD_ADDRESS; + if (worldAddress) return redirect(`/worlds/${worldAddress}`); + return notFound(); +} diff --git a/packages/explorer/src/middleware.ts b/packages/explorer/src/middleware.ts deleted file mode 100644 index 006a30c617..0000000000 --- a/packages/explorer/src/middleware.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; - -export function middleware(request: NextRequest) { - const pathname = request.nextUrl.pathname; - const worldAddress = process.env.WORLD_ADDRESS; - - if ((pathname === "/" || pathname === "/worlds") && worldAddress) { - return NextResponse.redirect(new URL(`/worlds/${worldAddress}/explorer`, request.url)); - } - - return NextResponse.next(); -} - -export const config = { - matcher: "/((?!api|_next/static|_next/image|favicon.ico).*)", -};