-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
875 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
packages/interface/src/features/admin/components/DeployContracts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { useRouter } from "next/router"; | ||
import { useState, useCallback } from "react"; | ||
import { useAccount } from "wagmi"; | ||
|
||
import { Steps } from "~/components/Steps"; | ||
import { Form, FormSection, FormControl, Select } from "~/components/ui/Form"; | ||
import { Heading } from "~/components/ui/Heading"; | ||
import { useRound } from "~/contexts/Round"; | ||
import { DeploymentSchema, chainTypes, gatingStrategyTypes } from "~/features/rounds/types"; | ||
import { useIsCorrectNetwork } from "~/hooks/useIsCorrectNetwork"; | ||
|
||
import { EDeployContractsStep, DeployContractsButtons } from "./DeployContractsButtons"; | ||
import { ReviewDeployContractsDetails } from "./ReviewDeployContractsDetails"; | ||
import { VoiceCreditProxySelect } from "./VoiceCreditProxySelect"; | ||
|
||
export const DeployContracts = (): JSX.Element => { | ||
const router = useRouter(); | ||
const [step, setStep] = useState<EDeployContractsStep>(EDeployContractsStep.CONFIGURE); | ||
|
||
const { isCorrectNetwork, correctNetwork } = useIsCorrectNetwork(); | ||
|
||
const { address } = useAccount(); | ||
|
||
const { deployContracts } = useRound(); | ||
|
||
const handleNextStep = useCallback(() => { | ||
if (step === EDeployContractsStep.CONFIGURE) { | ||
setStep(EDeployContractsStep.REVIEW); | ||
} | ||
}, [step, setStep]); | ||
|
||
const handleBackStep = useCallback(() => { | ||
if (step === EDeployContractsStep.REVIEW) { | ||
setStep(EDeployContractsStep.CONFIGURE); | ||
} | ||
}, [step, setStep]); | ||
|
||
const onSubmit = () => { | ||
deployContracts(); | ||
router.push("/"); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Heading size="4xl">Deploy Core Contracts</Heading> | ||
|
||
<p className="text-gray-400">These initial MACI core contracts configuration will apply to all future rounds.</p> | ||
|
||
<div className="dark:border-lighterBlack rounded-lg border border-gray-200 p-4"> | ||
<Steps step={step} stepNames={["Configure Contracts", "Review & Deploy"]} /> | ||
|
||
<Form schema={DeploymentSchema} onSubmit={onSubmit}> | ||
<FormSection | ||
className={step === EDeployContractsStep.CONFIGURE ? "block" : "hidden"} | ||
description="Please select from the available options:" | ||
title="Configure Contracts" | ||
> | ||
<FormControl required hint="Choose a chain to deploy your contracts" label="Chain to deploy" name="chain"> | ||
<Select> | ||
{Object.entries(chainTypes).map(([value, label]) => ( | ||
<option key={value} value={value}> | ||
{label} | ||
</option> | ||
))} | ||
</Select> | ||
</FormControl> | ||
|
||
<FormControl required hint="Choose a gating strategy" label="Gating strategy" name="gatingStrategy"> | ||
<Select> | ||
{Object.entries(gatingStrategyTypes).map(([value, label]) => ( | ||
<option key={value} value={label}> | ||
{label} | ||
</option> | ||
))} | ||
</Select> | ||
</FormControl> | ||
|
||
<VoiceCreditProxySelect /> | ||
</FormSection> | ||
|
||
{step === EDeployContractsStep.REVIEW && <ReviewDeployContractsDetails />} | ||
|
||
{step === EDeployContractsStep.REVIEW && ( | ||
<div className="mb-2 w-full text-right text-sm italic text-blue-400"> | ||
{!address && <p>You must connect wallet to create an application</p>} | ||
|
||
{!isCorrectNetwork && <p className="gap-2">You must be connected to {correctNetwork.name}</p>} | ||
</div> | ||
)} | ||
|
||
<DeployContractsButtons | ||
isPending={false} | ||
isUploading={false} | ||
step={step} | ||
onBackStep={handleBackStep} | ||
onNextStep={handleNextStep} | ||
/> | ||
</Form> | ||
</div> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.