Skip to content

Conversation

@jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Apr 18, 2025

PR-Codex overview

This PR primarily focuses on updating the @kleros/kleros-v2-contracts dependency version, removing unused files, and introducing new hooks and components to improve scrolling behavior and contract interactions within the application.

Detailed summary

  • Updated @kleros/kleros-v2-contracts from ^0.9.2 to ^0.9.3 in multiple files.
  • Deleted web/src/consts/arbitration.ts and web/src/hooks/queries/useArbitrationCostFromKlerosCore.ts.
  • Added useScrollTop hook for smooth scrolling to the top.
  • Created ScrollTop component to manage scroll behavior based on URL parameters.
  • Replaced useArbitrationCost with useReadKlerosCoreArbitrationCost in TransactionDetails.
  • Updated AttachmentDisplay to include ScrollTop and modified styles.
  • Enhanced wagmi.config.ts to accommodate new arbitrator contracts structure.

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

Summary by CodeRabbit

  • Chores

    • Updated dependency "@kleros/kleros-v2-contracts" to version ^0.9.3 in both contracts and web projects.
  • Refactor

    • Replaced custom arbitration cost hook with a generated contract hook in transaction details.
    • Centralized arbitrator contract deployment imports and configuration, streamlining contract artifact handling.
  • Cleanup

    • Removed unused constants and custom arbitration cost hook related to Kleros Core from the codebase.
  • New Features

    • Added a new scroll-to-top component that supports smooth scrolling to page sections via URL parameters.
    • Introduced a custom hook to enable programmatic scrolling to the top of the viewport.
  • Style

    • Enhanced attachment display component with improved styling, responsive layout, and better external link semantics.

@jaybuidl jaybuidl requested review from a team as code owners April 18, 2025 14:24
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 18, 2025

Walkthrough

This set of changes updates the @kleros/kleros-v2-contracts dependency to version ^0.9.3 in both the contracts and web packages. It removes local logic for retrieving the Kleros Core contract address and arbitration cost, instead relying on contract deployment data and generated hooks from the updated dependency. The arbitration cost hook and address constant are deleted, and corresponding usages are refactored to use the new generated hooks and contract data. The configuration logic is updated to import and utilize arbitrator contract deployments from the dependency, modifying function signatures and adding helper utilities for contract configuration. Additionally, new UI components and hooks related to scroll behavior were introduced, and styling improvements were made to the AttachmentDisplay component.

Changes

File(s) Change Summary
contracts/package.json, web/package.json Updated @kleros/kleros-v2-contracts dependency to ^0.9.3; added as devDependency in web.
web/src/consts/arbitration.ts, web/src/hooks/queries/useArbitrationCostFromKlerosCore.ts Deleted constant for Kleros Core address and custom arbitration cost hook; removed local contract logic.
web/src/pages/MyTransactions/TransactionDetails/index.tsx Refactored to use generated arbitration cost hook from updated dependency instead of local implementation.
web/wagmi.config.ts Updated to import arbitrator contract deployments from dependency, changed function signatures, added helper for contract config.
web/src/components/ScrollTop.tsx Added new React component ScrollTop to handle scrolling to top or specific sections on page load.
web/src/hooks/useScrollTop.ts Added new hook useScrollTop to provide a scroll-to-top function using overlay scroll context.
web/src/pages/AttachmentDisplay/index.tsx Enhanced styling and layout of AttachmentDisplay component; replaced external link element with styled component; added ScrollTop.

Sequence Diagram(s)

sequenceDiagram
    participant TransactionDetails (Component)
    participant GeneratedHook (useReadKlerosCoreArbitrationCost)
    participant KlerosCoreContract

    TransactionDetails->>GeneratedHook: Call useReadKlerosCoreArbitrationCost(arbitratorExtraData)
    GeneratedHook->>KlerosCoreContract: Query arbitrationCost(bytes)
    KlerosCoreContract-->>GeneratedHook: Return arbitration cost
    GeneratedHook-->>TransactionDetails: Provide arbitration cost result
Loading

Possibly related PRs

Suggested labels

Type: Maintenance :construction:, Package: Contracts

Suggested reviewers

  • jaybuidl
  • Harman-singh-waraich

Poem

A hop and a skip, through contracts we go,
Out with the old hooks, in with the new flow!
Addresses and costs, now fetched with more ease,
With dependencies fresh, our code aims to please.
The rabbit approves, with a digital cheer—
Kleros contracts updated, the path is now clear!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between ae9a027 and 75d36f7.

📒 Files selected for processing (1)
  • web/src/pages/MyTransactions/TransactionDetails/index.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/pages/MyTransactions/TransactionDetails/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Redirect rules - kleros-escrow-v2
  • GitHub Check: Redirect rules - kleros-escrow-v2
  • GitHub Check: Header rules - kleros-escrow-v2
  • GitHub Check: Header rules - kleros-escrow-v2
  • GitHub Check: Pages changed - kleros-escrow-v2
  • GitHub Check: Pages changed - kleros-escrow-v2

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

@jaybuidl jaybuidl added Type: Bug 🐛 Package: Web Escrow web frontend labels Apr 18, 2025
@netlify
Copy link

netlify bot commented Apr 18, 2025

Deploy Preview for kleros-escrow-v2 ready!

Name Link
🔨 Latest commit 75d36f7
🔍 Latest deploy log https://app.netlify.com/sites/kleros-escrow-v2/deploys/68029801386f3a00080548bd
😎 Deploy Preview https://deploy-preview-111--kleros-escrow-v2.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.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 18, 2025
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 (1)
web/src/components/ScrollTop.tsx (1)

1-31: Well-implemented scroll management component with possible dependency issue

The component correctly implements scroll management with section targeting. However, the useEffect dependency array is empty while the effect uses several variables from component scope (search, pathname, navigate, scrollTop).

While this might be intentional to only trigger the scroll once, it can lead to stale closures if these values change between renders. Consider whether these dependencies should be added to the array or if there should be a comment explaining why they're intentionally omitted.

- }, []);
+ }, [pathname, search, navigate, scrollTop]); // Re-run if any of these values change

Or if the intention is to only run once regardless of dependency changes:

- }, []);
+ }, []); // Intentionally empty - we only want to scroll once on initial mount
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 19e277d and ae9a027.

📒 Files selected for processing (3)
  • web/src/components/ScrollTop.tsx (1 hunks)
  • web/src/hooks/useScrollTop.ts (1 hunks)
  • web/src/pages/AttachmentDisplay/index.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
web/src/hooks/useScrollTop.ts (1)
web/src/context/OverlayScrollContext.tsx (1)
  • OverlayScrollContext (3-3)
web/src/pages/AttachmentDisplay/index.tsx (3)
web/src/styles/landscapeStyle.ts (2)
  • MAX_WIDTH_LANDSCAPE (3-3)
  • landscapeStyle (7-11)
web/src/styles/responsiveSize.ts (1)
  • responsiveSize (9-12)
web/src/components/ExternalLink.tsx (1)
  • ExternalLink (5-9)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Redirect rules - kleros-escrow-v2
  • GitHub Check: Header rules - kleros-escrow-v2
  • GitHub Check: Pages changed - kleros-escrow-v2
🔇 Additional comments (7)
web/src/hooks/useScrollTop.ts (1)

1-15: Well-implemented scrolling utility hook

The hook provides a clean implementation for scrolling to the top of a page using the OverlayScrollContext. The optional chaining is a good approach for safely accessing nested properties, preventing runtime errors if any part of the chain is undefined.

The optional smooth parameter provides flexibility in controlling the scrolling behavior.

web/src/pages/AttachmentDisplay/index.tsx (6)

2-4: Good use of styled-components with responsive utilities

The imports for styled-components and responsive utilities are well organized and provide access to the necessary styling tools.


11-12: Component integration

Good integration of the new ScrollTop component and using the ExternalLink component for consistency across the application.


18-32: Enhanced container styling with responsive design

The updated Container styling improves visual appearance with background color, proper padding, and a maximum width constraint. The use of landscapeStyle for responsive adjustments is a good practice for maintaining consistent layout across different screen sizes.


40-46: Refactored external link with improved styling

The styled ExternalLink component provides a cleaner implementation than the previous direct styled anchor. The alignment and spacing adjustments improve the visual layout.


63-65: Security improvement in external link

The change from "noreferrer" to "noopener noreferrer" in the rel attribute is an important security enhancement. The "noopener" prevents the opened page from accessing the window.opener property, which can be a security risk.


77-77: Good UX enhancement with automatic scrolling

Adding the ScrollTop component improves user experience by managing scroll position when viewing attachments.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 18, 2025
@kemuru kemuru merged commit 9fc0510 into dev Apr 23, 2025
7 checks passed
@kemuru kemuru deleted the fix(web)/wagmi-generate branch April 23, 2025 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants