Skip to content

Commit a491d8b

Browse files
committed
Show Deterministic Deploy warning banner if constructor params exist (#4717)
FIXES DASH-257 <!-- start pr-codex --> --- ## PR-Codex overview The focus of this PR is to enhance the Custom Contract Form in the dashboard by adding a warning for deterministic deployment. ### Detailed summary - Added `CircleAlertIcon` and warning message for deterministic deployment - Updated the layout of the deterministic deploy checkbox and warning display > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent a7b3d0e commit a491d8b

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

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

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { Spinner } from "@/components/ui/Spinner/Spinner";
4+
import { Alert, AlertTitle } from "@/components/ui/alert";
45
import { Button } from "@/components/ui/button";
56
import { Checkbox, CheckboxWithLabel } from "@/components/ui/checkbox";
67
import { ToolTipLabel } from "@/components/ui/tooltip";
@@ -22,7 +23,7 @@ import { SolidityInput } from "contract-ui/components/solidity-inputs";
2223
import { useTrack } from "hooks/analytics/useTrack";
2324
import { useTxNotifications } from "hooks/useTxNotifications";
2425
import { replaceTemplateValues } from "lib/deployment/template-values";
25-
import { ExternalLinkIcon } from "lucide-react";
26+
import { CircleAlertIcon, ExternalLinkIcon } from "lucide-react";
2627
import Link from "next/link";
2728
import { useCallback, useMemo } from "react";
2829
import { FormProvider, type UseFormReturn, useForm } from "react-hook-form";
@@ -480,6 +481,9 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
480481
enabled: walletChain !== undefined && metadata !== undefined,
481482
});
482483

484+
const shouldShowDeterministicDeployWarning =
485+
constructorParams.length > 0 && form.watch("deployDeterministic");
486+
483487
return (
484488
<>
485489
<FormProvider {...form}>
@@ -837,23 +841,37 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
837841
{metadata?.deployType === "standard" && (
838842
<>
839843
{/* Deterministic deploy */}
840-
<CheckboxWithLabel>
841-
<Checkbox
842-
{...form.register("deployDeterministic")}
843-
checked={form.watch("deployDeterministic")}
844-
onCheckedChange={(c) =>
845-
form.setValue("deployDeterministic", !!c)
846-
}
847-
/>
848-
<ToolTipLabel label="Allows having the same contract address on multiple chains. You can control the address by specifying a salt for create2 deployment below">
849-
<div className="inline-flex gap-1.5 items-center">
850-
<span className="tex-sm">
851-
Deploy at a deterministic address
852-
</span>
853-
<FiHelpCircle className="size-4" />
854-
</div>
855-
</ToolTipLabel>
856-
</CheckboxWithLabel>
844+
845+
<div className="flex flex-col gap-3">
846+
<CheckboxWithLabel>
847+
<Checkbox
848+
{...form.register("deployDeterministic")}
849+
checked={form.watch("deployDeterministic")}
850+
onCheckedChange={(c) =>
851+
form.setValue("deployDeterministic", !!c)
852+
}
853+
/>
854+
<ToolTipLabel label="Allows having the same contract address on multiple chains. You can control the address by specifying a salt for create2 deployment below">
855+
<div className="inline-flex gap-1.5 items-center">
856+
<span className="tex-sm">
857+
Deploy at a deterministic address
858+
</span>
859+
<FiHelpCircle className="size-4" />
860+
</div>
861+
</ToolTipLabel>
862+
</CheckboxWithLabel>
863+
864+
{shouldShowDeterministicDeployWarning && (
865+
<Alert variant="warning">
866+
<CircleAlertIcon className="size-5" />
867+
<AlertTitle>
868+
Deterministic deployment would only result in the same
869+
contract address if you use the same contructor params
870+
on every deployment.
871+
</AlertTitle>
872+
</Alert>
873+
)}
874+
</div>
857875

858876
{/* Optional Salt Input */}
859877
{isCreate2Deployment && (

0 commit comments

Comments
 (0)