-
Notifications
You must be signed in to change notification settings - Fork 20
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
WalkthroughThe 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
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
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
Possibly related PRs
Suggested reviewers
Poem
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
src/config/theme/index.tsOops! 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:
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.tsOops! 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:
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.tsOops! 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:
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.
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
e01fc83
to
44e083a
Compare
There was a problem hiding this 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 logicThe 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
📒 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 matchingThe 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 configurationThe "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 typeThe 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 optionsThis 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 READMERemoved "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 centralizedisInitia
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 tsLength of output: 1855
Verified: The use of the centralized
useInitia
hook inuseAllowCustomNetworks
is correct.
- The implementation of
useInitia
insrc/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.
Summary by CodeRabbit
Documentation
Refactor