Skip to content

Commit 0c1bb6c

Browse files
committed
[Dashboard] Deploy config updates (#6159)
TOOL-3389 <!-- ## 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 introduces a default fee configuration for contract deployments, updates the handling of platform fees, and improves the UI components related to fee management, ensuring that default values are used consistently throughout the application. ### Detailed summary - Added `DEFAULT_FEE_RECIPIENT` and `DEFAULT_FEE_BPS` to `addresses.ts`. - Introduced `hasDefaultFeeConfig` in `ContractSettingsPage`. - Filtered out specific functions related to platform fees in `contract-function.tsx`. - Integrated platform fee logic in `CustomContractForm`. - Updated `PlatformFeeFieldset` to reflect marketplace conditions. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent dceb47d commit 0c1bb6c

File tree

7 files changed

+77
-63
lines changed

7 files changed

+77
-63
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/settings/ContractSettingsPage.client.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function ContractSettingsPageClient(props: {
2525
contract={props.contract}
2626
functionSelectors={metadataQuery.data.functionSelectors}
2727
twAccount={props.twAccount}
28+
hasDefaultFeeConfig={true}
2829
/>
2930
);
3031
}

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/settings/ContractSettingsPage.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ export function ContractSettingsPage(props: {
7979
contract: ThirdwebContract;
8080
functionSelectors: string[];
8181
twAccount: Account | undefined;
82+
hasDefaultFeeConfig: boolean;
8283
}) {
83-
const { functionSelectors, contract, twAccount } = props;
84+
const { functionSelectors, contract, twAccount, hasDefaultFeeConfig } = props;
8485
return (
8586
<ContractSettingsPageInner
8687
contract={contract}
@@ -96,10 +97,13 @@ export function ContractSettingsPage(props: {
9697
CommonExt.isGetDefaultRoyaltyInfoSupported(functionSelectors),
9798
CommonExt.isSetDefaultRoyaltyInfoSupported(functionSelectors),
9899
].every(Boolean)}
99-
isPlatformFeesSupported={[
100-
CommonExt.isGetPlatformFeeInfoSupported(functionSelectors),
101-
CommonExt.isSetPlatformFeeInfoSupported(functionSelectors),
102-
].every(Boolean)}
100+
isPlatformFeesSupported={
101+
!hasDefaultFeeConfig &&
102+
[
103+
CommonExt.isGetPlatformFeeInfoSupported(functionSelectors),
104+
CommonExt.isSetPlatformFeeInfoSupported(functionSelectors),
105+
].every(Boolean)
106+
}
103107
twAccount={twAccount}
104108
/>
105109
);

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/settings/page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { DEFAULT_FEE_RECIPIENT } from "constants/addresses";
12
import { notFound } from "next/navigation";
23
import { localhost } from "thirdweb/chains";
4+
import { getPlatformFeeInfo } from "thirdweb/extensions/common";
35
import { getRawAccount } from "../../../../../account/settings/getAccount";
46
import { getContractPageParamsInfo } from "../_utils/getContractFromParams";
57
import { getContractPageMetadata } from "../_utils/getContractPageMetadata";
@@ -33,11 +35,19 @@ export default async function Page(props: {
3335
getContractPageMetadata(info.contract),
3436
]);
3537

38+
let hasDefaultFeeConfig = true;
39+
try {
40+
const feeInfo = await getPlatformFeeInfo({ contract });
41+
hasDefaultFeeConfig =
42+
feeInfo[0].toLowerCase() === DEFAULT_FEE_RECIPIENT.toLowerCase();
43+
} catch {}
44+
3645
return (
3746
<ContractSettingsPage
3847
contract={info.contract}
3948
functionSelectors={metadata.functionSelectors}
4049
twAccount={account}
50+
hasDefaultFeeConfig={hasDefaultFeeConfig}
4151
/>
4252
);
4353
}

apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Flex, FormControl } from "@chakra-ui/react";
1515
import { useMutation, useQuery } from "@tanstack/react-query";
1616
import { verifyContract } from "app/(dashboard)/(chain)/[chain_id]/[contractAddress]/sources/ContractSourcesPage";
1717
import { NetworkSelectorButton } from "components/selects/NetworkSelectorButton";
18+
import { DEFAULT_FEE_BPS, DEFAULT_FEE_RECIPIENT } from "constants/addresses";
1819
import { SolidityInput } from "contract-ui/components/solidity-inputs";
1920
import { useTrack } from "hooks/analytics/useTrack";
2021
import { useTxNotifications } from "hooks/useTxNotifications";
@@ -190,6 +191,8 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
190191
!isFactoryDeployment &&
191192
(metadata?.name.includes("AccountFactory") || false);
192193

194+
const isMarketplace = metadata?.name.includes("MarketplaceV3") || false;
195+
193196
const parsedDeployParams = useMemo(
194197
() => ({
195198
...deployParams.reduce(
@@ -445,9 +448,8 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
445448
name: params.contractMetadata?.name || "",
446449
contractURI: _contractURI,
447450
defaultAdmin: params.deployParams._defaultAdmin as string,
448-
platformFeeBps: Number(params.deployParams._platformFeeBps),
449-
platformFeeRecipient: params.deployParams
450-
._platformFeeRecipient as string,
451+
platformFeeBps: DEFAULT_FEE_BPS,
452+
platformFeeRecipient: DEFAULT_FEE_RECIPIENT,
451453
trustedForwarders: params.deployParams._trustedForwarders
452454
? JSON.parse(params.deployParams._trustedForwarders as string)
453455
: undefined,
@@ -462,6 +464,8 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
462464
payees,
463465
shares,
464466
_contractURI,
467+
_platformFeeBps: DEFAULT_FEE_BPS,
468+
_platformFeeRecipient: DEFAULT_FEE_RECIPIENT,
465469
};
466470

467471
const salt = params.deployDeterministic
@@ -707,7 +711,9 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
707711
/>
708712
)}
709713

710-
{hasPlatformFee && <PlatformFeeFieldset form={form} />}
714+
{hasPlatformFee && (
715+
<PlatformFeeFieldset isMarketplace={isMarketplace} />
716+
)}
711717

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

apps/dashboard/src/components/contract-components/contract-deploy-form/platform-fee-fieldset.tsx

Lines changed: 34 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,45 @@
1-
import { FormFieldSetup } from "@/components/blocks/FormFieldSetup";
2-
import { BasisPointsInput } from "components/inputs/BasisPointsInput";
3-
import { SolidityInput } from "contract-ui/components/solidity-inputs";
1+
import Link from "next/link";
42
import { Fieldset } from "./common";
5-
import type { CustomContractDeploymentForm } from "./custom-contract";
63

74
interface PlatformFeeFieldsetProps {
8-
form: CustomContractDeploymentForm;
5+
isMarketplace: boolean;
96
}
107

11-
export const PlatformFeeFieldset: React.FC<PlatformFeeFieldsetProps> = ({
12-
form,
13-
}) => {
8+
export const PlatformFeeFieldset: React.FC<PlatformFeeFieldsetProps> = (
9+
props,
10+
) => {
1411
return (
1512
<Fieldset legend="Platform fees">
1613
<div className="flex flex-col gap-4 md:flex-row">
17-
<FormFieldSetup
18-
className="grow"
19-
label="Recipient Address"
20-
isRequired
21-
errorMessage={
22-
form.getFieldState(
23-
"deployParams._platformFeeRecipient",
24-
form.formState,
25-
).error?.message
26-
}
27-
helperText={
28-
<>
29-
For contract with primary sales, get additional fees for all
30-
primary sales that happen on this contract. (This is useful if you
31-
are deploying this contract for a 3rd party and want to take fees
32-
for your service). <br /> If this contract is a marketplace, get a
33-
percentage of all the secondary sales that happen on your
34-
contract.
35-
</>
36-
}
37-
>
38-
<SolidityInput
39-
solidityType="address"
40-
{...form.register("deployParams._platformFeeRecipient")}
41-
/>
42-
</FormFieldSetup>
43-
44-
<FormFieldSetup
45-
label="Percentage"
46-
isRequired
47-
className="shrink-0 md:max-w-[150px]"
48-
errorMessage={
49-
form.getFieldState("deployParams._platformFeeBps", form.formState)
50-
.error?.message
51-
}
52-
>
53-
<BasisPointsInput
54-
value={Number(form.watch("deployParams._platformFeeBps"))}
55-
onChange={(value) =>
56-
form.setValue("deployParams._platformFeeBps", value.toString(), {
57-
shouldTouch: true,
58-
})
59-
}
60-
/>
61-
</FormFieldSetup>
14+
{props.isMarketplace ? (
15+
<p className="mb-3 pt-4 text-muted-foreground text-sm italic">
16+
A 2.5% platform fee is deducted from each sale to support ongoing
17+
platform operations and improvements.{" "}
18+
<Link
19+
target="_blank"
20+
className="text-blue-500 underline"
21+
href={
22+
"https://blog.thirdweb.com/mint-fees-for-contract-deployments-update/"
23+
}
24+
>
25+
Read more.
26+
</Link>
27+
</p>
28+
) : (
29+
<p className="mb-3 pt-4 text-muted-foreground text-sm italic">
30+
A 2.5% platform fee is deducted from each primary sale price to
31+
support ongoing platform operations and improvements.{" "}
32+
<Link
33+
target="_blank"
34+
className="text-blue-500 underline"
35+
href={
36+
"https://blog.thirdweb.com/mint-fees-for-contract-deployments-update/"
37+
}
38+
>
39+
Read more.
40+
</Link>
41+
</p>
42+
)}
6243
</div>
6344
</Fieldset>
6445
);

apps/dashboard/src/components/contract-functions/contract-function.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,14 @@ export const ContractFunctionsPanel: React.FC<ContractFunctionsPanelProps> = ({
286286
}) => {
287287
// TODO: clean this up
288288
const functionsWithExtension = useMemo(() => {
289-
const allFunctions = fnsOrEvents.filter((f) => f.type === "function");
289+
const allFunctions = fnsOrEvents
290+
.filter((f) => f.type === "function")
291+
.filter(
292+
(f) =>
293+
f.name !== "setPlatformFeeInfo" &&
294+
f.name !== "setFlatPlatformFeeInfo" &&
295+
f.name !== "setPlatformFeeType",
296+
);
290297
const results: ExtensionFunctions[] = [];
291298
results.push({
292299
extension: "",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
export const THIRDWEB_DEPLOYER_ADDRESS =
22
"0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024";
3+
4+
export const DEFAULT_FEE_RECIPIENT =
5+
"0x1af20c6b23373350ad464700b5965ce4b0d2ad94";
6+
7+
export const DEFAULT_FEE_BPS = 250;

0 commit comments

Comments
 (0)