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: fix chainid bug in refetch #1817

Closed
wants to merge 1 commit into from
Closed

Conversation

kemuru
Copy link
Contributor

@kemuru kemuru commented Dec 26, 2024

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

  • Added DEFAULT_CHAIN import in multiple query hooks.
  • Updated GraphQL fetch calls to include chainId: DEFAULT_CHAIN in:
    • useLabelInfoQuery
    • useHomePageQuery
    • useUserQuery
    • useCourtPolicyURI
    • useDrawQuery
    • useDisputeDetailsQuery
    • useTopUsersByCoherenceScore
    • useHomePageBlockQuery
    • useDisputeTemplateFromId
    • useDisputeMaintenanceQuery
    • useClassicAppealQuery
    • useEvidences
    • useAllCasesQuery
    • useCourtTree
    • useCounter
    • useCourtDetails
    • useVotingHistory
    • useJurorStakeDetailsQuery
    • useCasesQuery
    • useMyCasesQuery

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Introduced a default chain identifier in various query functions to enhance data fetching capabilities.
    • Added a new configuration function for the LiFiWidget, improving customization options for the widget's appearance and behavior.
  • Bug Fixes

    • Enhanced the responsiveness of the ErrorFallback component for better display across different screen orientations.
  • Chores

    • Updated multiple query hooks to include a default chain ID for improved query execution consistency.

Copy link
Contributor

coderabbitai bot commented Dec 26, 2024

Walkthrough

The pull request introduces a consistent modification across multiple query hooks in the web application. The primary change involves importing DEFAULT_CHAIN from the consts/chains module and adding a chainId parameter set to DEFAULT_CHAIN when calling graphqlBatcher.fetch. This standardizes the chain identification process across various query functions, ensuring a uniform approach to specifying the blockchain context for data retrieval.

Changes

File Change Summary
web-devtools/src/hooks/queries/useDisputeTemplateFromId.ts Added DEFAULT_CHAIN import and chainId to graphqlBatcher.fetch
web/src/hooks/queries/* Multiple query hooks updated with DEFAULT_CHAIN import and chainId parameter
web/src/components/ErrorFallback.tsx Added responsive styles using landscapeStyle for ErrorContainer and InfoWrapper
web/src/layout/Header/navbar/Menu/Settings/index.tsx Updated StyledTabs with responsive width in landscape mode
web/src/pages/GetPnk/Widget.tsx Added getWidgetConfig function for LiFiWidget configuration

Suggested labels

Type: Bug :bug:, Type: Enhancement :sparkles:, Package: Web

Suggested reviewers

  • alcercu

Possibly related PRs

Poem

🐰 Chains of code, dancing light,
Default paths now shining bright
GraphQL queries, smooth and clean
Landscape styles, a coder's dream
Rabbit hops through lines with glee! 🌈

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


🪧 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 or @coderabbitai title 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

netlify bot commented Dec 26, 2024

Deploy Preview for kleros-v2-testnet-devtools ready!

Name Link
🔨 Latest commit 94d23ec
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet-devtools/deploys/676d698a2fb58b0008feec40
😎 Deploy Preview https://deploy-preview-1817--kleros-v2-testnet-devtools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 26, 2024

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit 94d23ec
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/676d698adcf0f400088cf758
😎 Deploy Preview https://deploy-preview-1817--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 26, 2024

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit 94d23ec
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/676d698a3dbde6000829434b
😎 Deploy Preview https://deploy-preview-1817--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codeclimate bot commented Dec 26, 2024

Code Climate has analyzed commit 94d23ec and detected 11 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 11

View more on Code Climate.

Copy link

netlify bot commented Dec 26, 2024

Deploy Preview for kleros-v2-university ready!

Name Link
🔨 Latest commit 94d23ec
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/676d698bcf3a170008ddc764
😎 Deploy Preview https://deploy-preview-1817--kleros-v2-university.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@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 (14)
web-devtools/src/hooks/queries/useDisputeTemplateFromId.ts (1)

33-33: Consider making chainId 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 and toChain: 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 and toToken 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 the integrator 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 to start 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 the queryKey (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 static DEFAULT_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.
Importing DEFAULT_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 hardcoding DEFAULT_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 inserting chainId: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9daf106 and 94d23ec.

📒 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.

@kemuru
Copy link
Contributor Author

kemuru commented Dec 30, 2024

closing since we discovered this was not the issue

@kemuru kemuru closed this Dec 30, 2024
@kemuru kemuru deleted the fix/appeal-tab-update-in-mobile branch December 30, 2024 15:59
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.

1 participant