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/support custom chain for EVM wallet #1235

Merged
merged 4 commits into from
Feb 18, 2025
Merged

Conversation

Poafs1
Copy link
Collaborator

@Poafs1 Poafs1 commented Feb 17, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved support for custom Ethereum chain IDs along with minor stability improvements.
  • New Features

    • Enhanced Ethereum wallet integration, offering smoother chain switching with enriched chain details.
    • Updated contract verification displays now present example addresses in a clear hexadecimal format.
    • Optimized deployment workflows with improved WebAssembly configuration handling, streamlining the user experience.
    • Introduced wallet filtering based on EVM feature availability, enhancing wallet selection.
    • Added new error handling for wallet provider checks during fee simulation.

Copy link

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

@Poafs1 Poafs1 changed the title Feature/support custom chain for EVM wallet Fix/support custom chain for EVM wallet Feb 17, 2025
Copy link

coderabbitai bot commented Feb 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update documentation and modify several hooks and components to support EVM custom chain IDs. The CHANGELOG.md now records a new bug fix entry. In the hooks, unused conversion logic is removed and new parameters from useEvmParams are integrated to affect chain switching and transaction signing. Additionally, UI components for contract verification now convert Bech32 addresses to hexadecimal using updated utility functions. A hook managing configuration is also introduced, and a utility function now returns a numeric chain ID.

Changes

File(s) Change Summary
CHANGELOG.md Added a new bug fix entry: “Support EVM custom chain id and minor bug fixes” with a link to PR #1235.
src/lib/app-provider/hooks/useExampleAddresses.ts Removed the toHex import and deleted the logic for generating the evmContract address from the returned object.
src/lib/app-provider/hooks/useSignAndBroadcastEvm.ts - Added import of useEvmParams.
- Updated chainConfig destructuring to include prettyName, logo_URIs, and registry.
- Reordered variable declarations.
- Modified logic to format evmChainId with "0x" prefix.
- Introduced feeDenom validation and a chain addition request via wallet_addEthereumChain, followed by a chain switch with wallet_switchEthereumChain.
src/lib/pages/deploy-script/index.tsx Added the useMoveConfig hook with { shouldRedirect: true } to integrate new configuration functionality.
src/lib/pages/evm-contract-verify/components/ContractLibrary.tsx
src/lib/pages/evm-contract-verify/index.tsx
Updated imports to include bech32AddressToHex and replaced usage of exampleContractAddress with exampleBechAddress sourced from useExampleAddresses, converting Bech32 addresses to hexadecimal for display.
src/lib/utils/evm.ts Changed the convertCosmosChainIdToEvmChainId function to return a number instead of a string by replacing .toFixed() with .toNumber().
src/lib/providers/initia-widget.tsx Updated InitiaWidgetProvider to simplify the key property and added a new filterWallet property to filter wallets based on EVM features.
src/lib/services/tx/simulateFeeEvm.ts Enhanced error handling by destructuring walletProvider from useCurrentChain and checking its type before fee simulation.

Possibly related PRs

  • docs: update changelog and version to v1.9.3 #1178: The changes in the main PR, which involve adding a bug fix entry related to EVM custom chain IDs in the CHANGELOG.md, are related to this PR that also updates the CHANGELOG.md with a new version entry and features.
  • Fix Initiaition-2 to dev #1164: The changes in the main PR regarding the addition of a bug fix entry in CHANGELOG.md are related to this PR, which also modifies the CHANGELOG.md to include new entries for bug fixes and improvements.
  • Feat: wireup verifications #1232: The changes in the main PR regarding the addition of a bug fix entry for EVM custom chain ID support are related to this PR, which also involves EVM functionalities, specifically the support for EVM verification; both PRs modify the CHANGELOG.md file to document their respective updates.

Suggested reviewers

  • evilpeach

Poem

Oh, I’m a rabbit with code so bright,
Hopping through changes in the dark of night,
EVM chains now shine in a brand new hue,
With every fix, my world feels anew 🥕,
Bech32 and hex dance in the garden's light!
Happy coding with a twitch of delight!

(🐰💻)

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/pages/deploy-script/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-contract-verify/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-contract-verify/components/ContractLibrary.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 25b010a and 35a8ec3.

📒 Files selected for processing (3)
  • src/lib/pages/deploy-script/index.tsx (2 hunks)
  • src/lib/pages/evm-contract-verify/components/ContractLibrary.tsx (3 hunks)
  • src/lib/pages/evm-contract-verify/index.tsx (3 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: 1

🧹 Nitpick comments (1)
src/lib/app-provider/hooks/useSignAndBroadcastEvm.ts (1)

74-79: Add input validation for feeDenom.

While the code handles undefined cases, it would be beneficial to validate the feeDenom format before slicing.

-const feeDenom = data?.params.feeDenom.slice(-40) ?? "";
+const feeDenom = data?.params.feeDenom?.match(/[0-9a-fA-F]{40}$/)?.[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 7af7d14 and ca373f2.

📒 Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • src/lib/app-provider/hooks/useExampleAddresses.ts (1 hunks)
  • src/lib/app-provider/hooks/useSignAndBroadcastEvm.ts (2 hunks)
  • src/lib/pages/deploy-script/index.tsx (2 hunks)
  • src/lib/pages/evm-contract-verify/components/ContractLibrary.tsx (3 hunks)
  • src/lib/pages/evm-contract-verify/index.tsx (3 hunks)
  • src/lib/utils/evm.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (7)
src/lib/app-provider/hooks/useExampleAddresses.ts (1)

1-32: LGTM! Clean and well-structured hook implementation.

The hook follows React best practices with proper memoization and type safety.

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

20-20: LGTM! Proper address format conversion.

The changes correctly handle the conversion from Bech32 to hex format for the example address.

Also applies to: 45-45

src/lib/pages/deploy-script/index.tsx (1)

41-41: Verify the impact of the WebAssembly configuration.

The useWasmConfig hook is added with shouldRedirect: true. Please ensure that:

  1. The redirection behavior is tested for both valid and invalid WebAssembly configurations.
  2. The user experience is smooth when redirection occurs.
src/lib/pages/evm-contract-verify/index.tsx (1)

82-82: LGTM! Consistent address format handling.

The changes maintain consistency with other components in handling address format conversion from Bech32 to hex.

Also applies to: 248-248

src/lib/app-provider/hooks/useSignAndBroadcastEvm.ts (2)

9-9: LGTM! New imports and variables support custom chain functionality.

The added imports and variable declarations are necessary for supporting custom EVM chains, providing access to chain parameters and configuration.

Also applies to: 57-61, 63-64


70-72: LGTM! Proper chain ID formatting.

The chain ID is now correctly formatted with "0x" prefix for EVM compatibility.

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

102-102: LGTM! Improved type consistency.

Changed from toFixed() to toNumber() to return a numeric chain ID, which is more appropriate for the EVM chain ID calculation.

@Poafs1 Poafs1 merged commit d1fb3f0 into develop Feb 18, 2025
10 of 12 checks passed
@Poafs1 Poafs1 deleted the feat/wallet-filtering branch February 18, 2025 04:17
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