Skip to content

Commit

Permalink
Update deterministic deploy option (#1789)
Browse files Browse the repository at this point in the history
update deterministic deploy option
  • Loading branch information
kumaryash90 authored Oct 16, 2023
1 parent 082aac0 commit 80582cc
Showing 1 changed file with 63 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ const CustomContractForm: React.FC<CustomContractFormProps> = ({
fullPublishMetadata.data?.deployType === "autoFactory" ||
fullPublishMetadata.data?.deployType === "customFactory";

const isAccountFactory =
(fullPublishMetadata.data?.publisher === "deployer.thirdweb.eth" ||
fullPublishMetadata.data?.publisher ===
"0xdd99b75f095d0c4d5112aCe938e4e6ed962fb024") &&
fullPublishMetadata.data?.name.includes("AccountFactory");

const deployParams = isFactoryDeployment
? initializerParams
: constructorParams;
Expand Down Expand Up @@ -163,14 +169,14 @@ const CustomContractForm: React.FC<CustomContractFormProps> = ({
}>({
defaultValues: {
addToDashboard: shouldDefaulCheckAddToDashboard,
deployDeterministic: false,
deployDeterministic: isAccountFactory,
saltForCreate2: "",
signerAsSalt: true,
deployParams: parseDeployParams,
},
values: {
addToDashboard: shouldDefaulCheckAddToDashboard,
deployDeterministic: false,
deployDeterministic: isAccountFactory,
saltForCreate2: "",
signerAsSalt: true,
deployParams: parseDeployParams,
Expand Down Expand Up @@ -498,81 +504,62 @@ const CustomContractForm: React.FC<CustomContractFormProps> = ({

{fullPublishMetadata.data?.deployType === "standard" && (
<Flex gap={4} flexDir="column">
<Accordion allowToggle>
<AccordionItem borderColor="borderColor" borderBottom="none">
<AccordionButton px={0}>
<Text flex="1" textAlign="left">
Advanced deployment options
</Text>
<AccordionIcon />
</AccordionButton>

<AccordionPanel
py={4}
px={0}
as={Flex}
flexDir="column"
gap={4}
>
<Checkbox
{...form.register("deployDeterministic")}
isChecked={form.watch("deployDeterministic")}
>
<Tooltip
label={
<Card py={2} px={4} bgColor="backgroundHighlight">
<Text fontSize="small" lineHeight={6}>
Allows having the same contract address on multiple
chains. You can control the address by specifying a salt
for create2 deployment below.
</Text>
</Card>
}
isDisabled={false}
p={0}
bg="transparent"
boxShadow="none"
>
<HStack>
<Heading as="label" size="label.md">
Deploy at a deterministic address
</Heading>
<Icon as={FiHelpCircle} />
</HStack>
</Tooltip>
</Checkbox>

{isCreate2Deployment && (
<FormControl>
<Flex alignItems="center" my={1}>
<FormLabel mb={0} flex="1" display="flex">
<Flex alignItems="baseline" gap={1}>
Optional Salt Input
<Text size="label.sm">(saltForCreate2)</Text>
</Flex>
</FormLabel>
<FormHelperText mt={0}>string</FormHelperText>
</Flex>
<SolidityInput
defaultValue={""}
solidityType={"string"}
{...form.register(`saltForCreate2`)}
/>
<Flex alignItems="center" gap={3}>
<Checkbox
{...form.register("deployDeterministic")}
isChecked={form.watch("deployDeterministic")}
>
<Tooltip
label={
<Card py={2} px={4} bgColor="backgroundHighlight">
<Text fontSize="small" lineHeight={6}>
Allows having the same contract address on multiple
chains. You can control the address by specifying a
salt for create2 deployment below.
</Text>
</Card>
}
isDisabled={false}
p={0}
bg="transparent"
boxShadow="none"
>
<HStack>
<Heading as="label" size="label.md">
Deterministic address
</Heading>
<Icon as={FiHelpCircle} />
</HStack>
</Tooltip>
</Checkbox>

{isCreate2Deployment && (
<FormControl>
<Flex alignItems="center" my={1}>
<FormLabel mb={0} flex="1" display="flex">
<Flex alignItems="baseline" gap={1}>
Optional Salt Input
<Text size="label.sm">(saltForCreate2)</Text>
</Flex>
</FormLabel>
<FormHelperText mt={0}>string</FormHelperText>
</Flex>
<SolidityInput
defaultValue={""}
solidityType={"string"}
{...form.register(`saltForCreate2`)}
/>
<Flex alignItems="center" gap={3}>
<Checkbox
{...form.register("signerAsSalt")}
isChecked={form.watch("signerAsSalt")}
/>

<Text mt={1}>
Include deployer wallet address in salt (recommended)
</Text>
</Flex>
</FormControl>
)}
</AccordionPanel>
</AccordionItem>
</Accordion>
{...form.register("signerAsSalt")}
isChecked={form.watch("signerAsSalt")}
/>

<Text mt={1}>
Include deployer wallet address in salt (recommended)
</Text>
</Flex>
</FormControl>
)}
</Flex>
)}

Expand Down

0 comments on commit 80582cc

Please sign in to comment.