Skip to content

Commit a230532

Browse files
committed
Update deploy config (#6667)
<!-- ## 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 support for contracts that have no fees by adding new properties and constants to handle fee exemption logic. It modifies several components to utilize the new metadata and fee configurations, ensuring that contracts can be deployed without fees based on specific versions and chains. ### Detailed summary - Added `contractMetadataNoFee` prop to `DeployFormForUri` and `CustomContractForm`. - Introduced `ZERO_FEE_VERSIONS` and `ZERO_FEE_CHAINS` constants in `fee-config.ts`. - Updated `DeployFormForPublishInfo` to fetch metadata for contracts without fees. - Adjusted fee logic in `CustomContractForm` to use `ZERO_FEE_CHAINS`. - Modified deployment logic to conditionally use fee-exempt metadata. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 60235ad commit a230532

File tree

6 files changed

+68
-37
lines changed

6 files changed

+68
-37
lines changed

apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default async function DirectDeployPage(props: DirectDeployPageProps) {
3333
/>
3434
<DeployFormForUri
3535
contractMetadata={metadata}
36+
contractMetadataNoFee={metadata}
3637
modules={null}
3738
pathname={`/contracts/deploy/${params.compiler_uri}`}
3839
/>

apps/dashboard/src/app/(dashboard)/published-contract/components/publish-based-deploy.tsx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
fetchPublishedContractVersion,
44
fetchPublishedContractVersions,
55
} from "components/contract-components/fetch-contracts-with-versions";
6+
import { ZERO_FEE_VERSIONS } from "constants/fee-config";
67
import { isAddress } from "thirdweb";
78
import { fetchDeployMetadata } from "thirdweb/contract";
89
import { resolveAddress } from "thirdweb/extensions/ens";
@@ -46,29 +47,41 @@ export async function DeployFormForPublishInfo(props: PublishBasedDeployProps) {
4647
publishedContractVersions.find((v) => v.version === props.version) ||
4748
publishedContractVersions[0];
4849

50+
const publishedContractNoFee = publishedContractVersions.find(
51+
(v) => v.version === ZERO_FEE_VERSIONS[v.name],
52+
);
53+
4954
if (!publishedContract) {
5055
return null;
5156
}
5257

5358
const moduleUris = modules
5459
.filter((m) => m !== null && m !== undefined)
5560
.map((m) => m.publishMetadataUri);
56-
const [contractMetadata, ...fetchedModules] = await Promise.all([
57-
fetchDeployMetadata({
58-
client,
59-
// force `ipfs://` prefix
60-
uri: publishedContract.publishMetadataUri.startsWith("ipfs://")
61-
? publishedContract.publishMetadataUri
62-
: `ipfs://${publishedContract.publishMetadataUri}`,
63-
}).catch(() => null),
64-
...(moduleUris || []).map((uri) =>
61+
const [contractMetadata, contractMetadataNoFee, ...fetchedModules] =
62+
await Promise.all([
6563
fetchDeployMetadata({
6664
client,
6765
// force `ipfs://` prefix
68-
uri: uri.startsWith("ipfs://") ? uri : `ipfs://${uri}`,
66+
uri: publishedContract.publishMetadataUri.startsWith("ipfs://")
67+
? publishedContract.publishMetadataUri
68+
: `ipfs://${publishedContract.publishMetadataUri}`,
6969
}).catch(() => null),
70-
),
71-
]);
70+
fetchDeployMetadata({
71+
client,
72+
// force `ipfs://` prefix
73+
uri: publishedContractNoFee?.publishMetadataUri.startsWith("ipfs://")
74+
? publishedContractNoFee.publishMetadataUri
75+
: `ipfs://${publishedContractNoFee?.publishMetadataUri}`,
76+
}).catch(() => null),
77+
...(moduleUris || []).map((uri) =>
78+
fetchDeployMetadata({
79+
client,
80+
// force `ipfs://` prefix
81+
uri: uri.startsWith("ipfs://") ? uri : `ipfs://${uri}`,
82+
}).catch(() => null),
83+
),
84+
]);
7285

7386
return (
7487
<div className="mx-auto flex w-full max-w-[1000px] flex-col gap-8 pb-20">
@@ -79,6 +92,7 @@ export async function DeployFormForPublishInfo(props: PublishBasedDeployProps) {
7992
/>
8093
<DeployFormForUri
8194
contractMetadata={contractMetadata}
95+
contractMetadataNoFee={contractMetadataNoFee}
8296
modules={fetchedModules.filter((m) => m !== null)}
8397
pathname={`/${props.publisher}/${props.contract_id}${props.version ? `/${props.version}` : ""}/deploy`}
8498
/>

apps/dashboard/src/app/(dashboard)/published-contract/components/uri-based-deploy.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import { loginRedirect } from "../../../login/loginRedirect";
88

99
type DeployFormForUriProps = {
1010
contractMetadata: FetchDeployMetadataResult | null;
11+
contractMetadataNoFee: FetchDeployMetadataResult | null;
1112
modules: FetchDeployMetadataResult[] | null;
1213
pathname: string;
1314
};
1415

1516
export async function DeployFormForUri(props: DeployFormForUriProps) {
16-
const { contractMetadata, modules, pathname } = props;
17+
const { contractMetadata, contractMetadataNoFee, modules, pathname } = props;
1718

1819
if (!contractMetadata) {
1920
return <div>Could not fetch metadata</div>;
@@ -46,6 +47,7 @@ export async function DeployFormForUri(props: DeployFormForUriProps) {
4647
<ChakraProviderSetup>
4748
<CustomContractForm
4849
metadata={contractMetadata}
50+
metadataNoFee={contractMetadataNoFee}
4951
modules={modules?.filter((m) => m !== null)}
5052
jwt={authToken}
5153
teamsAndProjects={teamsAndProjects}

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

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
DEFAULT_FEE_RECIPIENT,
2121
THIRDWEB_PUBLISHER_ADDRESS,
2222
} from "constants/addresses";
23+
import { ZERO_FEE_CHAINS } from "constants/fee-config";
2324
import { SolidityInput } from "contract-ui/components/solidity-inputs";
2425
import { useTrack } from "hooks/analytics/useTrack";
2526
import { useTxNotifications } from "hooks/useTxNotifications";
@@ -79,6 +80,7 @@ import { TrustedForwardersFieldset } from "./trusted-forwarders-fieldset";
7980

8081
interface CustomContractFormProps {
8182
metadata: FetchDeployMetadataResult;
83+
metadataNoFee: FetchDeployMetadataResult | null;
8284
jwt: string;
8385
modules?: FetchDeployMetadataResult[];
8486
teamsAndProjects: MinimalTeamsAndProjects;
@@ -150,6 +152,7 @@ function rewriteTwPublisher(publisher: string | undefined) {
150152

151153
export const CustomContractForm: React.FC<CustomContractFormProps> = ({
152154
metadata,
155+
metadataNoFee,
153156
modules,
154157
jwt,
155158
teamsAndProjects,
@@ -213,7 +216,8 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
213216
defaultFeeRecipientFunction &&
214217
metadata.publisher === THIRDWEB_PUBLISHER_ADDRESS;
215218

216-
const isFeeExempt = walletChain?.id === 232 || walletChain?.id === 37111;
219+
const isFeeExempt =
220+
walletChain?.id && ZERO_FEE_CHAINS.includes(walletChain.id);
217221

218222
const [customFactoryNetwork, customFactoryAddress] = Object.entries(
219223
metadata?.factoryDeploymentData?.customFactoryInput
@@ -514,19 +518,17 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
514518
name: params.contractMetadata?.name || "",
515519
contractURI: _contractURI,
516520
defaultAdmin: params.deployParams._defaultAdmin as string,
517-
platformFeeBps:
518-
metadata.version === "7.0.0" && isFeeExempt
519-
? Number(params.deployParams._platformFeeBps)
520-
: DEFAULT_FEE_BPS_NEW,
521-
platformFeeRecipient:
522-
metadata.version === "7.0.0" && isFeeExempt
523-
? (params.deployParams._platformFeeRecipient as string)
524-
: DEFAULT_FEE_RECIPIENT,
521+
platformFeeBps: isFeeExempt
522+
? Number(params.deployParams._platformFeeBps)
523+
: DEFAULT_FEE_BPS_NEW,
524+
platformFeeRecipient: isFeeExempt
525+
? (params.deployParams._platformFeeRecipient as string)
526+
: DEFAULT_FEE_RECIPIENT,
525527
trustedForwarders: params.deployParams._trustedForwarders
526528
? JSON.parse(params.deployParams._trustedForwarders as string)
527529
: undefined,
528530
},
529-
version: metadata.version,
531+
version: isFeeExempt ? "7.0.0" : metadata.version,
530532
});
531533
}
532534

@@ -536,15 +538,14 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
536538
payees,
537539
shares,
538540
_contractURI,
539-
platformFeeBps: hasInbuiltDefaultFeeConfig
540-
? DEFAULT_FEE_BPS_NEW
541-
: isFeeExempt
542-
? Number(params.deployParams._platformFeeBps)
541+
platformFeeBps: isFeeExempt
542+
? Number(params.deployParams._platformFeeBps)
543+
: hasInbuiltDefaultFeeConfig
544+
? DEFAULT_FEE_BPS_NEW
543545
: DEFAULT_FEE_BPS,
544-
platformFeeRecipient:
545-
!hasInbuiltDefaultFeeConfig && isFeeExempt
546-
? (params.deployParams._platformFeeRecipient as string)
547-
: DEFAULT_FEE_RECIPIENT,
546+
platformFeeRecipient: isFeeExempt
547+
? (params.deployParams._platformFeeRecipient as string)
548+
: DEFAULT_FEE_RECIPIENT,
548549
};
549550

550551
const salt = params.deployDeterministic
@@ -562,7 +563,7 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
562563
account: activeAccount,
563564
chain: walletChain,
564565
client: thirdwebClient,
565-
deployMetadata: metadata,
566+
deployMetadata: isFeeExempt && metadataNoFee ? metadataNoFee : metadata,
566567
initializeParams,
567568
implementationConstructorParams,
568569
salt,
@@ -782,11 +783,7 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
782783
<PlatformFeeFieldset
783784
form={form}
784785
isMarketplace={isMarketplace}
785-
disabled={
786-
hasInbuiltDefaultFeeConfig ||
787-
(isMarketplace && metadata.version !== "7.0.0") ||
788-
!isFeeExempt
789-
}
786+
disabled={!isFeeExempt}
790787
/>
791788
)}
792789

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export const ZERO_FEE_VERSIONS: Record<string, string> = {
2+
DropERC721: "5.0.5",
3+
DropERC1155: "5.0.5",
4+
DropERC20: "5.0.3",
5+
TokenERC721: "5.0.2",
6+
TokenERC1155: "5.0.2",
7+
TokenERC20: "5.0.2",
8+
LoyaltyCard: "5.0.3",
9+
MarketplaceV3: "7.0.0",
10+
OpenEditionERC721FlatFee: "1.0.2",
11+
};
12+
13+
export const ZERO_FEE_CHAINS = [232, 37111];

packages/thirdweb/src/contract/deployment/zksync/implementations.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export const ZKSYNC_IMPLEMENTATIONS: Record<number, Record<string, string>> = {
2020
[2741]: {
2121
MarketplaceV3: "0x4b14569c7B79DBe686Ac3Ba5996131E7EDaB7a93",
2222
},
23+
[232]: {
24+
MarketplaceV3: "0x9742f5ac11958cFAd151eBF0Fc31302fA409036E",
25+
},
2326
};
2427

2528
export const ZKSYNC_WETH: Record<number, string> = {
@@ -29,4 +32,5 @@ export const ZKSYNC_WETH: Record<number, string> = {
2932
[37111]: "0xaA91D645D7a6C1aeaa5988e0547267B77d33fe16",
3033
[555271]: "0xb0b8b267d44c64BA6dD1Daf442949887c85199f6",
3134
[2741]: "0x3439153EB7AF838Ad19d56E1571FBD09333C2809",
35+
[232]: "0xE5ecd226b3032910CEaa43ba92EE8232f8237553",
3236
};

0 commit comments

Comments
 (0)