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(components): add deployed bytecode #1204

Merged
merged 5 commits into from
Jan 23, 2025

Conversation

Poafs1
Copy link
Collaborator

@Poafs1 Poafs1 commented Jan 22, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a generic TypeSwitch component for tab navigation.
    • Added ContractByteCode component to display contract bytecode details.
    • Created EvmContractDetailsContract component for improved contract information display.
    • Added new feature entry for deployed bytecode in the changelog.
  • Refactoring

    • Replaced InteractionTypeSwitch with a more generic TypeSwitch component.
    • Removed EvmContractDetailsBytecode component.
    • Updated contract details page to use new components.
  • Improvements

    • Added new enum EvmContractDetailsContractTabs for more flexible tab management.
    • Enhanced contract information retrieval with additional code extraction.
    • Introduced new schema for EVM transaction message validation.

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

Copy link

coderabbitai bot commented Jan 22, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces a new generic TypeSwitch component for tab navigation, removes the existing EvmContractDetailsBytecode and InteractionTypeSwitch components, and modifies the EVM contract details page. The changes involve creating a more flexible tab-switching mechanism with a reusable component, updating the contract details view to utilize the new component, and introducing an enum for contract detail tabs. These modifications enhance the user interface for contract interactions and details.

Changes

File Change Summary
src/lib/components/TypeSwitch.tsx Added new generic TypeSwitch component for tab navigation
src/lib/pages/evm-contract-details/components/EvmContractDetailsBytecode.tsx Removed entirely
src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/ContractByteCode.tsx Added new ContractByteCode component for displaying bytecode
src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx Added new EvmContractDetailsContract component with tab navigation
src/lib/pages/evm-contract-details/index.tsx Updated to use new EvmContractDetailsContract component
src/lib/pages/evm-contract-details/types.ts Added EvmContractDetailsContractTabs enum
src/lib/pages/interact-contract/components/InteractionTypeSwitch.tsx Removed entirely
src/lib/pages/interact-contract/components/index.ts Removed export for InteractionTypeSwitch
src/lib/pages/interact-contract/index.tsx Replaced InteractionTypeSwitch with TypeSwitch
src/lib/services/evm/lcd.ts Minor modification to getEvmContractInfoSequencer function
CHANGELOG.md Added entry for new feature: EVM contract details deployed bytecode

Possibly related PRs

Suggested reviewers

  • evilpeach
  • songwongtp

Poem

🐰 Tabs dancing light and free,
A switch that brings simplicity!
From bytecode to contract's might,
Our TypeSwitch shines so bright!
Hopping through interfaces with glee 🎉


📜 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 ffec31a and 7e8d6cd.

📒 Files selected for processing (3)
  • src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/ContractByteCode.tsx (1 hunks)
  • src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx (1 hunks)
  • src/lib/pages/evm-contract-details/index.tsx (2 hunks)

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

🔭 Outside diff range comments (1)
src/lib/services/evm/lcd.ts (1)

Line range hint 23-47: Consider retrieving multiple transactions

The function only looks at the first transaction, which might miss the relevant create event. Consider:

  1. Implementing pagination to look through more transactions
  2. Adding a parameter to control the number of transactions to search
  3. Adding proper error handling for when the create event is not found
🧹 Nitpick comments (5)
src/lib/pages/evm-contract-details/types.ts (1)

12-17: Maintain consistent naming convention in enum values

The enum values should follow a consistent naming convention. Currently, "byteCode" uses camelCase while other values use lowercase.

 export enum EvmContractDetailsContractTabs {
   Code = "code",
   Compiler = "compiler",
   Abi = "abi",
-  ByteCode = "byteCode",
+  ByteCode = "bytecode",
 }
src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/ContractByteCode.tsx (2)

5-8: Add validation for empty string props

Consider adding validation or placeholder text for when code or deployedCode are empty strings to improve user experience.


10-28: Consider adding loading states for large bytecode

Large bytecode strings might cause performance issues. Consider:

  1. Adding a loading state while rendering large strings
  2. Implementing virtualization for better performance
  3. Adding a truncate option with "Show More" button

Also, the component's directory has a typo: "Contarct" should be "Contract".

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

13-38: Add error boundaries for component safety

Consider wrapping the component with error boundaries to gracefully handle rendering errors, especially for invalid bytecode or contract data.

src/lib/components/TypeSwitch.tsx (1)

43-43: Consider making tab width responsive.

The fixed width of 96px might not accommodate longer tab names and could break the layout on smaller screens.

Consider using a dynamic width approach:

-          w="96px"
+          minW="96px"
+          flex="1"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dd5d0ff and ef2b2bb.

📒 Files selected for processing (10)
  • src/lib/components/TypeSwitch.tsx (1 hunks)
  • src/lib/pages/evm-contract-details/components/EvmContractDetailsBytecode.tsx (0 hunks)
  • src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/ContractByteCode.tsx (1 hunks)
  • src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx (1 hunks)
  • src/lib/pages/evm-contract-details/index.tsx (2 hunks)
  • src/lib/pages/evm-contract-details/types.ts (1 hunks)
  • src/lib/pages/interact-contract/components/InteractionTypeSwitch.tsx (0 hunks)
  • src/lib/pages/interact-contract/components/index.ts (0 hunks)
  • src/lib/pages/interact-contract/index.tsx (2 hunks)
  • src/lib/services/evm/lcd.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • src/lib/pages/interact-contract/components/index.ts
  • src/lib/pages/evm-contract-details/components/EvmContractDetailsBytecode.tsx
  • src/lib/pages/interact-contract/components/InteractionTypeSwitch.tsx
🔇 Additional comments (6)
src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx (2)

24-24: Address the TODO comment

The comment "TODO: Support all status" needs to be addressed. Please clarify the requirements and timeline for supporting all statuses.

Would you like me to help create an issue to track this TODO item?


33-35: Implement remaining tab views

Only the ByteCode tab is currently implemented. The other tabs (Code, Compiler, Abi) defined in EvmContractDetailsContractTabs need to be implemented.

✅ Verification successful

Review comment is accurate - missing tab implementations

The code confirms that while all tabs (Code, Compiler, Abi, ByteCode) are defined in EvmContractDetailsContractTabs and rendered in the UI via TypeSwitch, only the ByteCode tab has an actual implementation. The other three tabs need to be implemented:

  • Code tab implementation missing
  • Compiler tab implementation missing
  • Abi tab implementation missing
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify if other tab implementations exist in the codebase
rg -g '*.tsx' -g '*.ts' "EvmContractDetailsContractTabs\.(Code|Compiler|Abi)"

Length of output: 79


Script:

#!/bin/bash
# Find the enum definition and related components
echo "=== Enum Definition ==="
rg -g '*.ts*' "enum EvmContractDetailsContractTabs"

echo -e "\n=== Related Components ==="
fd -e tsx -e ts "(Code|Compiler|Abi|Contract)\.tsx$|/Contract.*\.tsx$"

echo -e "\n=== Current Tab Usage ==="
rg -g '*.tsx' "currentTab === EvmContractDetailsContractTabs" -A 2

Length of output: 1711


Script:

#!/bin/bash
# Get enum definition and component structure
echo "=== Enum Definition Content ==="
cat src/lib/pages/evm-contract-details/types.ts

echo -e "\n=== Main Component Structure ==="
cat src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx

Length of output: 2129

src/lib/services/evm/lcd.ts (1)

46-46: Verify impact of return type change

The addition of the code field to the return object might affect existing consumers of this function.

src/lib/components/TypeSwitch.tsx (1)

6-11: LGTM! Well-defined generic interface.

The TypeSwitchProps interface is well-structured with clear generic constraints and optional properties.

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

143-146: LGTM! Clean component replacement.

The replacement of EvmContractDetailsBytecode with EvmContractDetailsContract is well-implemented with proper prop passing.

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

153-157: LGTM! Clean migration to TypeSwitch.

The migration from InteractionTypeSwitch to TypeSwitch is well-implemented, maintaining the same functionality while leveraging the new generic component.

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)
CHANGELOG.md (1)

42-42: LGTM! The new changelog entry follows the established format.

The entry is properly placed under the "Features" section and correctly linked to PR #1204.

Consider adding more details about what this feature enables users to do, for example:

-Add EVM contract details deployed bytecode
+Add EVM contract details deployed bytecode view to inspect contract's on-chain bytecode
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ef2b2bb and ef63716.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
CHANGELOG.md (1)

Line range hint 1-1147: LGTM! The changelog is well-structured and follows best practices.

The file maintains:

  • Clear categorization of changes
  • Consistent formatting
  • Proper versioning
  • Good organization

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/services/types/tx.ts (1)

495-498: Add JSDoc comments to document the schema.

The schema definition is correct and well-structured. Consider adding JSDoc comments to document:

  • The purpose of this schema
  • The expected format of the code field (bytecode)
  • Example usage
+/**
+ * Schema for EVM contract creation messages.
+ * @property {string} type - The message type identifier
+ * @property {string} code - The contract bytecode to be deployed
+ * @example
+ * const msg = {
+ *   type: "/minievm.evm.v1.MsgCreate",
+ *   code: "0x608060405234801561001057600080fd5b50610..."
+ * };
+ */
 export const zEvmMsgCreate = z.object({
   type: z.literal("/minievm.evm.v1.MsgCreate"),
   code: z.string(),
 });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e0b47f6 and ffec31a.

📒 Files selected for processing (2)
  • src/lib/services/evm/lcd.ts (2 hunks)
  • src/lib/services/types/tx.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/services/evm/lcd.ts
🔇 Additional comments (1)
src/lib/services/types/tx.ts (1)

178-178: LGTM! Preserves message-specific fields.

The spread operator ensures all message-specific fields are included in the transformed Message object.

@Poafs1 Poafs1 merged commit c3ddef0 into develop Jan 23, 2025
7 of 12 checks passed
@Poafs1 Poafs1 deleted the feature/evm-contract-verified-byte-code branch January 23, 2025 08:38
@coderabbitai coderabbitai bot mentioned this pull request Jan 29, 2025
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