Skip to content
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

Chore/ofir asks #788

Merged
merged 3 commits into from
Dec 16, 2024
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
1 change: 1 addition & 0 deletions packages/shared/src/types/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface IBaseEditedVaultDescription {
emails: IEditedCommunicationEmail[];
oneLiner?: string;
intendedCompetitionAmount?: number;
loc?: number;
curator?: {
username: string;
role: CuratorRole;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ interface IBaseVaultDescription {
starttime?: number;
oneLiner?: string;
intendedCompetitionAmount?: number;
loc?: number;
curator?: {
username: string;
role: CuratorRole;
Expand Down
5 changes: 4 additions & 1 deletion packages/web/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@
"bonusPointsReminder": "Remember, you have 12 hours to submit after claiming. Happy fixing and testing!",
"bonusPointsEnabled": "Enable bonus points?",
"claimFixAndTest": "Claim fix and test",
"linesOfCode": "Lines of code (LoC)",
"issueAlreadyHaveValidSubmission": "This issue already have a valid submission. You can submit complementary submission in other issue.",
"oneSubmissionIsBeingReviewed": "One submission is being reviewed. Please wait, if the submission is not complete, you can submit another one.",
"MyWallet": {
Expand Down Expand Up @@ -1652,7 +1653,9 @@
"curator-placeholder": "Select curator of the vault",
"curatorRole": "Curator role",
"curatorRole-placeholder": "Select the role of the curator",
"clearCurator": "Clear curator"
"clearCurator": "Clear curator",
"loc-placeholder": "Enter number of lines of code",
"loc": "Lines of code"
},
"signatureMessage": "I hereby confirm the details in ipfs hash {{ipfsHash}}.",
"committee-details": "Committee Details",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
import DocumentIcon from "@mui/icons-material/DescriptionOutlined";
import DiffIcon from "@mui/icons-material/DifferenceOutlined";
import OpenIcon from "@mui/icons-material/LaunchOutlined";
import HashtagIcon from "@mui/icons-material/NumbersOutlined";
import OverviewIcon from "@mui/icons-material/SelfImprovementOutlined";
import TerminalIcon from "@mui/icons-material/Terminal";
import ContractsIcon from "@mui/icons-material/ViewInAr";
Expand Down Expand Up @@ -215,6 +216,17 @@ export const InScopeSection = ({ vault }: InScopeSectionProps) => {
</Alert>
)}

{/* LoC */}
{vault.description["project-metadata"].loc && (
<>
<h4 className="section-subtitle mb-4">
<HashtagIcon className="icon" />
<span>{t("linesOfCode")}:</span>
<span>{vault.description["project-metadata"].loc}</span>
</h4>
</>
)}
Comment on lines +219 to +228
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove unnecessary Fragment wrapper.

The Fragment wrapper is redundant since it contains only one child element.

Apply this diff to optimize the code:

-      {vault.description["project-metadata"].loc && (
-        <>
-          <h4 className="section-subtitle mb-4">
-            <HashtagIcon className="icon" />
-            <span>{t("linesOfCode")}:</span>
-            <span>{vault.description["project-metadata"].loc}</span>
-          </h4>
-        </>
-      )}
+      {vault.description["project-metadata"].loc && (
+        <h4 className="section-subtitle mb-4">
+          <HashtagIcon className="icon" />
+          <span>{t("linesOfCode")}:</span>
+          <span>{vault.description["project-metadata"].loc}</span>
+        </h4>
+      )}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{/* LoC */}
{vault.description["project-metadata"].loc && (
<>
<h4 className="section-subtitle mb-4">
<HashtagIcon className="icon" />
<span>{t("linesOfCode")}:</span>
<span>{vault.description["project-metadata"].loc}</span>
</h4>
</>
)}
{/* LoC */}
{vault.description["project-metadata"].loc && (
<h4 className="section-subtitle mb-4">
<HashtagIcon className="icon" />
<span>{t("linesOfCode")}:</span>
<span>{vault.description["project-metadata"].loc}</span>
</h4>
)}
🧰 Tools
🪛 Biome (1.9.4)

[error] 221-227: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment

(lint/complexity/noUselessFragments)


{/* Overview */}
{vault.description.scope?.description && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const getBountySubmissionTexts = (
const toEncrypt = `**Project Name:** ${submissionData.project?.projectName}\n
**Project Id:** ${submissionData.project?.projectId}\n
**Beneficiary:** ${submissionData.contact?.beneficiary}\n
**HATS Profile:** ${hackerProfile ? `${hackerProfile?.username}` : "---"}\n
**HATS Profile:** ${hackerProfile ? `[HATS Profile](https://app.hats.finance/profile/${hackerProfile?.username})` : "---"}\n
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Extract hardcoded URLs to constants.

The HATS Profile URL is hardcoded in multiple places. This should be moved to a constant or configuration value for better maintainability.

+const HATS_PROFILE_BASE_URL = 'https://app.hats.finance/profile';
+const getHatsProfileUrl = (username: string) => `${HATS_PROFILE_BASE_URL}/${username}`;

-**HATS Profile:** ${hackerProfile ? `[HATS Profile](https://app.hats.finance/profile/${hackerProfile?.username})` : "---"}\n
+**HATS Profile:** ${hackerProfile ? `[HATS Profile](${getHatsProfileUrl(hackerProfile?.username)})` : "---"}\n

Also applies to: 128-128

**Communication channel:** ${submissionData.contact?.communicationChannel} (${submissionData.contact?.communicationChannelType})

${descriptions
Expand Down Expand Up @@ -125,7 +125,7 @@ export const getGithubIssueDescription = (
return `${submissionData.ref === "audit-wizard" ? "***Submitted via auditwizard.io***\n" : ""}
**Github username:** ${submissionData.contact?.githubUsername ? `@${submissionData.contact?.githubUsername}` : "--"}
**Twitter username:** ${submissionData.contact?.twitterUsername ? `${submissionData.contact?.twitterUsername}` : "--"}
**HATS Profile:** ${hackerProfile ? `${hackerProfile?.username}` : "---"}
**HATS Profile:** ${hackerProfile ? `[HATS Profile](https://app.hats.finance/profile/${hackerProfile?.username})` : "---"}\n
**Beneficiary:** ${submissionData.contact?.beneficiary}
**Submission hash (on-chain):** ${submissionData.submissionResult?.transactionHash}
**Severity:** ${description.severity}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ export function VaultDetailsForm() {
helper={watch("project-metadata.oneLiner") ? `${watch("project-metadata.oneLiner")?.length ?? 0} characters` : ""}
/>

<div className="w-50">
<FormInput
{...register("project-metadata.loc")}
colorable
disabled={allFormDisabled}
placeholder={t("VaultEditor.vault-details.loc-placeholder")}
label={t("VaultEditor.vault-details.loc")}
type="number"
/>
</div>

{requireMessageSignature && (
<>
<p className="mb-3 helper-text">{t("VaultEditor.vault-details.messageToSign-explanation")}</p>
Expand Down
Loading