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

Fix(pages): check verified contract and minor EVM contract details #1239

Merged
merged 2 commits into from
Feb 20, 2025

Conversation

Poafs1
Copy link
Collaborator

@Poafs1 Poafs1 commented Feb 20, 2025

Summary by CodeRabbit

  • Refactor

    • Simplified link handling in documentation and license sections by consolidating URL logic.
    • Revised verification option labeling and version ordering for improved clarity.
  • Style

    • Updated the file removal action to use an icon-only button with refined hover effects.
    • Enhanced the overview layout with a more flexible grid and responsive spacing.
  • Bug Fixes

    • Improved the contract verification form by disabling submissions for already verified contracts and providing clearer error messages.
    • Fixed verification checks for EVM contracts.

Copy link

vercel bot commented Feb 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
celatone-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2025 3:55am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
celatone-frontend-main ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 3:55am
initia-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 3:55am
neutron-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 3:55am
osmosis-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 3:55am
sei-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 3:55am
terra-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 3:55am

Copy link

coderabbitai bot commented Feb 20, 2025

Walkthrough

This pull request refactors several React components and helper functions. The changes include simplifying the URL construction logic in the UserDocsLink component by removing the handleLink function and isExternal prop, adjusting the link in ContractLicenseInfoAccordion, replacing a button with an icon button in UploadCard, modifying theme return values in useCardTheme, updating grid layouts and hover behaviors in OverviewInfo, enhancing option formatting logic in a helper, adding extra verification and error handling in the contract verification component, and reversing version arrays in the EVM types.

Changes

File(s) Change Summary
src/lib/components/UserDocsLink.tsx
src/lib/pages/evm-contract-verify/components/ContractLicenseInfoAccordion.tsx
Removed handleLink function and isExternal prop; integrated URL logic inline; updated href from a GitHub URL to a relative path; replaced isExternal with isDevTool; updated trackWebsite call accordingly.
src/lib/components/upload/UploadCard.tsx Replaced the Button component with an IconButton for file removal; set variant to "ghost-error" and adjusted icon, size, and aria-label; added hover style customizations.
src/lib/components/upload/hooks/useCardTheme.ts Removed the buttonVariant property from the theme configuration returned within the getTheme function.
src/lib/pages/evm-contract-details/components/evm-contract-details-overview/OverviewInfo.tsx Updated the grid template from fixed to a flexible column layout; changed columnGap to be responsive; removed showCopyOnHover from two instances of ExplorerLink.
src/lib/pages/evm-contract-verify/helpers.ts Modified the formatEvmOptions mapping logic to conditionally format labels for options with the value "default".
src/lib/pages/evm-contract-verify/index.tsx Updated the form disable logic by adding a condition that checks if the contract is already verified; adjusted error handling to display a specific message when the contract is verified.
src/lib/types/evm.ts Applied a transformation to both solidity_evm_versions and vyper_evm_versions fields to return the arrays in reverse order.
CHANGELOG.md Added a new entry for fixing the check for verified EVM contracts and minor details related to EVM contract information.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VerifyComponent as EvmContractVerifyBody
    participant Validator

    User->>VerifyComponent: Enter contract address
    VerifyComponent->>Validator: Perform base verification
    Validator-->>VerifyComponent: Return verification status
    alt Contract is already verified
        VerifyComponent->>User: Display error "Contract is already verified"
        VerifyComponent->>User: Disable submission
    else Verification passes
        VerifyComponent->>User: Display any other errors (if present)
        VerifyComponent->>User: Enable form submission
    end
Loading

Possibly related PRs

Suggested reviewers

  • evilpeach

Poem

I'm just a bunny, hopping through code,
Simplifying links and lightening the load.
With each change, my joy multiplies,
Bugs hidden away, no more disguise.
Code now dances in a rhythm so neat—
A rabbit's cheer, a playful beat!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/lib/components/upload/UploadCard.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.json".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0df919c and 0e4a579.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/lib/components/upload/UploadCard.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/components/upload/UploadCard.tsx
🔇 Additional comments (1)
CHANGELOG.md (1)

91-91: Changelog Entry Formatting and Clarity

The newly added entry for PR #1239 is clearly formatted and follows the existing style conventions within the "Bug fixes" section. The description “Fix check verified EVM contract and minor EVM contract details” succinctly communicates the change and accurately reflects the PR objectives.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/lib/pages/evm-contract-verify/index.tsx (1)

129-188: 🛠️ Refactor suggestion

Refactor isFormDisabled for better maintainability.

The function is complex and handles multiple validation scenarios. Consider breaking it down into smaller, focused functions:

const isBaseValidationSuccess = (formData: EvmContractVerifyForm) => {
  return (
    zEvmContractVerifyBase.safeParse({
      contractAddress: formData.contractAddress,
      licenseType: formData.licenseType,
      language: formData.language,
      compilerVersion: formData.compilerVersion,
      option: formData.option,
    }).success &&
    formData.language !== undefined &&
    formData.option !== undefined
  );
};

const isOptionValidationSuccess = (
  option: EvmVerifyOptions | undefined,
  formData: EvmContractVerifyForm
) => {
  if (!option) return false;
  if (isVerifyByExternals(option)) return true;
  
  const baseSuccess = formData.licenseType !== undefined && formData.compilerVersion !== "";
  if (!baseSuccess) return false;

  const optionValidators = {
    [EvmVerifyOptions.SolidityUploadFiles]: () =>
      zEvmContractVerifySolidityOptionUploadFilesForm.safeParse(
        formData.verifyForm.solidityUploadFiles
      ).success,
    // Add other validators...
  };

  return optionValidators[option]?.() ?? false;
};

const isFormDisabled = () => {
  return (
    !isBaseValidationSuccess(watch()) ||
    !isOptionValidationSuccess(option, watch()) ||
    !!evmVerifyInfo?.isVerified
  );
};
🧹 Nitpick comments (3)
src/lib/components/UserDocsLink.tsx (1)

27-28: LGTM! Component structure has been simplified.

The removal of the handleLink function and inline URL construction makes the code more straightforward and easier to understand.

Consider extracting the duplicated URL construction logic.

The URL construction logic is duplicated in both the href and trackWebsite calls.

 export const UserDocsLink = ({
   title,
   cta,
   href,
   isButton = false,
   isInline = false,
   isDevTool = false,
   mt = 8,
-}: UserDocsLinkProps) =>
+}: UserDocsLinkProps) => {
+  const constructedUrl = `${isDevTool ? DEVELOPER_TOOL_DOCS_LINK : USER_GUIDE_DOCS_LINK}/${href}`;
+  return (
   isButton ? (
     <Link
-      href={`${isDevTool ? DEVELOPER_TOOL_DOCS_LINK : USER_GUIDE_DOCS_LINK}/${href}`}
+      href={constructedUrl}
       onClick={(e) => {
-        trackWebsite(
-          `${isDevTool ? DEVELOPER_TOOL_DOCS_LINK : USER_GUIDE_DOCS_LINK}/${href}`
-        );
+        trackWebsite(constructedUrl);
         e.stopPropagation();
       }}

Also applies to: 30-31, 32-34

src/lib/types/evm.ts (1)

190-194: Consider moving array reversal to the UI layer.

While the transformation works, reversing arrays in the type definition couples presentation logic with data structure. Consider:

  1. Moving the reversal to the UI components where the versions are displayed.
  2. Adding a separate function in a helper file to handle version sorting/ordering.

This separation would:

  • Keep the type definition focused on data structure
  • Allow more flexibility in how versions are ordered in different UI contexts
  • Make it easier to modify the sorting logic if requirements change
-    solidity_evm_versions: z
-      .array(z.string())
-      .transform((val) => val.reverse()),
+    solidity_evm_versions: z.array(z.string()),
-    vyper_evm_versions: z.array(z.string()).transform((val) => val.reverse()),
+    vyper_evm_versions: z.array(z.string()),

Add a helper function:

// src/lib/helpers/version.ts
export const getSortedVersions = (versions: string[]) => [...versions].reverse();
src/lib/pages/evm-contract-verify/index.tsx (1)

228-228: Consider using theme tokens for spacing.

The hardcoded padding values could be replaced with theme tokens for consistency.

-          <PageContainer px={12} pt={9} pb={40} p={0}>
+          <PageContainer px="spacing.12" pt="spacing.9" pb="spacing.40" p={0}>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fda9341 and 0df919c.

📒 Files selected for processing (8)
  • src/lib/components/UserDocsLink.tsx (2 hunks)
  • src/lib/components/upload/UploadCard.tsx (2 hunks)
  • src/lib/components/upload/hooks/useCardTheme.ts (0 hunks)
  • src/lib/pages/evm-contract-details/components/evm-contract-details-overview/OverviewInfo.tsx (2 hunks)
  • src/lib/pages/evm-contract-verify/components/ContractLicenseInfoAccordion.tsx (1 hunks)
  • src/lib/pages/evm-contract-verify/helpers.ts (1 hunks)
  • src/lib/pages/evm-contract-verify/index.tsx (3 hunks)
  • src/lib/types/evm.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • src/lib/components/upload/hooks/useCardTheme.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
src/lib/pages/evm-contract-verify/components/ContractLicenseInfoAccordion.tsx (1)

47-48: LGTM!

The changes align with the updated UserDocsLink component interface, using the relative path and isDevTool prop for better documentation management.

src/lib/components/upload/UploadCard.tsx (1)

54-70: LGTM! UI improvements enhance user experience.

The changes improve the UI by:

  • Using a more compact IconButton for the delete action
  • Adding clear hover states for better user feedback
  • Maintaining accessibility with an appropriate aria-label
src/lib/pages/evm-contract-details/components/evm-contract-details-overview/OverviewInfo.tsx (1)

32-33: LGTM! Layout improvements enhance responsiveness.

The changes to the grid template columns and column gap values improve the component's flexibility and responsiveness:

  • Using repeat(4, max-content) allows columns to adapt to their content.
  • Responsive column gaps (base: 14, 2xl: 36) provide better spacing across different screen sizes.

Also applies to: 37-40

src/lib/pages/evm-contract-verify/index.tsx (1)

260-264: LGTM! Improved error handling for verified contracts.

The conditional error message provides better feedback by explicitly indicating when a contract is already verified.

@songwongtp songwongtp merged commit c823ba4 into develop Feb 20, 2025
13 checks passed
@songwongtp songwongtp deleted the fix/evm-contract branch February 20, 2025 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants