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: update isInitia logic, filter initia wallet #1253

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

evilpeach
Copy link
Collaborator

@evilpeach evilpeach commented Feb 27, 2025

Summary by CodeRabbit

  • Documentation

    • Updated changelog and README to outline recent improvements in wallet support and theme presentation.
  • Refactor

    • Revised local chain configuration to exclusively support a single wallet option.
    • Streamlined theme selection and wallet filtering logic for a more consistent user experience.

Copy link

vercel bot commented Feb 27, 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 27, 2025 5:22am
initia-celatone-rehearsal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2025 5:22am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
celatone-frontend-main ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 5:22am
initia-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 5:22am
neutron-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 5:22am
osmosis-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 5:22am
sei-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 5:22am
terra-celatone-frontend ⬜️ Ignored (Inspect) Visit Preview Feb 27, 2025 5:22am

Copy link

coderabbitai bot commented Feb 27, 2025

Walkthrough

The changes include adding a new improvement entry in the changelog (referencing PR #1253) and updating various configuration files to remove or replace the "initia" wallet. The updates modify wallet arrays in the chain configurations and associated type definitions, refactor the theme selection logic from a switch-case to if-statements, and adjust the control flow of custom network hooks and widget filtering. These adjustments streamline the logic for determining wallet support, theme selection, and network routing.

Changes

File(s) Summary
CHANGELOG.md Added a new improvement entry for PR #1253: "Filter initia wallet, change isInitia logic, and theme logic".
README.md, src/config/chain/devChainConfigs.ts, src/lib/stores/chain-config.test.ts, src/lib/types/chainConfig.ts Updated wallet configurations: removed "initia" and switched to "keplr" or limited options accordingly.
src/config/theme/index.ts Refactored the getTheme function: replaced switch-case with if conditions to determine the theme based on chain values.
src/lib/app-provider/hooks/useAllowCustomNetworks.ts, src/lib/app-provider/hooks/useInitia.ts Modified hook logic: now using useInitia and broadening the string-matching condition for "initia".
src/lib/providers/initia-widget.tsx Adjusted wallet filtering in filterWallet to explicitly exclude wallets of type "initia".

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant getTheme
    Caller->>getTheme: Provide chain value
    alt Chain includes "initia"
      getTheme-->>Caller: Returns INITIA_THEME
    else alt Chain equals "sei"
      getTheme-->>Caller: Returns SEI_THEME
    else
      getTheme-->>Caller: Returns DEFAULT_THEME
    end
Loading
sequenceDiagram
    participant Component
    participant useAllowCustomNetworks
    participant useInitia
    Component->>useAllowCustomNetworks: Call with shouldRedirect flag
    useAllowCustomNetworks->>useInitia: Retrieve isInitia value
    alt isInitia is false and redirection needed
      useAllowCustomNetworks->>Component: Navigate to "/"
    end
    useAllowCustomNetworks-->>Component: Return isInitia value
Loading

Possibly related PRs

  • Fix Initiaition-2 to dev #1164: Involves similar modifications to the network hook and wallet filtering logic, particularly related to handling "initia" and custom network configurations.

Suggested reviewers

  • songwongtp
  • Poafs1

Poem

I'm a rabbit in code, hopping with delight,
Filtering wallets by day and debugging by night.
Themes shift with a swift, clear, if-driven flow,
From "initia" to "keplr," watch the logic glow!
In this refined code garden, my hops are ever so bright.
🎉🐰 Enjoy the changes as I nibble bytes in pure 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/config/theme/index.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-import".

(The package "eslint-plugin-import" 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-import@latest --save-dev

The plugin "eslint-plugin-import" 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/app-provider/hooks/useAllowCustomNetworks.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-import".

(The package "eslint-plugin-import" 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-import@latest --save-dev

The plugin "eslint-plugin-import" 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/app-provider/hooks/useInitia.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-import".

(The package "eslint-plugin-import" 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-import@latest --save-dev

The plugin "eslint-plugin-import" 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.

  • 4 others
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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.

@evilpeach evilpeach force-pushed the feat/update-isinitia branch from e01fc83 to 44e083a Compare February 27, 2025 05:04
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/config/theme/index.ts (1)

8-11: Improved theme selection logic

The refactoring from switch-case to if-statements improves readability and flexibility. The new implementation checks if the chain includes "initia" rather than requiring an exact match, which allows for better handling of chain variations.

Consider adding a comment explaining the logic change from exact matching to substring matching for "initia", as this is a subtle but important change in behavior.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 815af3a and 44e083a.

📒 Files selected for processing (9)
  • CHANGELOG.md (1 hunks)
  • README.md (1 hunks)
  • src/config/chain/devChainConfigs.ts (1 hunks)
  • src/config/theme/index.ts (1 hunks)
  • src/lib/app-provider/hooks/useAllowCustomNetworks.ts (2 hunks)
  • src/lib/app-provider/hooks/useInitia.ts (1 hunks)
  • src/lib/providers/initia-widget.tsx (1 hunks)
  • src/lib/stores/chain-config.test.ts (1 hunks)
  • src/lib/types/chainConfig.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🔇 Additional comments (7)
src/lib/app-provider/hooks/useInitia.ts (1)

8-8: Modified condition to use substring matching

The condition now checks if "initia" is a substring of the chain name, rather than requiring an exact match. This broadens when useInitia() returns true to include chains like "localinitia" or any chain with "initia" in its name.

src/config/chain/devChainConfigs.ts (1)

14-14: Replaced wallet support from "initia" to "keplr"

The wallet configuration for the "localinitia" chain has been updated to support "keplr" instead of "initia". This aligns with the PR objective to filter out the initia wallet.

src/lib/stores/chain-config.test.ts (1)

13-13: Removed "initia" from mock wallet configuration

The "initia" wallet has been removed from the test mock configuration, ensuring consistency with the implementation changes made elsewhere in the codebase.

src/lib/providers/initia-widget.tsx (1)

36-37: Added explicit filter to exclude "initia" wallet type

The filterWallet function now explicitly filters out the "initia" wallet type, in addition to the existing EVM-related condition. This ensures the "initia" wallet is consistently excluded across the application.

src/lib/types/chainConfig.ts (1)

204-205: Removed "initia" from wallet options

This change aligns with the PR objective of filtering the initia wallet by removing "initia" from the union of literal wallet types in the zChainConfig schema. This will ensure that "initia" is no longer accepted as a valid wallet option throughout the application.

README.md (1)

74-74: Updated wallet configuration in README

Removed "initia" from the wallets array in the localinitia configuration example, keeping only "keplr". This change is consistent with the schema modification in chainConfig.ts and aligns with the PR objective.

src/lib/app-provider/hooks/useAllowCustomNetworks.ts (1)

1-14:

✅ Verification successful

Refactored network permission logic to use useInitia

The implementation has been changed to use the useInitia hook instead of checking chain IDs directly. This simplifies the logic and leverages the centralized isInitia check.

Let's verify that the useInitia hook is correctly implemented to ensure this change works as expected:


🏁 Script executed:

#!/bin/bash
# Verify implementation of useInitia hook
rg -A 10 "export const useInitia" --type ts

Length of output: 1855


Verified: The use of the centralized useInitia hook in useAllowCustomNetworks is correct.

  • The implementation of useInitia in src/lib/app-provider/hooks/useInitia.ts properly returns a boolean based on whether the chain includes "initia".
  • The refactoring in useAllowCustomNetworks now leverages this centralized logic, simplifying the custom network permission check and ensuring consistency.
  • No further adjustments are needed as the hook’s implementation aligns with the intended logic.

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