Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
913b243147 | ||
|
|
3edbe2898c | ||
|
|
926dad4556 | ||
|
|
0639d0d9ea | ||
|
|
4fed9f4593 | ||
|
|
f2e8b9ecab | ||
|
|
523412437b | ||
|
|
ac4ade6262 | ||
|
|
819ce86c61 | ||
|
|
86fd445276 | ||
|
|
55fba51dab | ||
|
|
7c95211b98 | ||
|
|
3bb1fe0e1f | ||
|
|
a1aba2989e | ||
|
|
deeca886a4 | ||
|
|
31c4bb22fc | ||
|
|
3b1e16c8b7 | ||
|
|
1f42ad2a2d |
@@ -16,6 +16,7 @@ yalc.lock
|
||||
./build/
|
||||
playwright-report/
|
||||
.env/
|
||||
.pnpm-store/
|
||||
|
||||
# codecov binary
|
||||
codecov
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { WalletNFT } from "lib/wallet/nfts/types";
|
||||
import { getVercelEnv } from "../../lib/vercel-utils";
|
||||
import { isAlchemySupported } from "../../lib/wallet/nfts/isAlchemySupported";
|
||||
import { isMoralisSupported } from "../../lib/wallet/nfts/isMoralisSupported";
|
||||
import { NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID } from "../constants/public-envs";
|
||||
import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "../constants/public-envs";
|
||||
import { MORALIS_API_KEY } from "../constants/server-envs";
|
||||
|
||||
type WalletNFTApiReturn =
|
||||
@@ -149,7 +149,7 @@ async function getWalletNFTsFromInsight(params: {
|
||||
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
"x-client-id": NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
||||
"x-client-id": NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import "server-only";
|
||||
import type {
|
||||
AnalyticsQueryParams,
|
||||
EcosystemWalletStats,
|
||||
EngineCloudStats,
|
||||
InAppWalletStats,
|
||||
RpcMethodStats,
|
||||
TransactionStats,
|
||||
@@ -431,3 +432,24 @@ export async function getUniversalBridgeWalletUsage(args: {
|
||||
const json = await res.json();
|
||||
return json.data as UniversalBridgeWalletStats[];
|
||||
}
|
||||
|
||||
export async function getEngineCloudMethodUsage(
|
||||
params: AnalyticsQueryParams,
|
||||
): Promise<EngineCloudStats[]> {
|
||||
const searchParams = buildSearchParams(params);
|
||||
const res = await fetchAnalytics(
|
||||
`v2/engine-cloud/requests?${searchParams.toString()}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
},
|
||||
);
|
||||
|
||||
if (res?.status !== 200) {
|
||||
console.error("Failed to fetch Engine Cloud method usage");
|
||||
return [];
|
||||
}
|
||||
|
||||
const json = await res.json();
|
||||
return json.data as EngineCloudStats[];
|
||||
}
|
||||
|
||||
@@ -67,6 +67,10 @@ interface TestWebhookResponse {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
type SupportedWebhookChainsResponse =
|
||||
| { chains: Array<number> }
|
||||
| { error: string };
|
||||
|
||||
export async function createWebhook(
|
||||
payload: CreateWebhookPayload,
|
||||
clientId: string,
|
||||
@@ -205,3 +209,31 @@ export async function testWebhook(
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSupportedWebhookChains(): Promise<SupportedWebhookChainsResponse> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://${THIRDWEB_INSIGHT_API_DOMAIN}/service/chains`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"x-service-api-key": process.env.INSIGHT_SERVICE_API_KEY || "",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.json();
|
||||
return { error: `Failed to fetch supported chains: ${errorText.error}` };
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
if (Array.isArray(data.data)) {
|
||||
return { chains: data.data };
|
||||
}
|
||||
return { error: "Unexpected response format" };
|
||||
} catch (error) {
|
||||
console.error("Error fetching supported chains:", error);
|
||||
return { error: `Failed to fetch supported chains: ${error}` };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ type PaymentLink = {
|
||||
chainId: number;
|
||||
};
|
||||
amount: bigint | undefined;
|
||||
purchaseData: unknown;
|
||||
purchaseData: Record<string, unknown> | undefined;
|
||||
};
|
||||
|
||||
export async function getPaymentLink(props: {
|
||||
|
||||
@@ -27,8 +27,15 @@ export function MultiNetworkSelector(props: {
|
||||
side?: "left" | "right" | "top" | "bottom";
|
||||
showSelectedValuesInModal?: boolean;
|
||||
client: ThirdwebClient;
|
||||
chainIds?: number[];
|
||||
}) {
|
||||
const { allChains, idToChain } = useAllChainsData();
|
||||
let { allChains, idToChain } = useAllChainsData();
|
||||
|
||||
if (props.chainIds && props.chainIds.length > 0) {
|
||||
allChains = allChains.filter((chain) =>
|
||||
props.chainIds?.includes(chain.chainId),
|
||||
);
|
||||
}
|
||||
|
||||
const options = useMemo(() => {
|
||||
let sortedChains = allChains;
|
||||
|
||||
@@ -41,6 +41,7 @@ type UpsellBannerCardProps = {
|
||||
cta: {
|
||||
text: React.ReactNode;
|
||||
icon?: React.ReactNode;
|
||||
target?: "_blank";
|
||||
link: string;
|
||||
};
|
||||
trackingCategory: string;
|
||||
@@ -55,7 +56,7 @@ export function UpsellBannerCard(props: UpsellBannerCardProps) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"relative overflow-hidden rounded-lg border bg-gradient-to-r p-5",
|
||||
"relative overflow-hidden rounded-lg border bg-gradient-to-r p-4 lg:p-6",
|
||||
color.border,
|
||||
color.bgFrom,
|
||||
)}
|
||||
@@ -73,7 +74,7 @@ export function UpsellBannerCard(props: UpsellBannerCardProps) {
|
||||
{props.icon ? (
|
||||
<div
|
||||
className={cn(
|
||||
"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-full",
|
||||
"mt-0.5 hidden h-9 w-9 shrink-0 items-center justify-center rounded-full lg:flex",
|
||||
color.iconBg,
|
||||
)}
|
||||
>
|
||||
@@ -90,9 +91,7 @@ export function UpsellBannerCard(props: UpsellBannerCardProps) {
|
||||
>
|
||||
{props.title}
|
||||
</h3>
|
||||
<p className={cn("mt-0.5 text-sm", color.desc)}>
|
||||
{props.description}
|
||||
</p>
|
||||
<p className={cn("text-sm", color.desc)}>{props.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -108,6 +107,7 @@ export function UpsellBannerCard(props: UpsellBannerCardProps) {
|
||||
href={props.cta.link}
|
||||
category={props.trackingCategory}
|
||||
label={props.trackingLabel}
|
||||
target={props.cta.target}
|
||||
>
|
||||
{props.cta.text}
|
||||
{props.cta.icon && <span className="ml-2">{props.cta.icon}</span>}
|
||||
|
||||
@@ -46,8 +46,12 @@ type ThirdwebAreaChartProps<TConfig extends ChartConfig> = {
|
||||
// chart className
|
||||
chartClassName?: string;
|
||||
isPending: boolean;
|
||||
className?: string;
|
||||
cardContentClassName?: string;
|
||||
hideLabel?: boolean;
|
||||
toolTipLabelFormatter?: (label: string, payload: unknown) => React.ReactNode;
|
||||
toolTipValueFormatter?: (value: unknown) => React.ReactNode;
|
||||
emptyChartState?: React.ReactElement;
|
||||
};
|
||||
|
||||
export function ThirdwebAreaChart<TConfig extends ChartConfig>(
|
||||
@@ -56,7 +60,7 @@ export function ThirdwebAreaChart<TConfig extends ChartConfig>(
|
||||
const configKeys = useMemo(() => Object.keys(props.config), [props.config]);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<Card className={props.className}>
|
||||
{props.header && (
|
||||
<CardHeader>
|
||||
<CardTitle className={cn("mb-2", props.header.titleClassName)}>
|
||||
@@ -70,12 +74,16 @@ export function ThirdwebAreaChart<TConfig extends ChartConfig>(
|
||||
|
||||
{props.customHeader && props.customHeader}
|
||||
|
||||
<CardContent className={cn(!props.header && "pt-6")}>
|
||||
<CardContent
|
||||
className={cn(!props.header && "pt-6", props.cardContentClassName)}
|
||||
>
|
||||
<ChartContainer config={props.config} className={props.chartClassName}>
|
||||
{props.isPending ? (
|
||||
<LoadingChartState />
|
||||
) : props.data.length === 0 ? (
|
||||
<EmptyChartState />
|
||||
<EmptyChartState type="area">
|
||||
{props.emptyChartState}
|
||||
</EmptyChartState>
|
||||
) : (
|
||||
<AreaChart accessibilityLayer data={props.data}>
|
||||
<CartesianGrid vertical={false} />
|
||||
@@ -100,6 +108,7 @@ export function ThirdwebAreaChart<TConfig extends ChartConfig>(
|
||||
props.hideLabel !== undefined ? props.hideLabel : true
|
||||
}
|
||||
labelFormatter={props.toolTipLabelFormatter}
|
||||
valueFormatter={props.toolTipValueFormatter}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -75,7 +75,9 @@ export function ThirdwebBarChart<TConfig extends ChartConfig>(
|
||||
{props.isPending ? (
|
||||
<LoadingChartState />
|
||||
) : props.data.length === 0 ? (
|
||||
<EmptyChartState>{props.emptyChartState}</EmptyChartState>
|
||||
<EmptyChartState type="bar">
|
||||
{props.emptyChartState}
|
||||
</EmptyChartState>
|
||||
) : (
|
||||
<BarChart accessibilityLayer data={props.data}>
|
||||
<CartesianGrid vertical={false} />
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ToolTipLabel } from "@/components/ui/tooltip";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { CheckIcon, CircleDollarSignIcon } from "lucide-react";
|
||||
import { CheckIcon, DollarSignIcon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import type React from "react";
|
||||
import { TEAM_PLANS } from "utils/pricing";
|
||||
@@ -105,9 +105,12 @@ export const PricingCard: React.FC<PricingCardProps> = ({
|
||||
|
||||
{/* Price */}
|
||||
<div className="flex flex-col gap-0.5">
|
||||
{plan.isStartingPriceOnly && (
|
||||
<span className="text-muted-foreground text-xs">Starting at</span>
|
||||
)}
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-semibold text-2xl text-foreground tracking-tight">
|
||||
${plan.price}
|
||||
${plan.price.toLocaleString()}
|
||||
</span>
|
||||
|
||||
{!isCustomPrice && (
|
||||
@@ -183,10 +186,10 @@ const billingPlanToSkuMap: Record<Team["billingPlan"], ProductSKU | undefined> =
|
||||
{
|
||||
starter: "plan:starter",
|
||||
growth: "plan:growth",
|
||||
accelerate: "plan:accelerate",
|
||||
scale: "plan:scale",
|
||||
pro: "plan:pro",
|
||||
// we can't render checkout buttons for these plans:
|
||||
pro: undefined,
|
||||
accelerate: undefined,
|
||||
free: undefined,
|
||||
growth_legacy: undefined,
|
||||
starter_legacy: undefined,
|
||||
@@ -201,16 +204,19 @@ function FeatureItem({ text }: FeatureItemProps) {
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<CheckIcon className="size-4 shrink-0 text-green-500" />
|
||||
{Array.isArray(text) ? (
|
||||
<ToolTipLabel label={text[1]}>
|
||||
<DollarSignIcon className="size-4 shrink-0 text-green-500" />
|
||||
</ToolTipLabel>
|
||||
) : (
|
||||
<CheckIcon className="size-4 shrink-0 text-green-500" />
|
||||
)}
|
||||
{Array.isArray(text) ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<p className="text-muted-foreground">
|
||||
{titleStr}{" "}
|
||||
<span className="text-muted-foreground md:hidden">{text[1]}</span>
|
||||
</p>
|
||||
<ToolTipLabel label={text[1]}>
|
||||
<CircleDollarSignIcon className="hidden size-4 text-muted-foreground md:block" />
|
||||
</ToolTipLabel>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-muted-foreground">{titleStr}</p>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
export function LoadingDots() {
|
||||
return (
|
||||
<div className="fade-in-0 flex animate-in gap-2 duration-300">
|
||||
<span className="sr-only">Loading...</span>
|
||||
<div className="size-4 animate-bounce rounded-full bg-foreground [animation-delay:-0.3s]" />
|
||||
<div className="size-4 animate-bounce rounded-full bg-foreground [animation-delay:-0.15s]" />
|
||||
<div className="size-4 animate-bounce rounded-full bg-foreground" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Input } from "./input";
|
||||
export function DecimalInput(props: {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
maxValue?: number;
|
||||
id?: string;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<Input
|
||||
id={props.id}
|
||||
type="text"
|
||||
value={props.value}
|
||||
className={props.className}
|
||||
inputMode="decimal"
|
||||
onChange={(e) => {
|
||||
const number = Number(e.target.value);
|
||||
// ignore if string becomes invalid number
|
||||
if (Number.isNaN(number)) {
|
||||
return;
|
||||
}
|
||||
if (props.maxValue && number > props.maxValue) {
|
||||
return;
|
||||
}
|
||||
// replace leading multiple zeros with single zero
|
||||
let cleanedValue = e.target.value.replace(/^0+/, "0");
|
||||
// replace leading zero before decimal point
|
||||
if (!cleanedValue.includes(".")) {
|
||||
cleanedValue = cleanedValue.replace(/^0+/, "");
|
||||
}
|
||||
props.onChange(cleanedValue || "0");
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
export const NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID =
|
||||
export const NEXT_PUBLIC_DASHBOARD_CLIENT_ID =
|
||||
process.env.NEXT_PUBLIC_DASHBOARD_CLIENT_ID || "";
|
||||
|
||||
export const NEXT_PUBLIC_NEBULA_APP_CLIENT_ID =
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
||||
NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||
NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
||||
} from "@/constants/public-envs";
|
||||
import {
|
||||
@@ -76,7 +76,7 @@ export function getConfiguredThirdwebClient(options: {
|
||||
return createThirdwebClient({
|
||||
teamId: options.teamId,
|
||||
secretKey: options.secretKey,
|
||||
clientId: NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
||||
clientId: NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||
config: {
|
||||
storage: {
|
||||
gatewayUrl: NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
||||
|
||||
@@ -5,6 +5,7 @@ export type ProductSKU =
|
||||
| "plan:custom"
|
||||
| "plan:accelerate"
|
||||
| "plan:scale"
|
||||
| "plan:pro"
|
||||
| "product:ecosystem_wallets"
|
||||
| "product:engine_standard"
|
||||
| "product:engine_premium"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { apiServerProxy } from "@/actions/proxies";
|
||||
import type { Project } from "@/api/projects";
|
||||
import type { Team } from "@/api/team";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useActiveAccount } from "thirdweb/react";
|
||||
import { accountKeys, authorizedWallets } from "../cache-keys";
|
||||
@@ -188,7 +187,7 @@ export function useUpdateNotifications() {
|
||||
export const verifyEmailClient = async (input: ConfirmEmailInput) => {
|
||||
type Result = {
|
||||
error?: { message: string };
|
||||
data: { team: Team; account: Account };
|
||||
data: { account: Account };
|
||||
};
|
||||
|
||||
const res = await apiServerProxy<Result>({
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TeamHeader } from "../../team/components/TeamHeader/team-header";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+2
-2
@@ -4,7 +4,7 @@ import { CopyTextButton } from "@/components/ui/CopyTextButton";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { ToolTipLabel } from "@/components/ui/tooltip";
|
||||
import { isProd } from "@/constants/env-utils";
|
||||
import { NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID } from "@/constants/public-envs";
|
||||
import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "@/constants/public-envs";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { CircleCheckIcon, XIcon } from "lucide-react";
|
||||
import { hostnameEndsWith } from "utils/url";
|
||||
@@ -14,7 +14,7 @@ function useChainStatswithRPC(_rpcUrl: string) {
|
||||
let rpcUrl = _rpcUrl.replace(
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
"${THIRDWEB_API_KEY}",
|
||||
NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
||||
NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||
);
|
||||
|
||||
// based on the environment hit dev or production
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
getAuthToken,
|
||||
getAuthTokenWalletAddress,
|
||||
} from "../../../../api/lib/getAuthToken";
|
||||
import { TeamHeader } from "../../../../team/components/TeamHeader/team-header";
|
||||
import { StarButton } from "../../components/client/star-button";
|
||||
import { getChain, getChainMetadata } from "../../utils";
|
||||
import { AddChainToWallet } from "./components/client/add-chain-to-wallet";
|
||||
@@ -95,7 +96,10 @@ The following is the user's message:
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
<NebulaChatButton
|
||||
isLoggedIn={!!authToken}
|
||||
networks={chain.testnet ? "testnet" : "mainnet"}
|
||||
@@ -225,7 +229,7 @@ The following is the user's message:
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+14
-16
@@ -82,21 +82,19 @@ export const MetadataHeader: React.FC<MetadataHeaderProps> = ({
|
||||
</h1>
|
||||
)}
|
||||
|
||||
{chain && (
|
||||
<Link
|
||||
href={`/${chain.slug}`}
|
||||
className="flex w-fit shrink-0 items-center gap-2 rounded-3xl border border-border bg-card px-2.5 py-1.5 hover:bg-accent"
|
||||
>
|
||||
<ChainIconClient
|
||||
src={chain.icon?.url}
|
||||
client={client}
|
||||
className="size-4"
|
||||
/>
|
||||
{cleanedChainName && (
|
||||
<span className="text-xs">{cleanedChainName}</span>
|
||||
)}
|
||||
</Link>
|
||||
)}
|
||||
<Link
|
||||
href={`/${chain.slug}`}
|
||||
className="flex w-fit shrink-0 items-center gap-2 rounded-3xl border border-border bg-card px-2.5 py-1.5 hover:bg-accent"
|
||||
>
|
||||
<ChainIconClient
|
||||
src={chain.icon?.url}
|
||||
client={client}
|
||||
className="size-4"
|
||||
/>
|
||||
{cleanedChainName && (
|
||||
<span className="text-xs">{cleanedChainName}</span>
|
||||
)}
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -115,7 +113,7 @@ export const MetadataHeader: React.FC<MetadataHeaderProps> = ({
|
||||
<CopyAddressButton
|
||||
address={address}
|
||||
copyIconPosition="left"
|
||||
className="bg-card text-xs"
|
||||
className="bg-card px-2.5 py-1.5 text-xs"
|
||||
variant="outline"
|
||||
/>
|
||||
|
||||
|
||||
+11
-1
@@ -81,7 +81,17 @@ export const PrimaryDashboardButton: React.FC<AddToDashboardCardProps> = ({
|
||||
|
||||
// if user is on a project page
|
||||
if (projectMeta) {
|
||||
return null;
|
||||
return (
|
||||
<Button variant="default" asChild>
|
||||
<Link
|
||||
href={`/${contractInfo.chainSlug}/${contractAddress}`}
|
||||
target="_blank"
|
||||
className="gap-2"
|
||||
>
|
||||
View Asset Page <ExternalLinkIcon className="size-3.5" />
|
||||
</Link>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { resolveFunctionSelectors } from "lib/selectors";
|
||||
import type { ThirdwebContract } from "thirdweb";
|
||||
import { isERC20 } from "thirdweb/extensions/erc20";
|
||||
|
||||
export type NewPublicPageType = "erc20";
|
||||
|
||||
export async function shouldRenderNewPublicPage(
|
||||
contract: ThirdwebContract,
|
||||
): Promise<false | { type: NewPublicPageType }> {
|
||||
try {
|
||||
const functionSelectors = await resolveFunctionSelectors(contract).catch(
|
||||
() => undefined,
|
||||
);
|
||||
|
||||
if (!functionSelectors) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isERC20Contract = isERC20(functionSelectors);
|
||||
|
||||
if (isERC20Contract) {
|
||||
return {
|
||||
type: "erc20",
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+13
@@ -5,6 +5,7 @@ import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]
|
||||
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { ContractAnalyticsPage } from "./ContractAnalyticsPage";
|
||||
|
||||
export async function SharedAnalyticsPage(props: {
|
||||
@@ -22,6 +23,18 @@ export async function SharedAnalyticsPage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /analytics page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const [
|
||||
{ eventSelectorToName, writeFnSelectorToName },
|
||||
{ isInsightSupported },
|
||||
|
||||
+13
@@ -4,6 +4,7 @@ import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[
|
||||
import { ClaimConditions } from "../_components/claim-conditions/claim-conditions";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { ClaimConditionsClient } from "./ClaimConditions.client";
|
||||
|
||||
export async function SharedClaimConditionsPage(props: {
|
||||
@@ -22,6 +23,18 @@ export async function SharedClaimConditionsPage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /claim-conditions page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const { clientContract, serverContract, isLocalhostChain } = info;
|
||||
|
||||
if (isLocalhostChain) {
|
||||
|
||||
+14
@@ -1,7 +1,9 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { resolveContractAbi } from "thirdweb/contract";
|
||||
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { ContractCodePage } from "./contract-code-page";
|
||||
import { ContractCodePageClient } from "./contract-code-page.client";
|
||||
|
||||
@@ -20,6 +22,18 @@ export async function SharedCodePage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /code page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const { clientContract, serverContract, chainMetadata, isLocalhostChain } =
|
||||
info;
|
||||
|
||||
|
||||
+14
@@ -20,8 +20,10 @@ import { eth_getCode, getRpcClient } from "thirdweb/rpc";
|
||||
import type { TransactionReceipt } from "thirdweb/transaction";
|
||||
import { type AbiFunction, decodeFunctionData } from "thirdweb/utils";
|
||||
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { DataTable } from "./data-table";
|
||||
import { NoCrossChainPrompt } from "./no-crosschain-prompt";
|
||||
|
||||
@@ -48,6 +50,18 @@ export async function SharedCrossChainPage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /cross-chain page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const { clientContract, serverContract } = info;
|
||||
|
||||
const isModularCore = (await getContractPageMetadata(serverContract))
|
||||
|
||||
+14
@@ -1,6 +1,8 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { EventsFeed } from "./events-feed";
|
||||
|
||||
export async function SharedEventsPage(props: {
|
||||
@@ -18,6 +20,18 @@ export async function SharedEventsPage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /events page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<EventsFeed
|
||||
contract={info.clientContract}
|
||||
|
||||
+14
@@ -1,7 +1,9 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { resolveContractAbi } from "thirdweb/contract";
|
||||
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { ContractExplorerPage } from "./ContractExplorerPage";
|
||||
import { ContractExplorerPageClient } from "./ContractExplorerPage.client";
|
||||
|
||||
@@ -21,6 +23,18 @@ export async function SharedExplorerPage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /explorer page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const { clientContract, serverContract, chainMetadata, isLocalhostChain } =
|
||||
info;
|
||||
|
||||
|
||||
+18
@@ -1,3 +1,5 @@
|
||||
import { UpsellBannerCard } from "@/components/blocks/UpsellBannerCard";
|
||||
import { ExternalLinkIcon } from "lucide-react";
|
||||
import type { ThirdwebContract } from "thirdweb";
|
||||
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { TokenDetailsCard } from "../tokens/components/supply";
|
||||
@@ -43,6 +45,22 @@ export const ContractOverviewPage: React.FC<ContractOverviewPageProps> = ({
|
||||
return (
|
||||
<div className="flex flex-col gap-10 lg:flex-row lg:gap-8">
|
||||
<div className="flex grow flex-col gap-10 overflow-hidden">
|
||||
{isErc20 && (
|
||||
<UpsellBannerCard
|
||||
title="Public asset page available"
|
||||
description="A public page is available for this contract for anyone to buy this asset"
|
||||
cta={{
|
||||
text: "View asset page",
|
||||
icon: <ExternalLinkIcon className="size-4" />,
|
||||
target: "_blank",
|
||||
link: `/${chainSlug}/${contract.address}`,
|
||||
}}
|
||||
trackingCategory="erc20-contract"
|
||||
trackingLabel="view-asset-page"
|
||||
accentColor="blue"
|
||||
/>
|
||||
)}
|
||||
|
||||
<ContractChecklist
|
||||
isErc721={isErc721}
|
||||
isErc1155={isErc1155}
|
||||
|
||||
+118
-51
@@ -7,6 +7,7 @@ import {
|
||||
useContractTransactionAnalytics,
|
||||
useContractUniqueWalletAnalytics,
|
||||
} from "data/analytics/hooks";
|
||||
import { differenceInCalendarDays, formatDate } from "date-fns";
|
||||
import { useTrack } from "hooks/analytics/useTrack";
|
||||
import { ArrowRightIcon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
@@ -14,8 +15,14 @@ import { useMemo, useState } from "react";
|
||||
import type { ProjectMeta } from "../../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { buildContractPagePath } from "../../_utils/contract-page-path";
|
||||
|
||||
function getDayKey(date: Date) {
|
||||
return date.toISOString().split("T")[0];
|
||||
function getDateKey(date: Date, precision: "day" | "hour") {
|
||||
const dayKey = date.toISOString().split("T")[0];
|
||||
if (precision === "day") {
|
||||
return dayKey;
|
||||
}
|
||||
|
||||
const hourKey = date.getHours();
|
||||
return `${dayKey}-${hourKey}`;
|
||||
}
|
||||
|
||||
export function ContractAnalyticsOverviewCard(props: {
|
||||
@@ -34,60 +41,13 @@ export function ContractAnalyticsOverviewCard(props: {
|
||||
})(),
|
||||
);
|
||||
const [endDate] = useState(new Date());
|
||||
|
||||
const wallets = useContractUniqueWalletAnalytics({
|
||||
const { data, precision, isPending } = useContractAnalyticsOverview({
|
||||
chainId: props.chainId,
|
||||
contractAddress: props.contractAddress,
|
||||
startDate,
|
||||
endDate,
|
||||
});
|
||||
|
||||
const transactions = useContractTransactionAnalytics({
|
||||
chainId: props.chainId,
|
||||
contractAddress: props.contractAddress,
|
||||
startDate,
|
||||
endDate,
|
||||
});
|
||||
|
||||
const events = useContractEventAnalytics({
|
||||
chainId: props.chainId,
|
||||
contractAddress: props.contractAddress,
|
||||
startDate,
|
||||
endDate,
|
||||
});
|
||||
|
||||
const isPending =
|
||||
wallets.isPending || transactions.isPending || events.isPending;
|
||||
|
||||
const mergedData = useMemo(() => {
|
||||
if (isPending) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const time = (wallets.data || transactions.data || events.data || []).map(
|
||||
(wallet) => wallet.time,
|
||||
);
|
||||
|
||||
return time.map((time) => {
|
||||
const wallet = wallets.data?.find(
|
||||
(wallet) => getDayKey(wallet.time) === getDayKey(time),
|
||||
);
|
||||
const transaction = transactions.data?.find(
|
||||
(transaction) => getDayKey(transaction.time) === getDayKey(time),
|
||||
);
|
||||
const event = events.data?.find((event) => {
|
||||
return getDayKey(event.time) === getDayKey(time);
|
||||
});
|
||||
|
||||
return {
|
||||
time,
|
||||
wallets: wallet?.count || 0,
|
||||
transactions: transaction?.count || 0,
|
||||
events: event?.count || 0,
|
||||
};
|
||||
});
|
||||
}, [wallets.data, transactions.data, events.data, isPending]);
|
||||
|
||||
const analyticsPath = buildContractPagePath({
|
||||
projectMeta: props.projectMeta,
|
||||
chainIdOrSlug: props.chainSlug,
|
||||
@@ -111,10 +71,11 @@ export function ContractAnalyticsOverviewCard(props: {
|
||||
color: "hsl(var(--chart-3))",
|
||||
},
|
||||
}}
|
||||
data={mergedData || []}
|
||||
data={data || []}
|
||||
isPending={isPending}
|
||||
showLegend
|
||||
chartClassName="aspect-[1.5] lg:aspect-[3]"
|
||||
toolTipLabelFormatter={toolTipLabelFormatterWithPrecision(precision)}
|
||||
customHeader={
|
||||
<div className="flex items-center justify-between gap-4 border-b p-6 py-4">
|
||||
<h2 className="font-semibold text-xl tracking-tight">Analytics</h2>
|
||||
@@ -141,3 +102,109 @@ export function ContractAnalyticsOverviewCard(props: {
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function useContractAnalyticsOverview(props: {
|
||||
chainId: number;
|
||||
contractAddress: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
}) {
|
||||
const { chainId, contractAddress, startDate, endDate } = props;
|
||||
const wallets = useContractUniqueWalletAnalytics({
|
||||
chainId: chainId,
|
||||
contractAddress: contractAddress,
|
||||
startDate,
|
||||
endDate,
|
||||
});
|
||||
|
||||
const transactions = useContractTransactionAnalytics({
|
||||
chainId: chainId,
|
||||
contractAddress: contractAddress,
|
||||
startDate,
|
||||
endDate,
|
||||
});
|
||||
|
||||
const events = useContractEventAnalytics({
|
||||
chainId: chainId,
|
||||
contractAddress: contractAddress,
|
||||
startDate,
|
||||
endDate,
|
||||
});
|
||||
|
||||
const isPending =
|
||||
wallets.isPending || transactions.isPending || events.isPending;
|
||||
|
||||
const { data, precision } = useMemo(() => {
|
||||
if (isPending) {
|
||||
return {
|
||||
data: undefined,
|
||||
precision: "day" as const,
|
||||
};
|
||||
}
|
||||
|
||||
const time = (wallets.data || transactions.data || events.data || []).map(
|
||||
(wallet) => wallet.time,
|
||||
);
|
||||
|
||||
// if the time difference between the first and last time is less than 3 days - use hour precision
|
||||
const firstTime = time[0];
|
||||
const lastTime = time[time.length - 1];
|
||||
const timeDiff =
|
||||
firstTime && lastTime
|
||||
? differenceInCalendarDays(lastTime, firstTime)
|
||||
: undefined;
|
||||
|
||||
const precision: "day" | "hour" = !timeDiff
|
||||
? "hour"
|
||||
: timeDiff < 3
|
||||
? "hour"
|
||||
: "day";
|
||||
|
||||
return {
|
||||
data: time.map((time) => {
|
||||
const wallet = wallets.data?.find(
|
||||
(wallet) =>
|
||||
getDateKey(wallet.time, precision) === getDateKey(time, precision),
|
||||
);
|
||||
const transaction = transactions.data?.find(
|
||||
(transaction) =>
|
||||
getDateKey(transaction.time, precision) ===
|
||||
getDateKey(time, precision),
|
||||
);
|
||||
|
||||
const event = events.data?.find((event) => {
|
||||
return (
|
||||
getDateKey(event.time, precision) === getDateKey(time, precision)
|
||||
);
|
||||
});
|
||||
|
||||
return {
|
||||
time,
|
||||
wallets: wallet?.count || 0,
|
||||
transactions: transaction?.count || 0,
|
||||
events: event?.count || 0,
|
||||
};
|
||||
}),
|
||||
precision,
|
||||
};
|
||||
}, [wallets.data, transactions.data, events.data, isPending]);
|
||||
|
||||
return {
|
||||
data,
|
||||
precision,
|
||||
isPending,
|
||||
};
|
||||
}
|
||||
|
||||
export function toolTipLabelFormatterWithPrecision(precision: "day" | "hour") {
|
||||
return function toolTipLabelFormatter(_v: string, item: unknown) {
|
||||
if (Array.isArray(item)) {
|
||||
const time = item[0].payload.time as number;
|
||||
return formatDate(
|
||||
new Date(time),
|
||||
precision === "day" ? "MMM d, yyyy" : "MMM d, yyyy hh:mm a",
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
+14
@@ -1,7 +1,9 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { ContractPermissionsPage } from "./ContractPermissionsPage";
|
||||
import { ContractPermissionsPageClient } from "./ContractPermissionsPage.client";
|
||||
|
||||
@@ -21,6 +23,18 @@ export async function SharedPermissionsPage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /permissions page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const { clientContract, serverContract, isLocalhostChain } = info;
|
||||
if (isLocalhostChain) {
|
||||
return (
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { ToggleThemeButton } from "@/components/color-mode-toggle";
|
||||
import Link from "next/link";
|
||||
import { ThirdwebMiniLogo } from "../../../../../../components/ThirdwebMiniLogo";
|
||||
import { PublicPageConnectButton } from "./PublicPageConnectButton";
|
||||
|
||||
export function PageHeader() {
|
||||
return (
|
||||
<div className="border-b border-dashed">
|
||||
<header className="container flex max-w-8xl justify-between py-3">
|
||||
<div className="flex items-center gap-4">
|
||||
<Link href="/team" className="flex items-center gap-2">
|
||||
<ThirdwebMiniLogo className="h-6" />
|
||||
<span className="hidden font-bold text-2xl tracking-tight lg:block">
|
||||
thirdweb
|
||||
</span>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-5">
|
||||
<ToggleThemeButton />
|
||||
<PublicPageConnectButton />
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
|
||||
import { getSDKTheme } from "app/(app)/components/sdk-component-theme";
|
||||
import { useAllChainsData } from "hooks/chains/allChains";
|
||||
import { useTheme } from "next-themes";
|
||||
import { ConnectButton } from "thirdweb/react";
|
||||
|
||||
const client = getClientThirdwebClient();
|
||||
|
||||
export function PublicPageConnectButton(props: {
|
||||
connectButtonClassName?: string;
|
||||
}) {
|
||||
const { theme } = useTheme();
|
||||
const t = theme === "light" ? "light" : "dark";
|
||||
const { allChainsV5 } = useAllChainsData();
|
||||
|
||||
return (
|
||||
<ConnectButton
|
||||
theme={getSDKTheme(t)}
|
||||
client={client}
|
||||
connectModal={{
|
||||
privacyPolicyUrl: "/privacy-policy",
|
||||
termsOfServiceUrl: "/terms",
|
||||
showThirdwebBranding: false,
|
||||
}}
|
||||
connectButton={{
|
||||
className: props.connectButtonClassName,
|
||||
}}
|
||||
appMetadata={{
|
||||
name: "thirdweb",
|
||||
logoUrl: "https://thirdweb.com/favicon.ico",
|
||||
url: "https://thirdweb.com",
|
||||
}}
|
||||
chains={allChainsV5}
|
||||
// we have an AutoConnect already added in root layout with AA configuration
|
||||
autoConnect={false}
|
||||
/>
|
||||
);
|
||||
}
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { storybookThirdwebClient } from "stories/utils";
|
||||
import { getContract } from "thirdweb";
|
||||
import type { ChainMetadata } from "thirdweb/chains";
|
||||
import { ThirdwebProvider } from "thirdweb/react";
|
||||
import { ContractHeaderUI } from "./ContractHeader";
|
||||
|
||||
const meta = {
|
||||
title: "ERC20/ContractHeader",
|
||||
component: ContractHeaderUI,
|
||||
parameters: {
|
||||
nextjs: {
|
||||
appDirectory: true,
|
||||
},
|
||||
},
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<ThirdwebProvider>
|
||||
<div className="container max-w-7xl py-10">
|
||||
<Story />
|
||||
</div>
|
||||
</ThirdwebProvider>
|
||||
),
|
||||
],
|
||||
} satisfies Meta<typeof ContractHeaderUI>;
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
const mockTokenImage =
|
||||
"ipfs://ipfs/QmXYgTEavjF6c9X1a2pt5E379MYqSwFzzKvsUbSnRiSUEc/ea207d218948137.67aa26cfbd956.png";
|
||||
|
||||
const ethereumChainMetadata: ChainMetadata = {
|
||||
name: "Ethereum Mainnet",
|
||||
chain: "ethereum",
|
||||
chainId: 1,
|
||||
networkId: 1,
|
||||
nativeCurrency: {
|
||||
name: "Ether",
|
||||
symbol: "ETH",
|
||||
decimals: 18,
|
||||
},
|
||||
rpc: ["https://eth.llamarpc.com"],
|
||||
shortName: "eth",
|
||||
slug: "ethereum",
|
||||
testnet: false,
|
||||
icon: {
|
||||
url: "https://thirdweb.com/chain-icons/ethereum.svg",
|
||||
width: 24,
|
||||
height: 24,
|
||||
format: "svg",
|
||||
},
|
||||
explorers: [
|
||||
{
|
||||
name: "Etherscan",
|
||||
url: "https://etherscan.io",
|
||||
standard: "EIP3091",
|
||||
},
|
||||
],
|
||||
stackType: "evm",
|
||||
};
|
||||
|
||||
const mockContract = getContract({
|
||||
client: storybookThirdwebClient,
|
||||
chain: {
|
||||
id: 1,
|
||||
name: "Ethereum",
|
||||
rpc: "https://eth.llamarpc.com",
|
||||
},
|
||||
address: "0x1234567890123456789012345678901234567890",
|
||||
});
|
||||
|
||||
const mockSocialUrls = {
|
||||
twitter: "https://twitter.com",
|
||||
discord: "https://discord.gg",
|
||||
telegram: "https://web.telegram.org/",
|
||||
website: "https://example.com",
|
||||
github: "https://github.com",
|
||||
linkedin: "https://linkedin.com",
|
||||
tiktok: "https://tiktok.com",
|
||||
instagram: "https://instagram.com",
|
||||
custom: "https://example.com",
|
||||
reddit: "https://reddit.com",
|
||||
youtube: "https://youtube.com",
|
||||
};
|
||||
|
||||
export const WithImageAndMultipleSocialUrls: Story = {
|
||||
args: {
|
||||
name: "Sample Token",
|
||||
symbol: "SMPL",
|
||||
image: mockTokenImage,
|
||||
chainMetadata: ethereumChainMetadata,
|
||||
clientContract: mockContract,
|
||||
socialUrls: {
|
||||
twitter: mockSocialUrls.twitter,
|
||||
discord: mockSocialUrls.discord,
|
||||
telegram: mockSocialUrls.telegram,
|
||||
website: mockSocialUrls.website,
|
||||
github: mockSocialUrls.github,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const WithBrokenImageAndSingleSocialUrl: Story = {
|
||||
args: {
|
||||
name: "Sample Token",
|
||||
symbol: "SMPL",
|
||||
image: "broken-image.png",
|
||||
chainMetadata: ethereumChainMetadata,
|
||||
clientContract: mockContract,
|
||||
socialUrls: {
|
||||
website: mockSocialUrls.website,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const WithoutImageAndNoSocialUrls: Story = {
|
||||
args: {
|
||||
name: "Sample Token",
|
||||
symbol: "SMPL",
|
||||
image: undefined,
|
||||
chainMetadata: ethereumChainMetadata,
|
||||
clientContract: mockContract,
|
||||
socialUrls: {},
|
||||
},
|
||||
};
|
||||
|
||||
export const LongNameAndLotsOfSocialUrls: Story = {
|
||||
args: {
|
||||
name: "This is a very long token name that should wrap to multiple lines",
|
||||
symbol: "LONG",
|
||||
image: "https://thirdweb.com/chain-icons/ethereum.svg",
|
||||
chainMetadata: ethereumChainMetadata,
|
||||
clientContract: mockContract,
|
||||
socialUrls: {
|
||||
twitter: mockSocialUrls.twitter,
|
||||
discord: mockSocialUrls.discord,
|
||||
telegram: mockSocialUrls.telegram,
|
||||
reddit: mockSocialUrls.reddit,
|
||||
youtube: mockSocialUrls.youtube,
|
||||
website: mockSocialUrls.website,
|
||||
github: mockSocialUrls.github,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const AllSocialUrls: Story = {
|
||||
args: {
|
||||
name: "Sample Token",
|
||||
symbol: "SMPL",
|
||||
image: "https://thirdweb.com/chain-icons/ethereum.svg",
|
||||
chainMetadata: ethereumChainMetadata,
|
||||
clientContract: mockContract,
|
||||
socialUrls: {
|
||||
twitter: mockSocialUrls.twitter,
|
||||
discord: mockSocialUrls.discord,
|
||||
telegram: mockSocialUrls.telegram,
|
||||
reddit: mockSocialUrls.reddit,
|
||||
youtube: mockSocialUrls.youtube,
|
||||
website: mockSocialUrls.website,
|
||||
github: mockSocialUrls.github,
|
||||
linkedin: mockSocialUrls.linkedin,
|
||||
tiktok: mockSocialUrls.tiktok,
|
||||
instagram: mockSocialUrls.instagram,
|
||||
custom: mockSocialUrls.custom,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const InvalidSocialUrls: Story = {
|
||||
args: {
|
||||
name: "Sample Token",
|
||||
symbol: "SMPL",
|
||||
image: "https://thirdweb.com/chain-icons/ethereum.svg",
|
||||
chainMetadata: ethereumChainMetadata,
|
||||
clientContract: mockContract,
|
||||
socialUrls: {
|
||||
twitter: "invalid-url",
|
||||
discord: "invalid-url",
|
||||
telegram: "invalid-url",
|
||||
reddit: "",
|
||||
youtube: mockSocialUrls.youtube,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const SomeSocialUrls: Story = {
|
||||
args: {
|
||||
name: "Sample Token",
|
||||
symbol: "SMPL",
|
||||
image: "https://thirdweb.com/chain-icons/ethereum.svg",
|
||||
chainMetadata: ethereumChainMetadata,
|
||||
clientContract: mockContract,
|
||||
socialUrls: {
|
||||
website: mockSocialUrls.website,
|
||||
twitter: mockSocialUrls.twitter,
|
||||
},
|
||||
},
|
||||
};
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
import { Img } from "@/components/blocks/Img";
|
||||
import { CopyAddressButton } from "@/components/ui/CopyAddressButton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ToolTipLabel } from "@/components/ui/tooltip";
|
||||
import { resolveSchemeWithErrorHandler } from "@/lib/resolveSchemeWithErrorHandler";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { ChainIconClient } from "components/icons/ChainIcon";
|
||||
import { GithubIcon } from "components/icons/brand-icons/GithubIcon";
|
||||
import { InstagramIcon } from "components/icons/brand-icons/InstagramIcon";
|
||||
import { LinkedInIcon } from "components/icons/brand-icons/LinkedinIcon";
|
||||
import { RedditIcon } from "components/icons/brand-icons/RedditIcon";
|
||||
import { TiktokIcon } from "components/icons/brand-icons/TiktokIcon";
|
||||
import { XIcon as TwitterXIcon } from "components/icons/brand-icons/XIcon";
|
||||
import { YoutubeIcon } from "components/icons/brand-icons/YoutubeIcon";
|
||||
import { ExternalLinkIcon, GlobeIcon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useMemo } from "react";
|
||||
import type { ThirdwebContract } from "thirdweb";
|
||||
import type { ChainMetadata } from "thirdweb/chains";
|
||||
import { DiscordIcon } from "../../../../../../../../../components/icons/brand-icons/DiscordIcon";
|
||||
import { TelegramIcon } from "../../../../../../../../../components/icons/brand-icons/TelegramIcon";
|
||||
|
||||
const platformToIcons: Record<string, React.FC<{ className?: string }>> = {
|
||||
twitter: TwitterXIcon,
|
||||
x: TwitterXIcon,
|
||||
discord: DiscordIcon,
|
||||
telegram: TelegramIcon,
|
||||
reddit: RedditIcon,
|
||||
website: GlobeIcon,
|
||||
github: GithubIcon,
|
||||
youtube: YoutubeIcon,
|
||||
instagram: InstagramIcon,
|
||||
tiktok: TiktokIcon,
|
||||
linkedin: LinkedInIcon,
|
||||
};
|
||||
|
||||
export function ContractHeaderUI(props: {
|
||||
name: string;
|
||||
symbol: string | undefined;
|
||||
image: string | undefined;
|
||||
chainMetadata: ChainMetadata;
|
||||
clientContract: ThirdwebContract;
|
||||
socialUrls: object;
|
||||
}) {
|
||||
const socialUrls = useMemo(() => {
|
||||
const socialUrlsValue: { name: string; href: string }[] = [];
|
||||
for (const [key, value] of Object.entries(props.socialUrls)) {
|
||||
if (
|
||||
typeof value === "string" &&
|
||||
typeof key === "string" &&
|
||||
isValidUrl(value)
|
||||
) {
|
||||
socialUrlsValue.push({ name: key, href: value });
|
||||
}
|
||||
}
|
||||
|
||||
return socialUrlsValue;
|
||||
}, [props.socialUrls]);
|
||||
|
||||
const cleanedChainName = props.chainMetadata?.name
|
||||
?.replace("Mainnet", "")
|
||||
.trim();
|
||||
|
||||
const explorersToShow = getExplorersToShow(props.chainMetadata);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-start gap-4 border-b border-dashed py-8 lg:flex-row lg:items-center">
|
||||
{props.image && (
|
||||
<Img
|
||||
className="size-20 shrink-0 rounded-full border bg-muted"
|
||||
src={
|
||||
props.image
|
||||
? resolveSchemeWithErrorHandler({
|
||||
uri: props.image,
|
||||
client: props.clientContract.client,
|
||||
})
|
||||
: ""
|
||||
}
|
||||
fallback={
|
||||
<div className="flex items-center justify-center font-bold text-3xl text-muted-foreground/80">
|
||||
{props.name[0]}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="flex flex-col gap-3">
|
||||
{/* top row */}
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex flex-col flex-wrap gap-3 lg:flex-row lg:items-center">
|
||||
<h1 className="line-clamp-2 font-bold text-2xl tracking-tight lg:text-3xl">
|
||||
{props.name}
|
||||
</h1>
|
||||
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Link
|
||||
href={`/${props.chainMetadata.slug}`}
|
||||
className="flex w-fit shrink-0 items-center gap-2 rounded-3xl border border-border bg-card px-2.5 py-1.5 hover:bg-accent"
|
||||
>
|
||||
<ChainIconClient
|
||||
src={props.chainMetadata.icon?.url || ""}
|
||||
client={props.clientContract.client}
|
||||
className="size-4"
|
||||
/>
|
||||
{cleanedChainName && (
|
||||
<span className="text-xs">{cleanedChainName}</span>
|
||||
)}
|
||||
</Link>
|
||||
|
||||
{socialUrls
|
||||
.toSorted((a, b) => {
|
||||
const aIcon = platformToIcons[a.name.toLowerCase()];
|
||||
const bIcon = platformToIcons[b.name.toLowerCase()];
|
||||
|
||||
if (aIcon && bIcon) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (aIcon) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
})
|
||||
.map(({ name, href }) => (
|
||||
<SocialLink
|
||||
key={name}
|
||||
name={name}
|
||||
href={href}
|
||||
icon={platformToIcons[name.toLowerCase()]}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* bottom row */}
|
||||
<div className="flex flex-row flex-wrap items-center gap-2">
|
||||
<CopyAddressButton
|
||||
address={props.clientContract.address}
|
||||
copyIconPosition="left"
|
||||
className="rounded-full bg-card px-2.5 py-1.5 text-xs"
|
||||
variant="outline"
|
||||
/>
|
||||
|
||||
{explorersToShow?.map((validBlockExplorer) => (
|
||||
<BadgeLink
|
||||
key={validBlockExplorer.url}
|
||||
name={validBlockExplorer.name}
|
||||
href={`${validBlockExplorer.url.endsWith("/") ? validBlockExplorer.url : `${validBlockExplorer.url}/`}address/${props.clientContract.address}`}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* TODO - render social links here */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function isValidUrl(url: string) {
|
||||
try {
|
||||
new URL(url);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getExplorersToShow(chainMetadata: ChainMetadata) {
|
||||
const validBlockExplorers = chainMetadata.explorers
|
||||
?.filter((e) => e.standard === "EIP3091")
|
||||
?.slice(0, 2);
|
||||
|
||||
return validBlockExplorers?.slice(0, 1);
|
||||
}
|
||||
|
||||
function BadgeLink(props: {
|
||||
name: string;
|
||||
href: string;
|
||||
}) {
|
||||
return (
|
||||
<Button
|
||||
variant="outline"
|
||||
asChild
|
||||
className="!h-auto gap-2 rounded-full bg-card px-3 py-1.5 text-xs capitalize"
|
||||
>
|
||||
<Link href={props.href} target="_blank">
|
||||
{props.name}
|
||||
<ExternalLinkIcon className="size-3 text-muted-foreground/70" />
|
||||
</Link>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
function SocialLink(props: {
|
||||
name: string;
|
||||
href: string;
|
||||
icon?: React.FC<{ className?: string }>;
|
||||
}) {
|
||||
return (
|
||||
<ToolTipLabel label={props.name} contentClassName="capitalize">
|
||||
<Button
|
||||
variant="outline"
|
||||
asChild
|
||||
className={cn(
|
||||
"!h-auto gap-2 rounded-full bg-card px-3 py-1.5 text-xs capitalize",
|
||||
props.icon && "rounded-full p-1.5",
|
||||
)}
|
||||
>
|
||||
<Link href={props.href} target="_blank" className="capitalize">
|
||||
{props.icon ? <props.icon className="size-4" /> : props.name}
|
||||
{!props.icon && (
|
||||
<ExternalLinkIcon className="size-3 text-muted-foreground/70" />
|
||||
)}
|
||||
</Link>
|
||||
</Button>
|
||||
</ToolTipLabel>
|
||||
);
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
"use client";
|
||||
|
||||
import { useTheme } from "next-themes";
|
||||
import type { Chain, ThirdwebClient } from "thirdweb";
|
||||
import { PayEmbed } from "thirdweb/react";
|
||||
import { getSDKTheme } from "../../../../../../../components/sdk-component-theme";
|
||||
|
||||
export function BuyTokenEmbed(props: {
|
||||
client: ThirdwebClient;
|
||||
chain: Chain;
|
||||
tokenSymbol: string;
|
||||
tokenName: string;
|
||||
tokenAddress: string;
|
||||
}) {
|
||||
const { theme } = useTheme();
|
||||
return (
|
||||
<PayEmbed
|
||||
className="!rounded-xl !w-full"
|
||||
client={props.client}
|
||||
payOptions={{
|
||||
mode: "fund_wallet",
|
||||
metadata: {
|
||||
name: `Buy ${props.tokenSymbol}`,
|
||||
},
|
||||
prefillBuy: {
|
||||
chain: props.chain,
|
||||
token: {
|
||||
name: props.tokenName,
|
||||
symbol: props.tokenSymbol,
|
||||
address: props.tokenAddress,
|
||||
},
|
||||
amount: "1",
|
||||
allowEdits: {
|
||||
token: false,
|
||||
chain: false,
|
||||
amount: true,
|
||||
},
|
||||
},
|
||||
}}
|
||||
theme={getSDKTheme(theme === "light" ? "light" : "dark")}
|
||||
connectOptions={{
|
||||
autoConnect: false,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
+314
@@ -0,0 +1,314 @@
|
||||
"use client";
|
||||
|
||||
import { ThirdwebAreaChart } from "@/components/blocks/charts/area-chart";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SkeletonContainer } from "@/components/ui/skeleton";
|
||||
import { ToolTipLabel } from "@/components/ui/tooltip";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { differenceInCalendarDays, formatDate } from "date-fns";
|
||||
import { ArrowUpIcon, InfoIcon } from "lucide-react";
|
||||
import { ArrowDownIcon } from "lucide-react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useTokenPriceData } from "../_hooks/useTokenPriceData";
|
||||
|
||||
function PriceChartUI(props: {
|
||||
isPending: boolean;
|
||||
showTimeOfDay: boolean;
|
||||
data: Array<{
|
||||
date: string;
|
||||
price_usd: number;
|
||||
price_usd_cents: number;
|
||||
}>;
|
||||
}) {
|
||||
const data = props.data.map((item) => ({
|
||||
price: item.price_usd,
|
||||
time: new Date(item.date).getTime(),
|
||||
}));
|
||||
|
||||
return (
|
||||
<ThirdwebAreaChart
|
||||
className="border-none bg-background p-0"
|
||||
cardContentClassName="p-0"
|
||||
config={{
|
||||
price: {
|
||||
label: "Price",
|
||||
color: "hsl(var(--chart-1))",
|
||||
},
|
||||
}}
|
||||
data={data}
|
||||
isPending={props.isPending}
|
||||
chartClassName="aspect-[1.5] lg:aspect-[3]"
|
||||
hideLabel={false}
|
||||
toolTipLabelFormatter={getTooltipLabelFormatter(props.showTimeOfDay)}
|
||||
toolTipValueFormatter={(value) => {
|
||||
return tokenPriceUSDFormatter.format(value as number);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const tokenPriceUSDFormatter = new Intl.NumberFormat("en-US", {
|
||||
style: "currency",
|
||||
currency: "USD",
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 10,
|
||||
roundingMode: "halfEven",
|
||||
notation: "compact",
|
||||
});
|
||||
|
||||
const marketCapFormatter = new Intl.NumberFormat("en-US", {
|
||||
style: "currency",
|
||||
currency: "USD",
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0,
|
||||
roundingMode: "halfEven",
|
||||
notation: "compact",
|
||||
});
|
||||
|
||||
const holdersFormatter = new Intl.NumberFormat("en-US", {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0,
|
||||
notation: "compact",
|
||||
});
|
||||
|
||||
const percentChangeFormatter = new Intl.NumberFormat("en-US", {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 2,
|
||||
});
|
||||
|
||||
function getTooltipLabelFormatter(includeTimeOfDay: boolean) {
|
||||
return (_v: string, item: unknown) => {
|
||||
if (Array.isArray(item)) {
|
||||
const time = item[0].payload.time as number;
|
||||
return formatDate(
|
||||
new Date(time),
|
||||
includeTimeOfDay ? "MMM d, yyyy hh:mm a" : "MMM d, yyyy",
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export function TokenStats(params: {
|
||||
chainId: number;
|
||||
contractAddress: string;
|
||||
}) {
|
||||
const tokenPriceQuery = useTokenPriceData(params);
|
||||
const [interval, setInterval] = useState<Interval>("max");
|
||||
|
||||
const tokenPriceData = tokenPriceQuery.data;
|
||||
|
||||
const filteredHistoricalPrices = useMemo(() => {
|
||||
const currentDate = new Date();
|
||||
|
||||
if (tokenPriceData?.type === "no-data") {
|
||||
return [];
|
||||
}
|
||||
|
||||
return tokenPriceData?.data?.historical_prices.filter((item) => {
|
||||
const date = new Date(item.date);
|
||||
const maxDiff =
|
||||
interval === "24h"
|
||||
? 1
|
||||
: interval === "7d"
|
||||
? 7
|
||||
: interval === "30d"
|
||||
? 30
|
||||
: interval === "1y"
|
||||
? 365
|
||||
: Number.MAX_SAFE_INTEGER;
|
||||
|
||||
return differenceInCalendarDays(currentDate, date) <= maxDiff;
|
||||
});
|
||||
}, [tokenPriceData, interval]);
|
||||
|
||||
const priceUsd =
|
||||
tokenPriceData?.type === "no-data" || tokenPriceQuery.isError
|
||||
? "N/A"
|
||||
: tokenPriceData?.data?.price_usd;
|
||||
|
||||
const percentChange24h =
|
||||
tokenPriceData?.type === "no-data" || tokenPriceQuery.isError
|
||||
? "N/A"
|
||||
: tokenPriceData?.data?.percent_change_24h;
|
||||
|
||||
const marketCap =
|
||||
tokenPriceData?.type === "no-data" || tokenPriceQuery.isError
|
||||
? "N/A"
|
||||
: tokenPriceData?.data?.market_cap_usd;
|
||||
|
||||
const holders =
|
||||
tokenPriceData?.type === "no-data" || tokenPriceQuery.isError
|
||||
? "N/A"
|
||||
: tokenPriceData?.data?.holders;
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* price and change */}
|
||||
<div className="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div>
|
||||
<p className="mb-1 text-muted-foreground text-sm">Current Price</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<SkeletonContainer
|
||||
loadedData={priceUsd}
|
||||
skeletonData={10.0001}
|
||||
render={(v) => {
|
||||
return (
|
||||
<p className="font-bold text-4xl tracking-tight">
|
||||
{typeof v === "number"
|
||||
? tokenPriceUSDFormatter.format(v)
|
||||
: v}
|
||||
</p>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<SkeletonContainer
|
||||
loadedData={percentChange24h}
|
||||
skeletonData={0.001}
|
||||
render={(data) => {
|
||||
if (typeof data === "string") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const formattedAbsChange = percentChangeFormatter.format(
|
||||
Math.abs(data),
|
||||
);
|
||||
|
||||
const isAlmostZero =
|
||||
formattedAbsChange === percentChangeFormatter.format(0);
|
||||
|
||||
return (
|
||||
<Badge
|
||||
variant={
|
||||
isAlmostZero
|
||||
? "default"
|
||||
: data > 0
|
||||
? "success"
|
||||
: "destructive"
|
||||
}
|
||||
className="gap-2 text-sm"
|
||||
>
|
||||
<div className="flex items-center gap-0.5">
|
||||
{isAlmostZero ? null : data > 0 ? (
|
||||
<ArrowUpIcon className="size-3" />
|
||||
) : (
|
||||
<ArrowDownIcon className="size-3" />
|
||||
)}
|
||||
<span>
|
||||
{isAlmostZero ? "~0%" : `${formattedAbsChange}%`}
|
||||
</span>
|
||||
</div>
|
||||
<span>(1d)</span>
|
||||
</Badge>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<IntervalSelector interval={interval} setInterval={setInterval} />
|
||||
</div>
|
||||
|
||||
<div className="h-4" />
|
||||
<PriceChartUI
|
||||
showTimeOfDay={interval === "24h"}
|
||||
isPending={tokenPriceQuery.isPending}
|
||||
data={filteredHistoricalPrices || []}
|
||||
/>
|
||||
|
||||
<div className="mt-8 flex gap-6 border-y border-dashed py-4 [&>*:not(:first-child)]:border-l [&>*:not(:first-child)]:border-dashed [&>*:not(:first-child)]:pl-5 [&>*]:grow">
|
||||
<TokenStat
|
||||
value={
|
||||
typeof marketCap === "number"
|
||||
? marketCapFormatter.format(marketCap)
|
||||
: marketCap
|
||||
}
|
||||
skeletonData={"1000000000"}
|
||||
label="Market Cap"
|
||||
tooltip="Market capitalization is the total value of all tokens in circulation, calculated by multiplying the current price by the circulating supply"
|
||||
/>
|
||||
|
||||
<TokenStat
|
||||
skeletonData={"1000000000"}
|
||||
value={
|
||||
// show 0 value as N/A
|
||||
holders === 0
|
||||
? "N/A"
|
||||
: typeof holders === "number"
|
||||
? holdersFormatter.format(holders)
|
||||
: holders
|
||||
}
|
||||
label="Number of Holders"
|
||||
tooltip="The total number of unique wallet addresses that currently hold this token on the blockchain"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TokenStat<T extends string | number>(props: {
|
||||
value: T | undefined;
|
||||
skeletonData: T;
|
||||
label: string;
|
||||
tooltip: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<p className="text-muted-foreground text-sm">{props.label}</p>
|
||||
<ToolTipLabel label={props.tooltip}>
|
||||
<InfoIcon className="size-3.5 text-muted-foreground" />
|
||||
</ToolTipLabel>
|
||||
</div>
|
||||
<div className="flex">
|
||||
<SkeletonContainer
|
||||
skeletonData={props.skeletonData}
|
||||
loadedData={props.value}
|
||||
render={(v) => {
|
||||
return (
|
||||
<p className="font-semibold text-foreground text-xl tracking-tight">
|
||||
{v}
|
||||
</p>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
type Interval = "24h" | "7d" | "30d" | "1y" | "max";
|
||||
|
||||
function IntervalSelector(props: {
|
||||
interval: Interval;
|
||||
setInterval: (timeframe: Interval) => void;
|
||||
}) {
|
||||
const intervals: Record<Interval, string> = {
|
||||
"24h": "1D",
|
||||
"7d": "1W",
|
||||
"30d": "1M",
|
||||
"1y": "1Y",
|
||||
max: "MAX",
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex gap-2">
|
||||
{Object.entries(intervals).map(([key, value]) => (
|
||||
<Button
|
||||
key={key}
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"rounded-full",
|
||||
props.interval === key && "border-active-border bg-accent",
|
||||
)}
|
||||
size="sm"
|
||||
onClick={() => props.setInterval(key as Interval)}
|
||||
tabIndex={0}
|
||||
>
|
||||
{value}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
"use client";
|
||||
import { WalletAddress } from "@/components/blocks/wallet-address";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableContainer,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { formatDistanceToNow } from "date-fns";
|
||||
import {
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
ExternalLinkIcon,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { type ThirdwebContract, toTokens } from "thirdweb";
|
||||
import type { ChainMetadata } from "thirdweb/chains";
|
||||
import {
|
||||
type TokenTransfersData,
|
||||
useTokenTransfers,
|
||||
} from "../_hooks/useTokenTransfers";
|
||||
|
||||
const tokenAmountFormatter = new Intl.NumberFormat("en-US", {
|
||||
notation: "compact",
|
||||
maximumFractionDigits: 3,
|
||||
minimumFractionDigits: 0,
|
||||
});
|
||||
|
||||
function RecentTransfersUI(props: {
|
||||
data: TokenTransfersData[];
|
||||
tokenMetadata: {
|
||||
decimals: number;
|
||||
symbol: string;
|
||||
};
|
||||
isPending: boolean;
|
||||
rowsPerPage: number;
|
||||
page: number;
|
||||
setPage: (page: number) => void;
|
||||
explorerUrl: string;
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-4">
|
||||
<h2 className="font-semibold text-xl tracking-tight">
|
||||
Recent Transfers
|
||||
</h2>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Track all token transfers with detailed information about senders,
|
||||
recipients, amounts, and transaction timestamps
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<TableContainer className="rounded-b-none">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>From</TableHead>
|
||||
<TableHead>To</TableHead>
|
||||
<TableHead>Amount</TableHead>
|
||||
<TableHead>Time</TableHead>
|
||||
<TableHead>Transaction</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{props.isPending
|
||||
? Array.from({ length: props.rowsPerPage }).map((_, index) => (
|
||||
// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
|
||||
<SkeletonRow key={index} />
|
||||
))
|
||||
: props.data.map((transfer) => (
|
||||
<TableRow
|
||||
className="fade-in-0 animate-in duration-300"
|
||||
key={
|
||||
transfer.transaction_hash +
|
||||
transfer.amount +
|
||||
transfer.block_number +
|
||||
transfer.from_address
|
||||
}
|
||||
>
|
||||
<TableCell className="text-sm">
|
||||
<WalletAddress address={transfer.from_address} />
|
||||
</TableCell>
|
||||
<TableCell className="text-sm">
|
||||
<WalletAddress address={transfer.to_address} />
|
||||
</TableCell>
|
||||
<TableCell className="text-sm ">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span>
|
||||
{tokenAmountFormatter.format(
|
||||
Number(
|
||||
toTokens(
|
||||
BigInt(transfer.amount),
|
||||
props.tokenMetadata.decimals,
|
||||
),
|
||||
),
|
||||
)}
|
||||
</span>
|
||||
<span className="text-muted-foreground text-xs">
|
||||
{props.tokenMetadata.symbol}
|
||||
</span>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-sm">
|
||||
{formatDistanceToNow(
|
||||
new Date(
|
||||
transfer.block_timestamp.endsWith("Z")
|
||||
? transfer.block_timestamp
|
||||
: `${transfer.block_timestamp}Z`,
|
||||
),
|
||||
{
|
||||
addSuffix: true,
|
||||
},
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-8 w-8 p-0"
|
||||
asChild
|
||||
>
|
||||
<a
|
||||
href={`${props.explorerUrl}/tx/${transfer.transaction_hash}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={cn(
|
||||
"flex items-center justify-center",
|
||||
"hover:bg-accent hover:text-accent-foreground",
|
||||
)}
|
||||
>
|
||||
<ExternalLinkIcon className="h-4 w-4" />
|
||||
</a>
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
{props.data.length === 0 && !props.isPending && (
|
||||
<div className="flex w-full items-center justify-center py-20">
|
||||
<p className="text-muted-foreground">No transfers found</p>
|
||||
</div>
|
||||
)}
|
||||
</TableContainer>
|
||||
|
||||
<div className="flex items-center justify-end gap-3 rounded-b-lg border-x border-b bg-card px-6 py-5">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="gap-1.5 bg-background"
|
||||
disabled={props.page === 0 || props.isPending}
|
||||
onClick={() => props.setPage(props.page - 1)}
|
||||
>
|
||||
<ChevronLeftIcon className="size-4 text-muted-foreground" />
|
||||
Previous
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={props.isPending || props.data.length === 0}
|
||||
className="gap-1.5 bg-background"
|
||||
onClick={() => props.setPage(props.page + 1)}
|
||||
>
|
||||
Next
|
||||
<ChevronRightIcon className="size-4 text-muted-foreground" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SkeletonRow() {
|
||||
return (
|
||||
<TableRow className="fade-in-0 h-[73px] animate-in duration-300">
|
||||
<TableCell>
|
||||
<Skeleton className="h-6 w-[145px]" />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Skeleton className="h-6 w-[145px]" />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Skeleton className="h-6 w-32" />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Skeleton className="h-6 w-32" />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Skeleton className="h-6 w-6" />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
}
|
||||
|
||||
export function RecentTransfers(props: {
|
||||
clientContract: ThirdwebContract;
|
||||
tokenSymbol: string;
|
||||
chainMetadata: ChainMetadata;
|
||||
decimals: number;
|
||||
}) {
|
||||
const rowsPerPage = 10;
|
||||
const [page, setPage] = useState(0);
|
||||
const [hasFetchedOnce, setHasFetchedOnce] = useState(false);
|
||||
|
||||
const tokenQuery = useTokenTransfers({
|
||||
chainId: props.clientContract.chain.id,
|
||||
contractAddress: props.clientContract.address,
|
||||
page,
|
||||
limit: rowsPerPage,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
useEffect(() => {
|
||||
if (!tokenQuery.isPending) {
|
||||
setHasFetchedOnce(true);
|
||||
}
|
||||
}, [tokenQuery.isPending]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<RecentTransfersUI
|
||||
data={tokenQuery.data ?? []}
|
||||
isPending={tokenQuery.isPending && !hasFetchedOnce}
|
||||
rowsPerPage={rowsPerPage}
|
||||
tokenMetadata={{
|
||||
decimals: props.decimals,
|
||||
symbol: props.tokenSymbol,
|
||||
}}
|
||||
page={page}
|
||||
setPage={setPage}
|
||||
explorerUrl={
|
||||
props.chainMetadata.explorers?.[0]?.url ||
|
||||
`https://thirdweb.com/${props.chainMetadata.slug}`
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { storybookThirdwebClient } from "stories/utils";
|
||||
import { getContract } from "thirdweb";
|
||||
import { baseSepolia } from "thirdweb/chains";
|
||||
import { ThirdwebProvider } from "thirdweb/react";
|
||||
import { ClaimTokenCardUI } from "./claim-tokens-ui";
|
||||
|
||||
const meta = {
|
||||
title: "ERC20/ClaimTokenCardUI",
|
||||
component: Story,
|
||||
parameters: {
|
||||
nextjs: {
|
||||
appDirectory: true,
|
||||
},
|
||||
},
|
||||
decorators: [
|
||||
(Story) => (
|
||||
<ThirdwebProvider>
|
||||
<div className="py-10">
|
||||
<div className="mx-auto w-96">
|
||||
<Story />
|
||||
</div>
|
||||
</div>
|
||||
</ThirdwebProvider>
|
||||
),
|
||||
],
|
||||
} satisfies Meta<typeof Story>;
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
export const Variants: Story = {
|
||||
args: {},
|
||||
};
|
||||
|
||||
const mockContract = getContract({
|
||||
client: storybookThirdwebClient,
|
||||
chain: baseSepolia,
|
||||
address: "0xD6866d1EcB82D37556B6cFEc0dFE8800D8b4B50A",
|
||||
});
|
||||
|
||||
const claimConditionCurrency = {
|
||||
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
||||
decimals: 18,
|
||||
symbol: "ETH",
|
||||
};
|
||||
|
||||
const mockClaimCondition = {
|
||||
startTimestamp: 1747918865n,
|
||||
maxClaimableSupply:
|
||||
115792089237316195423570985008687907853269984665640564039457584007913129639935n,
|
||||
supplyClaimed: 790000000000000000000000n,
|
||||
quantityLimitPerWallet: 0n,
|
||||
merkleRoot:
|
||||
"0x369b56a08dc68160042e86415132e683545596577b2f6afa272046c18cbab38b",
|
||||
pricePerToken: 0n,
|
||||
currency: claimConditionCurrency.address,
|
||||
metadata: "ipfs://QmPgawkS1jYSudujQGzx2UbodZzNPbMgWto1LPEba1Pxpj/0",
|
||||
};
|
||||
|
||||
function Story() {
|
||||
return (
|
||||
<ClaimTokenCardUI
|
||||
contract={mockContract}
|
||||
name="Example Token"
|
||||
symbol="EXP"
|
||||
claimCondition={mockClaimCondition}
|
||||
claimConditionCurrency={claimConditionCurrency}
|
||||
chainMetadata={{
|
||||
stackType: "evm",
|
||||
chainId: 11155111,
|
||||
name: "Sepolia",
|
||||
chain: "ETH",
|
||||
shortName: "sep",
|
||||
nativeCurrency: {
|
||||
name: "Sepolia Ether",
|
||||
symbol: "ETH",
|
||||
decimals: 18,
|
||||
},
|
||||
rpc: ["https://11155111.rpc.thirdweb.com/${THIRDWEB_API_KEY}"],
|
||||
testnet: true,
|
||||
slug: "sepolia",
|
||||
}}
|
||||
decimals={18}
|
||||
/>
|
||||
);
|
||||
}
|
||||
+480
@@ -0,0 +1,480 @@
|
||||
"use client";
|
||||
import { Spinner } from "@/components/ui/Spinner/Spinner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DecimalInput } from "@/components/ui/decimal-input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { SkeletonContainer } from "@/components/ui/skeleton";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { TransactionButton } from "components/buttons/TransactionButton";
|
||||
import { useTrack } from "hooks/analytics/useTrack";
|
||||
import { CheckIcon, CircleIcon, ExternalLinkIcon, XIcon } from "lucide-react";
|
||||
import { useTheme } from "next-themes";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
type ThirdwebContract,
|
||||
padHex,
|
||||
sendAndConfirmTransaction,
|
||||
toTokens,
|
||||
waitForReceipt,
|
||||
} from "thirdweb";
|
||||
import type { ChainMetadata } from "thirdweb/chains";
|
||||
import {
|
||||
claimTo,
|
||||
type getActiveClaimCondition,
|
||||
getApprovalForTransaction,
|
||||
} from "thirdweb/extensions/erc20";
|
||||
import {
|
||||
useActiveAccount,
|
||||
useActiveWallet,
|
||||
useSendTransaction,
|
||||
} from "thirdweb/react";
|
||||
import { getClaimParams } from "thirdweb/utils";
|
||||
import { tryCatch } from "utils/try-catch";
|
||||
import { getSDKTheme } from "../../../../../../../../components/sdk-component-theme";
|
||||
import { PublicPageConnectButton } from "../../../_components/PublicPageConnectButton";
|
||||
import { getCurrencyMeta } from "../../_utils/getCurrencyMeta";
|
||||
|
||||
type ActiveClaimCondition = Awaited<ReturnType<typeof getActiveClaimCondition>>;
|
||||
|
||||
// TODO UI improvements - show how many tokens connected wallet can claim at max
|
||||
|
||||
export function ClaimTokenCardUI(props: {
|
||||
contract: ThirdwebContract;
|
||||
name: string;
|
||||
symbol: string | undefined;
|
||||
claimCondition: ActiveClaimCondition;
|
||||
chainMetadata: ChainMetadata;
|
||||
decimals: number;
|
||||
claimConditionCurrency: {
|
||||
decimals: number;
|
||||
symbol: string;
|
||||
};
|
||||
}) {
|
||||
const [quantity, setQuantity] = useState("1");
|
||||
const account = useActiveAccount();
|
||||
const activeWallet = useActiveWallet();
|
||||
const { theme } = useTheme();
|
||||
const trackEvent = useTrack();
|
||||
const sendClaimTx = useSendTransaction({
|
||||
payModal: {
|
||||
theme: getSDKTheme(theme === "light" ? "light" : "dark"),
|
||||
},
|
||||
});
|
||||
const [successScreen, setSuccessScreen] = useState<
|
||||
| undefined
|
||||
| {
|
||||
txHash: string;
|
||||
}
|
||||
>(undefined);
|
||||
|
||||
function trackAssetBuy(
|
||||
params:
|
||||
| {
|
||||
type: "attempt" | "success";
|
||||
}
|
||||
| {
|
||||
type: "error";
|
||||
errorMessage: string;
|
||||
},
|
||||
) {
|
||||
trackEvent({
|
||||
category: "asset",
|
||||
action: "buy",
|
||||
label: params.type,
|
||||
contractType: "DropERC20",
|
||||
accountAddress: account?.address,
|
||||
walletId: activeWallet?.id,
|
||||
chainId: props.contract.chain.id,
|
||||
...(params.type === "error"
|
||||
? {
|
||||
errorMessage: params.errorMessage,
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
}
|
||||
|
||||
const [stepsUI, setStepsUI] = useState<
|
||||
| undefined
|
||||
| {
|
||||
approve: undefined | "idle" | "pending" | "success" | "error";
|
||||
claim: "idle" | "pending" | "success" | "error";
|
||||
}
|
||||
>(undefined);
|
||||
|
||||
const approveAndClaim = useMutation({
|
||||
mutationFn: async () => {
|
||||
if (!account) {
|
||||
toast.error("Wallet is not connected");
|
||||
return;
|
||||
}
|
||||
|
||||
trackAssetBuy({
|
||||
type: "attempt",
|
||||
});
|
||||
|
||||
setStepsUI(undefined);
|
||||
|
||||
const transaction = claimTo({
|
||||
contract: props.contract,
|
||||
to: account.address,
|
||||
quantity: String(quantity),
|
||||
from: account.address,
|
||||
});
|
||||
|
||||
const approveTx = await getApprovalForTransaction({
|
||||
transaction,
|
||||
account,
|
||||
});
|
||||
|
||||
if (approveTx) {
|
||||
setStepsUI({
|
||||
approve: "pending",
|
||||
claim: "idle",
|
||||
});
|
||||
|
||||
const approveTxResult = await tryCatch(
|
||||
sendAndConfirmTransaction({
|
||||
transaction: approveTx,
|
||||
account,
|
||||
}),
|
||||
);
|
||||
|
||||
if (approveTxResult.error) {
|
||||
setStepsUI({
|
||||
approve: "error",
|
||||
claim: "idle",
|
||||
});
|
||||
|
||||
trackAssetBuy({
|
||||
type: "error",
|
||||
errorMessage: approveTxResult.error.message,
|
||||
});
|
||||
|
||||
console.error(approveTxResult.error);
|
||||
toast.error("Failed to approve spending", {
|
||||
description: approveTxResult.error.message,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setStepsUI({
|
||||
approve: "success",
|
||||
claim: "pending",
|
||||
});
|
||||
}
|
||||
|
||||
async function sendAndConfirm() {
|
||||
const result = await sendClaimTx.mutateAsync(transaction);
|
||||
return await waitForReceipt(result);
|
||||
}
|
||||
|
||||
setStepsUI({
|
||||
approve: approveTx ? "success" : undefined,
|
||||
claim: "pending",
|
||||
});
|
||||
|
||||
const claimTxResult = await tryCatch(sendAndConfirm());
|
||||
if (claimTxResult.error) {
|
||||
setStepsUI({
|
||||
approve: approveTx ? "success" : undefined,
|
||||
claim: "error",
|
||||
});
|
||||
|
||||
trackAssetBuy({
|
||||
type: "error",
|
||||
errorMessage: claimTxResult.error.message,
|
||||
});
|
||||
|
||||
console.error(claimTxResult.error);
|
||||
toast.error("Failed to buy tokens", {
|
||||
description: claimTxResult.error.message,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setStepsUI({
|
||||
approve: approveTx ? "success" : undefined,
|
||||
claim: "success",
|
||||
});
|
||||
|
||||
trackAssetBuy({
|
||||
type: "success",
|
||||
});
|
||||
|
||||
setSuccessScreen({
|
||||
txHash: claimTxResult.data.transactionHash,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const claimParamsQuery = useQuery({
|
||||
queryKey: ["claim-params", props.contract.address, account?.address],
|
||||
queryFn: async () => {
|
||||
const defaultPricing = {
|
||||
pricePerTokenWei: props.claimCondition.pricePerToken,
|
||||
currencyAddress: props.claimCondition.currency,
|
||||
decimals: props.claimConditionCurrency.decimals,
|
||||
symbol: props.claimConditionCurrency.symbol,
|
||||
};
|
||||
|
||||
if (!account) {
|
||||
return defaultPricing;
|
||||
}
|
||||
|
||||
const merkleRoot = props.claimCondition.merkleRoot;
|
||||
if (!merkleRoot || merkleRoot === padHex("0x", { size: 32 })) {
|
||||
return defaultPricing;
|
||||
}
|
||||
|
||||
const claimParams = await getClaimParams({
|
||||
contract: props.contract,
|
||||
to: account.address,
|
||||
quantity: 1n, // not relevant
|
||||
type: "erc20",
|
||||
tokenDecimals: props.decimals,
|
||||
from: account.address,
|
||||
});
|
||||
|
||||
const meta = await getCurrencyMeta({
|
||||
currencyAddress: claimParams.currency,
|
||||
chainMetadata: props.chainMetadata,
|
||||
chain: props.contract.chain,
|
||||
client: props.contract.client,
|
||||
});
|
||||
|
||||
return {
|
||||
pricePerTokenWei: claimParams.pricePerToken,
|
||||
currencyAddress: claimParams.currency,
|
||||
decimals: meta.decimals,
|
||||
symbol: meta.symbol,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
const claimParamsData = claimParamsQuery.data;
|
||||
|
||||
if (successScreen) {
|
||||
const explorerUrl =
|
||||
props.chainMetadata.explorers?.[0]?.url ??
|
||||
`https://thirdweb.com/${props.chainMetadata.slug}`;
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border bg-card p-6">
|
||||
{/* icon */}
|
||||
<div className="flex justify-center py-8">
|
||||
<div className="rounded-full border bg-background p-3">
|
||||
<CheckIcon className="size-8" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mb-12">
|
||||
<h2 className="mb-1 text-center font-bold text-xl">
|
||||
Purchase Successful
|
||||
</h2>
|
||||
<p className="text-center text-muted-foreground text-sm">
|
||||
You have successfully purchased {quantity}{" "}
|
||||
{props.symbol || "tokens"}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button className="w-full bg-muted/50" variant="outline" asChild>
|
||||
<Link
|
||||
href={`${explorerUrl}/tx/${successScreen.txHash}`}
|
||||
target="_blank"
|
||||
className="gap-1.5"
|
||||
>
|
||||
View Transaction{" "}
|
||||
<ExternalLinkIcon className="size-3.5 text-muted-foreground" />
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={() => setSuccessScreen(undefined)}
|
||||
className="mt-3 w-full"
|
||||
>
|
||||
Buy More
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border bg-card ">
|
||||
<div className="border-b px-4 py-5 lg:px-5">
|
||||
<h2 className="font-bold text-lg">Buy {props.symbol}</h2>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Buy tokens from the primary sale
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="p-4 lg:p-5">
|
||||
<div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="token-amount">Tokens</Label>
|
||||
<PriceInput
|
||||
quantity={quantity}
|
||||
setQuantity={setQuantity}
|
||||
id="token-amount"
|
||||
symbol={props.symbol}
|
||||
/>
|
||||
{/* <p className="text-xs text-muted-foreground">Maximum purchasable: {tokenData.maxPurchasable} tokens</p> */}
|
||||
</div>
|
||||
|
||||
<div className="h-4" />
|
||||
|
||||
<div className="space-y-3 rounded-lg bg-muted/50 p-3">
|
||||
{/* Price per token */}
|
||||
<div className="flex justify-between font-medium text-sm">
|
||||
<span>Price per token</span>
|
||||
|
||||
<SkeletonContainer
|
||||
skeletonData={`0.00 ${props.claimConditionCurrency.symbol}`}
|
||||
loadedData={
|
||||
claimParamsData
|
||||
? claimParamsData.pricePerTokenWei === 0n
|
||||
? "FREE"
|
||||
: `${toTokens(
|
||||
claimParamsData.pricePerTokenWei,
|
||||
claimParamsData.decimals,
|
||||
)} ${claimParamsData.symbol}`
|
||||
: undefined
|
||||
}
|
||||
render={(v) => {
|
||||
return <span className="">{v}</span>;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Quantity */}
|
||||
<div className="flex justify-between font-medium text-sm">
|
||||
<span>Quantity</span>
|
||||
<span>{quantity}</span>
|
||||
</div>
|
||||
|
||||
{/* Total Price */}
|
||||
<div className="border-active-border border-t border-dashed pt-4">
|
||||
<div className="flex justify-between font-semibold text-sm">
|
||||
<span>Total Price</span>
|
||||
<SkeletonContainer
|
||||
skeletonData={"0.00 ETH"}
|
||||
loadedData={
|
||||
claimParamsData
|
||||
? claimParamsData.pricePerTokenWei === 0n
|
||||
? "FREE"
|
||||
: `${
|
||||
Number(
|
||||
toTokens(
|
||||
claimParamsData.pricePerTokenWei,
|
||||
claimParamsData.decimals,
|
||||
),
|
||||
) * Number(quantity)
|
||||
} ${claimParamsData.symbol}`
|
||||
: undefined
|
||||
}
|
||||
render={(v) => {
|
||||
return <span>{v}</span>;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="h-6" />
|
||||
|
||||
{account ? (
|
||||
<TransactionButton
|
||||
transactionCount={undefined}
|
||||
checkBalance={false}
|
||||
isLoggedIn={true}
|
||||
isPending={approveAndClaim.isPending}
|
||||
onClick={async () => {
|
||||
approveAndClaim.mutate();
|
||||
}}
|
||||
variant="default"
|
||||
className="!w-full"
|
||||
txChainID={props.contract.chain.id}
|
||||
disabled={approveAndClaim.isPending || !claimParamsData}
|
||||
>
|
||||
Buy
|
||||
</TransactionButton>
|
||||
) : (
|
||||
<PublicPageConnectButton connectButtonClassName="!w-full" />
|
||||
)}
|
||||
|
||||
{/* only show steps if approval is required */}
|
||||
{stepsUI?.approve && (
|
||||
<div className="mt-6 border-t border-dashed pt-3">
|
||||
<h2 className="mb-2 font-semibold">Status</h2>
|
||||
<div className="space-y-2">
|
||||
{stepsUI.approve && (
|
||||
<StepUI title="Approve Spending" status={stepsUI.approve} />
|
||||
)}
|
||||
|
||||
{stepsUI.claim && (
|
||||
<StepUI title={"Buy Tokens"} status={stepsUI.claim} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
type Status = "idle" | "pending" | "success" | "error";
|
||||
|
||||
const statusToIcon: Record<Status, React.FC<{ className: string }>> = {
|
||||
pending: Spinner,
|
||||
success: CheckIcon,
|
||||
error: XIcon,
|
||||
idle: CircleIcon,
|
||||
};
|
||||
|
||||
function StepUI(props: {
|
||||
title: string;
|
||||
status: Status;
|
||||
}) {
|
||||
const Icon = statusToIcon[props.status];
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center gap-2",
|
||||
props.status === "pending" && "text-blue-500",
|
||||
props.status === "success" && "text-green-500",
|
||||
props.status === "error" && "text-red-500",
|
||||
)}
|
||||
>
|
||||
<Icon className="size-4" />
|
||||
<p className="font-medium text-sm">{props.title}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PriceInput(props: {
|
||||
quantity: string;
|
||||
setQuantity: (quantity: string) => void;
|
||||
id: string;
|
||||
symbol: string | undefined;
|
||||
}) {
|
||||
return (
|
||||
<div className="relative">
|
||||
<DecimalInput
|
||||
id={props.id}
|
||||
value={String(props.quantity)}
|
||||
onChange={(value) => {
|
||||
props.setQuantity(value);
|
||||
}}
|
||||
className="!text-2xl h-auto truncate bg-muted/50 pr-14 font-bold"
|
||||
/>
|
||||
{props.symbol && (
|
||||
<div className="-translate-y-1/2 absolute top-1/2 right-4 font-semibold text-base text-muted-foreground">
|
||||
{props.symbol}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
"use client";
|
||||
|
||||
import { ThirdwebAreaChart } from "@/components/blocks/charts/area-chart";
|
||||
import {} from "data/analytics/hooks";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
toolTipLabelFormatterWithPrecision,
|
||||
useContractAnalyticsOverview,
|
||||
} from "../../../../overview/components/Analytics";
|
||||
|
||||
export function ContractAnalyticsOverview(props: {
|
||||
contractAddress: string;
|
||||
chainId: number;
|
||||
chainSlug: string;
|
||||
}) {
|
||||
const [startDate] = useState(
|
||||
(() => {
|
||||
const date = new Date();
|
||||
date.setDate(date.getDate() - 14);
|
||||
return date;
|
||||
})(),
|
||||
);
|
||||
const [endDate] = useState(new Date());
|
||||
|
||||
const { data, precision, isPending } = useContractAnalyticsOverview({
|
||||
chainId: props.chainId,
|
||||
contractAddress: props.contractAddress,
|
||||
startDate,
|
||||
endDate,
|
||||
});
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex flex-col">
|
||||
<h2 className="font-semibold text-xl tracking-tight">Analytics</h2>
|
||||
<p className="mb-3 text-muted-foreground text-sm">
|
||||
View trends in unique wallets, transactions, and events over time for
|
||||
this contract
|
||||
</p>
|
||||
</div>
|
||||
<ThirdwebAreaChart
|
||||
className="border-none bg-background p-0"
|
||||
cardContentClassName="p-0"
|
||||
config={{
|
||||
wallets: {
|
||||
label: "Unique Wallets",
|
||||
color: "hsl(var(--chart-1))",
|
||||
},
|
||||
transactions: {
|
||||
label: "Transactions",
|
||||
color: "hsl(var(--chart-2))",
|
||||
},
|
||||
events: {
|
||||
label: "Events",
|
||||
color: "hsl(var(--chart-3))",
|
||||
},
|
||||
}}
|
||||
data={data || []}
|
||||
isPending={isPending}
|
||||
showLegend
|
||||
hideLabel={false}
|
||||
chartClassName="aspect-[1.5] lg:aspect-[3]"
|
||||
toolTipLabelFormatter={toolTipLabelFormatterWithPrecision(precision)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
import { isProd } from "@/constants/env-utils";
|
||||
import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "@/constants/public-envs";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
type TokenPriceData = {
|
||||
price_usd: number;
|
||||
price_usd_cents: number;
|
||||
percent_change_24h: number;
|
||||
market_cap_usd: number;
|
||||
volume_24h_usd: number;
|
||||
volume_change_24h: number;
|
||||
holders: number;
|
||||
historical_prices: Array<{
|
||||
date: string;
|
||||
price_usd: number;
|
||||
price_usd_cents: number;
|
||||
}>;
|
||||
};
|
||||
|
||||
export function useTokenPriceData(params: {
|
||||
chainId: number;
|
||||
contractAddress: string;
|
||||
}) {
|
||||
return useQuery({
|
||||
queryKey: ["token-price-chart", params.chainId, params.contractAddress],
|
||||
retry: false,
|
||||
retryOnMount: false,
|
||||
refetchOnWindowFocus: false,
|
||||
queryFn: async () => {
|
||||
const url = new URL(
|
||||
`https://insight.${isProd ? "thirdweb" : "thirdweb-dev"}.com/v1/tokens/price`,
|
||||
);
|
||||
|
||||
url.searchParams.set("include_historical_prices", "true");
|
||||
url.searchParams.set("chain_id", params.chainId.toString());
|
||||
url.searchParams.set("address", params.contractAddress);
|
||||
url.searchParams.set("include_holders", "true");
|
||||
url.searchParams.set("clientId", NEXT_PUBLIC_DASHBOARD_CLIENT_ID);
|
||||
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) {
|
||||
throw new Error(await res.text());
|
||||
}
|
||||
|
||||
const json = await res.json();
|
||||
const priceData = json.data[0] as TokenPriceData | undefined;
|
||||
return priceData
|
||||
? {
|
||||
type: "data-found" as const,
|
||||
data: priceData,
|
||||
}
|
||||
: { type: "no-data" as const };
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
});
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
import { isProd } from "@/constants/env-utils";
|
||||
import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "@/constants/public-envs";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
export type TokenTransfersData = {
|
||||
from_address: string;
|
||||
to_address: string;
|
||||
contract_address: string;
|
||||
block_number: string;
|
||||
block_timestamp: string;
|
||||
log_index: string;
|
||||
transaction_hash: string;
|
||||
transfer_type: string;
|
||||
chain_id: number;
|
||||
token_type: string;
|
||||
amount: string;
|
||||
};
|
||||
|
||||
export function useTokenTransfers(params: {
|
||||
chainId: number;
|
||||
contractAddress: string;
|
||||
page: number;
|
||||
limit: number;
|
||||
}) {
|
||||
return useQuery({
|
||||
queryKey: ["token-transfers", params],
|
||||
retry: false,
|
||||
retryOnMount: false,
|
||||
refetchOnWindowFocus: false,
|
||||
queryFn: async () => {
|
||||
const domain = isProd ? "thirdweb" : "thirdweb-dev";
|
||||
const url = new URL(
|
||||
`https://insight.${domain}.com/v1/tokens/transfers/${params.contractAddress}`,
|
||||
);
|
||||
|
||||
url.searchParams.set("include_historical_prices", "true");
|
||||
url.searchParams.set("chain_id", params.chainId.toString());
|
||||
url.searchParams.set("include_holders", "true");
|
||||
url.searchParams.set("page", params.page.toString());
|
||||
url.searchParams.set("limit", params.limit.toString());
|
||||
url.searchParams.set("clientId", NEXT_PUBLIC_DASHBOARD_CLIENT_ID);
|
||||
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) {
|
||||
throw new Error(await res.text());
|
||||
}
|
||||
|
||||
const json = await res.json();
|
||||
const data = json.data as TokenTransfersData[];
|
||||
return data;
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
});
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
import { type ThirdwebClient, getContract } from "thirdweb";
|
||||
import { NATIVE_TOKEN_ADDRESS } from "thirdweb";
|
||||
import { getAddress } from "thirdweb";
|
||||
import type { Chain, ChainMetadata } from "thirdweb/chains";
|
||||
import { symbol } from "thirdweb/extensions/common";
|
||||
import { decimals } from "thirdweb/extensions/erc20";
|
||||
|
||||
export async function getCurrencyMeta(params: {
|
||||
currencyAddress: string;
|
||||
chainMetadata: ChainMetadata;
|
||||
chain: Chain;
|
||||
client: ThirdwebClient;
|
||||
}): Promise<{
|
||||
decimals: number;
|
||||
symbol: string;
|
||||
}> {
|
||||
// if native token
|
||||
if (getAddress(params.currencyAddress) === getAddress(NATIVE_TOKEN_ADDRESS)) {
|
||||
return {
|
||||
decimals: params.chainMetadata.nativeCurrency.decimals,
|
||||
symbol: params.chainMetadata.nativeCurrency.symbol,
|
||||
};
|
||||
}
|
||||
|
||||
const currencyTokenContract = getContract({
|
||||
address: params.currencyAddress,
|
||||
chain: params.chain,
|
||||
client: params.client,
|
||||
});
|
||||
|
||||
const [currencyDecimals, currencySymbol] = await Promise.all([
|
||||
decimals({
|
||||
contract: currencyTokenContract,
|
||||
}),
|
||||
symbol({
|
||||
contract: currencyTokenContract,
|
||||
}),
|
||||
]);
|
||||
|
||||
return {
|
||||
decimals: currencyDecimals,
|
||||
symbol: currencySymbol,
|
||||
};
|
||||
}
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
import type { ThirdwebContract } from "thirdweb";
|
||||
import {} from "thirdweb";
|
||||
import type { ChainMetadata } from "thirdweb/chains";
|
||||
import { getContractMetadata } from "thirdweb/extensions/common";
|
||||
import { decimals, getActiveClaimCondition } from "thirdweb/extensions/erc20";
|
||||
import { PageHeader } from "../_components/PageHeader";
|
||||
import { ContractHeaderUI } from "./_components/ContractHeader";
|
||||
import { BuyTokenEmbed } from "./_components/PayEmbedSection";
|
||||
import { TokenStats } from "./_components/PriceChart";
|
||||
import { RecentTransfers } from "./_components/RecentTransfers";
|
||||
import { ClaimTokenCardUI } from "./_components/claim-tokens/claim-tokens-ui";
|
||||
import { ContractAnalyticsOverview } from "./_components/contract-analytics/contract-analytics";
|
||||
import { getCurrencyMeta } from "./_utils/getCurrencyMeta";
|
||||
|
||||
export async function ERC20PublicPage(props: {
|
||||
serverContract: ThirdwebContract;
|
||||
clientContract: ThirdwebContract;
|
||||
chainMetadata: ChainMetadata;
|
||||
}) {
|
||||
const [contractMetadata, activeClaimCondition, tokenDecimals] =
|
||||
await Promise.all([
|
||||
getContractMetadata({
|
||||
contract: props.serverContract,
|
||||
}),
|
||||
getActiveClaimConditionWithErrorHandler(props.serverContract),
|
||||
decimals({
|
||||
contract: props.serverContract,
|
||||
}),
|
||||
]);
|
||||
|
||||
const claimConditionCurrencyMeta = activeClaimCondition
|
||||
? await getCurrencyMeta({
|
||||
currencyAddress: activeClaimCondition.currency,
|
||||
chainMetadata: props.chainMetadata,
|
||||
chain: props.serverContract.chain,
|
||||
client: props.serverContract.client,
|
||||
}).catch(() => undefined)
|
||||
: undefined;
|
||||
|
||||
const buyEmbed = (
|
||||
<BuyEmbed
|
||||
clientContract={props.clientContract}
|
||||
chainMetadata={props.chainMetadata}
|
||||
tokenDecimals={tokenDecimals}
|
||||
tokenName={contractMetadata.name}
|
||||
tokenSymbol={contractMetadata.symbol}
|
||||
tokenAddress={props.clientContract.address}
|
||||
claimConditionMeta={
|
||||
activeClaimCondition && claimConditionCurrencyMeta
|
||||
? {
|
||||
activeClaimCondition,
|
||||
claimConditionCurrency: claimConditionCurrencyMeta,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<PageHeader />
|
||||
<div className="container flex max-w-8xl grow flex-col">
|
||||
<ContractHeaderUI
|
||||
chainMetadata={props.chainMetadata}
|
||||
clientContract={props.clientContract}
|
||||
image={contractMetadata.image}
|
||||
name={contractMetadata.name}
|
||||
symbol={contractMetadata.symbol}
|
||||
socialUrls={
|
||||
typeof contractMetadata.social_urls === "object" &&
|
||||
contractMetadata.social_urls !== null
|
||||
? contractMetadata.social_urls
|
||||
: {}
|
||||
}
|
||||
/>
|
||||
|
||||
<div className="h-6" />
|
||||
|
||||
<div className="flex flex-col gap-8 pb-20 xl:flex-row">
|
||||
<div className="flex grow flex-col gap-8 overflow-hidden">
|
||||
{activeClaimCondition ? (
|
||||
<div className="border-b border-dashed pb-6">
|
||||
<ContractAnalyticsOverview
|
||||
contractAddress={props.clientContract.address}
|
||||
chainId={props.chainMetadata.chainId}
|
||||
chainSlug={props.chainMetadata.slug}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<TokenStats
|
||||
chainId={props.chainMetadata.chainId}
|
||||
contractAddress={props.clientContract.address}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="xl:hidden">{buyEmbed}</div>
|
||||
|
||||
<RecentTransfers
|
||||
clientContract={props.clientContract}
|
||||
tokenSymbol={contractMetadata.symbol}
|
||||
chainMetadata={props.chainMetadata}
|
||||
decimals={tokenDecimals}
|
||||
/>
|
||||
|
||||
{!activeClaimCondition && (
|
||||
<ContractAnalyticsOverview
|
||||
contractAddress={props.clientContract.address}
|
||||
chainId={props.chainMetadata.chainId}
|
||||
chainSlug={props.chainMetadata.slug}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="hidden xl:block xl:w-96">
|
||||
<div className="-mt-6 sticky top-0 pt-6">{buyEmbed}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function BuyEmbed(props: {
|
||||
clientContract: ThirdwebContract;
|
||||
chainMetadata: ChainMetadata;
|
||||
tokenDecimals: number;
|
||||
tokenName: string;
|
||||
tokenSymbol: string;
|
||||
tokenAddress: string;
|
||||
claimConditionMeta:
|
||||
| {
|
||||
activeClaimCondition: ActiveClaimCondition;
|
||||
claimConditionCurrency: {
|
||||
decimals: number;
|
||||
symbol: string;
|
||||
};
|
||||
}
|
||||
| undefined;
|
||||
}) {
|
||||
if (!props.claimConditionMeta) {
|
||||
return (
|
||||
<BuyTokenEmbed
|
||||
client={props.clientContract.client}
|
||||
chain={props.clientContract.chain}
|
||||
tokenSymbol={props.tokenSymbol}
|
||||
tokenName={props.tokenName}
|
||||
tokenAddress={props.clientContract.address}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ClaimTokenCardUI
|
||||
contract={props.clientContract}
|
||||
decimals={props.tokenDecimals}
|
||||
name={props.tokenName}
|
||||
symbol={props.tokenSymbol}
|
||||
chainMetadata={props.chainMetadata}
|
||||
claimCondition={props.claimConditionMeta.activeClaimCondition}
|
||||
claimConditionCurrency={props.claimConditionMeta.claimConditionCurrency}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
async function getActiveClaimConditionWithErrorHandler(
|
||||
contract: ThirdwebContract,
|
||||
) {
|
||||
try {
|
||||
const activeClaimCondition = await getActiveClaimCondition({ contract });
|
||||
return activeClaimCondition;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
type ActiveClaimCondition = Awaited<ReturnType<typeof getActiveClaimCondition>>;
|
||||
+14
@@ -3,8 +3,10 @@ import { notFound } from "next/navigation";
|
||||
import type { ThirdwebContract } from "thirdweb";
|
||||
import { getPlatformFeeInfo } from "thirdweb/extensions/common";
|
||||
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { ContractSettingsPage } from "./ContractSettingsPage";
|
||||
import { ContractSettingsPageClient } from "./ContractSettingsPage.client";
|
||||
|
||||
@@ -24,6 +26,18 @@ export async function SharedContractSettingsPage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /settings page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const { clientContract, serverContract, isLocalhostChain } = info;
|
||||
|
||||
if (isLocalhostChain) {
|
||||
|
||||
+66
-33
@@ -11,6 +11,7 @@ import { NebulaChatButton } from "../../../../../nebula-app/(app)/components/Flo
|
||||
import { examplePrompts } from "../../../../../nebula-app/(app)/data/examplePrompts";
|
||||
import { getAuthTokenWalletAddress } from "../../../../api/lib/getAuthToken";
|
||||
import type { ProjectMeta } from "../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { TeamHeader } from "../../../../team/components/TeamHeader/team-header";
|
||||
import { ConfigureCustomChain } from "./_layout/ConfigureCustomChain";
|
||||
import { getContractMetadataHeaderData } from "./_layout/contract-metadata";
|
||||
import { ContractPageLayout } from "./_layout/contract-page-layout";
|
||||
@@ -19,6 +20,7 @@ import { supportedERCs } from "./_utils/detectedFeatures/supportedERCs";
|
||||
import { getContractPageParamsInfo } from "./_utils/getContractFromParams";
|
||||
import { getContractPageMetadata } from "./_utils/getContractPageMetadata";
|
||||
import { getContractPageSidebarLinks } from "./_utils/getContractPageSidebarLinks";
|
||||
import { shouldRenderNewPublicPage } from "./_utils/newPublicPage";
|
||||
|
||||
export async function SharedContractLayout(props: {
|
||||
contractAddress: string;
|
||||
@@ -53,17 +55,27 @@ export async function SharedContractLayout(props: {
|
||||
|
||||
if (isLocalhostChain) {
|
||||
return (
|
||||
<ContractPageLayoutClient
|
||||
chainMetadata={chainMetadata}
|
||||
contract={clientContract}
|
||||
teamsAndProjects={teamsAndProjects}
|
||||
projectMeta={props.projectMeta}
|
||||
>
|
||||
{props.children}
|
||||
</ContractPageLayoutClient>
|
||||
<ConditionalTeamHeaderLayout projectMeta={props.projectMeta}>
|
||||
<ContractPageLayoutClient
|
||||
chainMetadata={chainMetadata}
|
||||
contract={clientContract}
|
||||
teamsAndProjects={teamsAndProjects}
|
||||
projectMeta={props.projectMeta}
|
||||
>
|
||||
{props.children}
|
||||
</ContractPageLayoutClient>
|
||||
</ConditionalTeamHeaderLayout>
|
||||
);
|
||||
}
|
||||
|
||||
// if rendering new public page - do not render the old layout
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
return props.children;
|
||||
}
|
||||
}
|
||||
|
||||
const [
|
||||
isValidContract,
|
||||
contractPageMetadata,
|
||||
@@ -99,31 +111,33 @@ Users may be considering integrating the contract into their applications. Discu
|
||||
The following is the user's message:`;
|
||||
|
||||
return (
|
||||
<ContractPageLayout
|
||||
chainMetadata={chainMetadata}
|
||||
contract={clientContract}
|
||||
sidebarLinks={sidebarLinks}
|
||||
dashboardContractMetadata={contractMetadata}
|
||||
externalLinks={externalLinks}
|
||||
teamsAndProjects={teamsAndProjects}
|
||||
projectMeta={props.projectMeta}
|
||||
>
|
||||
<NebulaChatButton
|
||||
isLoggedIn={!!accountAddress}
|
||||
networks={info.chainMetadata.testnet ? "testnet" : "mainnet"}
|
||||
isFloating={true}
|
||||
pageType="contract"
|
||||
label="Ask AI about this contract"
|
||||
client={clientContract.client}
|
||||
nebulaParams={{
|
||||
messagePrefix: contractPromptPrefix,
|
||||
chainIds: [chainId],
|
||||
wallet: accountAddress ?? undefined,
|
||||
}}
|
||||
examplePrompts={examplePrompts}
|
||||
/>
|
||||
{props.children}
|
||||
</ContractPageLayout>
|
||||
<ConditionalTeamHeaderLayout projectMeta={props.projectMeta}>
|
||||
<ContractPageLayout
|
||||
chainMetadata={chainMetadata}
|
||||
contract={clientContract}
|
||||
sidebarLinks={sidebarLinks}
|
||||
dashboardContractMetadata={contractMetadata}
|
||||
externalLinks={externalLinks}
|
||||
teamsAndProjects={teamsAndProjects}
|
||||
projectMeta={props.projectMeta}
|
||||
>
|
||||
<NebulaChatButton
|
||||
isLoggedIn={!!accountAddress}
|
||||
networks={info.chainMetadata.testnet ? "testnet" : "mainnet"}
|
||||
isFloating={true}
|
||||
pageType="contract"
|
||||
label="Ask AI about this contract"
|
||||
client={clientContract.client}
|
||||
nebulaParams={{
|
||||
messagePrefix: contractPromptPrefix,
|
||||
chainIds: [chainId],
|
||||
wallet: accountAddress ?? undefined,
|
||||
}}
|
||||
examplePrompts={examplePrompts}
|
||||
/>
|
||||
{props.children}
|
||||
</ContractPageLayout>
|
||||
</ConditionalTeamHeaderLayout>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -216,3 +230,22 @@ export async function generateContractLayoutMetadata(params: {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function ConditionalTeamHeaderLayout({
|
||||
children,
|
||||
projectMeta,
|
||||
}: { children: React.ReactNode; projectMeta: ProjectMeta | undefined }) {
|
||||
// if inside a project page - do not another team header
|
||||
if (projectMeta) {
|
||||
return children;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
+45
@@ -1,11 +1,18 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import type { ThirdwebContract } from "thirdweb";
|
||||
import type { ChainMetadata } from "thirdweb/chains";
|
||||
import type { ProjectMeta } from "../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { getContractPageParamsInfo } from "./_utils/getContractFromParams";
|
||||
import { getContractPageMetadata } from "./_utils/getContractPageMetadata";
|
||||
import {
|
||||
type NewPublicPageType,
|
||||
shouldRenderNewPublicPage,
|
||||
} from "./_utils/newPublicPage";
|
||||
import { ContractOverviewPage } from "./overview/ContractOverviewPage";
|
||||
import { PublishedBy } from "./overview/components/published-by.server";
|
||||
import { ContractOverviewPageClient } from "./overview/contract-overview-page.client";
|
||||
import { ERC20PublicPage } from "./public-pages/erc20/erc20";
|
||||
|
||||
export async function SharedContractOverviewPage(props: {
|
||||
contractAddress: string;
|
||||
@@ -24,6 +31,7 @@ export async function SharedContractOverviewPage(props: {
|
||||
|
||||
const { clientContract, serverContract, chainMetadata, isLocalhostChain } =
|
||||
info;
|
||||
|
||||
if (isLocalhostChain) {
|
||||
return (
|
||||
<ContractOverviewPageClient
|
||||
@@ -34,6 +42,21 @@ export async function SharedContractOverviewPage(props: {
|
||||
);
|
||||
}
|
||||
|
||||
// for public page
|
||||
if (!props.projectMeta) {
|
||||
const renderNewPublicPage = await shouldRenderNewPublicPage(serverContract);
|
||||
if (renderNewPublicPage) {
|
||||
return (
|
||||
<RenderNewPublicContractPage
|
||||
serverContract={serverContract}
|
||||
clientContract={clientContract}
|
||||
chainMetadata={chainMetadata}
|
||||
type={renderNewPublicPage.type}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const contractPageMetadata = await getContractPageMetadata(serverContract);
|
||||
|
||||
return (
|
||||
@@ -59,3 +82,25 @@ export async function SharedContractOverviewPage(props: {
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function RenderNewPublicContractPage(props: {
|
||||
serverContract: ThirdwebContract;
|
||||
clientContract: ThirdwebContract;
|
||||
chainMetadata: ChainMetadata;
|
||||
type: NewPublicPageType;
|
||||
}) {
|
||||
switch (props.type) {
|
||||
case "erc20": {
|
||||
return (
|
||||
<ERC20PublicPage
|
||||
serverContract={props.serverContract}
|
||||
clientContract={props.clientContract}
|
||||
chainMetadata={props.chainMetadata}
|
||||
/>
|
||||
);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -1,6 +1,8 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { ContractSourcesPage } from "./ContractSourcesPage";
|
||||
|
||||
export async function SharedContractSourcesPage(props: {
|
||||
@@ -18,5 +20,17 @@ export async function SharedContractSourcesPage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /sources page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return <ContractSourcesPage contract={info.clientContract} />;
|
||||
}
|
||||
|
||||
+14
@@ -4,8 +4,10 @@ import {
|
||||
isMintToSupported,
|
||||
} from "thirdweb/extensions/erc20";
|
||||
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
|
||||
import { redirectToContractLandingPage } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/utils";
|
||||
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
|
||||
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
|
||||
import { shouldRenderNewPublicPage } from "../_utils/newPublicPage";
|
||||
import { ContractTokensPage } from "./ContractTokensPage";
|
||||
import { ContractTokensPageClient } from "./ContractTokensPage.client";
|
||||
|
||||
@@ -25,6 +27,18 @@ export async function SharedContractTokensPage(props: {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// new public page can't show /tokens page
|
||||
if (!props.projectMeta) {
|
||||
const shouldHide = await shouldRenderNewPublicPage(info.serverContract);
|
||||
if (shouldHide) {
|
||||
redirectToContractLandingPage({
|
||||
contractAddress: props.contractAddress,
|
||||
chainIdOrSlug: props.chainIdOrSlug,
|
||||
projectMeta: props.projectMeta,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (info.isLocalhostChain) {
|
||||
return (
|
||||
<ContractTokensPageClient
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TeamHeader } from "../../../../team/components/TeamHeader/team-header";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TeamHeader } from "../../../team/components/TeamHeader/team-header";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TeamHeader } from "../../team/components/TeamHeader/team-header";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TeamHeader } from "../../team/components/TeamHeader/team-header";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { AppFooter } from "@/components/blocks/app-footer";
|
||||
import { ErrorProvider } from "../../../contexts/error-handler";
|
||||
import { TeamHeader } from "../team/components/TeamHeader/team-header";
|
||||
|
||||
export default function DashboardLayout(props: {
|
||||
children: React.ReactNode;
|
||||
@@ -8,9 +7,6 @@ export default function DashboardLayout(props: {
|
||||
return (
|
||||
<ErrorProvider>
|
||||
<div className="flex min-h-dvh flex-col bg-background">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
<div className="flex grow flex-col">{props.children}</div>
|
||||
<AppFooter />
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TeamHeader } from "../../team/components/TeamHeader/team-header";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TeamHeader } from "../../team/components/TeamHeader/team-header";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TeamHeader } from "../../team/components/TeamHeader/team-header";
|
||||
|
||||
export default function Layout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { SidebarLayout } from "@/components/blocks/SidebarLayout";
|
||||
import type { Metadata } from "next";
|
||||
import { TeamHeader } from "../../team/components/TeamHeader/team-header";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "thirdweb Blockchain Tools",
|
||||
@@ -11,31 +12,36 @@ export default function ToolLayout({
|
||||
children,
|
||||
}: { children: React.ReactNode }) {
|
||||
return (
|
||||
<SidebarLayout
|
||||
sidebarLinks={[
|
||||
{
|
||||
label: "Transaction Simulator",
|
||||
href: "/tools/transaction-simulator",
|
||||
},
|
||||
{
|
||||
label: "Wei Converter",
|
||||
href: "/tools/wei-converter",
|
||||
},
|
||||
{
|
||||
label: "Hex Converter",
|
||||
href: "/tools/hex-converter",
|
||||
},
|
||||
{
|
||||
label: "Unix Time Converter",
|
||||
href: "/tools/unixtime-converter",
|
||||
},
|
||||
{
|
||||
label: "Keccak-256 Converter",
|
||||
href: "/tools/keccak256-converter",
|
||||
},
|
||||
]}
|
||||
>
|
||||
{children}
|
||||
</SidebarLayout>
|
||||
<div className="flex grow flex-col">
|
||||
<div className="border-border border-b bg-card">
|
||||
<TeamHeader />
|
||||
</div>
|
||||
<SidebarLayout
|
||||
sidebarLinks={[
|
||||
{
|
||||
label: "Transaction Simulator",
|
||||
href: "/tools/transaction-simulator",
|
||||
},
|
||||
{
|
||||
label: "Wei Converter",
|
||||
href: "/tools/wei-converter",
|
||||
},
|
||||
{
|
||||
label: "Hex Converter",
|
||||
href: "/tools/hex-converter",
|
||||
},
|
||||
{
|
||||
label: "Unix Time Converter",
|
||||
href: "/tools/unixtime-converter",
|
||||
},
|
||||
{
|
||||
label: "Keccak-256 Converter",
|
||||
href: "/tools/keccak256-converter",
|
||||
},
|
||||
]}
|
||||
>
|
||||
{children}
|
||||
</SidebarLayout>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { newAccountStub, teamStub } from "stories/stubs";
|
||||
import { newAccountStub } from "stories/stubs";
|
||||
import { storybookLog } from "stories/utils";
|
||||
import { AccountOnboardingLayout } from "../onboarding-layout";
|
||||
import { VerifyEmail } from "./VerifyEmail";
|
||||
@@ -60,7 +60,6 @@ function Story(props: {
|
||||
throw new Error("Example error");
|
||||
}
|
||||
return {
|
||||
team: teamStub("foo", "free"),
|
||||
account: newAccountStub(),
|
||||
};
|
||||
}}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
"use client";
|
||||
|
||||
import type { Team } from "@/api/team";
|
||||
import { Spinner } from "@/components/ui/Spinner/Spinner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
@@ -24,17 +22,11 @@ import {
|
||||
|
||||
type VerifyEmailProps = {
|
||||
email: string;
|
||||
onEmailConfirmed: (params: {
|
||||
team: Team;
|
||||
account: Account;
|
||||
}) => void;
|
||||
onEmailConfirmed: (params: { account: Account }) => void;
|
||||
onBack: () => void;
|
||||
verifyEmail: (params: {
|
||||
confirmationToken: string;
|
||||
}) => Promise<{
|
||||
team: Team;
|
||||
account: Account;
|
||||
}>;
|
||||
}) => Promise<{ account: Account }>;
|
||||
resendConfirmationEmail: () => Promise<void>;
|
||||
trackEvent: (params: TrackingParams) => void;
|
||||
accountAddress: string;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
"use client";
|
||||
|
||||
import type { Team } from "@/api/team";
|
||||
import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
|
||||
import type { TrackingParams } from "hooks/analytics/useTrack";
|
||||
import { useState } from "react";
|
||||
@@ -27,18 +25,12 @@ type AccountOnboardingScreen =
|
||||
};
|
||||
|
||||
type AccountOnboardingProps = {
|
||||
onComplete: (param: {
|
||||
team: Team;
|
||||
account: Account;
|
||||
}) => void;
|
||||
onComplete: (param: { account: Account }) => void;
|
||||
accountAddress: string;
|
||||
trackEvent: (params: TrackingParams) => void;
|
||||
verifyEmail: (params: {
|
||||
confirmationToken: string;
|
||||
}) => Promise<{
|
||||
team: Team;
|
||||
account: Account;
|
||||
}>;
|
||||
}) => Promise<{ account: Account }>;
|
||||
resendEmailConfirmation: () => Promise<void>;
|
||||
loginOrSignup: (input: {
|
||||
email: string;
|
||||
@@ -106,12 +98,7 @@ export function AccountOnboardingUI(props: AccountOnboardingProps) {
|
||||
verifyEmail={props.verifyEmail}
|
||||
resendConfirmationEmail={props.resendEmailConfirmation}
|
||||
trackEvent={props.trackEvent}
|
||||
onEmailConfirmed={(data) => {
|
||||
props.onComplete({
|
||||
team: data.team,
|
||||
account: data.account,
|
||||
});
|
||||
}}
|
||||
onEmailConfirmed={props.onComplete}
|
||||
onBack={() => setScreen(screen.backScreen)}
|
||||
email={screen.email}
|
||||
/>
|
||||
|
||||
+33
-61
@@ -97,7 +97,8 @@ export function InviteTeamMembersUI(props: {
|
||||
recommendedMembers={[]}
|
||||
customCTASection={
|
||||
<div className="flex gap-3">
|
||||
{props.team.billingPlan === "free" && (
|
||||
{(props.team.billingPlan === "free" ||
|
||||
props.team.billingPlan === "starter") && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="default"
|
||||
@@ -154,30 +155,8 @@ function InviteModalContent(props: {
|
||||
getTeam: () => Promise<Team>;
|
||||
teamId: string;
|
||||
}) {
|
||||
const [planToShow, setPlanToShow] = useState<
|
||||
"starter" | "growth" | "accelerate" | "scale"
|
||||
>("growth");
|
||||
|
||||
const starterPlan = (
|
||||
<PricingCard
|
||||
billingPlan="starter"
|
||||
billingStatus={props.billingStatus}
|
||||
teamSlug={props.teamSlug}
|
||||
cta={{
|
||||
label: "Get Started",
|
||||
type: "checkout",
|
||||
onClick() {
|
||||
props.trackEvent({
|
||||
category: "teamOnboarding",
|
||||
action: "upgradePlan",
|
||||
label: "attempt",
|
||||
plan: "starter",
|
||||
});
|
||||
},
|
||||
}}
|
||||
getTeam={props.getTeam}
|
||||
teamId={props.teamId}
|
||||
/>
|
||||
const [planToShow, setPlanToShow] = useState<"growth" | "scale" | "pro">(
|
||||
"growth",
|
||||
);
|
||||
|
||||
const growthPlan = (
|
||||
@@ -203,28 +182,6 @@ function InviteModalContent(props: {
|
||||
/>
|
||||
);
|
||||
|
||||
const acceleratePlan = (
|
||||
<PricingCard
|
||||
billingPlan="accelerate"
|
||||
billingStatus={props.billingStatus}
|
||||
teamSlug={props.teamSlug}
|
||||
cta={{
|
||||
label: "Get started",
|
||||
type: "checkout",
|
||||
onClick() {
|
||||
props.trackEvent({
|
||||
category: "teamOnboarding",
|
||||
action: "upgradePlan",
|
||||
label: "attempt",
|
||||
plan: "accelerate",
|
||||
});
|
||||
},
|
||||
}}
|
||||
getTeam={props.getTeam}
|
||||
teamId={props.teamId}
|
||||
/>
|
||||
);
|
||||
|
||||
const scalePlan = (
|
||||
<PricingCard
|
||||
billingPlan="scale"
|
||||
@@ -247,6 +204,28 @@ function InviteModalContent(props: {
|
||||
/>
|
||||
);
|
||||
|
||||
const proPlan = (
|
||||
<PricingCard
|
||||
billingPlan="pro"
|
||||
billingStatus={props.billingStatus}
|
||||
teamSlug={props.teamSlug}
|
||||
cta={{
|
||||
label: "Get started",
|
||||
type: "checkout",
|
||||
onClick() {
|
||||
props.trackEvent({
|
||||
category: "teamOnboarding",
|
||||
action: "upgradePlan",
|
||||
label: "attempt",
|
||||
plan: "pro",
|
||||
});
|
||||
},
|
||||
}}
|
||||
getTeam={props.getTeam}
|
||||
teamId={props.teamId}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<SheetHeader className="space-y-0.5">
|
||||
@@ -266,43 +245,36 @@ function InviteModalContent(props: {
|
||||
|
||||
{/* Desktop */}
|
||||
<div className="hidden grid-cols-1 gap-6 md:grid-cols-4 md:gap-4 lg:grid">
|
||||
{starterPlan}
|
||||
{growthPlan}
|
||||
{acceleratePlan}
|
||||
{scalePlan}
|
||||
{proPlan}
|
||||
</div>
|
||||
|
||||
{/* Mobile */}
|
||||
<div className="lg:hidden">
|
||||
<TabButtons
|
||||
tabs={[
|
||||
{
|
||||
name: "Starter",
|
||||
onClick: () => setPlanToShow("starter"),
|
||||
isActive: planToShow === "starter",
|
||||
},
|
||||
{
|
||||
name: "Growth",
|
||||
onClick: () => setPlanToShow("growth"),
|
||||
isActive: planToShow === "growth",
|
||||
},
|
||||
{
|
||||
name: "Accelerate",
|
||||
onClick: () => setPlanToShow("accelerate"),
|
||||
isActive: planToShow === "accelerate",
|
||||
},
|
||||
{
|
||||
name: "Scale",
|
||||
onClick: () => setPlanToShow("scale"),
|
||||
isActive: planToShow === "scale",
|
||||
},
|
||||
{
|
||||
name: "Pro",
|
||||
onClick: () => setPlanToShow("pro"),
|
||||
isActive: planToShow === "pro",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<div className="h-4" />
|
||||
{planToShow === "starter" && starterPlan}
|
||||
{planToShow === "growth" && growthPlan}
|
||||
{planToShow === "accelerate" && acceleratePlan}
|
||||
{planToShow === "scale" && scalePlan}
|
||||
{planToShow === "pro" && proPlan}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
+16
-26
@@ -85,7 +85,10 @@ export function InviteSection(props: {
|
||||
let bottomSection: React.ReactNode = null;
|
||||
const maxAllowedInvitesAtOnce = 10;
|
||||
// invites are enabled if user has edit permission and team plan is not "free"
|
||||
const inviteEnabled = teamPlan !== "free" && props.userHasEditPermission;
|
||||
const inviteEnabled =
|
||||
teamPlan !== "free" &&
|
||||
teamPlan !== "starter" &&
|
||||
props.userHasEditPermission;
|
||||
|
||||
const form = useForm<InviteFormValues>({
|
||||
resolver: zodResolver(inviteFormSchema),
|
||||
@@ -108,7 +111,7 @@ export function InviteSection(props: {
|
||||
},
|
||||
});
|
||||
|
||||
if (teamPlan === "free") {
|
||||
if (teamPlan === "free" || teamPlan === "starter") {
|
||||
bottomSection = (
|
||||
<div className="lg:px6 flex items-center justify-between gap-4 border-border border-t px-4 py-4">
|
||||
<p className="text-muted-foreground text-sm">
|
||||
@@ -127,7 +130,7 @@ export function InviteSection(props: {
|
||||
) : (
|
||||
<Button variant="outline" size="sm" asChild>
|
||||
<Link
|
||||
href={`/team/${props.team.slug}/~/settings/billing`}
|
||||
href={`/team/${props.team.slug}/~/settings/billing?showPlans=true&highlight=growth`}
|
||||
className="gap-2"
|
||||
>
|
||||
Upgrade
|
||||
@@ -147,29 +150,16 @@ export function InviteSection(props: {
|
||||
} else {
|
||||
bottomSection = (
|
||||
<div className="flex items-center border-border border-t px-4 py-4 lg:justify-between lg:px-6">
|
||||
{teamPlan === "pro" ? (
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Team members are billed according to your plan.{" "}
|
||||
<Link
|
||||
href="https://meetings.hubspot.com/sales-thirdweb/thirdweb-pro"
|
||||
target="_blank"
|
||||
className="text-link-foreground hover:text-foreground"
|
||||
>
|
||||
Reach out to sales <ExternalLinkIcon className="inline size-3" />.
|
||||
</Link>
|
||||
</p>
|
||||
) : (
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Team members are billed according to your plan.{" "}
|
||||
<Link
|
||||
href="https://thirdweb.com/pricing"
|
||||
target="_blank"
|
||||
className="text-link-foreground hover:text-foreground"
|
||||
>
|
||||
View pricing <ExternalLinkIcon className="inline size-3" />
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Team members are billed according to your plan.{" "}
|
||||
<Link
|
||||
href="https://thirdweb.com/pricing"
|
||||
target="_blank"
|
||||
className="text-link-foreground hover:text-foreground"
|
||||
>
|
||||
View pricing <ExternalLinkIcon className="inline size-3" />
|
||||
</Link>
|
||||
</p>
|
||||
|
||||
<div className="flex gap-3">
|
||||
{!props.shouldHideInviteButton && (
|
||||
|
||||
+45
-3
@@ -38,6 +38,8 @@ export function CreateTokenAssetPage(props: {
|
||||
client: ThirdwebClient;
|
||||
teamId: string;
|
||||
projectId: string;
|
||||
teamSlug: string;
|
||||
projectSlug: string;
|
||||
}) {
|
||||
const account = useActiveAccount();
|
||||
const { idToChain } = useAllChainsData();
|
||||
@@ -52,7 +54,18 @@ export function CreateTokenAssetPage(props: {
|
||||
}
|
||||
|
||||
trackEvent(
|
||||
getTokenDeploymentTrackingData("attempt", Number(formValues.chain)),
|
||||
getTokenStepTrackingData({
|
||||
action: "deploy",
|
||||
chainId: Number(formValues.chain),
|
||||
status: "attempt",
|
||||
}),
|
||||
);
|
||||
|
||||
trackEvent(
|
||||
getTokenDeploymentTrackingData({
|
||||
type: "attempt",
|
||||
chainId: Number(formValues.chain),
|
||||
}),
|
||||
);
|
||||
|
||||
const socialUrls = formValues.socialUrls.reduce(
|
||||
@@ -91,7 +104,18 @@ export function CreateTokenAssetPage(props: {
|
||||
});
|
||||
|
||||
trackEvent(
|
||||
getTokenDeploymentTrackingData("success", Number(formValues.chain)),
|
||||
getTokenStepTrackingData({
|
||||
action: "deploy",
|
||||
chainId: Number(formValues.chain),
|
||||
status: "success",
|
||||
}),
|
||||
);
|
||||
|
||||
trackEvent(
|
||||
getTokenDeploymentTrackingData({
|
||||
type: "success",
|
||||
chainId: Number(formValues.chain),
|
||||
}),
|
||||
);
|
||||
|
||||
// add contract to project in background
|
||||
@@ -111,7 +135,20 @@ export function CreateTokenAssetPage(props: {
|
||||
};
|
||||
} catch (e) {
|
||||
trackEvent(
|
||||
getTokenDeploymentTrackingData("error", Number(formValues.chain)),
|
||||
getTokenStepTrackingData({
|
||||
action: "deploy",
|
||||
chainId: Number(formValues.chain),
|
||||
status: "error",
|
||||
errorMessage: e instanceof Error ? e.message : "Unknown error",
|
||||
}),
|
||||
);
|
||||
|
||||
trackEvent(
|
||||
getTokenDeploymentTrackingData({
|
||||
type: "error",
|
||||
chainId: Number(formValues.chain),
|
||||
errorMessage: e instanceof Error ? e.message : "Unknown error",
|
||||
}),
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
@@ -175,6 +212,7 @@ export function CreateTokenAssetPage(props: {
|
||||
action: "airdrop",
|
||||
chainId: Number(formValues.chain),
|
||||
status: "error",
|
||||
errorMessage: e instanceof Error ? e.message : "Unknown error",
|
||||
}),
|
||||
);
|
||||
throw e;
|
||||
@@ -244,6 +282,7 @@ export function CreateTokenAssetPage(props: {
|
||||
action: "mint",
|
||||
chainId: Number(formValues.chain),
|
||||
status: "error",
|
||||
errorMessage: e instanceof Error ? e.message : "Unknown error",
|
||||
}),
|
||||
);
|
||||
throw e;
|
||||
@@ -342,6 +381,7 @@ export function CreateTokenAssetPage(props: {
|
||||
action: "claim-conditions",
|
||||
chainId: Number(formValues.chain),
|
||||
status: "error",
|
||||
errorMessage: e instanceof Error ? e.message : "Unknown error",
|
||||
}),
|
||||
);
|
||||
throw e;
|
||||
@@ -352,6 +392,8 @@ export function CreateTokenAssetPage(props: {
|
||||
<CreateTokenAssetPageUI
|
||||
accountAddress={props.accountAddress}
|
||||
client={props.client}
|
||||
teamSlug={props.teamSlug}
|
||||
projectSlug={props.projectSlug}
|
||||
onLaunchSuccess={() => {
|
||||
revalidatePathAction(
|
||||
`/team/${props.teamId}/project/${props.projectId}/assets`,
|
||||
|
||||
+4
@@ -35,6 +35,8 @@ export function CreateTokenAssetPageUI(props: {
|
||||
client: ThirdwebClient;
|
||||
createTokenFunctions: CreateTokenFunctions;
|
||||
onLaunchSuccess: () => void;
|
||||
teamSlug: string;
|
||||
projectSlug: string;
|
||||
}) {
|
||||
const [step, setStep] = useState<"token-info" | "distribution" | "launch">(
|
||||
"token-info",
|
||||
@@ -114,6 +116,8 @@ export function CreateTokenAssetPageUI(props: {
|
||||
|
||||
{step === "launch" && (
|
||||
<LaunchTokenStatus
|
||||
teamSlug={props.teamSlug}
|
||||
projectSlug={props.projectSlug}
|
||||
client={props.client}
|
||||
onLaunchSuccess={props.onLaunchSuccess}
|
||||
onPrevious={() => {
|
||||
|
||||
+4
@@ -41,6 +41,8 @@ const mockCreateTokenFunctions = {
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
accountAddress: "0x1234567890123456789012345678901234567890",
|
||||
teamSlug: "test-team",
|
||||
projectSlug: "test-project",
|
||||
client: storybookThirdwebClient,
|
||||
createTokenFunctions: mockCreateTokenFunctions,
|
||||
onLaunchSuccess: () => {},
|
||||
@@ -50,6 +52,8 @@ export const Default: Story = {
|
||||
export const ErrorOnDeploy: Story = {
|
||||
args: {
|
||||
accountAddress: "0x1234567890123456789012345678901234567890",
|
||||
teamSlug: "test-team",
|
||||
projectSlug: "test-project",
|
||||
client: storybookThirdwebClient,
|
||||
onLaunchSuccess: () => {},
|
||||
createTokenFunctions: {
|
||||
|
||||
+1
-36
@@ -3,7 +3,7 @@
|
||||
import { FormFieldSetup } from "@/components/blocks/FormFieldSetup";
|
||||
import { TokenSelector } from "@/components/blocks/TokenSelector";
|
||||
import { DynamicHeight } from "@/components/ui/DynamicHeight";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { DecimalInput } from "@/components/ui/decimal-input";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import type { ThirdwebClient } from "thirdweb";
|
||||
import type { TokenDistributionForm } from "../form";
|
||||
@@ -112,38 +112,3 @@ export function TokenSaleSection(props: {
|
||||
</DynamicHeight>
|
||||
);
|
||||
}
|
||||
|
||||
function DecimalInput(props: {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
maxValue?: number;
|
||||
}) {
|
||||
return (
|
||||
<Input
|
||||
type="text"
|
||||
value={props.value}
|
||||
inputMode="decimal"
|
||||
onChange={(e) => {
|
||||
const number = Number(e.target.value);
|
||||
// ignore if string becomes invalid number
|
||||
if (Number.isNaN(number)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (props.maxValue && number > props.maxValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
// replace leading multiple zeros with single zero
|
||||
let cleanedValue = e.target.value.replace(/^0+/, "0");
|
||||
|
||||
// replace leading zero before decimal point
|
||||
if (!cleanedValue.includes(".")) {
|
||||
cleanedValue = cleanedValue.replace(/^0+/, "");
|
||||
}
|
||||
|
||||
props.onChange(cleanedValue || "0");
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
+27
-6
@@ -33,6 +33,8 @@ export function LaunchTokenStatus(props: {
|
||||
onPrevious: () => void;
|
||||
client: ThirdwebClient;
|
||||
onLaunchSuccess: () => void;
|
||||
teamSlug: string;
|
||||
projectSlug: string;
|
||||
}) {
|
||||
const formValues = props.values;
|
||||
const { createTokenFunctions } = props;
|
||||
@@ -44,18 +46,29 @@ export function LaunchTokenStatus(props: {
|
||||
const trackEvent = useTrack();
|
||||
|
||||
async function handleSubmitClick() {
|
||||
function launchTracking(type: "attempt" | "success" | "error") {
|
||||
function launchTracking(
|
||||
params:
|
||||
| {
|
||||
type: "attempt" | "success";
|
||||
}
|
||||
| {
|
||||
type: "error";
|
||||
errorMessage: string;
|
||||
},
|
||||
) {
|
||||
trackEvent(
|
||||
getLaunchTrackingData({
|
||||
chainId: Number(formValues.chain),
|
||||
airdropEnabled: formValues.airdropEnabled,
|
||||
saleEnabled: formValues.saleEnabled,
|
||||
type,
|
||||
...params,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
launchTracking("attempt");
|
||||
launchTracking({
|
||||
type: "attempt",
|
||||
});
|
||||
|
||||
function updateStatus(index: number, newStatus: MultiStepState["status"]) {
|
||||
setSteps((prev) => {
|
||||
@@ -82,12 +95,18 @@ export function LaunchTokenStatus(props: {
|
||||
// do not use await next step
|
||||
nextStep.execute();
|
||||
} else {
|
||||
launchTracking("success");
|
||||
launchTracking({
|
||||
type: "success",
|
||||
});
|
||||
props.onLaunchSuccess();
|
||||
}
|
||||
} catch (error) {
|
||||
updateStatus(index, "error");
|
||||
launchTracking("error");
|
||||
launchTracking({
|
||||
type: "error",
|
||||
errorMessage:
|
||||
error instanceof Error ? error.message : "Unknown error",
|
||||
});
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
@@ -100,7 +119,9 @@ export function LaunchTokenStatus(props: {
|
||||
retryLabel: "Failed to deploy contract",
|
||||
execute: createSequenceExecutorFn(0, async (values) => {
|
||||
const result = await createTokenFunctions.deployContract(values);
|
||||
setContractLink(`/${values.chain}/${result.contractAddress}`);
|
||||
setContractLink(
|
||||
`/team/${props.teamSlug}/${props.projectSlug}/contract/${values.chain}/${result.contractAddress}`,
|
||||
);
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
||||
+2
@@ -57,6 +57,8 @@ export default async function Page(props: {
|
||||
/>
|
||||
<div className="container max-w-5xl pt-8 pb-32">
|
||||
<CreateTokenAssetPage
|
||||
teamSlug={params.team_slug}
|
||||
projectSlug={params.project_slug}
|
||||
accountAddress={accountAddress}
|
||||
client={client}
|
||||
teamId={team.id}
|
||||
|
||||
+52
-15
@@ -1,40 +1,72 @@
|
||||
export function getTokenDeploymentTrackingData(
|
||||
type: "attempt" | "success" | "error",
|
||||
chainId: number,
|
||||
params: {
|
||||
chainId: number;
|
||||
} & (
|
||||
| {
|
||||
type: "attempt" | "success";
|
||||
}
|
||||
| {
|
||||
type: "error";
|
||||
errorMessage: string;
|
||||
}
|
||||
),
|
||||
) {
|
||||
// using "custom-contract" because it has to match the main deployment tracking format
|
||||
return {
|
||||
category: "custom-contract",
|
||||
action: "deploy",
|
||||
label: type,
|
||||
label: params.type,
|
||||
publisherAndContractName: "deployer.thirdweb.eth/DropERC20",
|
||||
chainId: chainId,
|
||||
chainId: params.chainId,
|
||||
deploymentType: "asset",
|
||||
};
|
||||
}
|
||||
|
||||
// example: asset.claim-conditions.attempt
|
||||
export function getTokenStepTrackingData(params: {
|
||||
action: "claim-conditions" | "airdrop" | "mint";
|
||||
chainId: number;
|
||||
status: "attempt" | "success" | "error";
|
||||
}) {
|
||||
export function getTokenStepTrackingData(
|
||||
params: {
|
||||
action: "claim-conditions" | "airdrop" | "mint" | "deploy";
|
||||
chainId: number;
|
||||
} & (
|
||||
| {
|
||||
status: "attempt" | "success";
|
||||
}
|
||||
| {
|
||||
status: "error";
|
||||
errorMessage: string;
|
||||
}
|
||||
),
|
||||
) {
|
||||
return {
|
||||
category: "asset",
|
||||
action: params.action,
|
||||
contractType: "DropERC20",
|
||||
label: params.status,
|
||||
chainId: params.chainId,
|
||||
...(params.status === "error"
|
||||
? {
|
||||
errorMessage: params.errorMessage,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
// example: asset.launch.attempt
|
||||
export function getLaunchTrackingData(params: {
|
||||
chainId: number;
|
||||
airdropEnabled: boolean;
|
||||
saleEnabled: boolean;
|
||||
type: "attempt" | "success" | "error";
|
||||
}) {
|
||||
export function getLaunchTrackingData(
|
||||
params: {
|
||||
chainId: number;
|
||||
airdropEnabled: boolean;
|
||||
saleEnabled: boolean;
|
||||
} & (
|
||||
| {
|
||||
type: "attempt" | "success";
|
||||
}
|
||||
| {
|
||||
type: "error";
|
||||
errorMessage: string;
|
||||
}
|
||||
),
|
||||
) {
|
||||
return {
|
||||
category: "asset",
|
||||
action: "launch",
|
||||
@@ -43,6 +75,11 @@ export function getLaunchTrackingData(params: {
|
||||
chainId: params.chainId,
|
||||
airdropEnabled: params.airdropEnabled,
|
||||
saleEnabled: params.saleEnabled,
|
||||
...(params.type === "error"
|
||||
? {
|
||||
errorMessage: params.errorMessage,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { BadgeContainer } from "stories/utils";
|
||||
import type { EngineCloudStats } from "types/analytics";
|
||||
import { EngineCloudBarChartCardUI } from "./EngineCloudBarChartCardUI";
|
||||
|
||||
const meta = {
|
||||
title: "Analytics/EngineCloudBarChartCard",
|
||||
component: Component,
|
||||
} satisfies Meta<typeof Component>;
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Variants: Story = {
|
||||
parameters: {
|
||||
viewport: { defaultViewport: "desktop" },
|
||||
},
|
||||
};
|
||||
|
||||
const generateTimeSeriesData = (days: number, pathnames: string[]) => {
|
||||
const data: EngineCloudStats[] = [];
|
||||
const today = new Date();
|
||||
|
||||
for (let i = days - 1; i >= 0; i--) {
|
||||
const date = new Date(today);
|
||||
date.setDate(date.getDate() - i);
|
||||
const dateStr = date.toISOString().split("T")[0];
|
||||
for (const pathname of pathnames) {
|
||||
data.push({
|
||||
// biome-ignore lint/style/noNonNullAssertion: we know this is not null
|
||||
date: dateStr!,
|
||||
chainId: "84532",
|
||||
pathname,
|
||||
totalRequests: Math.floor(Math.random() * 1000) + 100,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
function Component() {
|
||||
return (
|
||||
<div className="container max-w-6xl space-y-10 py-10">
|
||||
<BadgeContainer label="Multiple Pathnames">
|
||||
<EngineCloudBarChartCardUI
|
||||
rawData={generateTimeSeriesData(30, [
|
||||
"/v1/write/transaction",
|
||||
"/v1/sign/transaction",
|
||||
"/v1/sign/message",
|
||||
])}
|
||||
/>
|
||||
</BadgeContainer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
"use client";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import {
|
||||
type ChartConfig,
|
||||
ChartContainer,
|
||||
ChartTooltip,
|
||||
ChartTooltipContent,
|
||||
} from "@/components/ui/chart";
|
||||
import { formatDate } from "date-fns";
|
||||
import { useMemo } from "react";
|
||||
import {
|
||||
Bar,
|
||||
CartesianGrid,
|
||||
BarChart as RechartsBarChart,
|
||||
XAxis,
|
||||
} from "recharts";
|
||||
import type { EngineCloudStats } from "types/analytics";
|
||||
import { EmptyStateCard } from "../../../../../components/Analytics/EmptyStateCard";
|
||||
|
||||
export function EngineCloudBarChartCardUI({
|
||||
rawData,
|
||||
}: { rawData: EngineCloudStats[] }) {
|
||||
const { data, pathnames, chartConfig, isAllEmpty } = useMemo(() => {
|
||||
// Dynamically collect all unique pathnames
|
||||
const pathnameSet = new Set<string>();
|
||||
for (const item of rawData) {
|
||||
// Ignore empty pathname ''.
|
||||
if (item.pathname) {
|
||||
pathnameSet.add(item.pathname);
|
||||
}
|
||||
}
|
||||
const pathnames = Array.from(pathnameSet);
|
||||
|
||||
// Group by date, then by pathname
|
||||
const dateMap = new Map<string, Record<string, number>>();
|
||||
for (const { date, pathname, totalRequests } of rawData) {
|
||||
const map = dateMap.get(date) ?? {};
|
||||
map[pathname] = Number(totalRequests) || 0;
|
||||
dateMap.set(date, map);
|
||||
}
|
||||
|
||||
// Build data array for recharts
|
||||
const data = Array.from(dateMap.entries()).map(([date, value]) => {
|
||||
let total = 0;
|
||||
for (const pathname of pathnames) {
|
||||
if (!value[pathname]) value[pathname] = 0;
|
||||
total += value[pathname];
|
||||
}
|
||||
return { date, ...value, total };
|
||||
});
|
||||
|
||||
// Chart config
|
||||
const chartConfig: ChartConfig = {};
|
||||
for (const pathname of pathnames) {
|
||||
chartConfig[pathname] = { label: pathname };
|
||||
}
|
||||
|
||||
return {
|
||||
data,
|
||||
pathnames,
|
||||
chartConfig,
|
||||
isAllEmpty: data.every((d) => d.total === 0),
|
||||
};
|
||||
}, [rawData]);
|
||||
|
||||
if (data.length === 0 || isAllEmpty) {
|
||||
return <EmptyStateCard metric="RPC" link="https://portal.thirdweb.com/" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="flex flex-col items-stretch space-y-0 border-b p-0">
|
||||
<div className="flex flex-1 flex-col justify-center gap-1 p-6">
|
||||
<CardTitle className="font-semibold text-lg">
|
||||
Engine Cloud Requests
|
||||
</CardTitle>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="px-2 sm:p-6 sm:pl-0">
|
||||
<ChartContainer
|
||||
config={chartConfig}
|
||||
className="aspect-auto h-[250px] w-full pt-6"
|
||||
>
|
||||
<RechartsBarChart
|
||||
accessibilityLayer
|
||||
data={data}
|
||||
margin={{
|
||||
left: 12,
|
||||
right: 12,
|
||||
}}
|
||||
>
|
||||
<CartesianGrid vertical={false} />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tickLine={false}
|
||||
axisLine={false}
|
||||
tickMargin={8}
|
||||
minTickGap={32}
|
||||
tickFormatter={(value: string) => {
|
||||
const date = new Date(value);
|
||||
return date.toLocaleDateString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ChartTooltip
|
||||
content={
|
||||
<ChartTooltipContent
|
||||
labelFormatter={(d) => formatDate(new Date(d), "MMM d")}
|
||||
valueFormatter={(_value) => {
|
||||
const value = typeof _value === "number" ? _value : 0;
|
||||
return <span className="inline-flex gap-1.5">{value}</span>;
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{pathnames.map((pathname, idx) => (
|
||||
<Bar
|
||||
key={pathname}
|
||||
stackId="a"
|
||||
dataKey={pathname}
|
||||
radius={[
|
||||
idx === pathnames.length - 1 ? 4 : 0,
|
||||
idx === pathnames.length - 1 ? 4 : 0,
|
||||
idx === 0 ? 4 : 0,
|
||||
idx === 0 ? 4 : 0,
|
||||
]}
|
||||
fill={`hsl(var(--chart-${idx + 1}))`}
|
||||
strokeWidth={1}
|
||||
className="stroke-background"
|
||||
/>
|
||||
))}
|
||||
</RechartsBarChart>
|
||||
</ChartContainer>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { getEngineCloudMethodUsage } from "@/api/analytics";
|
||||
import { LoadingChartState } from "components/analytics/empty-chart-state";
|
||||
import { Suspense } from "react";
|
||||
import type { AnalyticsQueryParams } from "types/analytics";
|
||||
import { EngineCloudBarChartCardUI } from "./EngineCloudBarChartCardUI";
|
||||
|
||||
export function EngineCloudChartCard(props: AnalyticsQueryParams) {
|
||||
return (
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="h-[400px]">
|
||||
<LoadingChartState />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<EngineCloudChartCardAsync {...props} />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
async function EngineCloudChartCardAsync(props: AnalyticsQueryParams) {
|
||||
const rawData = await getEngineCloudMethodUsage(props);
|
||||
|
||||
return <EngineCloudBarChartCardUI rawData={rawData} />;
|
||||
}
|
||||
+1
-5
@@ -75,11 +75,7 @@ export function ProjectSidebarLayout(props: {
|
||||
},
|
||||
{
|
||||
href: `${layoutPath}/engine`,
|
||||
label: (
|
||||
<span className="flex items-center gap-2">
|
||||
Engine <Badge>New</Badge>
|
||||
</span>
|
||||
),
|
||||
label: "Engine",
|
||||
icon: EngineIcon,
|
||||
tracking: tracking("engine"),
|
||||
},
|
||||
|
||||
-81
@@ -1,9 +1,6 @@
|
||||
import type { Team } from "@/api/team";
|
||||
import { UnderlineLink } from "@/components/ui/UnderlineLink";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { TrackedLinkTW } from "@/components/ui/tracked-link";
|
||||
import { PRO_CONTACT_US_URL } from "constants/pro";
|
||||
import { ArrowRightIcon, DownloadIcon, ExternalLinkIcon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
|
||||
@@ -77,74 +74,6 @@ function EngineInfoSection(props: { team_slug: string; project_slug: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
function CloudHostedEngineSection(props: {
|
||||
teamPlan: Exclude<Team["billingPlan"], "accelerate" | "scale">;
|
||||
teamSlug: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<h3 className="mb-0.5 font-semibold text-lg tracking-tight">
|
||||
Get Managed Engine
|
||||
</h3>
|
||||
|
||||
{props.teamPlan !== "pro" ? (
|
||||
<div>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Upgrade your plan to{" "}
|
||||
<UnderlineLink href="/pricing" target="_blank">
|
||||
Accelerate
|
||||
</UnderlineLink>{" "}
|
||||
or{" "}
|
||||
<UnderlineLink href="/pricing" target="_blank">
|
||||
Scale
|
||||
</UnderlineLink>{" "}
|
||||
to get a managed Engine instance
|
||||
</p>
|
||||
|
||||
<div className="h-5" />
|
||||
<div className="flex justify-start gap-3">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
asChild
|
||||
className="gap-2 bg-card"
|
||||
>
|
||||
<Link href={`/team/${props.teamSlug}/~/settings/billing`}>
|
||||
Upgrade Plan
|
||||
<ArrowRightIcon className="size-3 text-muted-foreground" />
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
asChild
|
||||
className="gap-2 bg-card"
|
||||
>
|
||||
<Link href="/pricing" target="_blank">
|
||||
View Pricing
|
||||
<ExternalLinkIcon className="size-3 text-muted-foreground" />
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<p className="mb-4 text-muted-foreground text-sm">
|
||||
Contact us to get a managed engine for your team
|
||||
</p>
|
||||
<Button variant="outline" size="sm" asChild className="gap-2">
|
||||
<Link href={PRO_CONTACT_US_URL} target="_blank">
|
||||
Contact Us
|
||||
<ExternalLinkIcon className="size-3 text-muted-foreground" />
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function EngineFooterCard(props: {
|
||||
teamPlan: Team["billingPlan"];
|
||||
team_slug: string;
|
||||
@@ -152,16 +81,6 @@ export function EngineFooterCard(props: {
|
||||
}) {
|
||||
return (
|
||||
<div className="relative rounded-lg border p-6">
|
||||
{props.teamPlan === "accelerate" || props.teamPlan === "scale" ? null : (
|
||||
<>
|
||||
<CloudHostedEngineSection
|
||||
teamPlan={props.teamPlan}
|
||||
teamSlug={props.team_slug}
|
||||
/>
|
||||
<Separator className="my-5" />
|
||||
</>
|
||||
)}
|
||||
|
||||
<EngineInfoSection
|
||||
team_slug={props.team_slug}
|
||||
project_slug={props.project_slug}
|
||||
|
||||
@@ -41,6 +41,7 @@ import { getAuthToken } from "../../../../api/lib/getAuthToken";
|
||||
import { loginRedirect } from "../../../../login/loginRedirect";
|
||||
import { CombinedBarChartCard } from "../../../components/Analytics/CombinedBarChartCard";
|
||||
import { PieChartCard } from "../../../components/Analytics/PieChartCard";
|
||||
import { EngineCloudChartCard } from "./components/EngineCloudChartCard";
|
||||
import { ProjectFTUX } from "./components/ProjectFTUX/ProjectFTUX";
|
||||
import { RpcMethodBarChartCard } from "./components/RpcMethodBarChartCard";
|
||||
import { TransactionsCharts } from "./components/Transactions";
|
||||
@@ -279,6 +280,13 @@ async function ProjectAnalytics(props: {
|
||||
teamId={project.teamId}
|
||||
projectId={project.id}
|
||||
/>
|
||||
<EngineCloudChartCard
|
||||
from={range.from}
|
||||
to={range.to}
|
||||
period={interval}
|
||||
teamId={project.teamId}
|
||||
projectId={project.id}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
+6
-1
@@ -41,9 +41,13 @@ import {
|
||||
|
||||
interface CreateWebhookModalProps {
|
||||
clientId: string;
|
||||
supportedChainIds: Array<number>;
|
||||
}
|
||||
|
||||
export function CreateWebhookModal({ clientId }: CreateWebhookModalProps) {
|
||||
export function CreateWebhookModal({
|
||||
clientId,
|
||||
supportedChainIds,
|
||||
}: CreateWebhookModalProps) {
|
||||
const router = useDashboardRouter();
|
||||
const thirdwebClient = useThirdwebClient();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
@@ -270,6 +274,7 @@ export function CreateWebhookModal({ clientId }: CreateWebhookModalProps) {
|
||||
goToNextStep={goToNextStep}
|
||||
goToPreviousStep={goToPreviousStep}
|
||||
isLoading={isLoading}
|
||||
supportedChainIds={supportedChainIds}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
+98
-95
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { MultiNetworkSelector } from "@/components/blocks/NetworkSelectors";
|
||||
import { Spinner } from "@/components/ui/Spinner/Spinner";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -13,17 +12,18 @@ import {
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { useThirdwebClient } from "@/constants/thirdweb.client";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import type { UseFormReturn } from "react-hook-form";
|
||||
|
||||
import { MultiNetworkSelector } from "@/components/blocks/NetworkSelectors";
|
||||
import { truncateMiddle } from "../utils/abiUtils";
|
||||
import type {
|
||||
AbiData,
|
||||
@@ -45,6 +45,75 @@ interface FilterDetailsStepProps {
|
||||
goToNextStep: () => void;
|
||||
goToPreviousStep: () => void;
|
||||
isLoading: boolean;
|
||||
supportedChainIds: Array<number>;
|
||||
}
|
||||
|
||||
interface SignatureDropdownProps {
|
||||
signatures: Array<{ name: string; signature: string; abi?: string }>;
|
||||
value: string;
|
||||
onChange: (val: string) => void;
|
||||
setAbi: (abi: string) => void;
|
||||
buttonLabel: string;
|
||||
secondaryTextFormatter: (sig: { name: string; signature: string }) => string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
function SignatureDropdown({
|
||||
signatures,
|
||||
value,
|
||||
onChange,
|
||||
setAbi,
|
||||
buttonLabel,
|
||||
secondaryTextFormatter,
|
||||
disabled,
|
||||
}: SignatureDropdownProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<Popover modal open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className={cn(
|
||||
"h-10 w-full rounded-md border bg-background px-3 py-2 text-left text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",
|
||||
!value && "text-muted-foreground",
|
||||
)}
|
||||
disabled={disabled}
|
||||
>
|
||||
{value
|
||||
? signatures.find((sig) => sig.signature === value)?.name || ""
|
||||
: buttonLabel}
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent
|
||||
className="max-h-60 w-[--radix-popover-trigger-width] overflow-y-auto p-0"
|
||||
align="start"
|
||||
>
|
||||
<ul className="divide-y divide-border">
|
||||
{signatures.map((sig) => (
|
||||
<li key={sig.signature}>
|
||||
<button
|
||||
type="button"
|
||||
className={cn(
|
||||
"w-full px-4 py-2 text-left text-sm hover:bg-accent focus:bg-accent",
|
||||
value === sig.signature && "bg-accent",
|
||||
)}
|
||||
onClick={() => {
|
||||
onChange(sig.signature);
|
||||
setAbi(sig.abi || "");
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
<div className="font-medium">{sig.name}</div>
|
||||
<div className="text-muted-foreground text-xs">
|
||||
{secondaryTextFormatter(sig)}
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
export function FilterDetailsStep({
|
||||
@@ -60,6 +129,7 @@ export function FilterDetailsStep({
|
||||
goToNextStep,
|
||||
goToPreviousStep,
|
||||
isLoading,
|
||||
supportedChainIds,
|
||||
}: FilterDetailsStepProps) {
|
||||
const thirdwebClient = useThirdwebClient();
|
||||
const queryClient = useQueryClient();
|
||||
@@ -106,6 +176,7 @@ export function FilterDetailsStep({
|
||||
}
|
||||
onChange={(chainIds) => field.onChange(chainIds.map(String))}
|
||||
client={thirdwebClient}
|
||||
chainIds={supportedChainIds}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
@@ -302,97 +373,29 @@ export function FilterDetailsStep({
|
||||
{watchFilterType === "event" &&
|
||||
Object.keys(fetchedAbis).length > 0 &&
|
||||
eventSignatures.length > 0 ? (
|
||||
<Select
|
||||
value={field.value}
|
||||
onValueChange={(value) => {
|
||||
field.onChange(value);
|
||||
// Find the selected event
|
||||
const selectedEvent = eventSignatures.find(
|
||||
(sig) => sig.signature === value,
|
||||
);
|
||||
// Set the ABI for the event
|
||||
form.setValue("sigHashAbi", selectedEvent?.abi || "");
|
||||
}}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select an event signature">
|
||||
{field.value
|
||||
? eventSignatures.find(
|
||||
(sig) => sig.signature === field.value,
|
||||
)?.name || ""
|
||||
: null}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent className="max-h-60 overflow-y-auto">
|
||||
{eventSignatures.map((event) => {
|
||||
// Truncate the hash for display purposes
|
||||
const truncatedHash = truncateMiddle(
|
||||
event.signature,
|
||||
6,
|
||||
4,
|
||||
);
|
||||
|
||||
return (
|
||||
<SelectItem
|
||||
key={event.signature}
|
||||
value={event.signature}
|
||||
title={event.name}
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<span className="font-medium">{event.name}</span>
|
||||
<span className="text-muted-foreground text-xs">
|
||||
Signature: {truncatedHash}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
);
|
||||
})}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<SignatureDropdown
|
||||
signatures={eventSignatures}
|
||||
value={field.value || ""}
|
||||
onChange={field.onChange}
|
||||
setAbi={(abi) => form.setValue("sigHashAbi", abi)}
|
||||
buttonLabel="Select an event signature"
|
||||
secondaryTextFormatter={(sig) =>
|
||||
`Signature: ${truncateMiddle(sig.signature, 6, 4)}`
|
||||
}
|
||||
/>
|
||||
) : watchFilterType === "transaction" &&
|
||||
Object.keys(fetchedTxAbis).length > 0 &&
|
||||
functionSignatures.length > 0 ? (
|
||||
<Select
|
||||
value={field.value}
|
||||
onValueChange={(value) => {
|
||||
field.onChange(value);
|
||||
// Find the selected function
|
||||
const selectedFunction = functionSignatures.find(
|
||||
(sig) => sig.signature === value,
|
||||
);
|
||||
// Set the ABI for the function
|
||||
form.setValue("sigHashAbi", selectedFunction?.abi || "");
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="max-w-full">
|
||||
<SelectValue placeholder="Select a function signature">
|
||||
{field.value
|
||||
? functionSignatures.find(
|
||||
(sig) => sig.signature === field.value,
|
||||
)?.name || ""
|
||||
: null}
|
||||
</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent className="max-h-60 max-w-[600px] overflow-y-auto">
|
||||
{functionSignatures.map((func) => (
|
||||
<SelectItem
|
||||
key={func.signature}
|
||||
value={func.signature}
|
||||
title={func.signature}
|
||||
className="w-full overflow-x-auto"
|
||||
>
|
||||
<div className="flex w-full flex-col">
|
||||
<span className="overflow-x-auto whitespace-nowrap pb-1 font-medium">
|
||||
{func.name}
|
||||
</span>
|
||||
<span className="overflow-x-auto text-muted-foreground text-xs">
|
||||
Selector: {func.signature}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<SignatureDropdown
|
||||
signatures={functionSignatures}
|
||||
value={field.value || ""}
|
||||
onChange={field.onChange}
|
||||
setAbi={(abi) => form.setValue("sigHashAbi", abi)}
|
||||
buttonLabel="Select a function signature"
|
||||
secondaryTextFormatter={(sig) =>
|
||||
`Selector: ${sig.signature}`
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<Input
|
||||
placeholder={
|
||||
|
||||
+10
-2
@@ -32,9 +32,14 @@ function getEventType(filters: WebhookFilters): string {
|
||||
interface WebhooksTableProps {
|
||||
webhooks: WebhookResponse[];
|
||||
clientId: string;
|
||||
supportedChainIds: number[];
|
||||
}
|
||||
|
||||
export function WebhooksTable({ webhooks, clientId }: WebhooksTableProps) {
|
||||
export function WebhooksTable({
|
||||
webhooks,
|
||||
clientId,
|
||||
supportedChainIds,
|
||||
}: WebhooksTableProps) {
|
||||
const [isDeleting, setIsDeleting] = useState<Record<string, boolean>>({});
|
||||
const { testWebhookEndpoint, isTestingMap } = useTestWebhook(clientId);
|
||||
const router = useDashboardRouter();
|
||||
@@ -210,7 +215,10 @@ export function WebhooksTable({ webhooks, clientId }: WebhooksTableProps) {
|
||||
return (
|
||||
<div className="w-full">
|
||||
<div className="mb-4 flex items-center justify-end">
|
||||
<CreateWebhookModal clientId={clientId} />
|
||||
<CreateWebhookModal
|
||||
clientId={clientId}
|
||||
supportedChainIds={supportedChainIds}
|
||||
/>
|
||||
</div>
|
||||
<TWTable
|
||||
data={sortedWebhooks}
|
||||
|
||||
+22
-3
@@ -1,4 +1,8 @@
|
||||
import { type WebhookResponse, getWebhooks } from "@/api/insight/webhooks";
|
||||
import {
|
||||
type WebhookResponse,
|
||||
getSupportedWebhookChains,
|
||||
getWebhooks,
|
||||
} from "@/api/insight/webhooks";
|
||||
import { getProject } from "@/api/projects";
|
||||
import { TrackedUnderlineLink } from "@/components/ui/tracked-link";
|
||||
import { notFound } from "next/navigation";
|
||||
@@ -11,6 +15,7 @@ export default async function WebhooksPage({
|
||||
let webhooks: WebhookResponse[] = [];
|
||||
let clientId = "";
|
||||
let errorMessage = "";
|
||||
let supportedChainIds: number[] = [];
|
||||
|
||||
try {
|
||||
// Await params before accessing properties
|
||||
@@ -32,6 +37,13 @@ export default async function WebhooksPage({
|
||||
} else if (webhooksRes.data) {
|
||||
webhooks = webhooksRes.data;
|
||||
}
|
||||
|
||||
const supportedChainsRes = await getSupportedWebhookChains();
|
||||
if ("chains" in supportedChainsRes) {
|
||||
supportedChainIds = supportedChainsRes.chains;
|
||||
} else {
|
||||
errorMessage = supportedChainsRes.error;
|
||||
}
|
||||
} catch (error) {
|
||||
errorMessage = "Failed to load webhooks. Please try again later.";
|
||||
console.error("Error loading project or webhooks", error);
|
||||
@@ -71,7 +83,11 @@ export default async function WebhooksPage({
|
||||
</div>
|
||||
</div>
|
||||
) : webhooks.length > 0 ? (
|
||||
<WebhooksTable webhooks={webhooks} clientId={clientId} />
|
||||
<WebhooksTable
|
||||
webhooks={webhooks}
|
||||
clientId={clientId}
|
||||
supportedChainIds={supportedChainIds}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex flex-col items-center justify-center gap-4 rounded-lg border border-border p-12 text-center">
|
||||
<div>
|
||||
@@ -80,7 +96,10 @@ export default async function WebhooksPage({
|
||||
Create a webhook to get started.
|
||||
</p>
|
||||
</div>
|
||||
<CreateWebhookModal clientId={clientId} />
|
||||
<CreateWebhookModal
|
||||
clientId={clientId}
|
||||
supportedChainIds={supportedChainIds}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ export default async function Page(props: {
|
||||
chainIdOrSlug={params.chainIdOrSlug}
|
||||
projectMeta={{
|
||||
teamId: project.teamId,
|
||||
projectSlug: params.project_slug,
|
||||
projectSlug: project.slug,
|
||||
teamSlug: params.team_slug,
|
||||
}}
|
||||
isLoggedIn={true}
|
||||
|
||||
@@ -42,7 +42,7 @@ export function BarChart({
|
||||
className="aspect-auto h-[250px] w-full pt-6"
|
||||
>
|
||||
{data.length === 0 || data.every((d) => d[activeKey] === 0) ? (
|
||||
<EmptyChartState> {emptyChartContent} </EmptyChartState>
|
||||
<EmptyChartState type="bar"> {emptyChartContent} </EmptyChartState>
|
||||
) : (
|
||||
<RechartsBarChart
|
||||
accessibilityLayer
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
||||
NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||
NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
||||
} from "@/constants/public-envs";
|
||||
import {
|
||||
@@ -34,7 +34,7 @@ function getBridgeThirdwebClient() {
|
||||
|
||||
return createThirdwebClient({
|
||||
secretKey: undefined,
|
||||
clientId: NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
||||
clientId: NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||
config: {
|
||||
storage: {
|
||||
gatewayUrl: NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
||||
|
||||
@@ -53,6 +53,12 @@ export type WalletMeta = {
|
||||
|
||||
const maxAllowedImagesPerMessage = 4;
|
||||
|
||||
function showSigninToUploadImagesToast() {
|
||||
toast.error("Sign in to upload images to Nebula", {
|
||||
position: "top-right",
|
||||
});
|
||||
}
|
||||
|
||||
export function ChatBar(props: {
|
||||
sendMessage: (message: NebulaUserMessage) => void;
|
||||
isChatStreaming: boolean;
|
||||
@@ -76,6 +82,7 @@ export function ChatBar(props: {
|
||||
const [images, setImages] = useState<
|
||||
Array<{ file: File; b64: string | undefined }>
|
||||
>([]);
|
||||
const [isDragOver, setIsDragOver] = useState(false);
|
||||
|
||||
function handleSubmit(message: string) {
|
||||
const userMessage: NebulaUserMessage = {
|
||||
@@ -104,10 +111,45 @@ export function ChatBar(props: {
|
||||
},
|
||||
});
|
||||
|
||||
async function handleImageUpload(images: File[]) {
|
||||
const supportedFileTypes = ["image/jpeg", "image/png", "image/webp"];
|
||||
|
||||
async function handleImageUpload(files: File[]) {
|
||||
const totalFiles = files.length + images.length;
|
||||
|
||||
if (totalFiles > maxAllowedImagesPerMessage) {
|
||||
toast.error(
|
||||
`You can only upload up to ${maxAllowedImagesPerMessage} images at a time`,
|
||||
{
|
||||
position: "top-right",
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const validFiles: File[] = [];
|
||||
|
||||
for (const file of files) {
|
||||
if (!supportedFileTypes.includes(file.type)) {
|
||||
toast.error("Unsupported file type", {
|
||||
description: `File: ${file.name}`,
|
||||
position: "top-right",
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.size <= 5 * 1024 * 1024) {
|
||||
validFiles.push(file);
|
||||
} else {
|
||||
toast.error("Image is larger than 5MB", {
|
||||
description: `File: ${file.name}`,
|
||||
position: "top-right",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const urls = await Promise.all(
|
||||
images.map(async (image) => {
|
||||
validFiles.map(async (image) => {
|
||||
const b64 = await uploadImageMutation.mutateAsync(image);
|
||||
return { file: image, b64: b64 };
|
||||
}),
|
||||
@@ -126,9 +168,44 @@ export function ChatBar(props: {
|
||||
<DynamicHeight transition="height 200ms ease">
|
||||
<div
|
||||
className={cn(
|
||||
"overflow-hidden rounded-2xl border border-border bg-card",
|
||||
"overflow-hidden rounded-2xl border border-border bg-card transition-colors",
|
||||
isDragOver && "border-nebula-pink-foreground bg-nebula-pink/5",
|
||||
props.className,
|
||||
)}
|
||||
onDrop={(e) => {
|
||||
setIsDragOver(false);
|
||||
e.preventDefault();
|
||||
if (!props.allowImageUpload) {
|
||||
showSigninToUploadImagesToast();
|
||||
return;
|
||||
}
|
||||
const files = Array.from(e.dataTransfer.files);
|
||||
if (files.length > 0) handleImageUpload(files);
|
||||
}}
|
||||
onDragOver={(e) => {
|
||||
e.preventDefault();
|
||||
setIsDragOver(true);
|
||||
if (!props.allowImageUpload) {
|
||||
return;
|
||||
}
|
||||
}}
|
||||
onDragEnter={(e) => {
|
||||
e.preventDefault();
|
||||
setIsDragOver(true);
|
||||
if (!props.allowImageUpload) {
|
||||
return;
|
||||
}
|
||||
}}
|
||||
onDragLeave={(e) => {
|
||||
e.preventDefault();
|
||||
if (!props.allowImageUpload) {
|
||||
return;
|
||||
}
|
||||
// Only set drag over to false if we're leaving the container entirely
|
||||
if (!e.currentTarget.contains(e.relatedTarget as Node)) {
|
||||
setIsDragOver(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{images.length > 0 && (
|
||||
<ImagePreview
|
||||
@@ -146,6 +223,17 @@ export function ChatBar(props: {
|
||||
placeholder={props.placeholder}
|
||||
value={message}
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
onPaste={(e) => {
|
||||
const files = Array.from(e.clipboardData.files);
|
||||
if (files.length > 0) {
|
||||
e.preventDefault();
|
||||
if (!props.allowImageUpload) {
|
||||
showSigninToUploadImagesToast();
|
||||
return;
|
||||
}
|
||||
handleImageUpload(files);
|
||||
}
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
// ignore if shift key is pressed to allow entering new lines
|
||||
if (e.shiftKey) {
|
||||
@@ -257,34 +345,9 @@ export function ChatBar(props: {
|
||||
<ImageUploadButton
|
||||
multiple
|
||||
value={undefined}
|
||||
accept="image/jpeg,image/png,image/webp"
|
||||
accept={supportedFileTypes.join(",")}
|
||||
onChange={(files) => {
|
||||
const totalFiles = files.length + images.length;
|
||||
|
||||
if (totalFiles > maxAllowedImagesPerMessage) {
|
||||
toast.error(
|
||||
`You can only upload up to ${maxAllowedImagesPerMessage} images at a time`,
|
||||
{
|
||||
position: "top-right",
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const validFiles: File[] = [];
|
||||
|
||||
for (const file of files) {
|
||||
if (file.size <= 5 * 1024 * 1024) {
|
||||
validFiles.push(file);
|
||||
} else {
|
||||
toast.error("Image is larger than 5MB", {
|
||||
description: `File: ${file.name}`,
|
||||
position: "top-right",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleImageUpload(validFiles);
|
||||
handleImageUpload(files);
|
||||
}}
|
||||
variant="ghost"
|
||||
className="!h-auto w-auto shrink-0 gap-2 p-2"
|
||||
|
||||
@@ -5,13 +5,13 @@ import { cn } from "@/lib/utils";
|
||||
import { MessageCircleIcon, XIcon } from "lucide-react";
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { createThirdwebClient } from "thirdweb";
|
||||
import { NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID } from "../../../../../@/constants/public-envs";
|
||||
import { NEXT_PUBLIC_DASHBOARD_CLIENT_ID } from "../../../../../@/constants/public-envs";
|
||||
import { useTrack } from "../../../../../hooks/analytics/useTrack";
|
||||
import CustomChatContent from "./CustomChatContent";
|
||||
|
||||
// Create a thirdweb client for the chat functionality
|
||||
const client = createThirdwebClient({
|
||||
clientId: NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
||||
clientId: NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||
});
|
||||
|
||||
export function CustomChatButton(props: {
|
||||
|
||||
@@ -102,6 +102,7 @@ function CustomChatContentLoggedIn(props: {
|
||||
message:
|
||||
messageToSend.content.find((x) => x.type === "text")?.text ?? "",
|
||||
conversationId: sessionId,
|
||||
source: "dashboard-support",
|
||||
};
|
||||
const apiUrl = process.env.NEXT_PUBLIC_SIWA_URL;
|
||||
const response = await fetch(`${apiUrl}/v1/chat`, {
|
||||
|
||||
@@ -65,6 +65,7 @@ export default async function PayPage({
|
||||
name={paymentLink.title}
|
||||
image={paymentLink.imageUrl}
|
||||
theme={theme}
|
||||
purchaseData={paymentLink.purchaseData}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ export function PayPageEmbed({
|
||||
image,
|
||||
redirectUri,
|
||||
theme,
|
||||
purchaseData,
|
||||
}: {
|
||||
chainId: number;
|
||||
recipientAddress: string;
|
||||
@@ -27,6 +28,7 @@ export function PayPageEmbed({
|
||||
redirectUri?: string;
|
||||
clientId: string;
|
||||
theme?: "light" | "dark";
|
||||
purchaseData: Record<string, unknown> | undefined;
|
||||
}) {
|
||||
const { theme: browserTheme, setTheme } = useTheme();
|
||||
|
||||
@@ -51,6 +53,7 @@ export function PayPageEmbed({
|
||||
image,
|
||||
},
|
||||
mode: "direct_payment",
|
||||
purchaseData,
|
||||
paymentInfo: {
|
||||
chain,
|
||||
sellerAddress: recipientAddress,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
||||
NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||
NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
||||
} from "@/constants/public-envs";
|
||||
import {
|
||||
@@ -33,7 +33,7 @@ function getPayThirdwebClient() {
|
||||
|
||||
return createThirdwebClient({
|
||||
secretKey: undefined,
|
||||
clientId: NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID,
|
||||
clientId: NEXT_PUBLIC_DASHBOARD_CLIENT_ID,
|
||||
config: {
|
||||
storage: {
|
||||
gatewayUrl: NEXT_PUBLIC_IPFS_GATEWAY_URL,
|
||||
|
||||
@@ -92,6 +92,7 @@ export default async function PayPage({
|
||||
name={params.name}
|
||||
image={params.image}
|
||||
theme={params.theme}
|
||||
purchaseData={undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import { Spinner } from "@/components/ui/Spinner/Spinner";
|
||||
import { LoadingDots } from "@/components/ui/LoadingDots";
|
||||
import { type ChartConfig, ChartContainer } from "@/components/ui/chart";
|
||||
import { useMemo } from "react";
|
||||
import { Bar, BarChart } from "recharts";
|
||||
import { Area, AreaChart, Bar, BarChart } from "recharts";
|
||||
|
||||
type FakeCartData = {
|
||||
value: number;
|
||||
@@ -22,7 +21,10 @@ const skeletonChartConfig = {
|
||||
},
|
||||
} satisfies ChartConfig;
|
||||
|
||||
export function EmptyChartState({ children }: { children?: React.ReactNode }) {
|
||||
export function EmptyChartState({
|
||||
children,
|
||||
type,
|
||||
}: { children?: React.ReactNode; type: "bar" | "area" }) {
|
||||
const barChartData = useMemo(() => generateRandomData(), []);
|
||||
|
||||
return (
|
||||
@@ -30,35 +32,63 @@ export function EmptyChartState({ children }: { children?: React.ReactNode }) {
|
||||
<div className="absolute inset-0 z-[1] flex flex-col items-center justify-center font-medium text-base text-muted-foreground">
|
||||
{children ?? "No data available"}
|
||||
</div>
|
||||
<SkeletonBarChart data={barChartData} />
|
||||
<SkeletonBarChart data={barChartData} type={type} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function LoadingChartState() {
|
||||
return (
|
||||
<div className="pointer-events-none flex h-full w-full items-center justify-center rounded-lg bg-muted/50">
|
||||
<Spinner className="size-10" />
|
||||
<div className="pointer-events-none flex h-full w-full items-center justify-center rounded-lg bg-muted/30">
|
||||
<LoadingDots />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SkeletonBarChart(props: {
|
||||
data: FakeCartData[];
|
||||
type: "bar" | "area";
|
||||
}) {
|
||||
return (
|
||||
<ChartContainer
|
||||
config={skeletonChartConfig}
|
||||
className="pointer-events-none h-full w-full blur-[5px]"
|
||||
>
|
||||
<BarChart
|
||||
data={props.data}
|
||||
margin={{
|
||||
top: 20,
|
||||
}}
|
||||
>
|
||||
<Bar dataKey="value" fill="var(--color-value)" radius={8} />
|
||||
</BarChart>
|
||||
{props.type === "bar" ? (
|
||||
<BarChart
|
||||
data={props.data}
|
||||
margin={{
|
||||
top: 20,
|
||||
}}
|
||||
>
|
||||
<Bar dataKey="value" fill="var(--color-value)" radius={8} />
|
||||
</BarChart>
|
||||
) : (
|
||||
<AreaChart
|
||||
data={props.data}
|
||||
margin={{
|
||||
top: 20,
|
||||
}}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id="fill_area_skeleton" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop
|
||||
offset="5%"
|
||||
stopColor={"hsl(var(--muted-foreground)/0.5)"}
|
||||
stopOpacity={0.8}
|
||||
/>
|
||||
<stop offset="95%" stopColor="transparent" stopOpacity={0.1} />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<Area
|
||||
type="natural"
|
||||
dataKey="value"
|
||||
stroke="hsl(var(--muted-foreground))"
|
||||
fill="url(#fill_area_skeleton)"
|
||||
radius={8}
|
||||
/>
|
||||
</AreaChart>
|
||||
)}
|
||||
</ChartContainer>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,13 +80,20 @@ type MistmatchButtonProps = React.ComponentProps<typeof Button> & {
|
||||
txChainId: number;
|
||||
isLoggedIn: boolean;
|
||||
isPending: boolean;
|
||||
checkBalance?: boolean;
|
||||
};
|
||||
|
||||
export const MismatchButton = forwardRef<
|
||||
HTMLButtonElement,
|
||||
MistmatchButtonProps
|
||||
>((props, ref) => {
|
||||
const { txChainId, isLoggedIn, isPending, ...buttonProps } = props;
|
||||
const {
|
||||
txChainId,
|
||||
isLoggedIn,
|
||||
isPending,
|
||||
checkBalance = true,
|
||||
...buttonProps
|
||||
} = props;
|
||||
const account = useActiveAccount();
|
||||
const wallet = useActiveWallet();
|
||||
const activeWalletChain = useActiveWalletChain();
|
||||
@@ -150,7 +157,8 @@ export const MismatchButton = forwardRef<
|
||||
}
|
||||
|
||||
const isBalanceRequired =
|
||||
wallet.id === "smart" ? false : !GAS_FREE_CHAINS.includes(txChainId);
|
||||
checkBalance &&
|
||||
(wallet.id === "smart" ? false : !GAS_FREE_CHAINS.includes(txChainId));
|
||||
|
||||
const notEnoughBalance =
|
||||
(txChainBalance.data?.value || 0n) === 0n && isBalanceRequired;
|
||||
|
||||
@@ -29,6 +29,7 @@ type TransactionButtonProps = Omit<ButtonProps, "variant"> & {
|
||||
txChainID: number;
|
||||
variant?: "destructive" | "primary" | "default";
|
||||
isLoggedIn: boolean;
|
||||
checkBalance?: boolean;
|
||||
};
|
||||
|
||||
export const TransactionButton: React.FC<TransactionButtonProps> = ({
|
||||
@@ -38,6 +39,7 @@ export const TransactionButton: React.FC<TransactionButtonProps> = ({
|
||||
txChainID,
|
||||
variant,
|
||||
isLoggedIn,
|
||||
checkBalance,
|
||||
...restButtonProps
|
||||
}) => {
|
||||
const activeWallet = useActiveWallet();
|
||||
@@ -68,6 +70,7 @@ export const TransactionButton: React.FC<TransactionButtonProps> = ({
|
||||
txChainId={txChainID}
|
||||
{...restButtonProps}
|
||||
disabled={disabled}
|
||||
checkBalance={checkBalance}
|
||||
className={cn("relative overflow-hidden", restButtonProps.className)}
|
||||
style={{
|
||||
paddingLeft: transactionCount
|
||||
|
||||
@@ -156,7 +156,11 @@ export function ContractTableUI(props: {
|
||||
}}
|
||||
/>
|
||||
</TableHead>
|
||||
<TableHead>Contract Address</TableHead>
|
||||
{props.variant === "contract" && (
|
||||
<TableHead>Contract Address</TableHead>
|
||||
)}
|
||||
|
||||
{props.variant === "asset" && <TableHead> Asset Page</TableHead>}
|
||||
<TableHead>Actions</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
@@ -193,14 +197,30 @@ export function ContractTableUI(props: {
|
||||
/>
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<CopyAddressButton
|
||||
copyIconPosition="left"
|
||||
address={contract.contractAddress}
|
||||
variant="ghost"
|
||||
className="-translate-x-2 relative z-10"
|
||||
/>
|
||||
</TableCell>
|
||||
{props.variant === "contract" && (
|
||||
<TableCell>
|
||||
<CopyAddressButton
|
||||
copyIconPosition="left"
|
||||
address={contract.contractAddress}
|
||||
variant="ghost"
|
||||
className="-translate-x-2 relative z-10"
|
||||
/>
|
||||
</TableCell>
|
||||
)}
|
||||
|
||||
{props.variant === "asset" && (
|
||||
<TableCell>
|
||||
<Button variant="ghost" asChild size="sm">
|
||||
<Link
|
||||
href={`/${contract.chainId}/${contract.contractAddress}`}
|
||||
target="_blank"
|
||||
className="-translate-x-2 relative z-10 flex items-center gap-1.5 text-muted-foreground"
|
||||
>
|
||||
View <ExternalLinkIcon className="size-3" />
|
||||
</Link>
|
||||
</Button>
|
||||
</TableCell>
|
||||
)}
|
||||
|
||||
<TableCell>
|
||||
<ContractActionsCell
|
||||
|
||||
@@ -181,7 +181,7 @@ export const InAppWalletSettingsUI: React.FC<
|
||||
const authRequiredPlan = "growth";
|
||||
const brandingRequiredPlan = "starter";
|
||||
|
||||
// accelerate or higher plan required
|
||||
// growth or higher plan required
|
||||
const canEditSmsCountries =
|
||||
planToTierRecordForGating[props.teamPlan] >=
|
||||
planToTierRecordForGating[authRequiredPlan];
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { SVGProps } from "react";
|
||||
|
||||
export function DiscordIcon(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
enable-background="new 0 0 100 100"
|
||||
viewBox="0 0 100 100"
|
||||
{...props}
|
||||
fill="currentColor"
|
||||
width={20}
|
||||
height={20}
|
||||
role="presentation"
|
||||
>
|
||||
<path
|
||||
id="Layer_2"
|
||||
d="M85.778,24.561c-11.641-8.71-22.793-8.466-22.793-8.466s-1.14,1.302-1.14,1.302c13.839,4.152,20.27,10.257,20.27,10.257
|
||||
c-19.799-10.901-45.019-10.823-65.613,0c0,0,6.675-6.431,21.328-10.583c0,0-0.814-0.977-0.814-0.977s-11.071-0.244-22.793,8.466
|
||||
c0,0-11.722,21.084-11.722,47.052c0,0,6.838,11.722,24.829,12.292c0,0,3.012-3.582,5.454-6.675
|
||||
c-10.339-3.093-14.246-9.524-14.246-9.524c6.495,4.064,13.063,6.608,21.247,8.222c13.316,2.741,29.879-0.077,42.249-8.222
|
||||
c0,0-4.07,6.594-14.734,9.606c2.442,3.012,5.373,6.512,5.373,6.512C90.662,83.254,97.5,71.532,97.5,71.613
|
||||
C97.5,45.645,85.778,24.561,85.778,24.561z M34.818,64.043c-4.559,0-8.303-3.989-8.303-8.955c0.333-11.892,16.357-11.855,16.607,0
|
||||
C43.121,60.054,39.458,64.043,34.818,64.043z M64.531,64.043c-4.559,0-8.303-3.989-8.303-8.955c0.366-11.869,16.19-11.874,16.607,0
|
||||
C72.834,60.054,69.171,64.043,64.531,64.043z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { SVGProps } from "react";
|
||||
|
||||
export function TelegramIcon(props: SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
{...props}
|
||||
fill="currentColor"
|
||||
width={24}
|
||||
height={24}
|
||||
role="presentation"
|
||||
>
|
||||
<path d="m12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12c0-6.627-5.373-12-12-12zm5.894 8.221-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.446 1.394c-.14.18-.357.295-.6.295-.002 0-.003 0-.005 0l.213-3.054 5.56-5.022c.24-.213-.054-.334-.373-.121l-6.869 4.326-2.96-.924c-.64-.203-.658-.64.135-.954l11.566-4.458c.538-.196 1.006.128.832.941z" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -3,16 +3,17 @@ import type { SVGProps } from "react";
|
||||
export const XIcon = (props: SVGProps<SVGSVGElement>) => {
|
||||
return (
|
||||
<svg
|
||||
role="img"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="currentColor"
|
||||
width={24}
|
||||
height={24}
|
||||
height="20"
|
||||
viewBox="0 0 16 16"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
role="presentation"
|
||||
{...props}
|
||||
>
|
||||
<title>X</title>
|
||||
<path d="M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z" />
|
||||
<g id="Twitter">
|
||||
<path d="M9.14163 7.19284L13.6089 2H12.5503L8.67137 6.50887L5.57328 2H2L6.68492 8.81821L2 14.2637H3.05866L7.15491 9.50218L10.4267 14.2637H14L9.14163 7.19284ZM7.69165 8.87828L7.21697 8.19934L3.44011 2.79694H5.06615L8.11412 7.15685L8.5888 7.83579L12.5508 13.503H10.9248L7.69165 8.87828Z" />
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -28,8 +28,8 @@ export const AllVariants: Story = {
|
||||
|
||||
function Variants() {
|
||||
const [requiredPlan, setRequiredPlan] = useState<
|
||||
"free" | "growth" | "accelerate" | "pro"
|
||||
>("accelerate");
|
||||
"free" | "growth" | "scale" | "pro"
|
||||
>("scale");
|
||||
|
||||
const plans: Team["billingPlan"][] = [
|
||||
"free",
|
||||
@@ -38,6 +38,7 @@ function Variants() {
|
||||
"growth_legacy",
|
||||
"growth",
|
||||
"accelerate",
|
||||
"scale",
|
||||
"pro",
|
||||
];
|
||||
|
||||
@@ -57,7 +58,7 @@ function Variants() {
|
||||
<SelectContent>
|
||||
<SelectItem value="free">Free</SelectItem>
|
||||
<SelectItem value="growth">Growth</SelectItem>
|
||||
<SelectItem value="accelerate">Accelerate</SelectItem>
|
||||
<SelectItem value="scale">Scale</SelectItem>
|
||||
<SelectItem value="pro">Pro</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user