-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] Audit wizard integration #552
Changes from all commits
f3c3764
7a381b7
1cc1359
b514cd5
14370c0
949c54d
c0129b0
204e4b6
20419cf
1106905
2e212e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ import { StyledContactInfo } from "./styles"; | |
export function SubmissionContactInfo() { | ||
const { t } = useTranslation(); | ||
const { address: account } = useAccount(); | ||
const { submissionData, setSubmissionData, vault } = useContext(SubmissionFormContext); | ||
const { submissionData, setSubmissionData, vault, allFormDisabled } = useContext(SubmissionFormContext); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new variable - const { submissionData, setSubmissionData, vault } = useContext(SubmissionFormContext);
+ const { submissionData, setSubmissionData, vault, allFormDisabled } = useContext(SubmissionFormContext); |
||
|
||
const isAuditCompetition = vault?.description?.["project-metadata"].type === "audit"; | ||
|
||
|
@@ -44,7 +44,7 @@ export function SubmissionContactInfo() { | |
setSubmissionData((prev) => { | ||
if (prev) | ||
return { | ||
...prev!, | ||
...prev, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spread operator ( - ...prev!,
+ ...prev,
contact: { ...contactData, verified: true },
submissionsDescriptions: { ...prev.submissionsDescriptions, verified: false },
submissionResult: undefined, |
||
contact: { ...contactData, verified: true }, | ||
submissionsDescriptions: { ...prev.submissionsDescriptions, verified: false }, | ||
submissionResult: undefined, | ||
|
@@ -70,13 +70,15 @@ export function SubmissionContactInfo() { | |
|
||
<FormInput | ||
{...register("beneficiary")} | ||
disabled={allFormDisabled} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - {...register("beneficiary")}
+ {...register("beneficiary")}
+ disabled={allFormDisabled}
label={`${t("beneficiaryWalletAddress")}`}
placeholder={t("beneficiaryWalletAddressPlaceholder")}
colorable |
||
label={`${t("beneficiaryWalletAddress")}`} | ||
placeholder={t("beneficiaryWalletAddressPlaceholder")} | ||
colorable | ||
/> | ||
|
||
<FormRadioInput | ||
{...register("communicationChannelType")} | ||
disabled={allFormDisabled} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - {...register("communicationChannelType")}
+ {...register("communicationChannelType")}
+ disabled={allFormDisabled}
label={t("Submissions.addPreferredCommunicationChannel")}
radioOptions={[
{ label: t("discord"), value: "discord" }, |
||
label={t("Submissions.addPreferredCommunicationChannel")} | ||
radioOptions={[ | ||
{ label: t("discord"), value: "discord" }, | ||
|
@@ -87,6 +89,7 @@ export function SubmissionContactInfo() { | |
|
||
<FormInput | ||
{...register("communicationChannel")} | ||
disabled={allFormDisabled} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - {...register("communicationChannel")}
+ {...register("communicationChannel")}
+ disabled={allFormDisabled}
label={communicationChannelLabel}
placeholder={t("enterCommunicationChannel")}
colorable |
||
label={communicationChannelLabel} | ||
placeholder={t("enterCommunicationChannel")} | ||
colorable | ||
|
@@ -97,6 +100,7 @@ export function SubmissionContactInfo() { | |
<p className="mb-2">{t("Submissions.addGithubAccountConnectIssue")}</p> | ||
<FormInput | ||
{...register("githubUsername")} | ||
disabled={allFormDisabled} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - {...register("githubUsername")}
+ {...register("githubUsername")}
+ disabled={allFormDisabled}
label={`${t("githubUsername")}`}
placeholder={t("githubUsernamePlaceholder")}
colorable |
||
label={`${t("githubUsername")}`} | ||
placeholder={t("githubUsernamePlaceholder")} | ||
colorable | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ export const getGithubIssueDescription = ( | |
submissionData: ISubmissionData, | ||
description: ISubmissionsDescriptionsData["descriptions"][0] | ||
) => { | ||
return ` | ||
return `${submissionData.ref === "audit-wizard" ? "***Submitted via auditwizard.io***\n" : ""} | ||
**Github username:** ${submissionData.contact?.githubUsername ? `@${submissionData.contact?.githubUsername}` : "--"} | ||
**Submission hash (on-chain):** ${submissionData.submissionResult?.transactionHash} | ||
**Severity:** ${description.severity} | ||
Comment on lines
+91
to
94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes made here are adding a conditional check to modify the generated GitHub issue description based on whether the submission is from the audit wizard or not. This seems like a reasonable change, but it would be better if the string "audit-wizard" was replaced with a constant to avoid potential typos and improve maintainability. - return `${submissionData.ref === "audit-wizard" ? "***Submitted via auditwizard.io***\n" : ""}`
+ const AUDIT_WIZARD_REF = "audit-wizard";
+ return `${submissionData.ref === AUDIT_WIZARD_REF ? "***Submitted via auditwizard.io***\n" : ""}` This way, if the reference for the audit wizard ever needs to be changed, it can be done in one place rather than having to find all instances of the string in the codebase. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { StyledSubmissionProject } from "./styles"; | |
|
||
export function SubmissionProject() { | ||
const { t } = useTranslation(); | ||
const { submissionData, setSubmissionData } = useContext(SubmissionFormContext); | ||
const { submissionData, setSubmissionData, allFormDisabled } = useContext(SubmissionFormContext); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new variable - const { submissionData, setSubmissionData, allFormDisabled } = useContext(SubmissionFormContext);
+ const { submissionData, setSubmissionData, allFormDisabled = false } = useContext(SubmissionFormContext); |
||
const [userInput, setUserInput] = useState(""); | ||
const { activeVaults } = useVaults(); | ||
|
||
|
@@ -36,7 +36,7 @@ export function SubmissionProject() { | |
key={index} | ||
vault={vault} | ||
expanded={false} | ||
onSelect={() => handleSelectedProject(vault)} | ||
onSelect={!allFormDisabled ? () => handleSelectedProject(vault) : () => {}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ternary operator used here is a bit confusing and might lead to code readability issues. Instead of using an empty function as a fallback, consider moving the condition inside the - onSelect={!allFormDisabled ? () => handleSelectedProject(vault) : () => {}}
+ onSelect={() => handleSelectedProject(vault)} And then in your - const handleSelectedProject = (vault) => {
- // existing logic...
- }
+ const handleSelectedProject = (vault) => {
+ if (allFormDisabled) return;
+ // existing logic...
+ } |
||
selected={submissionData?.project?.projectId === vault.id} | ||
/> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import MDEditor from "@uiw/react-md-editor"; | ||
import { Alert, Button, FormInput, Loading } from "components"; | ||
import { disallowedElementsMarkdown } from "constants/constants"; | ||
import { SubmissionFormContext } from "pages/Submissions/SubmissionFormPage/store"; | ||
import { useContext } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
Comment on lines
+1
to
6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The import of + import MDEditor from "@uiw/react-md-editor";
+ import { disallowedElementsMarkdown } from "constants/constants"; |
||
|
@@ -34,15 +36,27 @@ export function SubmissionReview() { | |
/> | ||
</div> | ||
|
||
{/* <MDEditor.Markdown | ||
<br /> | ||
|
||
<MDEditor.Markdown | ||
disallowedElements={disallowedElementsMarkdown} | ||
source={submissionData?.submissionsDescriptions?.submissionMessage} | ||
style={{ whiteSpace: "normal", fontSize: "var(--xsmall)", background: "transparent", color: "var(--white)" }} | ||
/> */} | ||
/> | ||
|
||
<FormInput readOnly type="textarea" rows={20} value={submissionData?.submissionsDescriptions?.submissionMessage} /> | ||
{/* <FormInput readOnly type="textarea" rows={20} value={submissionData?.submissionsDescriptions?.submissionMessage} /> */} | ||
|
||
<div className="buttons"> | ||
{/* {submissionData.ref === "audit-wizard" && ( | ||
<Button | ||
filledColor="secondary" | ||
disabled={isSubmitting || isSigningSubmission} | ||
bigHorizontalPadding | ||
onClick={() => submitSubmission()} | ||
> | ||
{t("Submissions.editSubmission")} | ||
</Button> | ||
)} */} | ||
Comment on lines
+39
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The addition of the Also, there's commented-out code here. It's generally best to remove such code to keep the codebase clean and readable. If this code is needed for future reference, consider adding a descriptive comment explaining its purpose. Lastly, the button for editing submissions when + <MDEditor.Markdown
+ disallowedElements={disallowedElementsMarkdown}
+ source={submissionData?.submissionsDescriptions?.submissionMessage}
+ style={{ whiteSpace: "normal", fontSize: "var(--xsmall)", background: "transparent", color: "var(--white)" }}
+ />
- {/* <FormInput readOnly type="textarea" rows={20} value={submissionData?.submissionsDescriptions?.submissionMessage} /> */}
-
- <div className="buttons">
- {/* {submissionData.ref === "audit-wizard" && (
- <Button
- filledColor="secondary"
- disabled={isSubmitting || isSigningSubmission}
- bigHorizontalPadding
- onClick={() => submitSubmission()}
- >
- {t("Submissions.editSubmission")}
- </Button>
- )} */}
+ <Button disabled={isSubmitting || isSigningSubmission} bigHorizontalPadding onClick={() => submitSubmission()}>
+ {t("submit")}
+ </Button> |
||
<Button disabled={isSubmitting || isSigningSubmission} bigHorizontalPadding onClick={() => submitSubmission()}> | ||
{t("submit")} | ||
</Button> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeRabbit
The URL for the
auditWizardVerifyService
is hardcoded. This could lead to issues when you need to switch between different environments (like staging, production, etc.). Consider using environment variables for such values.This way, you can set the
AUDIT_WIZARD_VERIFY_SERVICE
environment variable as needed per environment, and if it's not set, it will default to the provided URL.