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

Feature/evm contract verfied abi #1206

Merged
merged 6 commits into from
Jan 23, 2025
Merged

Conversation

Poafs1
Copy link
Collaborator

@Poafs1 Poafs1 commented Jan 22, 2025

Summary by CodeRabbit

  • New Features

    • Added EVM contract details ABI display functionality
    • Introduced new component to show contract ABI information
    • Enhanced EVM contract verification information retrieval
  • Improvements

    • Updated import statements for better type management
    • Reorganized type definitions for EVM contract verification
  • Technical Updates

    • Added new query key for EVM verification information
    • Created new API and hook for fetching EVM contract verification details

Copy link

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

Copy link

coderabbitai bot commented Jan 22, 2025

Walkthrough

This pull request introduces EVM contract details ABI functionality, enhancing the contract verification and details display process. The changes include adding a new query key for EVM verification information, creating a ContractAbi component to render contract ABI, and implementing a new API and hook to fetch verification details. The modifications span multiple files across the project, focusing on improving the EVM contract details page and verification workflow.

Changes

File Change Summary
CHANGELOG.md Added new feature entry for EVM contract details ABI
src/lib/app-provider/env.ts Added EVM_VERIFY_INFO query key to CELATONE_QUERY_KEYS enum
src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/ContractAbi.tsx New component to display contract ABI
src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx Integrated ABI display and verification info fetching
src/lib/services/types/verification/evm.ts Added EvmProgrammingLanguage enum and verification-related schemas
src/lib/services/verification/evm/api.ts Added getEvmVerifyInfo API function
src/lib/services/verification/evm/index.ts Added useEvmVerifyInfo hook

Sequence Diagram

sequenceDiagram
    participant User
    participant EvmContractDetailsPage
    participant VerificationService
    participant API

    User->>EvmContractDetailsPage: View Contract Details
    EvmContractDetailsPage->>VerificationService: Fetch Verify Info
    VerificationService->>API: getEvmVerifyInfo(chainId, contractAddress)
    API-->>VerificationService: Return Verification Data
    VerificationService-->>EvmContractDetailsPage: Provide ABI
    EvmContractDetailsPage->>User: Display Contract ABI
Loading

Possibly related PRs

Suggested reviewers

  • evilpeach

Poem

🐰 Hop, hop, hooray! ABI's in play!
Contracts now speak with crystal clear way
Verification's dance, a technical delight
EVM details shining ever so bright
Code rabbit's magic, bringing clarity today! 🔍

✨ 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.

Base automatically changed from feature/evm-contract-verified-byte-code to develop January 23, 2025 08:38
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: 4

🧹 Nitpick comments (3)
src/lib/pages/evm-contract-verify/helpers.ts (1)

3-7: Consider consolidating imports for better maintainability.

The imports from lib/services/types could be more concise.

-import {
-  EvmProgrammingLanguage,
-  EvmVerifyConfig,
-  EVMVerifyLicenseType,
-} from "lib/services/types";
+import type { EvmProgrammingLanguage, EvmVerifyConfig, EVMVerifyLicenseType } from "lib/services/types";
src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/ContractAbi.tsx (1)

5-7: Consider strengthening the type safety of the ABI prop

The abi prop is typed as a string, but contract ABIs have a specific structure. Consider using a stricter type definition to catch potential issues at compile time.

interface ContractAbiProps {
-  abi: string;
+  abi: Array<{
+    type: string;
+    name?: string;
+    inputs?: Array<{
+      name: string;
+      type: string;
+      components?: Array<{
+        name: string;
+        type: string;
+      }>;
+    }>;
+    outputs?: Array<{
+      name: string;
+      type: string;
+    }>;
+    stateMutability?: string;
+  }>;
}
src/lib/services/verification/evm/index.ts (1)

17-28: Review query configuration settings

The current configuration has some potential concerns:

  1. staleTime: Infinity prevents refetching even when data might have changed
  2. Limited retry attempts might not be sufficient for transient failures
  3. Missing error handling callback
export const useEvmVerifyInfo = (contractAddress: HexAddr20) => {
  const { chainId } = useCurrentChain();

  return useQuery({
    queryKey: [CELATONE_QUERY_KEYS.EVM_VERIFY_INFO, chainId, contractAddress],
    queryFn: () => getEvmVerifyInfo(chainId, contractAddress),
    refetchOnWindowFocus: false,
-   retry: 1,
+   retry: 3,
-   staleTime: Infinity,
+   staleTime: 5 * 60 * 1000, // 5 minutes
    retryOnMount: false,
+   onError: (error) => {
+     console.error('Failed to fetch verification info:', error);
+   },
  });
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c3ddef0 and 4f96c10.

📒 Files selected for processing (12)
  • CHANGELOG.md (1 hunks)
  • src/lib/app-provider/env.ts (1 hunks)
  • src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/ContractAbi.tsx (1 hunks)
  • src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx (3 hunks)
  • src/lib/pages/evm-contract-verify/components/EvmContractVerifyOptions.tsx (1 hunks)
  • src/lib/pages/evm-contract-verify/components/EvmVersionToTarget.tsx (1 hunks)
  • src/lib/pages/evm-contract-verify/helpers.ts (1 hunks)
  • src/lib/pages/evm-contract-verify/index.tsx (1 hunks)
  • src/lib/pages/evm-contract-verify/types.ts (1 hunks)
  • src/lib/services/types/verification/evm.ts (2 hunks)
  • src/lib/services/verification/evm/api.ts (1 hunks)
  • src/lib/services/verification/evm/index.ts (2 hunks)
🔇 Additional comments (11)
src/lib/pages/evm-contract-verify/components/EvmVersionToTarget.tsx (1)

3-3: LGTM! Import consolidation looks good.

The consolidation of imports from lib/services/types aligns with the centralization of type definitions.

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

5-8: LGTM! Clear and well-defined enum.

The EvmProgrammingLanguage enum effectively centralizes the supported programming languages for EVM contracts.


38-46: LGTM! Well-structured source file schema.

The zEvmVerifyInfoSourceFile schema properly validates source file information with appropriate transformations.


48-69: Address the TODO comment for libraries field.

The schema looks comprehensive, but there's an unimplemented TODO comment for libraries that needs attention.

Would you like me to help implement the libraries array schema? I can propose an implementation based on common EVM contract library structures.

Also, let's verify the completeness of the schema:

✅ Verification successful

Libraries field should be an array of library objects with name and address

The libraries field should be implemented as:

libraries: z.array(
  z.object({
    name: z.string().min(1),
    address: zHexAddr20
  })
)

This matches the UI implementation in ContractLibraries.tsx and follows EVM contract library linking conventions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any library-related fields in contract verification
rg -g '*.{ts,tsx}' 'librar(y|ies)' --type-add 'tsx:*.tsx'

Length of output: 751


Script:

#!/bin/bash
# Check ContractLibraries component implementation and related types
cat src/lib/pages/evm-contract-verify/components/ContractLibraries.tsx

# Search for any library-related types or interfaces
ast-grep --pattern 'interface $_ {
  $$$
  librar$_
  $$$
}'

# Search for any library-related type definitions
ast-grep --pattern 'type $_ = {
  $$$
  librar$_
  $$$
}'

Length of output: 3585

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

3-4: LGTM! Clean import organization.

The separation of imports improves code organization while maintaining functionality.

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

1-1: LGTM! Proper type centralization.

The removal of the local enum in favor of the centralized import improves maintainability and consistency.

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

45-45: LGTM! Import consolidation improves type consistency.

The addition of EvmProgrammingLanguage import from lib/services/types aligns with the centralization of type definitions, making the codebase more maintainable.

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

2-7: Verify type consistency across the codebase.

Let's ensure the centralized types are consistently used across all EVM-related components.

✅ Verification successful

Types are consistently defined and imported across the codebase

The EvmProgrammingLanguage type is properly centralized in src/lib/services/types/verification/evm.ts and consistently imported and used across all EVM contract verification components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining local definitions or inconsistent imports of EvmProgrammingLanguage

# Check for local enum/type definitions
rg -t typescript "enum\s+EvmProgrammingLanguage|type\s+EvmProgrammingLanguage"

# Check for inconsistent imports
rg -t typescript "import.*EvmProgrammingLanguage.*from\s+(?!.*lib/services/types)"

Length of output: 506


Script:

#!/bin/bash
# Search for type definitions using ast-grep
ast-grep --pattern 'enum EvmProgrammingLanguage {
  $$$
}'

ast-grep --pattern 'type EvmProgrammingLanguage = $$$'

# Search for imports using simpler patterns
rg "import.*EvmProgrammingLanguage" --type ts

# Also check for actual usage
rg "EvmProgrammingLanguage\." --type ts
rg ":\s*EvmProgrammingLanguage" --type ts

Length of output: 1958

src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx (1)

Line range hint 32-33: Remove or update TODO comment

There's a TODO comment about supporting all status. Either implement the missing status support or create an issue to track this work item.

src/lib/app-provider/env.ts (1)

175-175: LGTM!

The new query key EVM_VERIFY_INFO follows the established naming convention and pattern. This addition is well-integrated with the existing enum structure.

CHANGELOG.md (1)

42-42: LGTM!

The changelog entry follows the Keep a Changelog format and provides clear information about the new feature with proper PR reference.

@evilpeach evilpeach merged commit 5f36b8a into develop Jan 23, 2025
13 checks passed
@evilpeach evilpeach deleted the feature/evm-contract-verfied-abi branch January 23, 2025 08:54
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