Skip to content

Commit e447da3

Browse files
committed
use social SDK for publisher page
1 parent b2b95a5 commit e447da3

File tree

21 files changed

+152
-651
lines changed

21 files changed

+152
-651
lines changed

.changeset/blue-bees-ring.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
default account components to not retry on failure

apps/dashboard/src/app/(dashboard)/profile/[addressOrEns]/ProfileUI.tsx

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,20 @@
11
import { Spinner } from "@/components/ui/Spinner/Spinner";
22
import { fetchPublishedContracts } from "components/contract-components/fetchPublishedContracts";
3-
import { PublisherSocials } from "components/contract-components/publisher/PublisherSocials";
4-
import { EditProfile } from "components/contract-components/publisher/edit-profile";
5-
import { PublisherAvatar } from "components/contract-components/publisher/masked-avatar";
63
import { DeployedContracts } from "components/contract-components/tables/deployed-contracts";
7-
import type { ProfileMetadata } from "constants/schemas";
84
import { Suspense } from "react";
9-
import { shortenIfAddress } from "utils/usedapp-external";
105
import { getSortedDeployedContracts } from "../../../account/contracts/_components/getSortedDeployedContracts";
6+
import { ProfileHeader } from "./components/profile-header";
117
import { PublishedContracts } from "./components/published-contracts";
128

139
export function ProfileUI(props: {
1410
profileAddress: string;
1511
ensName: string | undefined;
16-
publisherProfile: ProfileMetadata | null;
17-
showEditProfile: boolean;
1812
}) {
19-
const { profileAddress, ensName, publisherProfile, showEditProfile } = props;
20-
21-
const displayName = shortenIfAddress(ensName || profileAddress).replace(
22-
"deployer.thirdweb.eth",
23-
"thirdweb.eth",
24-
);
13+
const { profileAddress, ensName } = props;
2514

2615
return (
2716
<div className="container pt-8 pb-20">
28-
{/* Header */}
29-
<div className="flex w-full flex-col items-center justify-between gap-4 border-border border-b pb-6 md:flex-row">
30-
<div className="flex w-full items-center gap-4">
31-
<PublisherAvatar address={profileAddress} className="size-20" />
32-
<div>
33-
<h1 className="font-semibold text-4xl tracking-tight">
34-
{displayName}
35-
</h1>
36-
37-
{publisherProfile?.bio && (
38-
<p className="line-clamp-2 text-muted-foreground">
39-
{publisherProfile.bio}
40-
</p>
41-
)}
42-
43-
<div className="-translate-x-2 mt-1">
44-
{publisherProfile && (
45-
<PublisherSocials publisherProfile={publisherProfile} />
46-
)}
47-
</div>
48-
</div>
49-
</div>
50-
51-
{showEditProfile && (
52-
<div className="shrink-0">
53-
{publisherProfile && (
54-
<EditProfile publisherProfile={publisherProfile} />
55-
)}
56-
</div>
57-
)}
58-
</div>
59-
17+
<ProfileHeader profileAddress={profileAddress} />
6018
<div className="h-8" />
6119

6220
<div>

apps/dashboard/src/app/(dashboard)/profile/[addressOrEns]/components/PublishedContractTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {
1111
} from "@/components/ui/table";
1212
import { ToolTipLabel } from "@/components/ui/tooltip";
1313
import { TrackedLinkTW } from "@/components/ui/tracked-link";
14-
import { replaceDeployerAddress } from "components/explore/publisher";
1514
import { useTrack } from "hooks/analytics/useTrack";
15+
import { replaceDeployerAddress } from "lib/publisher-utils";
1616
import { replaceIpfsUrl } from "lib/sdk";
1717
import { ShieldCheckIcon } from "lucide-react";
1818
import Link from "next/link";
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"use client";
2+
3+
import { Skeleton } from "@/components/ui/skeleton";
4+
import { useThirdwebClient } from "@/constants/thirdweb.client";
5+
import { replaceDeployerAddress } from "lib/publisher-utils";
6+
import {
7+
AccountAddress,
8+
AccountAvatar,
9+
AccountBlobbie,
10+
AccountName,
11+
AccountProvider,
12+
} from "thirdweb/react";
13+
import { shortenIfAddress } from "utils/usedapp-external";
14+
15+
export function ProfileHeader(props: { profileAddress: string }) {
16+
const client = useThirdwebClient();
17+
return (
18+
<AccountProvider address={props.profileAddress} client={client}>
19+
<div className="flex w-full flex-col items-center justify-between gap-4 border-border border-b pb-6 md:flex-row">
20+
<div className="flex w-full items-center gap-4">
21+
<AccountAvatar
22+
className="size-20 rounded-full"
23+
loadingComponent={<Skeleton className="size-20 rounded-full" />}
24+
fallbackComponent={
25+
<AccountBlobbie className="size-20 rounded-full" />
26+
}
27+
/>
28+
<div>
29+
<h1 className="font-semibold text-4xl tracking-tight">
30+
<AccountName
31+
fallbackComponent={
32+
<AccountAddress
33+
formatFn={(addr) =>
34+
shortenIfAddress(replaceDeployerAddress(addr))
35+
}
36+
/>
37+
}
38+
loadingComponent={<Skeleton className="h-8 w-40" />}
39+
formatFn={(name) => replaceDeployerAddress(name)}
40+
/>
41+
</h1>
42+
</div>
43+
</div>
44+
</div>
45+
</AccountProvider>
46+
);
47+
}
Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { getActiveAccountCookie } from "@/constants/cookie";
2-
import { fetchPublisherProfile } from "components/contract-components/fetch-contracts-with-versions";
1+
import { replaceDeployerAddress } from "lib/publisher-utils";
32
import type { Metadata } from "next";
43
import { notFound } from "next/navigation";
5-
import { getAddress } from "thirdweb/utils";
64
import { shortenIfAddress } from "utils/usedapp-external";
75
import { ProfileUI } from "./ProfileUI";
86
import { resolveAddressAndEns } from "./resolveAddressAndEns";
@@ -16,22 +14,15 @@ type PageProps = {
1614
export default async function Page(props: PageProps) {
1715
const params = await props.params;
1816
const resolvedInfo = await resolveAddressAndEns(params.addressOrEns);
19-
const currentUserAddress = await getCurrentUserAddress();
2017

2118
if (!resolvedInfo) {
2219
return notFound();
2320
}
2421

25-
const publisherProfile = await fetchPublisherProfile(
26-
resolvedInfo.address,
27-
).catch(() => null);
28-
2922
return (
3023
<ProfileUI
3124
ensName={resolvedInfo.ensName}
3225
profileAddress={resolvedInfo.address}
33-
publisherProfile={publisherProfile}
34-
showEditProfile={currentUserAddress === resolvedInfo.address}
3526
/>
3627
);
3728
}
@@ -45,23 +36,11 @@ export async function generateMetadata(props: PageProps): Promise<Metadata> {
4536
}
4637

4738
const displayName = shortenIfAddress(
48-
resolvedInfo.ensName || resolvedInfo.address,
49-
).replace("deployer.thirdweb.eth", "thirdweb.eth");
39+
replaceDeployerAddress(resolvedInfo.ensName || resolvedInfo.address),
40+
);
5041

5142
return {
5243
title: displayName,
5344
description: `Visit ${displayName}'s profile. See their published contracts and deploy them in one click.`,
5445
};
5546
}
56-
57-
async function getCurrentUserAddress() {
58-
try {
59-
const currentUserAddress = await getActiveAccountCookie();
60-
if (!currentUserAddress) {
61-
return null;
62-
}
63-
return getAddress(currentUserAddress);
64-
} catch {
65-
return null;
66-
}
67-
}

apps/dashboard/src/components/contract-components/hooks.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,10 @@ import { isAddress } from "thirdweb/utils";
1212
import {
1313
type PublishedContractWithVersion,
1414
fetchPublishedContractVersions,
15-
fetchPublisherProfile,
1615
} from "./fetch-contracts-with-versions";
1716
import { fetchPublishedContracts } from "./fetchPublishedContracts";
1817
import { fetchPublishedContractsFromDeploy } from "./fetchPublishedContractsFromDeploy";
1918

20-
function publisherProfileQuery(publisherAddress?: string) {
21-
return queryOptions({
22-
queryKey: ["releaser-profile", publisherAddress],
23-
queryFn: () => {
24-
if (!publisherAddress) {
25-
throw new Error("publisherAddress is not defined");
26-
}
27-
return fetchPublisherProfile(publisherAddress);
28-
},
29-
enabled: !!publisherAddress,
30-
// 24h
31-
gcTime: 60 * 60 * 24 * 1000,
32-
// 1h
33-
staleTime: 60 * 60 * 1000,
34-
});
35-
}
36-
37-
export function usePublisherProfile(publisherAddress?: string) {
38-
return useQuery(publisherProfileQuery(publisherAddress));
39-
}
40-
4119
export function useAllVersions(
4220
publisherAddress: string | undefined,
4321
contractId: string | undefined,
@@ -169,6 +147,8 @@ function ensQuery(addressOrEnsName?: string) {
169147
throw new Error("Failed to resolve ENS name.");
170148
}
171149

150+
console.log("ensQuery", { address, ensName });
151+
172152
return {
173153
address,
174154
ensName,

apps/dashboard/src/components/contract-components/publisher/PublisherSocials.tsx

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)