Skip to content

Commit 0262763

Browse files
committed
Dashboard: Reduce useThirdwebClient hook usage (#7223)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily focuses on adding a `client` prop to various components across the dashboard application, enhancing their functionality and ensuring consistent access to the `ThirdwebClient`. ### Detailed summary - Added `client` prop to `BatchMetadata`, `Royalty`, `Mintable`, `Transferable`, `Claimable`, and other components. - Updated `WalletAddress` component to accept `client` prop in multiple instances. - Enhanced various tables and UI components to utilize the `client` prop for improved data handling. - Refactored existing components to ensure compatibility with the new `client` prop, ensuring consistent client access throughout the application. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced all WalletAddress displays across the dashboard to accept and utilize a new client context for improved integration and consistency. - **Refactor** - Updated multiple components and their props to require and pass a client instance, ensuring unified client handling throughout tables, modals, and analytics views. - Replaced static table column definitions with dynamic, memoized columns that respond to client changes. - Standardized prop names related to client identification for clarity and maintainability. - **Bug Fixes** - Ensured client context is consistently propagated to all relevant child components, preventing potential rendering or data issues. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 913b243 commit 0262763

File tree

56 files changed

+527
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+527
-248
lines changed

apps/dashboard/src/@/components/blocks/wallet-address.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
HoverCardContent,
66
HoverCardTrigger,
77
} from "@/components/ui/hover-card";
8-
import { useThirdwebClient } from "@/constants/thirdweb.client";
98
import { resolveSchemeWithErrorHandler } from "@/lib/resolveSchemeWithErrorHandler";
109
import { useClipboard } from "hooks/useClipboard";
1110
import { CheckIcon, CopyIcon, XIcon } from "lucide-react";
@@ -24,8 +23,8 @@ export function WalletAddress(props: {
2423
shortenAddress?: boolean;
2524
className?: string;
2625
iconClassName?: string;
26+
client: ThirdwebClient;
2727
}) {
28-
const thirdwebClient = useThirdwebClient();
2928
// default back to zero address if no address provided
3029
const address = useMemo(() => props.address || ZERO_ADDRESS, [props.address]);
3130

@@ -40,7 +39,7 @@ export function WalletAddress(props: {
4039

4140
const profiles = useSocialProfiles({
4241
address: address,
43-
client: thirdwebClient,
42+
client: props.client,
4443
});
4544

4645
const { onCopy, hasCopied } = useClipboard(address, 2000);
@@ -78,7 +77,7 @@ export function WalletAddress(props: {
7877
<WalletAvatar
7978
address={address}
8079
profiles={profiles.data || []}
81-
thirdwebClient={thirdwebClient}
80+
thirdwebClient={props.client}
8281
iconClassName={props.iconClassName}
8382
/>
8483
)}
@@ -122,7 +121,7 @@ export function WalletAddress(props: {
122121
) : (
123122
profiles.data?.map((profile) => {
124123
const walletAvatarLink = resolveSchemeWithErrorHandler({
125-
client: thirdwebClient,
124+
client: props.client,
126125
uri: profile.avatar,
127126
});
128127

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/(marketplace)/components/listing-drawer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ export const ListingDrawer: React.FC<NFTDrawerProps> = ({
9292
<p className="font-bold">Seller</p>
9393
</GridItem>
9494
<GridItem colSpan={9}>
95-
<WalletAddress address={renderData.creatorAddress} />
95+
<WalletAddress
96+
address={renderData.creatorAddress}
97+
client={contract.client}
98+
/>
9699
</GridItem>
97100
<GridItem colSpan={3}>
98101
<p className="font-bold">Listing ID</p>

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/(marketplace)/components/marketplace-table.tsx

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,6 @@ import { min } from "thirdweb/utils";
4040
import { ListingDrawer } from "./listing-drawer";
4141
import { LISTING_STATUS } from "./types";
4242

43-
const tableColumns: Column<DirectListing | EnglishAuction>[] = [
44-
{
45-
Header: "Listing Id",
46-
accessor: (row) => row.id.toString(),
47-
},
48-
{
49-
Header: "Media",
50-
accessor: (row) => row.asset.metadata,
51-
// biome-ignore lint/suspicious/noExplicitAny: FIXME
52-
Cell: (cell: any) => <MediaCell cell={cell} />,
53-
},
54-
{
55-
Header: "Name",
56-
accessor: (row) => row.asset.metadata.name ?? "N/A",
57-
},
58-
{
59-
Header: "Creator",
60-
accessor: (row) => row.creatorAddress,
61-
// biome-ignore lint/suspicious/noExplicitAny: FIXME
62-
Cell: ({ cell }: { cell: Cell<any, string> }) => (
63-
<WalletAddress address={cell.value} />
64-
),
65-
},
66-
{
67-
Header: "Price",
68-
accessor: (row) =>
69-
(row as DirectListing)?.currencyValuePerToken ||
70-
(row as EnglishAuction)?.buyoutCurrencyValue,
71-
// biome-ignore lint/suspicious/noExplicitAny: FIXME
72-
Cell: ({ cell }: { cell: Cell<any, any> }) => {
73-
return (
74-
<p className="whitespace-nowrap text-muted-foreground">
75-
{cell.value.displayValue} {cell.value.symbol}
76-
</p>
77-
);
78-
},
79-
},
80-
{
81-
Header: "Status",
82-
accessor: (row) => LISTING_STATUS[row.status],
83-
},
84-
];
85-
8643
interface MarketplaceTableProps {
8744
contract: ThirdwebContract;
8845
getAllQueryResult: UseQueryResult<DirectListing[] | EnglishAuction[]>;
@@ -132,6 +89,51 @@ export const MarketplaceTable: React.FC<MarketplaceTableProps> = ({
13289
return getValidQueryResult?.data || prevData;
13390
}, [getAllQueryResult, getValidQueryResult, listingsToShow, prevData]);
13491

92+
const tableColumns: Column<DirectListing | EnglishAuction>[] = useMemo(() => {
93+
return [
94+
{
95+
Header: "Listing Id",
96+
accessor: (row) => row.id.toString(),
97+
},
98+
{
99+
Header: "Media",
100+
accessor: (row) => row.asset.metadata,
101+
// biome-ignore lint/suspicious/noExplicitAny: FIXME
102+
Cell: (cell: any) => <MediaCell cell={cell} />,
103+
},
104+
{
105+
Header: "Name",
106+
accessor: (row) => row.asset.metadata.name ?? "N/A",
107+
},
108+
{
109+
Header: "Creator",
110+
accessor: (row) => row.creatorAddress,
111+
// biome-ignore lint/suspicious/noExplicitAny: FIXME
112+
Cell: ({ cell }: { cell: Cell<any, string> }) => (
113+
<WalletAddress address={cell.value} client={contract.client} />
114+
),
115+
},
116+
{
117+
Header: "Price",
118+
accessor: (row) =>
119+
(row as DirectListing)?.currencyValuePerToken ||
120+
(row as EnglishAuction)?.buyoutCurrencyValue,
121+
// biome-ignore lint/suspicious/noExplicitAny: FIXME
122+
Cell: ({ cell }: { cell: Cell<any, any> }) => {
123+
return (
124+
<p className="whitespace-nowrap text-muted-foreground">
125+
{cell.value.displayValue} {cell.value.symbol}
126+
</p>
127+
);
128+
},
129+
},
130+
{
131+
Header: "Status",
132+
accessor: (row) => LISTING_STATUS[row.status],
133+
},
134+
];
135+
}, [contract.client]);
136+
135137
const {
136138
getTableProps,
137139
getTableBodyProps,

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/account-permissions/components/account-signer.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Badge } from "@/components/ui/badge";
33
import { Flex, SimpleGrid, useBreakpointValue } from "@chakra-ui/react";
44
import { formatDistance } from "date-fns/formatDistance";
55
import { useAllChainsData } from "hooks/chains/allChains";
6+
import type { ThirdwebClient } from "thirdweb";
67
import { useActiveAccount } from "thirdweb/react";
78
import { Card, Heading, Text } from "tw-components";
89

@@ -16,11 +17,13 @@ export type AccountSignerType = {
1617
interface AccountSignerProps {
1718
item: AccountSignerType;
1819
contractChainId: number;
20+
client: ThirdwebClient;
1921
}
2022

2123
export const AccountSigner: React.FC<AccountSignerProps> = ({
2224
item,
2325
contractChainId,
26+
client,
2427
}) => {
2528
const address = useActiveAccount()?.address;
2629
const { idToChain } = useAllChainsData();
@@ -43,7 +46,11 @@ export const AccountSigner: React.FC<AccountSignerProps> = ({
4346
flexDir={{ base: "column", lg: "row" }}
4447
>
4548
<Heading size="label.lg">
46-
<WalletAddress shortenAddress={isMobile} address={signer} />
49+
<WalletAddress
50+
shortenAddress={isMobile}
51+
address={signer}
52+
client={client}
53+
/>
4754
</Heading>
4855
<div className="flex flex-row gap-2">
4956
{isAdmin ? <Badge>Admin Key</Badge> : <Badge>Scoped key</Badge>}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/account-permissions/components/account-signers.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const AccountSigners: React.FC<AccountSignersProps> = ({ contract }) => {
4040
<AccountSigner
4141
key={item.signer}
4242
item={item}
43+
client={contract.client}
4344
contractChainId={contract.chain.id}
4445
/>
4546
))}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/BatchMetadata.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function BatchMetadataModule(props: ModuleInstanceProps) {
9494
uploadMetadata={uploadMetadata}
9595
isOwnerAccount={!!ownerAccount}
9696
contractChainId={contract.chain.id}
97+
client={contract.client}
9798
/>
9899
);
99100
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/Claimable.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ function ClaimableModule(props: ModuleInstanceProps) {
271271
return (
272272
<ClaimableModuleUI
273273
{...props}
274+
client={props.contract.client}
274275
primarySaleRecipientSection={{
275276
data: primarySaleRecipientQuery.data
276277
? { primarySaleRecipient: primarySaleRecipientQuery.data }

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/Mintable.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ function MintableModule(props: ModuleInstanceProps) {
177177
name={props.contractInfo.name}
178178
isBatchMetadataInstalled={isBatchMetadataInstalled}
179179
contractChainId={contract.chain.id}
180+
client={contract.client}
180181
/>
181182
);
182183
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/OpenEditionMetadata.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function OpenEditionMetadataModule(props: ModuleInstanceProps) {
7373
setSharedMetadata={setSharedMetadata}
7474
isOwnerAccount={!!props.ownerAccount}
7575
contractChainId={props.contract.chain.id}
76+
client={props.contract.client}
7677
/>
7778
);
7879
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/Royalty.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ function RoyaltyModule(props: ModuleInstanceProps) {
150150
setRoyaltyInfoForToken={setRoyaltyInfoForToken}
151151
isOwnerAccount={!!ownerAccount}
152152
contractChainId={props.contract.chain.id}
153+
client={props.contract.client}
153154
/>
154155
);
155156
}

0 commit comments

Comments
 (0)