Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions apps/dashboard/src/@/components/ui/code.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use client";

import { useClipboard } from "hooks/useClipboard";
import { CheckIcon, CopyIcon } from "lucide-react";
import { cn } from "../../lib/utils";
import { Button } from "./button";

export function PlainTextCodeBlock(props: {
code: string;
copyButtonClassName?: string;
}) {
const { hasCopied, onCopy } = useClipboard(props.code);

return (
<div className="relative">
<code className="block whitespace-pre rounded-lg border border-border bg-muted/50 p-4">
{props.code}
</code>
<Button
size="sm"
variant="outline"
onClick={onCopy}
className={cn(
"absolute top-3.5 right-3.5 h-auto p-2",
props.copyButtonClassName,
)}
>
{hasCopied ? (
<CheckIcon className="size-3 text-green-500" />
) : (
<CopyIcon className="size-3 text-muted-foreground" />
)}
</Button>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";

import { PublishedBy } from "components/contract-components/shared/published-by";
import type { ThirdwebContract } from "thirdweb";
import { AnalyticsOverview } from "./components/Analytics";
Expand All @@ -21,6 +19,7 @@ interface ContractOverviewPageProps {
isPermissionsEnumerable: boolean;
chainSlug: string;
isAnalyticsSupported: boolean;
functionSelectors: string[];
}

const TRACKING_CATEGORY = "contract_overview";
Expand All @@ -35,6 +34,7 @@ export const ContractOverviewPage: React.FC<ContractOverviewPageProps> = ({
isPermissionsEnumerable,
chainSlug,
isAnalyticsSupported,
functionSelectors,
}) => {
return (
<div className="flex flex-col gap-8 lg:flex-row">
Expand All @@ -45,6 +45,7 @@ export const ContractOverviewPage: React.FC<ContractOverviewPageProps> = ({
isErc20={isErc20}
contract={contract}
chainSlug={chainSlug}
functionSelectors={functionSelectors}
/>

{isAnalyticsSupported && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { ThirdwebAreaChart } from "@/components/blocks/charts/area-chart";
import { Button } from "@/components/ui/button";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import {
Flex,
GridItem,
Expand All @@ -7,7 +9,9 @@ import {
} from "@chakra-ui/react";
import { ChakraNextImage as Image } from "components/Image";
import { PRODUCTS } from "components/product-pages/common/nav/data";
import { Card, Text, TrackedLink, type TrackedLinkProps } from "tw-components";
import { Card } from "tw-components/card";
import { TrackedLink, type TrackedLinkProps } from "tw-components/link";
import { Text } from "tw-components/text";

const RENDERED_PRODUCTS = ["sdk", "storage", "ui-components", "auth"];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use client";

import { AdminOnly } from "@3rdweb-sdk/react/components/roles/admin-only";
import { useIsMinter } from "@3rdweb-sdk/react/hooks/useContractRoles";
import { StepsCard } from "components/dashboard/StepsCard";
import { useContractFunctionSelectors } from "contract-ui/hooks/useContractFunctionSelectors";
import Link from "next/link";
import { useMemo } from "react";
import type { ThirdwebContract } from "thirdweb";
Expand All @@ -18,6 +19,7 @@ interface ContractChecklistProps {
isErc1155: boolean;
isErc20: boolean;
chainSlug: string;
functionSelectors: string[];
}

type Step = {
Expand All @@ -27,13 +29,10 @@ type Step = {
};

export const ContractChecklist: React.FC<ContractChecklistProps> = (props) => {
const functionSelectorQuery = useContractFunctionSelectors(props.contract);
return (
// if no permissions, simply return null (do not fail open)
<AdminOnly contract={props.contract} failOpen={false}>
{!!functionSelectorQuery.data?.length && (
<Inner functionSelectors={functionSelectorQuery.data} {...props} />
)}
<Inner {...props} />
</AdminOnly>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import {
type InternalTransaction,
useActivity,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { WalletAddress } from "@/components/blocks/wallet-address";
import { Badge } from "@/components/ui/badge";
import { SkeletonContainer } from "@/components/ui/skeleton";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"use client";

import { Flex, useBreakpointValue } from "@chakra-ui/react";
import type { ThirdwebContract } from "thirdweb";
import * as ERC721 from "thirdweb/extensions/erc721";
import * as ERC1155 from "thirdweb/extensions/erc1155";
import { useReadContract } from "thirdweb/react";
import { TrackedLink, type TrackedLinkProps } from "tw-components";
import { TrackedLink, type TrackedLinkProps } from "tw-components/link";
import { NFTCards } from "../../_components/NFTCards";

interface NFTDetailsProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { ToolTipLabel } from "@/components/ui/tooltip";
import { Box, Flex, List, SimpleGrid, Tag } from "@chakra-ui/react";
import { getAllRoleMembers } from "contract-ui/hooks/permissions";
Expand All @@ -8,14 +10,11 @@ import { useMemo } from "react";
import { toast } from "sonner";
import { type ThirdwebContract, ZERO_ADDRESS } from "thirdweb";
import { useReadContract } from "thirdweb/react";
import {
Button,
Card,
Heading,
Text,
TrackedLink,
type TrackedLinkProps,
} from "tw-components";
import { Button } from "tw-components/button";
import { Card } from "tw-components/card";
import { Heading } from "tw-components/heading";
import { TrackedLink, type TrackedLinkProps } from "tw-components/link";
import { Text } from "tw-components/text";
import { shortenIfAddress } from "utils/usedapp-external";

interface PermissionsTableProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default async function Page(props: {
}
chainSlug={chainMetadata.slug}
isAnalyticsSupported={contractPageMetadata.isAnalyticsSupported}
functionSelectors={contractPageMetadata.functionSelectors}
/>
);
}
57 changes: 32 additions & 25 deletions apps/dashboard/src/app/(dashboard)/explore/[category]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
import {
Breadcrumb,
BreadcrumbItem,
Expand All @@ -7,12 +6,16 @@ import {
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
import { ContractCard } from "components/explore/contract-card";
import {
ContractCard,
ContractCardSkeleton,
} from "components/explore/contract-card";
import { DeployUpsellCard } from "components/explore/upsells/deploy-your-own";
import { ALL_CATEGORIES, getCategory } from "data/explore";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { Suspense } from "react";

type ExploreCategoryPageProps = {
params: {
Expand Down Expand Up @@ -101,35 +104,36 @@ export default async function ExploreCategoryPage(
}

return (
<ContractCard
<Suspense
fallback={<ContractCardSkeleton />}
key={publisher + contractId + overrides?.title}
publisher={publisher}
contractId={contractId}
titleOverride={overrides?.title}
descriptionOverride={overrides?.description}
tracking={{
source: category.id,
itemIndex: `${idx}`,
}}
isBeta={category.isBeta}
modules={
modules?.length
? modules.map((m) => ({
publisher: m.split("/")[0] || "",
moduleId: m.split("/")[1] || "",
}))
: undefined
}
/>
>
<ContractCard
publisher={publisher}
contractId={contractId}
titleOverride={overrides?.title}
descriptionOverride={overrides?.description}
tracking={{
source: category.id,
itemIndex: `${idx}`,
}}
isBeta={category.isBeta}
modules={
modules?.length
? modules.map((m) => ({
publisher: m.split("/")[0] || "",
moduleId: m.split("/")[1] || "",
}))
: undefined
}
/>
</Suspense>
);
})}
</div>

<div className="h-16" />
{/* TODO: remove this once we update the deploy upsell card */}
<ChakraProviderSetup>
<DeployUpsellCard />
</ChakraProviderSetup>
<DeployUpsellCard />
</div>
</div>
);
Expand All @@ -140,3 +144,6 @@ export async function generateStaticParams() {
params: { category },
}));
}

// TODO - figure out why this page is not building if we let it be static
export const dynamic = "force-dynamic";
9 changes: 4 additions & 5 deletions apps/dashboard/src/app/(dashboard)/explore/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
import {
Breadcrumb,
BreadcrumbItem,
Expand Down Expand Up @@ -53,11 +52,11 @@ export default async function ExplorePage() {
</div>

<div className="h-16" />
{/* TODO: remove this once we update the deploy upsell card */}
<ChakraProviderSetup>
<DeployUpsellCard />
</ChakraProviderSetup>
<DeployUpsellCard />
</div>
</div>
);
}

// TODO - figure out why this page is not building if we let it be static
export const dynamic = "force-dynamic";
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getThirdwebClient } from "@/constants/thirdweb.server";
import { fetchDeployMetadata as sdkFetchDeployMetadata } from "thirdweb/contract";
import { removeUndefinedFromObjectDeep } from "../../utils/object";
import { toContractIdIpfsHash } from "./hooks";
import type { ContractId } from "./types";

// metadata PRE publish, only has the compiler output info (from CLI)

Expand All @@ -15,3 +15,10 @@ export async function fetchDeployMetadata(contractId: string) {
}),
);
}

function toContractIdIpfsHash(contractId: ContractId) {
if (contractId?.startsWith("ipfs://")) {
return contractId;
}
return `ipfs://${contractId}`;
}
7 changes: 0 additions & 7 deletions apps/dashboard/src/components/contract-components/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,6 @@ export function useFunctionParamsFromABI(abi?: Abi, functionName?: string) {
}, [abi, functionName]);
}

export function toContractIdIpfsHash(contractId: ContractId) {
if (contractId?.startsWith("ipfs://")) {
return contractId;
}
return `ipfs://${contractId}`;
}

export type PublishedContractDetails = Awaited<
ReturnType<typeof fetchPublishedContracts>
>[number];
Expand Down
Loading
Loading