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 @@ -33,6 +33,7 @@ export default async function DirectDeployPage(props: DirectDeployPageProps) {
/>
<DeployFormForUri
contractMetadata={metadata}
contractMetadataNoFee={metadata}
modules={null}
pathname={`/contracts/deploy/${params.compiler_uri}`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -46,29 +47,41 @@ 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;
}

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}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks wrong? you're fetching the same thing twice

Copy link
Member Author

@kumaryash90 kumaryash90 Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this second one is the hardcoded version metadata for specific cases.

first one is latest or given version metadata, as default.

}).catch(() => null),
...(moduleUris || []).map((uri) =>
fetchDeployMetadata({
client,
// force `ipfs://` prefix
uri: uri.startsWith("ipfs://") ? uri : `ipfs://${uri}`,
}).catch(() => null),
),
]);

return (
<div className="mx-auto flex w-full max-w-[1000px] flex-col gap-8 pb-20">
Expand All @@ -79,6 +92,7 @@ export async function DeployFormForPublishInfo(props: PublishBasedDeployProps) {
/>
<DeployFormForUri
contractMetadata={contractMetadata}
contractMetadataNoFee={contractMetadataNoFee}
modules={fetchedModules.filter((m) => m !== null)}
pathname={`/${props.publisher}/${props.contract_id}${props.version ? `/${props.version}` : ""}/deploy`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <div>Could not fetch metadata</div>;
Expand Down Expand Up @@ -46,6 +47,7 @@ export async function DeployFormForUri(props: DeployFormForUriProps) {
<ChakraProviderSetup>
<CustomContractForm
metadata={contractMetadata}
metadataNoFee={contractMetadataNoFee}
modules={modules?.filter((m) => m !== null)}
jwt={authToken}
teamsAndProjects={teamsAndProjects}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -79,6 +80,7 @@ import { TrustedForwardersFieldset } from "./trusted-forwarders-fieldset";

interface CustomContractFormProps {
metadata: FetchDeployMetadataResult;
metadataNoFee: FetchDeployMetadataResult | null;
jwt: string;
modules?: FetchDeployMetadataResult[];
teamsAndProjects: MinimalTeamsAndProjects;
Expand Down Expand Up @@ -150,6 +152,7 @@ function rewriteTwPublisher(publisher: string | undefined) {

export const CustomContractForm: React.FC<CustomContractFormProps> = ({
metadata,
metadataNoFee,
modules,
jwt,
teamsAndProjects,
Expand Down Expand Up @@ -213,7 +216,8 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
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
Expand Down Expand Up @@ -514,19 +518,17 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
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,
});
}

Expand All @@ -536,15 +538,14 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
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
Expand All @@ -562,7 +563,7 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
account: activeAccount,
chain: walletChain,
client: thirdwebClient,
deployMetadata: metadata,
deployMetadata: isFeeExempt && metadataNoFee ? metadataNoFee : metadata,
initializeParams,
implementationConstructorParams,
salt,
Expand Down Expand Up @@ -782,11 +783,7 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
<PlatformFeeFieldset
form={form}
isMarketplace={isMarketplace}
disabled={
hasInbuiltDefaultFeeConfig ||
(isMarketplace && metadata.version !== "7.0.0") ||
!isFeeExempt
}
disabled={!isFeeExempt}
/>
)}

Expand Down
13 changes: 13 additions & 0 deletions apps/dashboard/src/constants/fee-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const ZERO_FEE_VERSIONS: Record<string, string> = {
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];
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const ZKSYNC_IMPLEMENTATIONS: Record<number, Record<string, string>> = {
[2741]: {
MarketplaceV3: "0x4b14569c7B79DBe686Ac3Ba5996131E7EDaB7a93",
},
[232]: {
MarketplaceV3: "0x9742f5ac11958cFAd151eBF0Fc31302fA409036E",
},
};

export const ZKSYNC_WETH: Record<number, string> = {
Expand All @@ -29,4 +32,5 @@ export const ZKSYNC_WETH: Record<number, string> = {
[37111]: "0xaA91D645D7a6C1aeaa5988e0547267B77d33fe16",
[555271]: "0xb0b8b267d44c64BA6dD1Daf442949887c85199f6",
[2741]: "0x3439153EB7AF838Ad19d56E1571FBD09333C2809",
[232]: "0xE5ecd226b3032910CEaa43ba92EE8232f8237553",
};
Loading