Skip to content

Dashboard: Reduce useThirdwebClient hook usage #4 #7227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const CancelTab: React.FC<CancelTabProps> = ({
return (
<div className="flex flex-col gap-3 pt-3">
<TransactionButton
client={contract.client}
isLoggedIn={isLoggedIn}
txChainID={contract.chain.id}
transactionCount={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ export const CreateListingsForm: React.FC<CreateListingsFormProps> = ({
Cancel
</Button>
<TransactionButton
client={contract.client}
isLoggedIn={isLoggedIn}
txChainID={contract.chain.id}
isPending={isFormLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
hasRemovedPhases ||
!isMultiPhase ? (
<TransactionButton
client={contract.client}
isLoggedIn={isLoggedIn}
txChainID={contract.chain.id}
transactionCount={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const ResetClaimEligibility: React.FC<ResetClaimEligibilityProps> = ({
return (
<AdminOnly contract={contract} fallback={<div className="pb-5" />}>
<TransactionButton
client={contract.client}
isLoggedIn={isLoggedIn}
transactionCount={1}
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const DepositNative: React.FC<DepositNativeProps> = ({
value={amount}
/>
<TransactionButton
client={client}
isLoggedIn={isLoggedIn}
txChainID={v5Chain.id}
transactionCount={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const CreateAccountButton: React.FC<CreateAccountButtonProps> = ({

return (
<TransactionButton
client={contract.client}
isLoggedIn={isLoggedIn}
txChainID={contract.chain.id}
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useTxNotifications } from "hooks/useTxNotifications";
import { CircleAlertIcon } from "lucide-react";
import { useCallback } from "react";
import { useForm } from "react-hook-form";
import { sendAndConfirmTransaction } from "thirdweb";
import { type ThirdwebClient, sendAndConfirmTransaction } from "thirdweb";
import { BatchMetadataERC721, BatchMetadataERC1155 } from "thirdweb/modules";
import { parseAttributes } from "utils/parseAttributes";
import { z } from "zod";
Expand Down Expand Up @@ -105,6 +105,7 @@ export function BatchMetadataModuleUI(
uploadMetadata: (values: UploadMetadataFormValues) => Promise<void>;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
},
) {
return (
Expand All @@ -122,6 +123,7 @@ export function BatchMetadataModuleUI(
isLoggedIn={props.isLoggedIn}
uploadMetadata={props.uploadMetadata}
contractChainId={props.contractChainId}
client={props.client}
/>
)}
{!props.isOwnerAccount && (
Expand Down Expand Up @@ -164,6 +166,7 @@ function UploadMetadataNFTSection(props: {
uploadMetadata: (values: UploadMetadataFormValues) => Promise<void>;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const form = useForm<UploadMetadataFormValues>({
resolver: zodResolver(uploadMetadataFormSchema),
Expand Down Expand Up @@ -262,6 +265,7 @@ function UploadMetadataNFTSection(props: {

<div className="flex justify-end">
<TransactionButton
client={props.client}
isLoggedIn={props.isLoggedIn}
size="sm"
className="min-w-24"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { useFieldArray, useForm } from "react-hook-form";
import {
NATIVE_TOKEN_ADDRESS,
type PreparedTransaction,
type ThirdwebClient,
ZERO_ADDRESS,
getContract,
sendAndConfirmTransaction,
Expand Down Expand Up @@ -343,6 +344,7 @@ export function ClaimableModuleUI(
isLoading: boolean;
};
isLoggedIn: boolean;
client: ThirdwebClient;
},
) {
return (
Expand All @@ -358,6 +360,7 @@ export function ClaimableModuleUI(
</AccordionTrigger>
<AccordionContent className="px-1">
<MintNFTSection
client={props.client}
mint={props.mintSection.mint}
name={props.name}
contractChainId={props.contractChainId}
Expand Down Expand Up @@ -390,6 +393,7 @@ export function ClaimableModuleUI(
{props.name !== "ClaimableERC1155" || props.isValidTokenId ? (
props.claimConditionSection.data ? (
<ClaimConditionSection
client={props.client}
isLoggedIn={props.isLoggedIn}
isOwnerAccount={props.isOwnerAccount}
claimCondition={
Expand Down Expand Up @@ -424,6 +428,7 @@ export function ClaimableModuleUI(
<AccordionContent className="px-1">
{props.primarySaleRecipientSection.data ? (
<PrimarySaleRecipientSection
client={props.client}
isLoggedIn={props.isLoggedIn}
isOwnerAccount={props.isOwnerAccount}
primarySaleRecipient={
Expand Down Expand Up @@ -490,6 +495,7 @@ function ClaimConditionSection(props: {
tokenId: string;
noClaimConditionSet: boolean;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const { idToChain } = useAllChainsData();
const chain = idToChain.get(props.chainId);
Expand Down Expand Up @@ -741,6 +747,7 @@ function ClaimConditionSection(props: {

<div className="flex justify-end">
<TransactionButton
client={props.client}
isLoggedIn={props.isLoggedIn}
size="sm"
className="min-w-24"
Expand Down Expand Up @@ -775,6 +782,7 @@ function PrimarySaleRecipientSection(props: {
isOwnerAccount: boolean;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const form = useForm<PrimarySaleRecipientFormValues>({
resolver: zodResolver(primarySaleRecipientFormSchema),
Expand Down Expand Up @@ -823,6 +831,7 @@ function PrimarySaleRecipientSection(props: {

<div className="flex justify-end">
<TransactionButton
client={props.client}
isLoggedIn={props.isLoggedIn}
size="sm"
className="min-w-24 gap-2"
Expand Down Expand Up @@ -859,6 +868,7 @@ function MintNFTSection(props: {
name: string;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const form = useForm<MintFormValues>({
resolver: zodResolver(mintFormSchema),
Expand Down Expand Up @@ -940,6 +950,7 @@ function MintNFTSection(props: {

<div className="flex justify-end">
<TransactionButton
client={props.client}
size="sm"
className="min-w-24 gap-2"
disabled={mintMutation.isPending}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import { useTxNotifications } from "hooks/useTxNotifications";
import { CircleAlertIcon } from "lucide-react";
import { useCallback } from "react";
import { useForm } from "react-hook-form";
import { type PreparedTransaction, sendAndConfirmTransaction } from "thirdweb";
import {
type PreparedTransaction,
type ThirdwebClient,
sendAndConfirmTransaction,
} from "thirdweb";
import {
MintableERC20,
MintableERC721,
Expand Down Expand Up @@ -193,6 +197,7 @@ export function MintableModuleUI(
isBatchMetadataInstalled: boolean;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
},
) {
return (
Expand All @@ -216,6 +221,7 @@ export function MintableModuleUI(
name={props.name}
isBatchMetadataInstalled={props.isBatchMetadataInstalled}
contractChainId={props.contractChainId}
client={props.client}
/>
)}
{!props.isOwnerAccount && (
Expand Down Expand Up @@ -243,6 +249,7 @@ export function MintableModuleUI(
update={props.updatePrimaryRecipient}
contractChainId={props.contractChainId}
isLoggedIn={props.isLoggedIn}
client={props.client}
/>
</AccordionContent>
</AccordionItem>
Expand All @@ -263,6 +270,7 @@ function PrimarySalesSection(props: {
isOwnerAccount: boolean;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const form = useForm<UpdateFormValues>({
resolver: zodResolver(primarySaleRecipientFormSchema),
Expand Down Expand Up @@ -312,6 +320,7 @@ function PrimarySalesSection(props: {

<div className="mt-4 flex justify-end">
<TransactionButton
client={props.client}
isLoggedIn={props.isLoggedIn}
size="sm"
className="min-w-24"
Expand Down Expand Up @@ -341,6 +350,7 @@ function MintNFTSection(props: {
isBatchMetadataInstalled: boolean;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const form = useForm<MintFormValues>({
resolver: zodResolver(mintFormSchema),
Expand Down Expand Up @@ -524,6 +534,7 @@ function MintNFTSection(props: {

<div className="flex justify-end">
<TransactionButton
client={props.client}
isLoggedIn={props.isLoggedIn}
size="sm"
className="min-w-24"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export const InstallModuleForm = (props: InstallModuleFormProps) => {
{/* Submit */}
<div className="flex justify-end">
<TransactionButton
client={contract.client}
isLoggedIn={props.isLoggedIn}
txChainID={contract.chain.id}
transactionCount={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useTxNotifications } from "hooks/useTxNotifications";
import { CircleAlertIcon } from "lucide-react";
import { useCallback } from "react";
import { useForm } from "react-hook-form";
import { sendAndConfirmTransaction } from "thirdweb";
import { type ThirdwebClient, sendAndConfirmTransaction } from "thirdweb";
import { OpenEditionMetadataERC721 } from "thirdweb/modules";
import { z } from "zod";
import { ModuleCardUI, type ModuleCardUIProps } from "./module-card";
Expand Down Expand Up @@ -100,6 +100,7 @@ export function OpenEditionMetadataModuleUI(
setSharedMetadata={props.setSharedMetadata}
contractChainId={props.contractChainId}
isLoggedIn={props.isLoggedIn}
client={props.client}
/>
)}
{!props.isOwnerAccount && (
Expand All @@ -122,6 +123,7 @@ function SetSharedMetadataSection(props: {
setSharedMetadata: (values: SetSharedMetadataFormValues) => Promise<void>;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const form = useForm<SetSharedMetadataFormValues>({
resolver: zodResolver(setSharedMetadataFormSchema),
Expand Down Expand Up @@ -213,6 +215,7 @@ function SetSharedMetadataSection(props: {
<div className="flex justify-end">
<TransactionButton
size="sm"
client={props.client}
className="min-w-24"
disabled={setSharedMetadataMutation.isPending}
type="submit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useTxNotifications } from "hooks/useTxNotifications";
import { CircleAlertIcon } from "lucide-react";
import { useCallback } from "react";
import { useForm } from "react-hook-form";
import { sendAndConfirmTransaction } from "thirdweb";
import { type ThirdwebClient, sendAndConfirmTransaction } from "thirdweb";
import { RoyaltyERC721, RoyaltyERC1155 } from "thirdweb/modules";
import { useReadContract } from "thirdweb/react";
import { z } from "zod";
Expand Down Expand Up @@ -187,6 +187,7 @@ export function RoyaltyModuleUI(
setRoyaltyInfoForToken={props.setRoyaltyInfoForToken}
contractChainId={props.contractChainId}
isLoggedIn={props.isLoggedIn}
client={props.client}
/>
) : (
<Alert variant="info">
Expand All @@ -210,6 +211,7 @@ export function RoyaltyModuleUI(
defaultRoyaltyInfo={props.defaultRoyaltyInfo}
contractChainId={props.contractChainId}
isLoggedIn={props.isLoggedIn}
client={props.client}
/>
) : (
<Alert variant="info">
Expand All @@ -233,6 +235,7 @@ export function RoyaltyModuleUI(
transferValidator={props.transferValidator}
contractChainId={props.contractChainId}
isLoggedIn={props.isLoggedIn}
client={props.client}
/>
) : (
<Alert variant="info">
Expand Down Expand Up @@ -270,6 +273,7 @@ function RoyaltyInfoPerTokenSection(props: {
setRoyaltyInfoForToken: (values: RoyaltyInfoFormValues) => Promise<void>;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const form = useForm<RoyaltyInfoFormValues>({
resolver: zodResolver(royaltyInfoFormSchema),
Expand Down Expand Up @@ -349,6 +353,7 @@ function RoyaltyInfoPerTokenSection(props: {

<div className="mt-4 flex justify-end">
<TransactionButton
client={props.client}
isLoggedIn={props.isLoggedIn}
size="sm"
className="min-w-24"
Expand Down Expand Up @@ -384,6 +389,7 @@ function DefaultRoyaltyInfoSection(props: {
update: (values: DefaultRoyaltyFormValues) => Promise<void>;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const [defaultRoyaltyRecipient, defaultRoyaltyPercentage] =
props.defaultRoyaltyInfo || [];
Expand Down Expand Up @@ -453,6 +459,7 @@ function DefaultRoyaltyInfoSection(props: {

<div className="mt-4 flex justify-end">
<TransactionButton
client={props.client}
size="sm"
className="min-w-24"
disabled={updateMutation.isPending}
Expand Down Expand Up @@ -484,6 +491,7 @@ function TransferValidatorSection(props: {
update: (values: TransferValidatorFormValues) => Promise<void>;
contractChainId: number;
isLoggedIn: boolean;
client: ThirdwebClient;
}) {
const form = useForm<TransferValidatorFormValues>({
resolver: zodResolver(transferValidatorFormSchema),
Expand Down Expand Up @@ -531,6 +539,7 @@ function TransferValidatorSection(props: {

<div className="mt-4 flex justify-end">
<TransactionButton
client={props.client}
isLoggedIn={props.isLoggedIn}
size="sm"
className="min-w-24 gap-2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export function TransferableModuleUI(
updateButton={() => {
return (
<TransactionButton
client={props.client}
size="sm"
className="min-w-24 gap-2"
type="submit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export function ModuleCard(props: ModuleCardProps) {
</Button>

<TransactionButton
client={contract.client}
isLoggedIn={props.isLoggedIn}
txChainID={contract.chain.id}
transactionCount={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const AirdropTab: React.FC<AirdropTabProps> = ({
more, please do it in multiple transactions.
</p>
<TransactionButton
client={contract.client}
isLoggedIn={isLoggedIn}
txChainID={contract.chain.id}
transactionCount={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const BurnTab: React.FC<BurnTabProps> = ({ contract, tokenId, isLoggedIn }) => {
</Text>
)}
<TransactionButton
client={contract.client}
transactionCount={1}
isPending={isPending}
disabled={checking1155 || checking721 || isPending || !account}
Expand Down
Loading
Loading