Skip to content
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 @@ -25,6 +25,7 @@ export function ContractSettingsPageClient(props: {
contract={props.contract}
functionSelectors={metadataQuery.data.functionSelectors}
twAccount={props.twAccount}
hasDefaultFeeConfig={true}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ export function ContractSettingsPage(props: {
contract: ThirdwebContract;
functionSelectors: string[];
twAccount: Account | undefined;
hasDefaultFeeConfig: boolean;
}) {
const { functionSelectors, contract, twAccount } = props;
const { functionSelectors, contract, twAccount, hasDefaultFeeConfig } = props;
return (
<ContractSettingsPageInner
contract={contract}
Expand All @@ -96,10 +97,13 @@ export function ContractSettingsPage(props: {
CommonExt.isGetDefaultRoyaltyInfoSupported(functionSelectors),
CommonExt.isSetDefaultRoyaltyInfoSupported(functionSelectors),
].every(Boolean)}
isPlatformFeesSupported={[
CommonExt.isGetPlatformFeeInfoSupported(functionSelectors),
CommonExt.isSetPlatformFeeInfoSupported(functionSelectors),
].every(Boolean)}
isPlatformFeesSupported={
!hasDefaultFeeConfig &&
[
CommonExt.isGetPlatformFeeInfoSupported(functionSelectors),
CommonExt.isSetPlatformFeeInfoSupported(functionSelectors),
].every(Boolean)
}
twAccount={twAccount}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DEFAULT_FEE_RECIPIENT } from "constants/addresses";
import { notFound } from "next/navigation";
import { localhost } from "thirdweb/chains";
import { getPlatformFeeInfo } from "thirdweb/extensions/common";
import { getRawAccount } from "../../../../../account/settings/getAccount";
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
Expand Down Expand Up @@ -33,11 +35,19 @@ export default async function Page(props: {
getContractPageMetadata(info.contract),
]);

let hasDefaultFeeConfig = true;
try {
const feeInfo = await getPlatformFeeInfo({ contract });
hasDefaultFeeConfig =
feeInfo[0].toLowerCase() === DEFAULT_FEE_RECIPIENT.toLowerCase();
} catch {}

return (
<ContractSettingsPage
contract={info.contract}
functionSelectors={metadata.functionSelectors}
twAccount={account}
hasDefaultFeeConfig={hasDefaultFeeConfig}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Flex, FormControl } from "@chakra-ui/react";
import { useMutation, useQuery } from "@tanstack/react-query";
import { verifyContract } from "app/(dashboard)/(chain)/[chain_id]/[contractAddress]/sources/ContractSourcesPage";
import { NetworkSelectorButton } from "components/selects/NetworkSelectorButton";
import { DEFAULT_FEE_BPS, DEFAULT_FEE_RECIPIENT } from "constants/addresses";
import { SolidityInput } from "contract-ui/components/solidity-inputs";
import { useTrack } from "hooks/analytics/useTrack";
import { useTxNotifications } from "hooks/useTxNotifications";
Expand Down Expand Up @@ -190,6 +191,8 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
!isFactoryDeployment &&
(metadata?.name.includes("AccountFactory") || false);

const isMarketplace = metadata?.name.includes("MarketplaceV3") || false;

const parsedDeployParams = useMemo(
() => ({
...deployParams.reduce(
Expand Down Expand Up @@ -445,9 +448,8 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
name: params.contractMetadata?.name || "",
contractURI: _contractURI,
defaultAdmin: params.deployParams._defaultAdmin as string,
platformFeeBps: Number(params.deployParams._platformFeeBps),
platformFeeRecipient: params.deployParams
._platformFeeRecipient as string,
platformFeeBps: DEFAULT_FEE_BPS,
platformFeeRecipient: DEFAULT_FEE_RECIPIENT,
trustedForwarders: params.deployParams._trustedForwarders
? JSON.parse(params.deployParams._trustedForwarders as string)
: undefined,
Expand All @@ -462,6 +464,8 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
payees,
shares,
_contractURI,
_platformFeeBps: DEFAULT_FEE_BPS,
_platformFeeRecipient: DEFAULT_FEE_RECIPIENT,
};

const salt = params.deployDeterministic
Expand Down Expand Up @@ -707,7 +711,9 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
/>
)}

{hasPlatformFee && <PlatformFeeFieldset form={form} />}
{hasPlatformFee && (
<PlatformFeeFieldset isMarketplace={isMarketplace} />
)}

{isSplit && <SplitFieldset form={form} />}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,45 @@
import { FormFieldSetup } from "@/components/blocks/FormFieldSetup";
import { BasisPointsInput } from "components/inputs/BasisPointsInput";
import { SolidityInput } from "contract-ui/components/solidity-inputs";
import Link from "next/link";
import { Fieldset } from "./common";
import type { CustomContractDeploymentForm } from "./custom-contract";

interface PlatformFeeFieldsetProps {
form: CustomContractDeploymentForm;
isMarketplace: boolean;
}

export const PlatformFeeFieldset: React.FC<PlatformFeeFieldsetProps> = ({
form,
}) => {
export const PlatformFeeFieldset: React.FC<PlatformFeeFieldsetProps> = (
props,
) => {
return (
<Fieldset legend="Platform fees">
<div className="flex flex-col gap-4 md:flex-row">
<FormFieldSetup
className="grow"
label="Recipient Address"
isRequired
errorMessage={
form.getFieldState(
"deployParams._platformFeeRecipient",
form.formState,
).error?.message
}
helperText={
<>
For contract with primary sales, get additional fees for all
primary sales that happen on this contract. (This is useful if you
are deploying this contract for a 3rd party and want to take fees
for your service). <br /> If this contract is a marketplace, get a
percentage of all the secondary sales that happen on your
contract.
</>
}
>
<SolidityInput
solidityType="address"
{...form.register("deployParams._platformFeeRecipient")}
/>
</FormFieldSetup>

<FormFieldSetup
label="Percentage"
isRequired
className="shrink-0 md:max-w-[150px]"
errorMessage={
form.getFieldState("deployParams._platformFeeBps", form.formState)
.error?.message
}
>
<BasisPointsInput
value={Number(form.watch("deployParams._platformFeeBps"))}
onChange={(value) =>
form.setValue("deployParams._platformFeeBps", value.toString(), {
shouldTouch: true,
})
}
/>
</FormFieldSetup>
{props.isMarketplace ? (
<p className="mb-3 pt-4 text-muted-foreground text-sm italic">
A 2.5% platform fee is deducted from each sale to support ongoing
platform operations and improvements.{" "}
<Link
target="_blank"
className="text-blue-500 underline"
href={
"https://blog.thirdweb.com/mint-fees-for-contract-deployments-update/"
}
>
Read more.
</Link>
</p>
) : (
<p className="mb-3 pt-4 text-muted-foreground text-sm italic">
A 2.5% platform fee is deducted from each primary sale price to
support ongoing platform operations and improvements.{" "}
<Link
target="_blank"
className="text-blue-500 underline"
href={
"https://blog.thirdweb.com/mint-fees-for-contract-deployments-update/"
}
>
Read more.
</Link>
</p>
)}
</div>
</Fieldset>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,14 @@ export const ContractFunctionsPanel: React.FC<ContractFunctionsPanelProps> = ({
}) => {
// TODO: clean this up
const functionsWithExtension = useMemo(() => {
const allFunctions = fnsOrEvents.filter((f) => f.type === "function");
const allFunctions = fnsOrEvents
.filter((f) => f.type === "function")
.filter(
(f) =>
f.name !== "setPlatformFeeInfo" &&
f.name !== "setFlatPlatformFeeInfo" &&
f.name !== "setPlatformFeeType",
);
const results: ExtensionFunctions[] = [];
results.push({
extension: "",
Expand Down
5 changes: 5 additions & 0 deletions apps/dashboard/src/constants/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
export const THIRDWEB_DEPLOYER_ADDRESS =
"0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024";

export const DEFAULT_FEE_RECIPIENT =
"0x1af20c6b23373350ad464700b5965ce4b0d2ad94";

export const DEFAULT_FEE_BPS = 250;
Loading