-
Notifications
You must be signed in to change notification settings - Fork 47
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: fix chainid bug in refetch #1817
Conversation
WalkthroughThe pull request introduces a consistent modification across multiple query hooks in the web application. The primary change involves importing Changes
Suggested labels
Suggested reviewers
Possibly related PRs
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 🪧 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 (
|
✅ Deploy Preview for kleros-v2-testnet-devtools ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for kleros-v2-testnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for kleros-v2-neo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Code Climate has analyzed commit 94d23ec and detected 11 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
|
✅ Deploy Preview for kleros-v2-university ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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 (14)
web-devtools/src/hooks/queries/useDisputeTemplateFromId.ts (1)
33-33
: Consider makingchainId
configurable.Setting the chainId to
DEFAULT_CHAIN
ensures consistency. However, if you anticipate future requirements for dynamically switching chains, you might consider adding a parameter or environment-dependent logic in the query.web/src/pages/GetPnk/Widget.tsx (3)
Line range hint
19-26
: Consider retrieving chain IDs from a dedicated constants file.Hardcoded chain IDs (
fromChain: 1
andtoChain: 42161
) may cause maintenance overhead if these values must be changed in the future or made configurable. Retrieving them from a constants file or environment variables would enhance flexibility.
Line range hint
19-26
: Question the hardcoding of token addresses.Similarly, consider if
fromToken
andtoToken
might need future modifications. Using external configuration or referencing them from a well-defined contract-addresses module can reduce the risk of introducing errors during contract upgrades or transitions.
Line range hint
57-57
: Avoid repeating theintegrator
prop.You're passing
integrator: "Kleros"
within both the returned config and the<LiFiWidget>
component. Consider omitting one to avoid potential confusion if they ever diverge in the future.web/src/components/ErrorFallback.tsx (1)
46-46
: Align items carefully in landscape mode.
Aligning items tostart
on larger or rotated screens can improve the readability of content. Confirm the visual arrangement remains desirable when the screen is tall but narrow (e.g., tablet displays). Otherwise, the setup looks good.web/src/hooks/queries/useAllCasesQuery.ts (1)
25-30
: Consider aligning the queryKey with the chain.When using
DEFAULT_CHAIN
, you might want to include it in thequeryKey
(e.g.,queryKey: ['allCasesQuery', DEFAULT_CHAIN]
) if the application is expected to handle multiple chains. This helps avoid cache conflicts across different chain contexts.web/src/hooks/queries/useCourtPolicyURI.ts (1)
33-33
: Align query key with the chain ID if multi-chain support is needed.If multiple chains will be used, consider incorporating
DEFAULT_CHAIN
into the query key or allowing the chain ID to be overridden to avoid caching issues.web/src/hooks/queries/useTopUsersByCoherenceScore.ts (1)
36-36
: Assess potential dynamic chain usage
Setting a staticDEFAULT_CHAIN
prevents dynamic chain selection. If multiple chains must be supported in the future, consider making this parameter more flexible.web/src/hooks/queries/useUser.ts (1)
4-4
: Validate chain selection if multiple chains become relevant.
ImportingDEFAULT_CHAIN
is fine for a single-chain context, but ensure you revisit this if the application begins supporting dynamic or multiple chain contexts.web/src/layout/Header/navbar/Menu/Settings/index.tsx (1)
56-56
: Consider adding a max-width for better responsiveness.
This added landscape style effectively adjusts width, but you might also want to impose a max-width for large screens to ensure consistent visual appearance.web/src/hooks/queries/useCasesQuery.ts (2)
81-81
: Ensure future multi-chain support is addressed.
By hardcodingDEFAULT_CHAIN
, future dynamic chain usage may require additional refactoring.
103-103
: Extending multi-chain logic might be necessary.
This mirror change is fine, but if a user needs a different chain, consider an override parameter.web/src/hooks/queries/useHomePageBlockQuery.ts (1)
76-76
: Hardcoded chain ID could limit flexibility.
Consider a fallback mechanism or parameter if a user needs to switch chains in the future.web/src/hooks/queries/useCourtTree.ts (1)
44-49
: Confirm if a configurable chain parameter is needed.
While insertingchainId: DEFAULT_CHAIN
directly is effective, a configurable approach could better accommodate different environments or future chain expansions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (23)
web-devtools/src/hooks/queries/useDisputeTemplateFromId.ts
(2 hunks)web/src/components/ErrorFallback.tsx
(2 hunks)web/src/hooks/queries/useAllCasesQuery.ts
(2 hunks)web/src/hooks/queries/useCasesQuery.ts
(3 hunks)web/src/hooks/queries/useClassicAppealQuery.ts
(2 hunks)web/src/hooks/queries/useCounter.ts
(2 hunks)web/src/hooks/queries/useCourtDetails.ts
(2 hunks)web/src/hooks/queries/useCourtPolicyURI.ts
(2 hunks)web/src/hooks/queries/useCourtTree.ts
(2 hunks)web/src/hooks/queries/useDisputeDetailsQuery.ts
(2 hunks)web/src/hooks/queries/useDisputeMaintenanceQuery.ts
(2 hunks)web/src/hooks/queries/useDisputeTemplateFromId.ts
(2 hunks)web/src/hooks/queries/useDrawQuery.ts
(2 hunks)web/src/hooks/queries/useEvidences.ts
(2 hunks)web/src/hooks/queries/useHomePageBlockQuery.ts
(2 hunks)web/src/hooks/queries/useHomePageQuery.ts
(2 hunks)web/src/hooks/queries/useJurorStakeDetailsQuery.ts
(2 hunks)web/src/hooks/queries/useLabelInfoQuery.ts
(2 hunks)web/src/hooks/queries/useTopUsersByCoherenceScore.ts
(2 hunks)web/src/hooks/queries/useUser.ts
(2 hunks)web/src/hooks/queries/useVotingHistory.ts
(2 hunks)web/src/layout/Header/navbar/Menu/Settings/index.tsx
(1 hunks)web/src/pages/GetPnk/Widget.tsx
(1 hunks)
🔇 Additional comments (35)
web-devtools/src/hooks/queries/useDisputeTemplateFromId.ts (1)
4-4
: Import usage looks good.
Using DEFAULT_CHAIN
from "consts/chains"
is consistent with the PR’s objective of standardizing chain IDs across all queries.
web/src/pages/GetPnk/Widget.tsx (2)
19-19
: Function name is descriptive.
Naming the function getWidgetConfig
clearly communicates its purpose and return type. Continue using such descriptive names for improved readability.
Line range hint 27-54
: Thematic consistency is well-implemented.
The theme
property thoroughly applies custom styles, color palettes, and shapes across the widget. This fosters consistent styling with the overall application theme.
web/src/components/ErrorFallback.tsx (1)
31-31
: Nice responsive approach.
Using landscapeStyle
to switch the flex direction and justify-content in landscape orientation is a good way to ensure a more balanced and spacious layout on larger or rotated screens.
web/src/hooks/queries/useAllCasesQuery.ts (1)
4-4
: Import statement looks good.
Importing DEFAULT_CHAIN
ensures a consistent reference to the default chain across the codebase.
web/src/hooks/queries/useCounter.ts (2)
4-4
: Import of DEFAULT_CHAIN
is consistent with other query hooks.
It helps unify chain usage across the application.
32-38
: Confirm the chain usage for multi-environment setups.
If you intend to support different chains, verify that DEFAULT_CHAIN
is valid for all environments or consider making it configurable.
web/src/hooks/queries/useCourtPolicyURI.ts (1)
4-4
: Consistent approach to fetching data for a chosen chain.
Importing DEFAULT_CHAIN
ensures the court policy data is pinned to a known chain by default.
web/src/hooks/queries/useDisputeTemplateFromId.ts (2)
4-4
: Good import for default chain usage.
This aligns with the project-wide strategy of referencing a single default chain.
33-33
: Ensure the chain context remains correct for dispute templates.
If the dispute template can come from a different chain in future, consider making this chain parameter more flexible.
web/src/hooks/queries/useDrawQuery.ts (2)
4-4
: Good import to standardize chain usage.
Importing DEFAULT_CHAIN
aligns with the PR's objective of specifying a default chain ID consistently across queries.
35-35
: Consistent chain parameter inclusion.
Adding chainId: DEFAULT_CHAIN
ensures the fetch call is pinned to the default chain, preventing chain mismatch issues. Looks good!
web/src/hooks/queries/useJurorStakeDetailsQuery.ts (2)
4-4
: Synchronized chain definition.
Importing DEFAULT_CHAIN
here matches the rest of the PR changes for uniform chain specification.
34-39
: Correct application of the default chain.
Including chainId: DEFAULT_CHAIN
alongside the existing parameters ensures the query is scoped to the intended chain. Implementation is correct.
web/src/hooks/queries/useHomePageQuery.ts (2)
3-3
: Unified chain import.
The new DEFAULT_CHAIN
import follows the same approach as other queries in the PR, improving consistency.
44-44
: Proper chain specification in the fetch call.
This update addresses potential chain ID inconsistencies by leveraging the default chain value.
web/src/hooks/queries/useCourtDetails.ts (2)
4-4
: Consistent chain import strategy.
Using DEFAULT_CHAIN
ensures alignment with the PR’s objective of standardizing chain IDs.
41-46
: Appropriate use of the default chain ID.
Adding chainId: DEFAULT_CHAIN
finalizes the fix for the chain-refetch bug, making the query resilient to mismatched chain contexts.
web/src/hooks/queries/useDisputeDetailsQuery.ts (2)
4-4
: Use of DEFAULT_CHAIN
import is consistent
This import aligns with the PR objective of setting a default chain for queries. Looks good.
54-54
: Ensure correct usage of DEFAULT_CHAIN
Introducing chainId: DEFAULT_CHAIN
helps maintain consistency across queries. Verify that this hard-coded chain value is indeed the desired default and does not conflict with any environment-specific configurations.
web/src/hooks/queries/useDisputeMaintenanceQuery.ts (2)
4-4
: Consistent import of DEFAULT_CHAIN
Importing DEFAULT_CHAIN
further unifies the codebase’s approach to specifying the chain context.
48-48
: Added chainId
parameter
Adding chainId: DEFAULT_CHAIN
standardizes the chain identifier. Double-check that the provided ID is recognized in all deployment environments.
web/src/hooks/queries/useTopUsersByCoherenceScore.ts (1)
4-4
: DEFAULT_CHAIN
import consistency
This import ensures queries reference a default chain, as required by the PR objective.
web/src/hooks/queries/useLabelInfoQuery.ts (2)
3-3
: Appropriate DEFAULT_CHAIN
import
This import is uniform with changes elsewhere in the PR.
53-53
: Confirm chainId
usage
Adding chainId: DEFAULT_CHAIN
centralizes the chain logic. Verify that the server or upstream GraphQL layer respects this parameter appropriately.
web/src/hooks/queries/useVotingHistory.ts (2)
4-4
: Use consistent import ordering if needed.
While importing DEFAULT_CHAIN
is correct for the new feature, confirm that import ordering follows any team-linter or style guidelines. No functional issues are observed here.
61-66
: Successfully added the chainId parameter.
Passing chainId: DEFAULT_CHAIN
ensures that the same chain is consistently used when refetching voting history data. This addition addresses the PR objective of fixing the chainid bug in refetch. The usage looks correct, aligning with the existing query function pattern.
web/src/hooks/queries/useClassicAppealQuery.ts (2)
5-5
: Import statement is aligned with the new usage.
Importing DEFAULT_CHAIN
is consistent with the rest of the PR changes. No further comments here.
53-53
: Added chainId ensures consistent chain context.
Incorporating chainId: DEFAULT_CHAIN
matches the unified approach seen across other hooks. This is a straightforward and valid change.
web/src/hooks/queries/useUser.ts (1)
66-66
: Ensures user query fetch uses the right chain.
This integration of DEFAULT_CHAIN
properly aligns user data queries with a fixed chain. No critical issues identified.
web/src/hooks/queries/useEvidences.ts (2)
4-4
: Import is consistent with cross-file approach.
Adding DEFAULT_CHAIN
aligns with the other files in this PR to standardize queries by chain. No issues here.
60-60
: Applies the default chain ID for evidence queries.
This ensures evidence queries also remain consistent in their chain context. Everything looks good.
web/src/hooks/queries/useCasesQuery.ts (1)
5-5
: Import aligns with the PR goal to centralize chain usage.
This import is consistent with efforts to unify chain references across the app.
web/src/hooks/queries/useHomePageBlockQuery.ts (1)
4-4
: Import confirms consistent chain usage.
This maintains uniform handling of the chain reference across the codebase.
web/src/hooks/queries/useCourtTree.ts (1)
4-4
: Import ensures uniform chain reference.
This is consistent with the PR's strategy to unify chain-specific logic.
closing since we discovered this was not the issue |
PR-Codex overview
This PR primarily focuses on incorporating the
DEFAULT_CHAIN
constant into various GraphQL query hooks to ensure that the correct chain ID is used when fetching data.Detailed summary
DEFAULT_CHAIN
import in multiple query hooks.chainId: DEFAULT_CHAIN
in:useLabelInfoQuery
useHomePageQuery
useUserQuery
useCourtPolicyURI
useDrawQuery
useDisputeDetailsQuery
useTopUsersByCoherenceScore
useHomePageBlockQuery
useDisputeTemplateFromId
useDisputeMaintenanceQuery
useClassicAppealQuery
useEvidences
useAllCasesQuery
useCourtTree
useCounter
useCourtDetails
useVotingHistory
useJurorStakeDetailsQuery
useCasesQuery
useMyCasesQuery
Summary by CodeRabbit
New Features
LiFiWidget
, improving customization options for the widget's appearance and behavior.Bug Fixes
ErrorFallback
component for better display across different screen orientations.Chores