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

feat: evm verification status modal, bar #1213

Merged
merged 5 commits into from
Feb 3, 2025

Conversation

evilpeach
Copy link
Collaborator

@evilpeach evilpeach commented Jan 30, 2025

Summary by CodeRabbit

  • New Features

    • Added EVM Verification Status Modal and highlight bar.
    • Introduced new components for displaying contract verification details, including FailedDetails, InProgressDetails, VerifiedDetails, EvmVerifyProcess, and EvmVerifyRequestInfo.
    • Enhanced contract details page with verification status information through the EvmVerifySection.
    • Added a new tab for "Read/Write" functionality based on contract verification status.
  • Improvements

    • Streamlined contract verification process UI.
    • Added more detailed verification status tracking.
    • Improved mobile and desktop responsiveness for verification components.
  • Bug Fixes

    • Updated verification information handling.
    • Refined contract details navigation and tab management.

Copy link

vercel bot commented Jan 30, 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 3, 2025 4:58am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
celatone-frontend-main ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2025 4:58am
initia-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2025 4:58am
neutron-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2025 4:58am
osmosis-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2025 4:58am
sei-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2025 4:58am
terra-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2025 4:58am

Copy link

coderabbitai bot commented Jan 30, 2025

Walkthrough

This pull request introduces a comprehensive set of components and utilities for EVM contract verification status and details. The changes focus on enhancing the user interface for displaying contract verification information, including a new modal, verification process tracking, and updated components for contract details. The implementation provides a more detailed and interactive way to view verification statuses across different device types, with support for various verification states like not verified, in progress, failed, and verified.

Changes

File Change Summary
CHANGELOG.md Added new feature entry for EVM Verification Status Modal and highlight bar
src/lib/components/evm-verify-section/* Introduced new components (FailedDetails, InProgressDetails, NotVerifiedDetails, VerifiedDetails, EvmVerifySection) for handling different verification states
src/lib/components/modal/evm-verify-status/* Added modal components (EvmVerifyStatusModal, EvmVerifyStatusModalWithTrigger, EvmVerifyAlert, EvmVerifyProcess, EvmVerifyRequestInfo, EvmVerifyProcessStepIcon) for displaying verification status details
src/lib/pages/evm-contract-details/* Updated contract details components to use new verification section and adjusted imports accordingly
src/lib/services/types/verification/evm.ts Modified EvmVerifyInfo schema with optional fields and new computed property
src/lib/utils/verification/* Added utility functions for license type labeling and process step management

Suggested Reviewers

  • Poafs1
  • songwongtp

Poem

🐰 Verification's dance, a rabbit's delight,
Code verified, shining ever so bright!
Modal opens, steps unfold with grace,
From pending to complete, we embrace
The journey of contracts, clear and tight! 🔍

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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: 3

🧹 Nitpick comments (14)
src/lib/utils/verification/evm.ts (2)

29-29: Consider optimizing the order calculation.

While the current implementation works well for this size, consider using a pre-computed map for order numbers if the set grows larger, as Object.keys().indexOf() has O(n) complexity.

+ const orderMap = Object.fromEntries(
+   Object.keys(licenseLabels).map((key, index) => [key, index + 1])
+ );
- const orderNumber = Object.keys(licenseLabels).indexOf(license) + 1;
+ const orderNumber = orderMap[license] || 0;

3-6: Add JSDoc documentation for better maintainability.

Consider adding JSDoc documentation to describe the function's purpose, parameters, and return value.

+ /**
+  * Formats a license type into a human-readable label with an optional order number.
+  * @param license - The EVM verification license type
+  * @param withOrderNumber - Whether to include the order number in the output
+  * @returns Formatted license label string
+  */
export const getLicenseTypeLabel = (
  license: EVMVerifyLicenseType,
  withOrderNumber = true
) => {
src/lib/components/modal/evm-verify-status/EvmVerifyProcessStepIcon.tsx (2)

5-41: Clean up switch statement and consider type safety improvements.

The implementation is good, but has room for minor improvements:

  1. Remove the redundant "Pending" case as it's handled by default:
-    case "Pending":
     default:
       return (
         <Box
  1. Consider using a union type for better type safety:
type VerificationState = "Failed" | "Completed" | "In Progress" | "Pending";

export const EvmVerifyProcessStepIcon = ({ state }: { state: VerificationState }) => {
🧰 Tools
🪛 Biome (1.9.4)

[error] 25-25: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)


13-24: Consider extracting shared styles to reduce duplication.

The Box and Flex components share identical styling properties.

const commonStyles = {
  m: 1,
  w: "16px",
  minW: "16px",
  h: "16px",
  minH: "16px",
  background: "gray.800",
  borderRadius: "100%",
  border: "1px solid"
};

// Then use like:
<Flex {...commonStyles} borderColor="primary.main" />
<Box {...commonStyles} borderColor="gray.500" />

Also applies to: 28-39

src/lib/components/evm-verify-section/VerifiedDetails.tsx (1)

24-34: Consider enhancing accessibility for the clickable text.

The implementation looks clean and well-structured. Consider adding role="button" and aria-label to improve accessibility for screen readers.

 <Text
   as="span"
   cursor="pointer"
+  role="button"
+  aria-label="View source code"
   color="primary.main"
   transition="all 0.25s ease-in-out"
   _hover={{
     textDecoration: "underline",
     textDecorationColor: "primary.light",
   }}
   onClick={handleNavigate}
 >
src/lib/components/evm-verify-section/NotVerifiedDetails.tsx (2)

25-28: Extract common text content to avoid duplication.

The text content is duplicated between mobile and desktop views. Consider extracting it to a constant.

+const NOT_VERIFIED_MESSAGE = 
+  "This contract has not been verified. If you are the owner, you can " +
+  "verify it to allow other users to view the source code";

 export const NotVerifiedDetails = ({
   contractAddress,
 }: NotVerifiedDetailsProps) => {
   // ...
   if (isMobile)
     return (
       <>
         <Text variant="body2" color="text.dark">
-          This contract has not been verified. If you are the owner, you can
-          verify it to allow other users to view the source code
+          {NOT_VERIFIED_MESSAGE}
         </Text>
         // ...
     );

   return (
     <>
       <Text variant="body2" color="text.dark">
-        This contract has not been verified. If you are the owner, you can{" "}
+        {NOT_VERIFIED_MESSAGE.replace(" verify it", "")}{" "}
         <Text
           as="span"
           // ...
         >
           verify it
         </Text>
-        to allow other users to view the source code
       </Text>
       // ...
     );
 };

Also applies to: 37-53


39-53: Consider unifying the navigation triggers.

There are two separate elements triggering the same navigation. Consider wrapping them in a button group or similar component for better maintainability.

+import { ButtonGroup } from "@chakra-ui/react";

 // ...
 return (
   <>
     <Text variant="body2" color="text.dark">
       {NOT_VERIFIED_MESSAGE.replace(" verify it", "")}{" "}
     </Text>
+    <ButtonGroup spacing={2}>
       <Text
         as="span"
         // ... (existing styles)
       >
         verify it
       </Text>
       <Button variant="ghost-primary" size="sm" onClick={handleNavigate}>
         Verify contract
       </Button>
+    </ButtonGroup>
   </>
 );

Also applies to: 54-56

src/lib/components/evm-verify-section/index.tsx (2)

5-8: Clean up commented imports.

Remove the commented-out imports if they are no longer needed. If they will be used in the future, add a TODO comment explaining when they will be needed.

-// import { FailedDetails } from "./FailedDetails";
-// import { IndirectlyVerifiedDetails } from "./IndirectlyVerifiedDetails";
-// import { InProgressDetails } from "./InProgressDetails";

24-26: Consider consolidating duplicate NotVerifiedDetails rendering.

The NotVerifiedDetails component is rendered in two places with identical props. Consider moving the condition to avoid duplication.

 const EvmVerifySectionBody = ({
   contractAddress,
   evmVerifyInfo,
 }: EvmVerifySectionProps) => {
-  if (!evmVerifyInfo) {
-    return <NotVerifiedDetails contractAddress={contractAddress} />;
-  }
-
   const { errorMessage, isVerified, submittedTimestamp } = evmVerifyInfo ?? {};
 
   if (errorMessage) {
     return (
       <FailedDetails
         contractAddress={contractAddress}
         evmVerifyInfo={evmVerifyInfo}
       />
     );
   }
 
   if (isVerified) {
     return <VerifiedDetails contractAddress={contractAddress} />;
   }
 
   if (submittedTimestamp) {
     return (
       <InProgressDetails
         contractAddress={contractAddress}
         evmVerifyInfo={evmVerifyInfo}
       />
     );
   }
 
   return <NotVerifiedDetails contractAddress={contractAddress} />;
 };

Also applies to: 52-53

src/lib/components/evm-verify-section/FailedDetails.tsx (2)

30-33: Extract duplicate text to a constant.

The failure message text is duplicated between mobile and desktop views. Consider extracting it to a constant.

+const FAILURE_MESSAGE = (timestamp: string) =>
+  `Verification failed: Verification was submitted on ${timestamp} but an error occurred.`;

 export const FailedDetails = ({
   contractAddress,
   evmVerifyInfo,
 }: FailedDetailsProps) => {
   // ...
   if (isMobile)
     return (
       <>
         <Text variant="body2" color="text.dark">
-          Verification failed: Verification was submitted on{" "}
-          {formatUTC(evmVerifyInfo.submittedTimestamp)} but an error occurred.
+          {FAILURE_MESSAGE(formatUTC(evmVerifyInfo.submittedTimestamp))}
         </Text>
         // ...

Also applies to: 52-55


21-25: Consider extracting the route path to a constant.

The route path /evm-contracts/verify should be extracted to a constant to maintain consistency and ease updates.

+const VERIFY_ROUTE = "/evm-contracts/verify";

 export const FailedDetails = ({
   // ...
   const handleNavigate = () =>
     navigate({
-      pathname: "/evm-contracts/verify",
+      pathname: VERIFY_ROUTE,
       query: { contractAddress },
     });
src/lib/components/modal/evm-verify-status/EvmVerifyProcess.tsx (2)

21-21: Replace magic numbers with semantic spacing tokens.

The component uses magic numbers for spacing (mt={4} and height={4}). Consider using semantic spacing tokens for consistency.

-      <Flex direction="column" mt={4}>
+      <Flex direction="column" mt="spacingM">
       // ...
-                <Box height={4} />
+                <Box height="spacingM" />

Also applies to: 50-50


32-32: Use semantic color tokens for better theme support.

The component uses direct color values. Consider using semantic color tokens for better theme support and consistency.

-                    borderColor="gray.400"
+                    borderColor="border.secondary"
                   />
                 )}
               </Flex>
               <Flex direction="column">
                 <Text variant="body2" fontWeight={600} mt="2px">
                   {step.label}
                 </Text>
                 {step.errorMsg && (
-                  <Text variant="body3" color="error.main">
+                  <Text variant="body3" color="status.error">
                     {step.errorMsg}
                   </Text>
                 )}
                 {step.state === "In Progress" && (
-                <Text variant="body2" color="success.main">
+                <Text variant="body2" color="status.success">

Also applies to: 46-47, 60-61

src/lib/components/modal/evm-verify-status/index.tsx (1)

85-92: Extract onClick handler for better readability.

Consider extracting the onClick handler to a separate function for improved maintainability.

 export const EvmVerifyStatusModalWithTrigger = ({
   triggerElement,
   contractAddress,
   evmVerifyInfo,
 }: EvmVerifyStatusModalTriggerProps) => {
   const { isOpen, onClose, onOpen } = useDisclosure();
+
+  const handleClick = (e: React.MouseEvent) => {
+    e.stopPropagation();
+    onOpen();
+  };

   return (
     <>
-      <Flex
-        onClick={(e) => {
-          e.stopPropagation();
-          onOpen();
-        }}
-      >
+      <Flex onClick={handleClick}>
         {triggerElement}
       </Flex>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f65e52e and 2ff5c53.

📒 Files selected for processing (24)
  • CHANGELOG.md (1 hunks)
  • src/lib/components/evm-verify-section/FailedDetails.tsx (1 hunks)
  • src/lib/components/evm-verify-section/InProgressDetails.tsx (1 hunks)
  • src/lib/components/evm-verify-section/NotVerifiedDetails.tsx (2 hunks)
  • src/lib/components/evm-verify-section/VerifiedDetails.tsx (1 hunks)
  • src/lib/components/evm-verify-section/index.ts (0 hunks)
  • src/lib/components/evm-verify-section/index.tsx (1 hunks)
  • src/lib/components/modal/evm-verify-status/EvmVerifyAlert.tsx (1 hunks)
  • src/lib/components/modal/evm-verify-status/EvmVerifyProcess.tsx (1 hunks)
  • src/lib/components/modal/evm-verify-status/EvmVerifyProcessStepIcon.tsx (1 hunks)
  • src/lib/components/modal/evm-verify-status/EvmVerifyRequestInfo.tsx (1 hunks)
  • src/lib/components/modal/evm-verify-status/index.tsx (1 hunks)
  • src/lib/components/modal/evm-verify-status/utils.ts (1 hunks)
  • src/lib/pages/evm-contract-details/components/EvmContractDetailsOverview.tsx (3 hunks)
  • src/lib/pages/evm-contract-details/components/evm-contract-details-contract-info/index.tsx (1 hunks)
  • src/lib/pages/evm-contract-details/components/interact-evm-contract/index.tsx (3 hunks)
  • src/lib/pages/evm-contract-details/index.tsx (4 hunks)
  • src/lib/pages/evm-contract-details/types.ts (2 hunks)
  • src/lib/pages/evm-contract-verify/components/EvmContractVerifyFooter.tsx (1 hunks)
  • src/lib/pages/evm-contract-verify/helpers.ts (1 hunks)
  • src/lib/pages/evm-contract-verify/index.tsx (4 hunks)
  • src/lib/services/types/verification/evm.ts (1 hunks)
  • src/lib/utils/verification/evm.ts (1 hunks)
  • src/lib/utils/verification/index.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • src/lib/components/evm-verify-section/index.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/lib/components/modal/evm-verify-status/EvmVerifyProcessStepIcon.tsx

[error] 25-25: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)

🔇 Additional comments (35)
src/lib/utils/verification/index.ts (1)

1-2: LGTM! Clean barrel file implementation.

The addition of the EVM module export follows the established pattern and maintains consistency with the existing exports.

src/lib/pages/evm-contract-verify/helpers.ts (1)

3-4: LGTM! Clean refactor of license label functionality.

The relocation of getLicenseTypeLabel to a dedicated utils file improves code organization. The import and usage changes are consistent.

Let's verify that all imports of getLicenseTypeLabel have been updated:

✅ Verification successful

Refactoring verification complete - all imports updated correctly

The getLicenseTypeLabel function is properly exported from utils/verification/evm.ts and correctly re-exported through the utils module. All imports and usages have been updated to use the new location.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining direct imports of getLicenseTypeLabel from helpers
rg "from.*evm-contract-verify/helpers.*getLicenseTypeLabel"

# Search for all current imports to ensure they're from lib/utils
rg "import.*getLicenseTypeLabel.*from.*lib/utils"

Length of output: 335


Script:

#!/bin/bash
# Check implementation in lib/utils
ast-grep --pattern 'export function getLicenseTypeLabel'

# Search for any other usages of getLicenseTypeLabel
rg "getLicenseTypeLabel" -g '!*.md'

Length of output: 605


Script:

#!/bin/bash
# Check re-export in lib/utils
rg "export.*getLicenseTypeLabel" src/lib/utils/index.ts

Length of output: 57


Script:

#!/bin/bash
# Check for export patterns in utils/index.ts
cat src/lib/utils/index.ts

# Look for other potential index files
fd index.ts --exec grep -l "export.*getLicenseTypeLabel" {} \;

Length of output: 1412


Script:

#!/bin/bash
# Check verification directory structure and exports
ls -la src/lib/utils/verification/
cat src/lib/utils/verification/index.ts

Length of output: 470

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

21-21: LGTM! Simplified footer navigation.

The static "Cancel" label and removal of navigation-related props align well with the shift towards a modal-based verification status approach.

src/lib/pages/evm-contract-details/types.ts (2)

8-8: LGTM! Added ReadWrite tab for contract interaction.

The addition of the ReadWrite tab enhances the contract interaction capabilities.


20-20: LGTM! Improved enum naming.

The rename to EvmContractDetailsContractInfoTabs better reflects its specific purpose.

src/lib/components/evm-verify-section/InProgressDetails.tsx (1)

1-31: LGTM! Well-structured progress indicator component.

The component provides clear user feedback about the verification process with:

  • Informative message about potential duration
  • Easy access to detailed status via modal
  • Clean implementation using Chakra UI components
src/lib/components/modal/evm-verify-status/EvmVerifyAlert.tsx (1)

31-38: Consider sanitizing error messages for display.

The implementation looks solid. However, directly rendering error messages could potentially expose sensitive information or lead to XSS if the messages contain HTML/JS content.

Consider sanitizing the error message before display. Let's check if there's any error message sanitization in place:

✅ Verification successful

Error message handling is secure in this context

The error messages displayed in EvmVerifyAlert are system-generated from trusted sources (API responses, contract interactions, and internal validation) and rendered through Chakra UI's Text component, which provides built-in content escaping. Additional sanitization is not necessary in this case.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for error message sanitization patterns
rg -g '*.{ts,tsx}' 'sanitize|escape|purify|DOMPurify' src/

Length of output: 578


Script:

#!/bin/bash
# Search for error message handling in EVM verification
rg -g '*.{ts,tsx}' -B 3 -A 3 'errorMsg.*=|setErrorMsg' src/

Length of output: 6229

src/lib/components/modal/evm-verify-status/utils.ts (1)

18-47: 🛠️ Refactor suggestion

Add validation for edge cases in getProcessStep.

The function handles basic state transitions but might miss some edge cases:

  1. What happens if there's an error message but also a date?
  2. Should we validate that the date is not in the future?

Let's check if there's any timestamp validation elsewhere:

Consider adding validation:

 const getProcessStep = (
   date: Option<Date>,
   errorMsg: Option<string>,
   prevStepState?: ProcessStepState
 ) => {
+  // Validate date is not in the future
+  const isValidDate = date && date <= new Date();
+
+  // Error takes precedence over date
+  if (errorMsg) {
+    return {
+      state: ProcessStepState.FAILED,
+      errorMsg,
+      timestamp: isValidDate ? date : undefined,
+    };
+  }

   if (
     prevStepState === ProcessStepState.FAILED ||
     prevStepState === ProcessStepState.PENDING ||
     prevStepState === ProcessStepState.IN_PROGRESS
   )
     return {
       state: ProcessStepState.PENDING,
     };

-  if (date)
+  if (isValidDate)
     return {
       timestamp: date,
       state: ProcessStepState.COMPLETED,
     };

-  if (errorMsg)
-    return {
-      state: ProcessStepState.FAILED,
-      errorMsg,
-    };

   return {
     state: ProcessStepState.IN_PROGRESS,
   };
 };
src/lib/components/evm-verify-section/index.tsx (1)

55-72: LGTM! Well-structured responsive layout.

The component handles mobile responsiveness well using the useMobile hook and appropriate Chakra UI flex properties.

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

57-75: LGTM! Well-structured schema with proper optionality.

The changes to make certain fields optional and the addition of isVerified computed property improve the schema's flexibility while maintaining type safety.

src/lib/components/evm-verify-section/FailedDetails.tsx (1)

14-72: LGTM! Well-structured component with good mobile support.

The component handles both mobile and desktop views appropriately, with clear error messaging and proper navigation options.

src/lib/components/modal/evm-verify-status/EvmVerifyProcess.tsx (2)

12-70: LGTM! Well-structured process visualization.

The component effectively visualizes the verification process with good mobile support and clear step progression.


59-63: Ensure color contrast meets WCAG guidelines.

When using colors to convey status (e.g., "In Progress" state), ensure sufficient color contrast for accessibility.

src/lib/pages/evm-contract-details/components/evm-contract-details-contract-info/index.tsx (4)

13-17: LGTM! Clean interface and component declaration.

The props interface is well-typed and the component name change improves clarity.

Also applies to: 18-24


24-29: LGTM! Clean state management.

Good use of optional chaining for safe access to evmVerifyInfo.isVerified.


33-36: LGTM! Clean render logic.

The EvmVerifySection component receives all required props.


Line range hint 37-71: LGTM! Clean conditional rendering.

Good use of optional chaining and nullish coalescing for safe access to contractPath and abi.

src/lib/components/modal/evm-verify-status/EvmVerifyRequestInfo.tsx (3)

15-18: LGTM! Clean interface definition.

The props interface is well-typed and clearly defines the component's requirements.


20-45: LGTM! Clean component structure.

Good use of early return pattern for the unverified state, making the code more maintainable.


47-89: LGTM! Well-structured responsive design.

Good use of Chakra UI's responsive props and consistent spacing throughout the component.

src/lib/components/modal/evm-verify-status/index.tsx (2)

23-28: LGTM! Clean interface definitions.

Good use of TypeScript's Pick utility type for prop sharing between components.

Also applies to: 71-74


30-69: LGTM! Well-structured modal component.

Good use of Chakra UI's modal components and responsive design.

src/lib/pages/evm-contract-details/components/EvmContractDetailsOverview.tsx (2)

52-52: LGTM! Clean hook usage.

Good use of the useEvmVerifyInfo hook for fetching verification data.


56-59: LGTM! Clean component integration.

The EvmVerifySection component is well-integrated with the required props.

src/lib/pages/evm-contract-details/components/interact-evm-contract/index.tsx (3)

8-8: LGTM! New import for type safety.

The addition of TabIndex import enhances type safety for tab-related operations.


14-16: LGTM! Updated path name to support tab navigation.

The path name now includes a dynamic [tab] segment, improving routing capabilities.


61-61: LGTM! Consistent tab handling in navigation.

Both navigation callbacks now include the tab parameter, ensuring consistent routing behavior.

Also applies to: 80-80

src/lib/pages/evm-contract-details/index.tsx (4)

28-28: LGTM! Component renamed for better clarity.

The import statement reflects the renamed component EvmContractDetailsContractInfo, which better describes its purpose.


75-76: LGTM! Added verification state.

The isVerified state is correctly derived from evmVerifyInfo to control feature visibility.


144-149: LGTM! Conditional Read/Write tab.

The Read/Write tab is properly conditionally rendered based on the contract's verification status.


185-193: LGTM! New interaction panel.

The InteractEvmContract component is properly integrated with necessary props for contract interaction.

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

43-46: LGTM! Added necessary imports.

The new imports support verification functionality and modal management.


97-99: LGTM! Modal state management.

Using Chakra UI's useDisclosure hook for modal state management.


272-277: LGTM! Added verification status modal.

The EvmVerifyStatusModal is properly integrated with necessary props.

CHANGELOG.md (1)

42-42: LGTM! Well-documented changelog entry.

The new feature is properly documented in the changelog with a reference to the PR.

Copy link
Collaborator

@Poafs1 Poafs1 left a comment

Choose a reason for hiding this comment

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

look good, just a few comments. Thank!

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: 0

🧹 Nitpick comments (3)
src/lib/components/modal/evm-verify-status/EvmVerifyAlert.tsx (1)

19-37: Consider using break-word for better readability.

The text styling is good, but consider changing wordBreak="break-all" to wordBreak="break-word" for better readability of error messages. The current break-all might break words at any character, while break-word will try to break at word boundaries first.

         <Text
           variant="body3"
           color="error.main"
-          wordBreak="break-all"
+          wordBreak="break-word"
           lineHeight="normal"
         >
src/lib/components/modal/evm-verify-status/EvmVerifyRequestInfo.tsx (1)

9-13: Consider extracting common text styles to a theme.

The baseTextStyle object defines common text styles. Consider moving these styles to a theme configuration for better maintainability and consistency across components.

-const baseTextStyle: TextProps = {
-  color: "text.dark",
-  variant: "body2",
-  whiteSpace: "nowrap",
-};

Add to your theme configuration:

// theme.ts
export const theme = {
  components: {
    Text: {
      variants: {
        verifyInfoLabel: {
          color: "text.dark",
          variant: "body2",
          whiteSpace: "nowrap",
        }
      }
    }
  }
}
src/lib/components/evm-verify-section/index.tsx (1)

17-46: Simplify verification status handling.

Based on past review comments, since submittedTimestamp is a required field in DB, we can simplify the status handling logic.

 const EvmVerifySectionBody = ({
   contractAddress,
   evmVerifyInfo,
 }: EvmVerifySectionProps) => {
   if (!evmVerifyInfo) {
     return <NotVerifiedDetails contractAddress={contractAddress} />;
   }

-  const { errorMessage, isVerified } = evmVerifyInfo;
+  const { errorMessage, isVerified, submittedTimestamp } = evmVerifyInfo;

   if (errorMessage) {
     return (
       <FailedDetails
         contractAddress={contractAddress}
         evmVerifyInfo={evmVerifyInfo}
       />
     );
   }

   if (isVerified) {
     return <VerifiedDetails contractAddress={contractAddress} />;
   }

-  return (
-    <InProgressDetails
-      contractAddress={contractAddress}
-      evmVerifyInfo={evmVerifyInfo}
-    />
-  );
+  // Since submittedTimestamp is required, we can assume it's in progress
+  return <InProgressDetails contractAddress={contractAddress} evmVerifyInfo={evmVerifyInfo} />;
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4546167 and f3d9962.

📒 Files selected for processing (8)
  • CHANGELOG.md (1 hunks)
  • src/lib/components/evm-verify-section/VerifiedDetails.tsx (1 hunks)
  • src/lib/components/evm-verify-section/index.tsx (1 hunks)
  • src/lib/components/modal/evm-verify-status/EvmVerifyAlert.tsx (1 hunks)
  • src/lib/components/modal/evm-verify-status/EvmVerifyRequestInfo.tsx (1 hunks)
  • src/lib/components/modal/evm-verify-status/index.tsx (1 hunks)
  • src/lib/pages/evm-contract-verify/helpers.ts (2 hunks)
  • src/lib/utils/verification/evm.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • CHANGELOG.md
  • src/lib/components/evm-verify-section/VerifiedDetails.tsx
  • src/lib/components/modal/evm-verify-status/index.tsx
🔇 Additional comments (7)
src/lib/components/modal/evm-verify-status/EvmVerifyAlert.tsx (3)

1-7: LGTM! Clean imports and well-defined interface.

The imports are appropriate, and the interface is well-defined with a required prop, following React naming conventions.


8-15: LGTM! Well-structured component with responsive styling.

The component is correctly defined with responsive styling for different breakpoints.


16-18: LGTM! Consistent error theme styling.

The icon and color scheme appropriately convey the error state.

src/lib/components/modal/evm-verify-status/EvmVerifyRequestInfo.tsx (1)

20-90: LGTM! Well-structured component with good separation of concerns.

The component:

  • Handles both verified and unverified cases appropriately
  • Uses responsive design with mobile considerations
  • Properly types props and data
  • Follows React best practices
src/lib/utils/verification/evm.ts (1)

3-36: Consider using a mapping object for license labels.

Previous review comments suggested simplifying this logic. A mapping object would be more maintainable and performant than a switch statement.

-export const getLicenseTypeLabel = (license: EVMVerifyLicenseType) => {
-  switch (license) {
-    case EVMVerifyLicenseType.None:
-      return "No License (None)";
-    // ... other cases
-    default:
-      return "";
-  }
-};
+const LICENSE_TYPE_LABELS: Record<EVMVerifyLicenseType, string> = {
+  [EVMVerifyLicenseType.None]: "No License (None)",
+  [EVMVerifyLicenseType.Unlicense]: "The Unlicense (Unlicense)",
+  [EVMVerifyLicenseType.MIT]: "MIT License (MIT)",
+  // ... other mappings
+};
+
+export const getLicenseTypeLabel = (license: EVMVerifyLicenseType) =>
+  LICENSE_TYPE_LABELS[license] ?? "";
src/lib/components/evm-verify-section/index.tsx (1)

48-65: LGTM! Well-structured responsive layout.

The component:

  • Uses responsive design with mobile considerations
  • Properly handles layout changes based on screen size
  • Uses consistent styling with border and spacing
src/lib/pages/evm-contract-verify/helpers.ts (1)

77-79: LGTM! Good use of centralized utility.

The changes:

  • Properly utilize the centralized getLicenseTypeLabel utility
  • Add clear numerical prefixes to license options
  • Maintain type safety with proper mapping

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: 0

🧹 Nitpick comments (1)
src/lib/utils/verification/evm.ts (1)

33-35: Improve default case error handling.

Returning an empty string for unknown license types could lead to silent failures. Consider throwing an error or returning a more descriptive fallback.

    default:
-      return "";
+      throw new Error(`Unsupported license type: ${license}`);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f3d9962 and 329bab0.

📒 Files selected for processing (2)
  • src/lib/services/types/verification/evm.ts (3 hunks)
  • src/lib/utils/verification/evm.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/services/types/verification/evm.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
src/lib/utils/verification/evm.ts (2)

1-1: LGTM!

The import statement is clean and imports only the required type.


3-36: Implementation aligns with review feedback.

The current implementation follows the suggested approach from past reviews:

  • Uses a simple switch case for efficient mapping
  • Provides clear, consistent labeling format (full name + abbreviation)
  • Leverages TypeScript's type safety

@evilpeach evilpeach merged commit 1943d4a into develop Feb 3, 2025
13 checks passed
@evilpeach evilpeach deleted the feat/improve-evm-contract-details branch February 3, 2025 05:01
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.

3 participants