Skip to content

Commit 6ae54dd

Browse files
committed
Dashboard: Remove useThirdwebClient hook (#7228)
<!-- ## 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 focuses on integrating the `ThirdwebClient` into various components and functions across the application, enhancing the client functionality for better interaction with smart contracts and improving the overall architecture. ### Detailed summary - Added `client` prop to multiple components for better contract interactions. - Updated functions to utilize the `contract.client` instead of a generic client. - Removed redundant imports of `useThirdwebClient`. - Enhanced several UI components to accept and use the `client` prop. - Modified API calls to pass the `client` where necessary for fetching data. - Improved handling of ENS queries by passing the `client` directly. > The following files were skipped due to too many changes: `apps/dashboard/src/components/contract-components/hooks.ts`, `apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/connect/account-abstraction/factories/page.tsx`, `apps/dashboard/src/components/embedded-wallets/Configure/index.tsx`, `apps/dashboard/src/components/contract-components/contract-publish-form/index.tsx`, `apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx` > ✨ 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** - Many components now accept a client instance as a prop, enabling more explicit and flexible client management throughout the dashboard. - **Refactor** - Shifted from internal client initialization to explicit client prop injection across the app, affecting forms, tables, media components, contract publishing, and wallet settings. - Updated hooks and utility functions to require a client parameter instead of relying on internal context. - **Chores** - Removed unused files and internal hooks related to client management. - **Bug Fixes** - Improved consistency and reliability when handling authentication and client context in user flows. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 8245c06 commit 6ae54dd

File tree

85 files changed

+423
-284
lines changed

Some content is hidden

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

85 files changed

+423
-284
lines changed

apps/dashboard/src/@/constants/thirdweb.client.ts

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

apps/dashboard/src/@3rdweb-sdk/react/components/connect-wallet/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export const CustomConnectWallet = (props: {
198198
open={isNetworkConfigModalOpen}
199199
onOpenChange={setIsNetworkConfigModalOpen}
200200
editChain={editChain}
201+
client={client}
201202
/>
202203
</>
203204
);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ export const CreateListingsForm: React.FC<CreateListingsFormProps> = ({
559559
width="140px"
560560
height="140px"
561561
requireInteraction
562+
client={contract.client}
562563
/>
563564
</Box>
564565
</Tooltip>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const ListingDrawer: React.FC<NFTDrawerProps> = ({
5151
<div className="flex flex-row gap-6">
5252
<NFTMediaWithEmptyState
5353
metadata={renderData.asset.metadata}
54+
client={contract.client}
5455
requireInteraction
5556
width="150px"
5657
height="150px"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const MarketplaceTable: React.FC<MarketplaceTableProps> = ({
9999
Header: "Media",
100100
accessor: (row) => row.asset.metadata,
101101
// biome-ignore lint/suspicious/noExplicitAny: FIXME
102-
Cell: (cell: any) => <MediaCell cell={cell} />,
102+
Cell: (cell: any) => <MediaCell cell={cell} client={contract.client} />,
103103
},
104104
{
105105
Header: "Name",

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/NFTCards.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { SkeletonContainer } from "@/components/ui/skeleton";
22
import { TrackedLinkTW } from "@/components/ui/tracked-link";
33
import { useMemo } from "react";
4-
import { type NFT, ZERO_ADDRESS } from "thirdweb";
4+
import { type NFT, type ThirdwebClient, ZERO_ADDRESS } from "thirdweb";
55
import { NFTMediaWithEmptyState } from "tw-components/nft-media";
66
import type { ProjectMeta } from "../../../../../team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/types";
77
import { buildContractPagePath } from "../_utils/contract-page-path";
@@ -32,6 +32,7 @@ interface NFTCardsProps {
3232
isPending: boolean;
3333
allNfts?: boolean;
3434
projectMeta: ProjectMeta | undefined;
35+
client: ThirdwebClient;
3536
}
3637

3738
export const NFTCards: React.FC<NFTCardsProps> = ({
@@ -40,6 +41,7 @@ export const NFTCards: React.FC<NFTCardsProps> = ({
4041
isPending,
4142
allNfts,
4243
projectMeta,
44+
client,
4345
}) => {
4446
const dummyData = useMemo(() => {
4547
return Array.from({
@@ -73,6 +75,7 @@ export const NFTCards: React.FC<NFTCardsProps> = ({
7375
requireInteraction
7476
width="100%"
7577
height="100%"
78+
client={client}
7679
/>
7780
);
7881
}}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
528528
form.setValue(`phases.${index}.snapshot`, snapshot)
529529
}
530530
isDisabled={!canEditForm}
531+
client={contract.client}
531532
/>
532533

533534
<ClaimsConditionFormContext.Provider

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/snapshot-upload.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useCsvUpload } from "hooks/useCsvUpload";
1414
import { CircleAlertIcon, DownloadIcon, UploadIcon } from "lucide-react";
1515
import { useRef } from "react";
1616
import type { Column } from "react-table";
17-
import { ZERO_ADDRESS } from "thirdweb";
17+
import { type ThirdwebClient, ZERO_ADDRESS } from "thirdweb";
1818
import { CsvDataTable } from "../csv-data-table";
1919

2020
interface SnapshotAddressInput {
@@ -30,6 +30,7 @@ interface SnapshotUploadProps {
3030
isDisabled: boolean;
3131
value?: SnapshotAddressInput[] | undefined;
3232
onClose: () => void;
33+
client: ThirdwebClient;
3334
}
3435

3536
const csvParser = (items: SnapshotAddressInput[]): SnapshotAddressInput[] => {
@@ -49,6 +50,7 @@ const SnapshotViewerSheetContent: React.FC<SnapshotUploadProps> = ({
4950
isDisabled,
5051
value,
5152
onClose,
53+
client,
5254
}) => {
5355
const {
5456
normalizeQuery,
@@ -59,7 +61,11 @@ const SnapshotViewerSheetContent: React.FC<SnapshotUploadProps> = ({
5961
noCsv,
6062
reset,
6163
removeInvalid,
62-
} = useCsvUpload<SnapshotAddressInput>({ csvParser, defaultRawData: value });
64+
} = useCsvUpload<SnapshotAddressInput>({
65+
csvParser,
66+
defaultRawData: value,
67+
client,
68+
});
6369

6470
const paginationPortalRef = useRef<HTMLDivElement>(null);
6571
const normalizeData = normalizeQuery.data;

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/_layout/ConfigureCustomChain.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import { ConfigureNetworks } from "components/configure-networks/ConfigureNetwor
66
import { CheckIcon, CircleAlertIcon, RotateCcwIcon } from "lucide-react";
77
import { useState } from "react";
88
import { addChainOverrides } from "stores/chainStores";
9+
import type { ThirdwebClient } from "thirdweb";
910

1011
export function ConfigureCustomChain(props: {
1112
chainSlug: string;
13+
client: ThirdwebClient;
1214
}) {
1315
const { chainSlug } = props;
1416
const isSlugNumber = Number.isInteger(Number(chainSlug));
@@ -61,6 +63,7 @@ export function ConfigureCustomChain(props: {
6163
}
6264
}}
6365
editChain={undefined}
66+
client={props.client}
6467
/>
6568
</div>
6669
</div>

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/_layout/contract-metadata.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export async function getContractMetadataHeaderData(
4343
fetchDashboardContractMetadata(contract),
4444
fetchPublishedContractsFromDeploy({
4545
contract,
46-
client: contract.client,
4746
}),
4847
]);
4948

0 commit comments

Comments
 (0)