From a2305329fd18b4509a8aeb1cbfa6c5f47ed7757d Mon Sep 17 00:00:00 2001 From: kumaryash90 Date: Wed, 9 Apr 2025 22:24:46 +0000 Subject: [PATCH] Update deploy config (#6667) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## 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}` --- .../contracts/deploy/[compiler_uri]/page.tsx | 1 + .../components/publish-based-deploy.tsx | 38 +++++++++++----- .../components/uri-based-deploy.tsx | 4 +- .../contract-deploy-form/custom-contract.tsx | 45 +++++++++---------- apps/dashboard/src/constants/fee-config.ts | 13 ++++++ .../deployment/zksync/implementations.ts | 4 ++ 6 files changed, 68 insertions(+), 37 deletions(-) create mode 100644 apps/dashboard/src/constants/fee-config.ts diff --git a/apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx b/apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx index 14e56aef9c0..b49bdd73970 100644 --- a/apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx +++ b/apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx @@ -33,6 +33,7 @@ export default async function DirectDeployPage(props: DirectDeployPageProps) { /> diff --git a/apps/dashboard/src/app/(dashboard)/published-contract/components/publish-based-deploy.tsx b/apps/dashboard/src/app/(dashboard)/published-contract/components/publish-based-deploy.tsx index 34c9ff3fd05..68775febebc 100644 --- a/apps/dashboard/src/app/(dashboard)/published-contract/components/publish-based-deploy.tsx +++ b/apps/dashboard/src/app/(dashboard)/published-contract/components/publish-based-deploy.tsx @@ -3,6 +3,7 @@ import { fetchPublishedContractVersion, fetchPublishedContractVersions, } from "components/contract-components/fetch-contracts-with-versions"; +import { ZERO_FEE_VERSIONS } from "constants/fee-config"; import { isAddress } from "thirdweb"; import { fetchDeployMetadata } from "thirdweb/contract"; import { resolveAddress } from "thirdweb/extensions/ens"; @@ -46,6 +47,10 @@ export async function DeployFormForPublishInfo(props: PublishBasedDeployProps) { publishedContractVersions.find((v) => v.version === props.version) || publishedContractVersions[0]; + const publishedContractNoFee = publishedContractVersions.find( + (v) => v.version === ZERO_FEE_VERSIONS[v.name], + ); + if (!publishedContract) { return null; } @@ -53,22 +58,30 @@ export async function DeployFormForPublishInfo(props: PublishBasedDeployProps) { const moduleUris = modules .filter((m) => m !== null && m !== undefined) .map((m) => m.publishMetadataUri); - const [contractMetadata, ...fetchedModules] = await Promise.all([ - fetchDeployMetadata({ - client, - // force `ipfs://` prefix - uri: publishedContract.publishMetadataUri.startsWith("ipfs://") - ? publishedContract.publishMetadataUri - : `ipfs://${publishedContract.publishMetadataUri}`, - }).catch(() => null), - ...(moduleUris || []).map((uri) => + const [contractMetadata, contractMetadataNoFee, ...fetchedModules] = + await Promise.all([ fetchDeployMetadata({ client, // force `ipfs://` prefix - uri: uri.startsWith("ipfs://") ? uri : `ipfs://${uri}`, + uri: publishedContract.publishMetadataUri.startsWith("ipfs://") + ? publishedContract.publishMetadataUri + : `ipfs://${publishedContract.publishMetadataUri}`, }).catch(() => null), - ), - ]); + fetchDeployMetadata({ + client, + // force `ipfs://` prefix + uri: publishedContractNoFee?.publishMetadataUri.startsWith("ipfs://") + ? publishedContractNoFee.publishMetadataUri + : `ipfs://${publishedContractNoFee?.publishMetadataUri}`, + }).catch(() => null), + ...(moduleUris || []).map((uri) => + fetchDeployMetadata({ + client, + // force `ipfs://` prefix + uri: uri.startsWith("ipfs://") ? uri : `ipfs://${uri}`, + }).catch(() => null), + ), + ]); return (
@@ -79,6 +92,7 @@ export async function DeployFormForPublishInfo(props: PublishBasedDeployProps) { /> m !== null)} pathname={`/${props.publisher}/${props.contract_id}${props.version ? `/${props.version}` : ""}/deploy`} /> diff --git a/apps/dashboard/src/app/(dashboard)/published-contract/components/uri-based-deploy.tsx b/apps/dashboard/src/app/(dashboard)/published-contract/components/uri-based-deploy.tsx index c8c46795bda..c32f45f9da9 100644 --- a/apps/dashboard/src/app/(dashboard)/published-contract/components/uri-based-deploy.tsx +++ b/apps/dashboard/src/app/(dashboard)/published-contract/components/uri-based-deploy.tsx @@ -8,12 +8,13 @@ import { loginRedirect } from "../../../login/loginRedirect"; type DeployFormForUriProps = { contractMetadata: FetchDeployMetadataResult | null; + contractMetadataNoFee: FetchDeployMetadataResult | null; modules: FetchDeployMetadataResult[] | null; pathname: string; }; export async function DeployFormForUri(props: DeployFormForUriProps) { - const { contractMetadata, modules, pathname } = props; + const { contractMetadata, contractMetadataNoFee, modules, pathname } = props; if (!contractMetadata) { return
Could not fetch metadata
; @@ -46,6 +47,7 @@ export async function DeployFormForUri(props: DeployFormForUriProps) { m !== null)} jwt={authToken} teamsAndProjects={teamsAndProjects} diff --git a/apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx b/apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx index 60d494fa0c7..f940f26100a 100644 --- a/apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx +++ b/apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx @@ -20,6 +20,7 @@ import { DEFAULT_FEE_RECIPIENT, THIRDWEB_PUBLISHER_ADDRESS, } from "constants/addresses"; +import { ZERO_FEE_CHAINS } from "constants/fee-config"; import { SolidityInput } from "contract-ui/components/solidity-inputs"; import { useTrack } from "hooks/analytics/useTrack"; import { useTxNotifications } from "hooks/useTxNotifications"; @@ -79,6 +80,7 @@ import { TrustedForwardersFieldset } from "./trusted-forwarders-fieldset"; interface CustomContractFormProps { metadata: FetchDeployMetadataResult; + metadataNoFee: FetchDeployMetadataResult | null; jwt: string; modules?: FetchDeployMetadataResult[]; teamsAndProjects: MinimalTeamsAndProjects; @@ -150,6 +152,7 @@ function rewriteTwPublisher(publisher: string | undefined) { export const CustomContractForm: React.FC = ({ metadata, + metadataNoFee, modules, jwt, teamsAndProjects, @@ -213,7 +216,8 @@ export const CustomContractForm: React.FC = ({ defaultFeeRecipientFunction && metadata.publisher === THIRDWEB_PUBLISHER_ADDRESS; - const isFeeExempt = walletChain?.id === 232 || walletChain?.id === 37111; + const isFeeExempt = + walletChain?.id && ZERO_FEE_CHAINS.includes(walletChain.id); const [customFactoryNetwork, customFactoryAddress] = Object.entries( metadata?.factoryDeploymentData?.customFactoryInput @@ -514,19 +518,17 @@ export const CustomContractForm: React.FC = ({ name: params.contractMetadata?.name || "", contractURI: _contractURI, defaultAdmin: params.deployParams._defaultAdmin as string, - platformFeeBps: - metadata.version === "7.0.0" && isFeeExempt - ? Number(params.deployParams._platformFeeBps) - : DEFAULT_FEE_BPS_NEW, - platformFeeRecipient: - metadata.version === "7.0.0" && isFeeExempt - ? (params.deployParams._platformFeeRecipient as string) - : DEFAULT_FEE_RECIPIENT, + platformFeeBps: isFeeExempt + ? Number(params.deployParams._platformFeeBps) + : DEFAULT_FEE_BPS_NEW, + platformFeeRecipient: isFeeExempt + ? (params.deployParams._platformFeeRecipient as string) + : DEFAULT_FEE_RECIPIENT, trustedForwarders: params.deployParams._trustedForwarders ? JSON.parse(params.deployParams._trustedForwarders as string) : undefined, }, - version: metadata.version, + version: isFeeExempt ? "7.0.0" : metadata.version, }); } @@ -536,15 +538,14 @@ export const CustomContractForm: React.FC = ({ payees, shares, _contractURI, - platformFeeBps: hasInbuiltDefaultFeeConfig - ? DEFAULT_FEE_BPS_NEW - : isFeeExempt - ? Number(params.deployParams._platformFeeBps) + platformFeeBps: isFeeExempt + ? Number(params.deployParams._platformFeeBps) + : hasInbuiltDefaultFeeConfig + ? DEFAULT_FEE_BPS_NEW : DEFAULT_FEE_BPS, - platformFeeRecipient: - !hasInbuiltDefaultFeeConfig && isFeeExempt - ? (params.deployParams._platformFeeRecipient as string) - : DEFAULT_FEE_RECIPIENT, + platformFeeRecipient: isFeeExempt + ? (params.deployParams._platformFeeRecipient as string) + : DEFAULT_FEE_RECIPIENT, }; const salt = params.deployDeterministic @@ -562,7 +563,7 @@ export const CustomContractForm: React.FC = ({ account: activeAccount, chain: walletChain, client: thirdwebClient, - deployMetadata: metadata, + deployMetadata: isFeeExempt && metadataNoFee ? metadataNoFee : metadata, initializeParams, implementationConstructorParams, salt, @@ -782,11 +783,7 @@ export const CustomContractForm: React.FC = ({ )} diff --git a/apps/dashboard/src/constants/fee-config.ts b/apps/dashboard/src/constants/fee-config.ts new file mode 100644 index 00000000000..758fa256fd2 --- /dev/null +++ b/apps/dashboard/src/constants/fee-config.ts @@ -0,0 +1,13 @@ +export const ZERO_FEE_VERSIONS: Record = { + DropERC721: "5.0.5", + DropERC1155: "5.0.5", + DropERC20: "5.0.3", + TokenERC721: "5.0.2", + TokenERC1155: "5.0.2", + TokenERC20: "5.0.2", + LoyaltyCard: "5.0.3", + MarketplaceV3: "7.0.0", + OpenEditionERC721FlatFee: "1.0.2", +}; + +export const ZERO_FEE_CHAINS = [232, 37111]; diff --git a/packages/thirdweb/src/contract/deployment/zksync/implementations.ts b/packages/thirdweb/src/contract/deployment/zksync/implementations.ts index dd615300150..835e5ced8f0 100644 --- a/packages/thirdweb/src/contract/deployment/zksync/implementations.ts +++ b/packages/thirdweb/src/contract/deployment/zksync/implementations.ts @@ -20,6 +20,9 @@ export const ZKSYNC_IMPLEMENTATIONS: Record> = { [2741]: { MarketplaceV3: "0x4b14569c7B79DBe686Ac3Ba5996131E7EDaB7a93", }, + [232]: { + MarketplaceV3: "0x9742f5ac11958cFAd151eBF0Fc31302fA409036E", + }, }; export const ZKSYNC_WETH: Record = { @@ -29,4 +32,5 @@ export const ZKSYNC_WETH: Record = { [37111]: "0xaA91D645D7a6C1aeaa5988e0547267B77d33fe16", [555271]: "0xb0b8b267d44c64BA6dD1Daf442949887c85199f6", [2741]: "0x3439153EB7AF838Ad19d56E1571FBD09333C2809", + [232]: "0xE5ecd226b3032910CEaa43ba92EE8232f8237553", };