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: create multi contracts #1247

Merged
merged 1 commit into from
Feb 25, 2025
Merged

feat: create multi contracts #1247

merged 1 commit into from
Feb 25, 2025

Conversation

songwongtp
Copy link
Collaborator

@songwongtp songwongtp commented Feb 24, 2025

Summary by CodeRabbit

  • New Features

    • Support for multi-address creation transactions has been added.
    • Enhanced interaction for displaying multiple contract creation details on transaction pages.
  • Refactor

    • Redesigned components to improve the display and responsiveness of Ethereum address information.
    • Updated transaction detail views for a more streamlined experience.
  • Style

    • Introduced a new “primary” tag style for improved visual consistency.
    • Adjusted layout spacing in transaction-related components.
  • Chores

    • Integrated an updated UI dependency to enhance floating element behavior.

Copy link

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

Copy link

coderabbitai bot commented Feb 24, 2025

Walkthrough

The diff documents support for multi-address creation transactions in the CHANGELOG and adds a new dependency (@floating-ui/react) in package.json. It refactors the EVM-to-cell components by removing the old implementation and introducing a new structure and components (including a dedicated EvmToCellCreate component) with updated import paths and an added isCompact prop. Additionally, the changes update transaction service functions and types to support multi-contract handling, adjust layout properties in related components, add a new styling variant for tags, and remove deprecated logic in EVM utilities.

Changes

File(s) Change Summary
CHANGELOG.md
package.json
CHANGELOG.md: Added a new entry documenting multi-address creation transactions.
package.json: Added dependency "@floating-ui/react": "0.26.28".
src/lib/components/EvmToCell.tsx
src/lib/components/evm-to-cell/index.tsx
src/lib/components/evm-to-cell/evm-to-cell-create.tsx
src/lib/components/table/evm-transactions/*.tsx
Removed the old EvmToCell component and introduced new ones in a kebab-case folder structure.
Updated import paths and added the isCompact prop to support enhanced contract creation display with multi-contract handling via EvmToCellCreate.
src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxCreateContract.tsx
src/lib/pages/tx-details/components/evm-related-tx-section/*
Modified display logic in contract creation to support multiple contracts using the new hook useCreatedContractsByEvmTxHash.
Adjusted layout properties (e.g., margin, alignments) and updated import paths for consistency.
src/lib/services/tx/index.ts
src/lib/services/types/tx.ts
Enhanced transaction service functions for type safety:
- Updated useCosmosTxHashByEvmTxHash parameter type.
- Added useCosmosTxDataByEvmTxHash and useCreatedContractsByEvmTxHash.
- Modified receipt transformation to include contractAddress.
src/lib/styles/theme/components/tag.ts Introduced a new variant primary for the Tag component with updated background and text colors.
src/lib/types/evm.ts
src/lib/utils/evm.ts
Removed the deprecated SingleCreate enum entry and eliminated the isEvmSingleCreate function to simplify transaction processing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EvmCell as EvmToCell Component
    participant EvmCreate as EvmToCellCreate Component
    participant TxService as Transaction Service (useCreatedContractsByEvmTxHash)

    User->>EvmCell: Render with toAddress (type: Create)
    EvmCell->>EvmCreate: Pass address & tx hash (plus isCompact prop)
    EvmCreate->>TxService: Invoke useCreatedContractsByEvmTxHash(evmTxHash)
    TxService-->>EvmCreate: Return list of created contracts
    EvmCreate->>User: Display contract count/details based on retrieved data
Loading

Possibly related PRs

Suggested reviewers

  • evilpeach

Poem

In the realm of code so bright,
I, a rabbit, dance with delight.
Multi-address magic hops into view,
Floating UIs and hooks born anew.
With each commit, my burrow sings,
Cheers and bytes — joy that coding brings!
🐇✨

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/evm-to-cell/evm-to-cell-create.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.

src/lib/components/evm-to-cell/index.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.

src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxCreateContract.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.

  • 8 others
✨ 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: 1

🧹 Nitpick comments (4)
src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxCreateContract.tsx (1)

78-93: Consider memoizing the contract list rendering for better performance.

Since the contracts array is used in multiple places and the rendering logic is identical, consider extracting it into a memoized component.

+const ContractLink = React.memo(({ contract }: { contract: string }) => (
+  <Flex gap={1} align="center">
+    <CustomIcon
+      name="contract-address"
+      boxSize={3}
+      color="primary.main"
+    />
+    <ExplorerLink
+      value={contract}
+      type="evm_contract_address"
+      showCopyOnHover
+      textFormat="normal"
+      fixedHeight={false}
+    />
+  </Flex>
+));

 {contracts.map((contract) => (
-  <Flex key={contract} gap={1} align="center">
-    <CustomIcon
-      name="contract-address"
-      boxSize={3}
-      color="primary.main"
-    />
-    <ExplorerLink
-      value={contract}
-      type="evm_contract_address"
-      showCopyOnHover
-      textFormat="normal"
-      fixedHeight={false}
-    />
-  </Flex>
+  <ContractLink key={contract} contract={contract} />
 ))}
src/lib/components/evm-to-cell/evm-to-cell-create.tsx (2)

48-65: Consider adding keyboard accessibility.

While the hover interaction is implemented well, consider adding keyboard accessibility for better user experience.

Consider adding keyboard interaction handlers:

+  const { getReferenceProps, getFloatingProps } = useInteractions([
+    hover,
+    useRole({
+      role: "tooltip",
+    }),
+    useDismiss(),
+    useFocus(),
+  ]);

84-89: Adjust overflow property for better UX.

The overflow: scroll property always shows scrollbars. Consider using auto instead for better user experience.

Apply this diff:

-              overflow="scroll"
+              overflow="auto"
src/lib/services/tx/index.ts (1)

788-820: Well-structured contract creation hooks!

The new hooks effectively handle contract creation transactions with proper error handling and data transformation. The filtering of duplicate contracts in useCreatedContractsByEvmTxHash is a nice touch.

However, consider adding error handling for the event attribute access:

-      .map((event) => zHexAddr20.parse(event.attributes[0].value)) ?? [];
+      .map((event) => {
+        if (!event.attributes?.[0]?.value) {
+          throw new Error("Invalid contract_created event format");
+        }
+        return zHexAddr20.parse(event.attributes[0].value);
+      }) ?? [];
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 72c7333 and a33620b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • CHANGELOG.md (1 hunks)
  • package.json (1 hunks)
  • src/lib/components/EvmToCell.tsx (0 hunks)
  • src/lib/components/evm-to-cell/evm-to-cell-create.tsx (1 hunks)
  • src/lib/components/evm-to-cell/index.tsx (1 hunks)
  • src/lib/components/table/evm-transactions/EvmTransactionsTableMobileCard.tsx (1 hunks)
  • src/lib/components/table/evm-transactions/EvmTransactionsTableRow.tsx (2 hunks)
  • src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxCreateContract.tsx (3 hunks)
  • src/lib/pages/tx-details/components/evm-related-tx-section/EvmRelatedField.tsx (1 hunks)
  • src/lib/pages/tx-details/components/evm-related-tx-section/index.tsx (2 hunks)
  • src/lib/services/tx/index.ts (5 hunks)
  • src/lib/services/types/tx.ts (1 hunks)
  • src/lib/styles/theme/components/tag.ts (2 hunks)
  • src/lib/types/evm.ts (0 hunks)
  • src/lib/utils/evm.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • src/lib/types/evm.ts
  • src/lib/components/EvmToCell.tsx
✅ Files skipped from review due to trivial changes (3)
  • package.json
  • src/lib/components/table/evm-transactions/EvmTransactionsTableMobileCard.tsx
  • CHANGELOG.md
🧰 Additional context used
🪛 Biome (1.9.4)
src/lib/components/evm-to-cell/evm-to-cell-create.tsx

[error] 26-26: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🔇 Additional comments (12)
src/lib/styles/theme/components/tag.ts (1)

21-26: LGTM!

The new primary variant follows the established pattern and maintains consistency with the existing variants.

src/lib/pages/tx-details/components/evm-related-tx-section/EvmRelatedField.tsx (1)

27-27: LGTM!

The layout adjustments improve flexibility while maintaining responsive design across different screen sizes.

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

38-45:

❓ Verification inconclusive

Verify handling of all contract creation scenarios.

The removal of isEvmSingleCreate and direct assignment of evmTxHash suggests support for multi-contract creation. Please ensure all contract creation scenarios are properly handled.

Run the following script to verify contract creation handling:


🏁 Script executed:

#!/bin/bash
# Description: Search for contract creation patterns in the codebase.

# Test: Search for contract creation patterns
ast-grep --pattern $'getEvmToAddress($$$) {
  $$$
  if ($method === EvmMethodName.Create) {
    $$$
  }
  $$$
}'

# Test: Search for contract creation tests
rg -A 5 'test.*contract.*creation'

Length of output: 150


Action Required: Reassess Contract Creation Verification

The recent changes to support multi-contract creation by removing isEvmSingleCreate and directly assigning evmTxHash appear to align with the PR objectives. However, our initial automated search for tests or explicit patterns validating all contract creation scenarios (especially edge cases like a missing contractAddress) produced no output. Please double-check manually that:

  • All contract creation scenarios (including cases with missing or multiple contract addresses) are correctly handled.
  • Adequate test coverage exists to validate these scenarios, or consider adding tests if they’re missing.
src/lib/services/types/tx.ts (1)

483-489: LGTM!

The addition of contractAddress handling with proper checksum formatting and null checks is well-implemented and consistent with Ethereum address handling standards.

src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxCreateContract.tsx (1)

20-23: LGTM! Good use of default value for contracts array.

The hook usage is clean and handles the data properly with a default empty array, preventing potential undefined errors.

src/lib/components/evm-to-cell/index.tsx (1)

9-41: LGTM! Well-structured component with proper type safety.

The component has:

  • Clear interface definition
  • Proper null checks
  • Type-safe conditional rendering based on address type
src/lib/components/table/evm-transactions/EvmTransactionsTableRow.tsx (1)

7-7: LGTM! Clean import update and proper prop usage.

The changes correctly:

  • Update the import path to follow the new convention
  • Add the isCompact prop to EvmToCell for consistent layout

Also applies to: 91-91

src/lib/pages/tx-details/components/evm-related-tx-section/index.tsx (1)

5-5: LGTM! Clean import update and improved layout spacing.

The changes correctly:

  • Update the import path to follow the new convention
  • Add margin-top to improve vertical alignment of the arrow icon

Also applies to: 59-59

src/lib/components/evm-to-cell/evm-to-cell-create.tsx (2)

18-22: Props interface looks good!

The interface is well-defined with appropriate types and optional flags.


36-44: Component structure looks good!

The component is well-organized and follows React best practices for data fetching and state management.

src/lib/services/tx/index.ts (2)

114-114: Consider the implications of infinite stale time.

Setting staleTime: Infinity means the data will never be considered stale. Ensure this aligns with your data freshness requirements.

Consider if transaction data needs to be refreshed periodically to reflect chain state changes.


732-756: Error handling improvements look good!

The additional error check for undefined evmTxHash and the enabled condition update improve the robustness of the hook.

@songwongtp songwongtp merged commit 1ada98a into develop Feb 25, 2025
13 checks passed
@songwongtp songwongtp deleted the feat/created-multi branch February 25, 2025 04:50
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