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

Release v2-testnet-4.0.4 #1813

Merged
merged 40 commits into from
Dec 20, 2024
Merged

Release v2-testnet-4.0.4 #1813

merged 40 commits into from
Dec 20, 2024

Conversation

jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Dec 20, 2024

PR-Codex overview

This PR focuses on updates and improvements across various components of the Kleros application, including styling adjustments, dependency updates, and enhancements to functionality, particularly around staking and dispute management.

Detailed summary

  • Increased gap in multiple styled components for better spacing.
  • Updated dependencies in package.json files.
  • Added logging in useSessionStorage for error tracking.
  • Enhanced error handling in various components.
  • Added new utility functions for fetching role restrictions.
  • Improved styling and layout in various UI components.
  • Updated test cases to reflect changes in dispute kits.
  • Refined padding and margin in several components for better visual consistency.

The following files were skipped due to too many changes: web/src/assets/svgs/icons/law-balance.svg, web/src/context/Web3Provider.tsx, contracts/src/arbitration/KlerosCoreBase.sol, contracts/deployments/arbitrum/KlerosCoreRulerNeo_Proxy.json, yarn.lock, contracts/deployments/arbitrum/KlerosCoreRulerNeo.json, contracts/deployments/arbitrum/DisputeResolverRulerNeo.json, contracts/test/foundry/KlerosCore.t.sol, contracts/deployments/arbitrum/KlerosCoreRulerNeo_Implementation.json

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

Summary by CodeRabbit

  • New Features

    • Introduced new contracts: DisputeResolverRulerNeo and KlerosCoreRulerNeo with corresponding addresses.
    • Added functionality for role-based restrictions in the AtlasProvider component.
    • New script for generating coverage reports added.
  • Bug Fixes

    • Enhanced error handling for staking requirements in the InputDisplay component.
    • Improved reliability of tests by ensuring transactions are confirmed before assertions.
  • Documentation

    • Updated README to reflect new contract deployments and their addresses.
  • Style

    • Adjusted styling across various components for improved layout and responsiveness.
    • Updated padding and margin properties in multiple styled components.
  • Chores

    • Updated workflow configurations for contracts testing, including dependency installations and caching strategies.

unknownunknown1 and others added 30 commits December 12, 2024 03:05
feat(kleros-app): add-restrictions-check-in-upload-file
fix: better mobile margins, more hovers, cosmetic changes, slight bug…
Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces comprehensive changes across the Kleros v2 project, focusing on testing configurations, contract deployments, and UI enhancements. The modifications span multiple components, including workflow configurations, contract testing, deployment scripts, and frontend styling. Key areas of change include updating the GitHub Actions workflow for contracts testing, adding new contract deployments on Arbitrum, introducing mock contracts for testing, and refining UI components across various pages.

Changes

File/Directory Change Summary
.github/workflows/contracts-testing.yml Updated workflow configuration with specific action versions, Foundry toolchain installation, and lcov setup
contracts/.solcover.js Modified coverage reporter and expanded skip files configuration
contracts/README.md Added new contract deployment addresses for Arbitrum
contracts/deployments/arbitrum/ Added new JSON files for DisputeResolverRulerNeo and KlerosCoreRulerNeo contracts
contracts/src/ Updated various contract files with type adjustments and error handling improvements
web-devtools/ and web/ Numerous UI styling and layout refinements across multiple components

Suggested Labels

Type: Enhancement :sparkles:, Package: Web, Package: Contracts

Suggested Reviewers

  • alcercu

Poem

🐰 In the realm of code, a rabbit's delight,
Workflows dance, contracts shine bright
Deployments bloom on Arbitrum's shore
Testing magic opens every door
Kleros evolves with each commit's might! 🚀


🪧 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
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: 12

🔭 Outside diff range comments (1)
web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx (1)

Line range hint 86-105: Refactor error handling logic for better maintainability

The error handling logic in useEffect is becoming complex. Consider extracting it into a separate function for better maintainability and testing.

+ const getErrorMessage = (
+   parsedAmount: bigint,
+   balance: bigint,
+   jurorBalance: [unknown, unknown, bigint] | undefined,
+   action: ActionType,
+   courtDetails?: { court?: { minStake: string } }
+ ): string | undefined => {
+   if (parsedAmount > 0n && balance === 0n && action === ActionType.stake) {
+     return "You need a non-zero PNK balance to stake";
+   }
+   if (action === ActionType.stake && balance && parsedAmount > balance) {
+     return "Insufficient balance to stake this amount";
+   }
+   if (action !== ActionType.stake && jurorBalance && parsedAmount > jurorBalance[2]) {
+     return "Insufficient staked amount to withdraw this amount";
+   }
+   if (
+     action === ActionType.stake &&
+     courtDetails?.court?.minStake &&
+     jurorBalance &&
+     parsedAmount !== 0n &&
+     jurorBalance[2] + parsedAmount < BigInt(courtDetails.court.minStake)
+   ) {
+     return `Min Stake in court is: ${formatPNK(courtDetails.court.minStake)} PNK`;
+   }
+   return undefined;
+ };

  useEffect(() => {
-   if (parsedAmount > 0n && balance === 0n && isStaking) {
-     setErrorMsg("You need a non-zero PNK balance to stake");
-   } else if (isStaking && balance && parsedAmount > balance) {
-     setErrorMsg("Insufficient balance to stake this amount");
-   } else if (!isStaking && jurorBalance && parsedAmount > jurorBalance[2]) {
-     setErrorMsg("Insufficient staked amount to withdraw this amount");
-   } else if (
-     action === ActionType.stake &&
-     courtDetails &&
-     jurorBalance &&
-     parsedAmount !== 0n &&
-     jurorBalance[2] + parsedAmount < BigInt(courtDetails?.court?.minStake)
-   ) {
-     setErrorMsg(`Min Stake in court is: ${formatPNK(courtDetails?.court?.minStake)} PNK`);
-   } else {
-     setErrorMsg(undefined);
-   }
+   setErrorMsg(getErrorMessage(parsedAmount, balance ?? 0n, jurorBalance, action, courtDetails));
  }, [parsedAmount, isStaking, balance, jurorBalance, action, courtDetails]);
🧹 Nitpick comments (44)
cspell.json (1)

52-52: Consider standardizing capitalization and adding related terms.

  1. "Unstaking" should be lowercase to maintain consistency with "unstaked" and "unstake".
  2. Consider adding related terms that might be used in the codebase:
    • "crowdfunding"
    • "crowdfunded"

Apply this diff to fix the capitalization:

-    "Unstaking",
+    "unstaking",
web/src/pages/Home/TopJurors/JurorCard/DesktopCard.tsx (1)

34-36: Consider using theme opacity values.

The hover effect is well-implemented, but using a hardcoded opacity value (BB) might be better managed through the theme system for consistency.

Consider updating to:

-    background-color: ${({ theme }) => theme.lightGrey}BB;
+    background-color: ${({ theme }) => `${theme.lightGrey}${theme.hoverOpacity}`};
web/src/pages/Home/TopJurors/JurorCard/MobileCard.tsx (1)

5-5: Consider using theme variables for transparency values.

The styling changes improve visual consistency and interaction feedback. However, the hardcoded transparency value BB in the hover effect could be moved to a theme variable for better maintainability.

Consider refactoring the hover effect like this:

- background-color: ${({ theme }) => theme.lightGrey}BB;
+ background-color: ${({ theme }) => `${theme.lightGrey}${theme.hoverBackgroundOpacity}`};

This assumes adding hoverBackgroundOpacity: "BB" to your theme configuration.

Also applies to: 17-17, 23-23, 27-27, 34-37

web/src/components/FavoriteCases.tsx (1)

34-40: Consider using the existing --gap CSS variable

For better consistency with the rest of the component, consider using the existing --gap CSS variable (16px) instead of hardcoding 12px for the gap property.

const TitleAndClearLabel = styled.div`
  display: flex;
  flex-direction: row;
-  gap: 12px;
+  gap: var(--gap);
  align-items: center;
  margin-bottom: ${responsiveSize(12, 24)};
`;
kleros-app/src/lib/atlas/providers/AtlasProvider.tsx (2)

48-48: Ensure clarity in naming or usage of Role array.
While the property name "roleRestrictions" is clear, consider providing additional inline documentation or comments to clarify how it’s consumed downstream.


299-299: Check uploadFile callback dependencies.
All necessary dependencies, including "roleRestrictions" and "config.product," appear to be included in the dependency array. This ensures the callback remains fresh.

kleros-app/src/lib/atlas/hooks/useSessionStorage.ts (1)

10-12: User-friendly error logging.
Logging the error object before returning the default value aids debugging. Remember to remove or adjust logging in production if logs could become noisy.

kleros-app/src/lib/atlas/utils/fetchRestrictions.ts (1)

12-14: Properly scoped internal type.
"FetchRolesResponse" is localized and unexported, preventing accidental use elsewhere. This helps keep the domain model consistent.

web/src/context/Web3Provider.tsx (3)

16-19: Consider adding type safety to environment variables

The validation logic is good, but consider using a type-safe environment variable solution.

Consider using a library like zod for type-safe environment validation:

import { z } from 'zod';

const envSchema = z.object({
  ALCHEMY_API_KEY: z.string().min(1),
  WALLETCONNECT_PROJECT_ID: z.string().min(1),
});

const env = envSchema.parse({
  ALCHEMY_API_KEY: import.meta.env.ALCHEMY_API_KEY,
  WALLETCONNECT_PROJECT_ID: import.meta.env.WALLETCONNECT_PROJECT_ID,
});

Also applies to: 72-75


24-30: LGTM: Improved error handling for chain configuration

The refactoring improves error handling and chain support. Consider adding test coverage for the error cases.

Would you like me to help create unit tests for the alchemyURL function, particularly for error cases?

Also applies to: 35-42


35-42: Consider extracting configuration logic

The Web3Provider is handling multiple responsibilities (environment validation, chain configuration, and provider setup).

Consider extracting the configuration logic into a separate module (e.g., web3Config.ts) to improve maintainability and separation of concerns. This would make the Web3Provider focus solely on providing the context.

Also applies to: 71-76

web/src/pages/Dashboard/Courts/CourtCard/index.tsx (1)

23-25: Consider removing redundant hover style.

The cursor: auto is the default behavior and doesn't need to be explicitly set unless overriding a different cursor style.

- :hover {
-   cursor: auto;
- }
web/src/pages/Home/TopJurors/Header/Coherence.tsx (1)

35-36: LGTM: Improved responsive design logic.

The switch from manual window size checking to the useIsDesktop hook:

  • Improves code readability
  • Reduces complexity
  • Makes the responsive behavior more maintainable

Consider documenting the breakpoint values used in useIsDesktop hook in a central location for consistency across the application.

Also applies to: 39-39

web/src/pages/GetPnk/index.tsx (1)

22-22: Consider maintaining responsive padding for smaller screens

While the simplified padding provides consistency, the change from responsive to fixed padding might affect the component's appearance on very small screens. Consider keeping some level of responsiveness for extreme cases.

-  padding: 16px 16px 40px;
+  padding: 16px ${responsiveSize(16, 16)} 40px;

Also applies to: 30-30, 31-35

web/src/pages/Cases/index.tsx (1)

16-16: LGTM! Consider extracting common padding values.

The padding implementation looks good with proper mobile-first approach and landscape mode handling. However, since these padding values (32px/40px for mobile, 48px/60px for landscape) appear to be used across multiple components, consider extracting them into theme constants for better maintainability.

// styles/theme.ts
export const PADDING = {
  mobile: {
    vertical: '32px 40px',
    horizontal: '16px'
  },
  landscape: {
    vertical: '48px 60px',
    horizontal: responsiveSize(0, 132)
  }
} as const;

Also applies to: 20-24

web/src/pages/Home/TopJurors/Header/Rewards.tsx (1)

Line range hint 31-35: Consider internationalizing the tooltip message.

The tooltip message is quite long and contains user-facing text. Consider moving it to a translations file for better maintainability and future localization support.

// translations/en.ts
export const REWARDS = {
  tooltip: "Users have an economic interest in serving as jurors in Kleros: collecting the Juror Rewards in exchange for their work. Each juror who is coherent with the final ruling receive the Juror Rewards composed of arbitration fees (ETH) + PNK redistribution between jurors."
};
web/src/pages/Home/index.tsx (1)

24-33: Consider creating a shared layout component.

The Container styling pattern (fixed padding + landscape mode) is repeated across multiple components (Cases, Home). Consider creating a shared layout component to reduce duplication and maintain consistency.

// components/layout/ResponsiveContainer.tsx
const ResponsiveContainer = styled.div`
  width: 100%;
  background-color: ${({ theme }) => theme.lightBackground};
  padding: 16px 16px 40px;
  max-width: ${MAX_WIDTH_LANDSCAPE};
  margin: 0 auto;

  ${landscapeStyle(
    () => css`
      padding: 16px ${responsiveSize(0, 132)} 60px;
    `
  )}
`;

export default ResponsiveContainer;
web/src/pages/Home/TopJurors/JurorCard/Rewards.tsx (1)

8-8: LGTM! Consider destructuring props for better readability.

The changes improve responsive behavior by using the useIsDesktop hook for tooltip placement. The implementation is clean and aligns with the PR's UI enhancement goals.

Consider destructuring the props for better readability:

-const Rewards: React.FC<IRewards> = ({ address }) => {
+const Rewards: React.FC<IRewards> = ({ address }) => {
+  const { value = "", unit = "ETH", showUnitInDisplay = false } = props;

Also applies to: 52-52, 57-62

web/src/components/DisputeView/DisputeCardView.tsx (1)

39-40: Add TypeScript types to TruncatedTitle props.

The new StyledCaseCardTitle component and its usage look good, but the TruncatedTitle function is missing TypeScript types for its props.

Consider adding proper types:

-const TruncatedTitle = ({ text, maxLength }) => {
+interface TruncatedTitleProps {
+  text: string;
+  maxLength: number;
+}
+
+const TruncatedTitle: React.FC<TruncatedTitleProps> = ({ text, maxLength }) => {

Also applies to: 44-44, 49-49

web/src/components/DisputePreview/Policies.tsx (1)

2-2: LGTM: Enhanced responsive design with landscape support

The changes standardize spacing metrics and add proper landscape mode support, improving the component's responsiveness across different device orientations.

Consider documenting these standardized spacing values (12px/16px/20px/32px) in a design system guide to maintain consistency across the application.

Also applies to: 11-11, 20-21, 24-28

web/src/pages/Cases/CaseDetails/Overview/index.tsx (1)

2-2: LGTM: Consistent responsive design implementation

The changes align with the application-wide standardization of spacing metrics and landscape mode support.

Consider extracting these common spacing values into theme constants:

+ // theme.ts
+ export const spacing = {
+   default: {
+     gap: '16px',
+     padding: '20px 16px 16px',
+   },
+   landscape: {
+     gap: '24px',
+     padding: '32px',
+   },
+ };

  // Overview/index.tsx
  const Container = styled.div`
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
-   gap: 16px;
-   padding: 20px 16px 16px;
+   gap: ${({ theme }) => theme.spacing.default.gap};
+   padding: ${({ theme }) => theme.spacing.default.padding};

    ${landscapeStyle(
      () => css`
-       padding: 32px;
-       gap: 24px;
+       padding: ${({ theme }) => theme.spacing.landscape.padding};
+       gap: ${({ theme }) => theme.spacing.landscape.gap};
      `
    )}
  `;

This would make it easier to maintain consistent spacing across components and update them globally if needed.

Also applies to: 14-14, 27-35

web/src/pages/Cases/CaseDetails/Appeal/OptionCard.tsx (1)

108-108: Consider simplifying boolean comparison

The boolean comparison in the winner prop can be simplified.

-<WinnerLabel winner={winner ? true : false}>
+<WinnerLabel winner={!!winner}>
web/src/components/DisputeView/PeriodBanner.tsx (1)

Line range hint 65-73: Consider enhancing type safety for period colors

The period colors mapping could benefit from a type-safe implementation.

type PeriodColorMap = {
  [K in Periods]: [string, string];
};

const PERIOD_COLORS = (theme: Theme): PeriodColorMap => ({
  [Periods.appeal]: [theme.tint, theme.tintMedium],
  [Periods.execution]: [theme.secondaryPurple, theme.mediumPurple],
  [Periods.evidence]: [theme.primaryBlue, theme.mediumBlue],
  [Periods.commit]: [theme.primaryBlue, theme.mediumBlue],
  [Periods.vote]: [theme.primaryBlue, theme.mediumBlue],
});

const getPeriodColors = (period: Periods, theme: Theme): [string, string] => 
  PERIOD_COLORS(theme)[period];
web/src/pages/Dashboard/index.tsx (1)

29-37: Consider maintaining responsive padding for mobile

While the change to fixed padding values simplifies the styling, consider keeping the responsive padding for mobile screens to ensure optimal display on smaller devices. The current fixed value of 16px might be too large for very small screens.

Consider this alternative:

-  padding: 32px 16px 40px;
+  padding: ${responsiveSize(16, 32)} 16px ${responsiveSize(24, 40)};
web/src/pages/Home/CourtOverview/Chart.tsx (1)

Line range hint 71-93: Consider memoizing processed data calculations

The data processing functions (processedCourtsData, processedStakedPNKData) are recalculated on every render. Consider using useMemo to optimize performance, especially with large datasets.

- const processedCourtsData = courtsChartData?.reduce(
+ const processedCourtsData = useMemo(() => courtsChartData?.reduce(
    (accData: CasesByCourtsChartData, current) => {
      if (BigInt(current.numberDisputes) > 0) {
        return {
          labels: [...accData.labels, current.name ?? ""],
          cases: [...accData.cases, current.numberDisputes],
          totalCases: accData.totalCases + parseInt(current.numberDisputes, 10),
        };
      }
      return accData;
    },
    { labels: [], cases: [], totalCases: 0 }
-  );
+  ), [courtsChartData]);
web/src/pages/Cases/CaseDetails/Evidence/index.tsx (2)

Line range hint 93-102: Add error boundary for evidence rendering

Consider wrapping the evidence rendering logic in an error boundary to gracefully handle rendering failures.

+ import { ErrorBoundary } from 'components/ErrorBoundary';

// Inside render
- {evidences?.realEvidences.map(
+ <ErrorBoundary fallback={<div>Failed to load evidence</div>}>
+   {evidences?.realEvidences.map(
      ({ evidence, sender, timestamp, transactionHash, name, description, fileURI, evidenceIndex }) => (
        <EvidenceCard
          key={timestamp}
          index={parseInt(evidenceIndex)}
          sender={sender?.id}
          {...{ evidence, timestamp, transactionHash, name, description, fileURI }}
        />
      )
-   )}
+   )}
+ </ErrorBoundary>

Line range hint 82-88: Optimize evidence filtering with useMemo

The evidence filtering logic could be more granular to prevent unnecessary recalculations.

- const evidences = useMemo(() => {
+ const spamEvidences = useMemo(() => 
+   data?.evidences?.filter((evidence) => isSpam(evidence.id)),
+   [data?.evidences]
+ );

+ const realEvidences = useMemo(() =>
+   data?.evidences?.filter((evidence) => !isSpam(evidence.id)),
+   [data?.evidences]
+ );

+ const evidences = useMemo(() => {
    if (!data?.evidences) return;
-   const spamEvidences = data.evidences.filter((evidence) => isSpam(evidence.id));
-   const realEvidences = data.evidences.filter((evidence) => !isSpam(evidence.id));
    return { realEvidences, spamEvidences };
-  }, [data]);
+  }, [realEvidences, spamEvidences]);
web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx (1)

Line range hint 63-79: Consider using reducer for complex state management

The component uses multiple useState hooks that are closely related. Consider using useReducer for better state management.

+ type State = {
+   debouncedAmount: string;
+   errorMsg?: string;
+   isPopupOpen: boolean;
+ };

+ type Action =
+   | { type: 'SET_DEBOUNCED_AMOUNT'; payload: string }
+   | { type: 'SET_ERROR'; payload?: string }
+   | { type: 'SET_POPUP'; payload: boolean };

+ const reducer = (state: State, action: Action): State => {
+   switch (action.type) {
+     case 'SET_DEBOUNCED_AMOUNT':
+       return { ...state, debouncedAmount: action.payload };
+     case 'SET_ERROR':
+       return { ...state, errorMsg: action.payload };
+     case 'SET_POPUP':
+       return { ...state, isPopupOpen: action.payload };
+     default:
+       return state;
+   }
+ };
web/src/components/EvidenceCard.tsx (1)

234-234: Consider using consistent punctuation

The index format changed from "#{index}:" to "#{index}." - ensure this change is consistent with the design system's guidelines.

web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx (1)

Line range hint 266-289: Consider improving readability of the disabled state logic

While the logic is correct, the nested conditions could be more readable. Consider extracting the minimum stake check into a separate variable.

 const isDisabled = useMemo(() => {
+    const isStakeAmountBelowMinimum =
+      action === ActionType.stake &&
+      targetStake !== 0n &&
+      courtDetails &&
+      targetStake < BigInt(courtDetails?.court?.minStake);
+
-    if (
-      parsedAmount == 0n ||
-      (action === ActionType.stake &&
-        targetStake !== 0n &&
-        courtDetails &&
-        targetStake < BigInt(courtDetails?.court?.minStake))
-    )
+    if (parsedAmount == 0n || isStakeAmountBelowMinimum)
       return true;
contracts/src/test/SortitionModuleMock.sol (1)

18-22: Add natspec for function parameters

The implementation looks good, but please add natspec documentation for the _key parameter and return values.

-    function getSortitionProperties(bytes32 _key) external view returns (uint256 K, uint256 nodeLength) {
+    /// @param _key The key of the sortition sum tree to query
+    /// @return K The branching factor of the tree
+    /// @return nodeLength The total number of nodes in the tree
+    function getSortitionProperties(bytes32 _key) external view returns (uint256 K, uint256 nodeLength) {
web-devtools/src/consts/chains.ts (1)

8-8: Consider extracting repeated conditional logic

The isProductionDeployment() condition is repeated multiple times. Consider extracting the chain selections into constants for better maintainability.

+const EXECUTION_CHAIN = isProductionDeployment() ? arbitrum : arbitrumSepolia;
+const QUERY_CHAIN = isProductionDeployment() ? gnosis : gnosisChiado;
+
 export const SUPPORTED_CHAINS: Record<number, Chain> = {
-  [isProductionDeployment() ? arbitrum.id : arbitrumSepolia.id]: isProductionDeployment() ? arbitrum : arbitrumSepolia,
+  [EXECUTION_CHAIN.id]: EXECUTION_CHAIN,
 };
 
 export const QUERY_CHAINS: Record<number, Chain> = {
-  [isProductionDeployment() ? gnosis.id : gnosisChiado.id]: isProductionDeployment() ? gnosis : gnosisChiado,
+  [QUERY_CHAIN.id]: QUERY_CHAIN,

Also applies to: 12-12

contracts/src/test/KlerosCoreMock.sol (2)

3-7: Consider completing the metadata tags.

The custom metadata tags for reviewers, auditors, bounties, and deployments are empty. While this is a test contract, maintaining consistent documentation practices across all contracts is beneficial.


16-24: LGTM! Consider adding function documentation.

The implementation looks good. Both view functions provide appropriate test access to internal contract data. Consider adding NatSpec documentation to describe the parameters and return values.

+    /// @notice Returns the children courts for a given court ID
+    /// @param _courtId The ID of the court
+    /// @return children Array of court IDs that are children of the given court
     function getCourtChildren(uint256 _courtId) external view returns (uint256[] memory children) {
         children = courts[_courtId].children;
     }

+    /// @notice Decodes the extra data to extract court ID, minimum jurors, and dispute kit ID
+    /// @param _extraData The encoded extra data
+    /// @return courtID The ID of the court
+    /// @return minJurors The minimum number of jurors
+    /// @return disputeKitID The ID of the dispute kit
     function extraDataToCourtIDMinJurorsDisputeKit(
         bytes memory _extraData
     ) external view returns (uint96 courtID, uint256 minJurors, uint256 disputeKitID) {
scripts/cancel-all-netlify-builds.sh (1)

5-10: Address shellcheck warnings about return value masking.

The current local variable declarations mask return values. Consider declaring and assigning separately.

-    local siteId=$1
+    local siteId
+    siteId=$1
     readarray -t builds < <(netlify api listSiteDeploys -d '{ "site_id": "'$siteId'", "state": "new"}' | jq --compact-output '.[]')
     for build in "${builds[@]}"
     do
-        local name=$(jq -r .name <<< $build)
-        local branch=$(jq -r .branch <<< $build)
+        local name
+        local branch
+        name=$(jq -r .name <<< $build)
+        branch=$(jq -r .branch <<< $build)
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 9-9: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 10-10: Declare and assign separately to avoid masking return values.

(SC2155)

contracts/scripts/coverage.sh (2)

26-35: Consider documenting lcov options

The lcov command uses multiple options that affect coverage reporting. Consider adding comments explaining:

  • Why these specific options were chosen
  • What each option does
  • The impact of these settings on the coverage report

1-62: Consider script improvements for maintainability

The script could benefit from the following improvements:

  1. Extract configuration values (like excluded directories) to variables
  2. Add error handling for required tools (lcov, genhtml)
  3. Add a help/usage message

Would you like me to provide an improved version of the script?

.github/workflows/contracts-testing.yml (1)

66-67: Verify Foundry and lcov installation order

The workflow installs Foundry and lcov for coverage reporting. Consider combining these installations into a single step to optimize workflow execution time.

- - name: Install Foundry
-   uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 # v1.2.0
-
- - name: Install lcov
-   run: sudo apt-get install -y lcov
+ - name: Install tools
+   run: |
+     curl -L https://foundry.paradigm.xyz | bash
+     foundryup
+     sudo apt-get install -y lcov

Also applies to: 69-70

web-devtools/src/context/Web3Provider.tsx (1)

Line range hint 22-29: Chain mapping structure enhancement

The alchemyToViemChain mapping is well-organized and includes all necessary chains. However, consider adding JSDoc comments to document the mapping's purpose and structure.

+/**
+ * Maps Viem chain IDs to Alchemy network identifiers
+ * @see https://github.com/alchemyplatform/alchemy-sdk-js/blob/c4440cb/src/types/types.ts#L98-L153
+ */
 const alchemyToViemChain: Record<number, string> = {
web-devtools/wagmi.config.ts (1)

Line range hint 41-48: Chain mapping implementation

The chain mapping is well-structured but consider adding error handling for chain ID conflicts.

 const chainMap: Record<string, Chain> = {
   arbitrum,
   arbitrumSepolia,
   sepolia,
   mainnet,
   gnosisChiado,
   gnosis,
 };
+
+// Verify no chain ID conflicts
+const chainIds = new Set();
+Object.values(chainMap).forEach(chain => {
+  if (chainIds.has(chain.id)) {
+    throw new Error(`Duplicate chain ID found: ${chain.id}`);
+  }
+  chainIds.add(chain.id);
+});
contracts/src/arbitration/interfaces/IDisputeKit.sol (2)

44-44: Document migration path for deprecated parameter

While the deprecation notice is helpful, it would be beneficial to:

  1. Document when this parameter will be removed
  2. Provide migration guidance for existing implementations
  3. Explain how Kleros Core now handles the vote count internally

Consider expanding the documentation:

- /// @param _nbVotes Maximal number of votes this dispute can get. DEPRECATED as we don't need to pass it now. KC handles the count.
+ /// @param _nbVotes Maximal number of votes this dispute can get.
+ /// @custom:deprecated This parameter will be removed in the next major version (v3.0.0).
+ /// Kleros Core now handles vote counting internally. When upgrading:
+ /// 1. You can pass any value for this parameter as it's ignored
+ /// 2. Update your implementation to rely on Kleros Core for vote counting
+ /// @see KlerosCore.getVoteCount() for the new vote counting mechanism

Line range hint 45-50: Consider marking the parameter as deprecated in the function signature

To make the deprecation more visible at the implementation level, consider using a custom deprecated attribute.

function createDispute(
    uint256 _coreDisputeID,
    uint256 _numberOfChoices,
    bytes calldata _extraData,
-   uint256 _nbVotes
+   uint256 _nbVotes /* @custom:deprecated */
) external;
contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol (1)

605-608: LGTM! Consider adding a reference to the insolvency check.

The comment effectively explains the minStake requirement handling and its implications. To make it even clearer, consider adding a reference to where the insolvency check is performed (i.e., in the totalStaked >= totalLocked + lockedAmountPerJuror check below).

 /// Note that we don't check the minStake requirement here because of the implicit staking in parent courts.
 /// minStake is checked directly during staking process however it's possible for the juror to get drawn
 /// while having < minStake if it is later increased by governance.
-/// This issue is expected and harmless since we check for insolvency anyway.
+/// This issue is expected and harmless since we check for insolvency anyway through the totalStaked >= totalLocked + lockedAmountPerJuror check below.
contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol (1)

623-626: LGTM! Maintain consistency with DisputeKitClassic.

The comment matches the one in DisputeKitClassic, which is appropriate as both dispute kits share the same minStake handling logic. If you update the comment in DisputeKitClassic as suggested, please apply the same change here for consistency.

 /// Note that we don't check the minStake requirement here because of the implicit staking in parent courts.
 /// minStake is checked directly during staking process however it's possible for the juror to get drawn
 /// while having < minStake if it is later increased by governance.
-/// This issue is expected and harmless since we check for insolvency anyway.
+/// This issue is expected and harmless since we check for insolvency anyway through the totalStaked >= totalLocked + lockedAmountPerJuror check below.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4269a5c and f00f73d.

⛔ Files ignored due to path filters (2)
  • web/src/assets/svgs/icons/law-balance.svg is excluded by !**/*.svg
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (78)
  • .github/workflows/contracts-testing.yml (2 hunks)
  • contracts/.solcover.js (2 hunks)
  • contracts/README.md (1 hunks)
  • contracts/deployments/arbitrum/DisputeResolverRulerNeo.json (1 hunks)
  • contracts/deployments/arbitrum/KlerosCoreRulerNeo.json (1 hunks)
  • contracts/deployments/arbitrum/KlerosCoreRulerNeo_Proxy.json (1 hunks)
  • contracts/lib/forge-std (1 hunks)
  • contracts/package.json (1 hunks)
  • contracts/scripts/coverage.sh (1 hunks)
  • contracts/src/arbitration/KlerosCoreBase.sol (7 hunks)
  • contracts/src/arbitration/SortitionModuleBase.sol (2 hunks)
  • contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol (1 hunks)
  • contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol (1 hunks)
  • contracts/src/arbitration/interfaces/IDisputeKit.sol (1 hunks)
  • contracts/src/libraries/Constants.sol (2 hunks)
  • contracts/src/test/KlerosCoreMock.sol (1 hunks)
  • contracts/src/test/SortitionModuleMock.sol (1 hunks)
  • contracts/test/arbitration/index.ts (1 hunks)
  • contracts/test/rng/index.ts (6 hunks)
  • cspell.json (2 hunks)
  • kleros-app/src/lib/atlas/hooks/useSessionStorage.ts (1 hunks)
  • kleros-app/src/lib/atlas/providers/AtlasProvider.tsx (8 hunks)
  • kleros-app/src/lib/atlas/utils/fetchRestrictions.ts (1 hunks)
  • package.json (1 hunks)
  • scripts/cancel-all-netlify-builds.sh (2 hunks)
  • web-devtools/src/app/(main)/dispute-template/FetchDisputeRequestInput.tsx (1 hunks)
  • web-devtools/src/app/(main)/ruler/SelectArbitrable.tsx (1 hunks)
  • web-devtools/src/consts/chains.ts (1 hunks)
  • web-devtools/src/context/Web3Provider.tsx (5 hunks)
  • web-devtools/src/utils/getDisputeRequestParamsFromTxn.ts (1 hunks)
  • web-devtools/src/utils/wagmiConfig.ts (0 hunks)
  • web-devtools/wagmi.config.ts (2 hunks)
  • web/src/components/DisputePreview/Policies.tsx (2 hunks)
  • web/src/components/DisputeView/CardLabels/index.tsx (1 hunks)
  • web/src/components/DisputeView/DisputeCardView.tsx (2 hunks)
  • web/src/components/DisputeView/DisputeInfo/DisputeInfoCard.tsx (0 hunks)
  • web/src/components/DisputeView/PeriodBanner.tsx (2 hunks)
  • web/src/components/EvidenceCard.tsx (4 hunks)
  • web/src/components/FavoriteCases.tsx (4 hunks)
  • web/src/components/FileViewer/index.tsx (1 hunks)
  • web/src/components/Verdict/FinalDecision.tsx (5 hunks)
  • web/src/context/Web3Provider.tsx (4 hunks)
  • web/src/layout/Footer/index.tsx (1 hunks)
  • web/src/pages/Cases/AttachmentDisplay/Header.tsx (1 hunks)
  • web/src/pages/Cases/CaseDetails/Appeal/OptionCard.tsx (2 hunks)
  • web/src/pages/Cases/CaseDetails/Appeal/index.tsx (1 hunks)
  • web/src/pages/Cases/CaseDetails/Evidence/index.tsx (2 hunks)
  • web/src/pages/Cases/CaseDetails/Overview/index.tsx (3 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/PendingVotesBox.tsx (1 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/VotesDetails/AccordionTitle.tsx (1 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/VotesDetails/index.tsx (3 hunks)
  • web/src/pages/Cases/CaseDetails/Voting/index.tsx (3 hunks)
  • web/src/pages/Cases/index.tsx (1 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx (3 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/Simulator/index.tsx (1 hunks)
  • web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx (5 hunks)
  • web/src/pages/Courts/CourtDetails/Stats.tsx (2 hunks)
  • web/src/pages/Courts/CourtDetails/index.tsx (1 hunks)
  • web/src/pages/Courts/index.tsx (2 hunks)
  • web/src/pages/Dashboard/Courts/CourtCard/Stake.tsx (1 hunks)
  • web/src/pages/Dashboard/Courts/CourtCard/index.tsx (2 hunks)
  • web/src/pages/Dashboard/Courts/index.tsx (1 hunks)
  • web/src/pages/Dashboard/index.tsx (3 hunks)
  • web/src/pages/GetPnk/index.tsx (2 hunks)
  • web/src/pages/Home/Community/index.tsx (1 hunks)
  • web/src/pages/Home/CourtOverview/BarChart.tsx (0 hunks)
  • web/src/pages/Home/CourtOverview/Chart.tsx (1 hunks)
  • web/src/pages/Home/CourtOverview/ExtraStats.tsx (2 hunks)
  • web/src/pages/Home/CourtOverview/Header.tsx (1 hunks)
  • web/src/pages/Home/CourtOverview/Stats.tsx (5 hunks)
  • web/src/pages/Home/CourtOverview/TimeSeriesChart.tsx (0 hunks)
  • web/src/pages/Home/TopJurors/Header/Coherence.tsx (2 hunks)
  • web/src/pages/Home/TopJurors/Header/MobileHeader.tsx (1 hunks)
  • web/src/pages/Home/TopJurors/Header/Rewards.tsx (3 hunks)
  • web/src/pages/Home/TopJurors/JurorCard/DesktopCard.tsx (3 hunks)
  • web/src/pages/Home/TopJurors/JurorCard/MobileCard.tsx (4 hunks)
  • web/src/pages/Home/TopJurors/JurorCard/Rewards.tsx (2 hunks)
  • web/src/pages/Home/index.tsx (2 hunks)
💤 Files with no reviewable changes (4)
  • web/src/pages/Home/CourtOverview/TimeSeriesChart.tsx
  • web/src/pages/Home/CourtOverview/BarChart.tsx
  • web/src/components/DisputeView/DisputeInfo/DisputeInfoCard.tsx
  • web-devtools/src/utils/wagmiConfig.ts
✅ Files skipped from review due to trivial changes (8)
  • contracts/lib/forge-std
  • web/src/pages/Home/CourtOverview/Header.tsx
  • web/src/pages/Cases/CaseDetails/Voting/VotesDetails/AccordionTitle.tsx
  • web/src/pages/Cases/CaseDetails/Voting/PendingVotesBox.tsx
  • web/src/pages/Courts/CourtDetails/StakePanel/Simulator/index.tsx
  • web/src/pages/Courts/CourtDetails/Stats.tsx
  • web/src/pages/Courts/CourtDetails/index.tsx
  • web/src/components/DisputeView/CardLabels/index.tsx
🧰 Additional context used
📓 Learnings (2)
kleros-app/src/lib/atlas/hooks/useSessionStorage.ts (1)
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1755
File: kleros-app/src/lib/atlas/hooks/useSessionStorage.ts:3-12
Timestamp: 2024-11-21T05:38:11.576Z
Learning: In the `useSessionStorage` hook in `kleros-app/src/lib/atlas/hooks/useSessionStorage.ts`, the error handling in the `catch` block covers cases where `window` is undefined or `sessionStorage` throws an exception, so additional checks are unnecessary.
web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx (1)
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1775
File: web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx:0-0
Timestamp: 2024-12-09T12:36:59.441Z
Learning: In the `StakeWithdrawButton` component, the transaction flow logic is tightly linked to component updates, so extracting it into a custom hook does not provide significant benefits.
🪛 yamllint (1.35.1)
.github/workflows/contracts-testing.yml

[error] 45-45: trailing spaces

(trailing-spaces)


[error] 46-46: trailing spaces

(trailing-spaces)


[error] 50-50: trailing spaces

(trailing-spaces)


[error] 75-75: trailing spaces

(trailing-spaces)

🪛 Shellcheck (0.10.0)
scripts/cancel-all-netlify-builds.sh

[warning] 9-9: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 10-10: Declare and assign separately to avoid masking return values.

(SC2155)

🔇 Additional comments (79)
cspell.json (1)

24-24: LGTM! The additions of "crowdfunder" and "unstaked" are appropriate.

These terms align well with the project's domain language and follow the existing capitalization patterns.

Also applies to: 51-51

web/src/pages/Home/TopJurors/JurorCard/DesktopCard.tsx (1)

6-6: LGTM! Good use of shared styling.

The addition of hoverShortTransitionTiming from common styles promotes consistency across the application.

Also applies to: 15-15

web/src/pages/Home/TopJurors/JurorCard/MobileCard.tsx (2)

59-59: LGTM! Consistent spacing improvements.

The gap adjustments to 8px create a more consistent layout following the 8-point grid system, which improves visual hierarchy and readability.

Also applies to: 73-73


Line range hint 1-116: Well-structured component with good TypeScript integration.

The component demonstrates good practices:

  • Clear separation of styled components
  • Type-safe props handling with TypeScript
  • Responsive design with landscape styles
  • Consistent styling patterns
web/src/components/FavoriteCases.tsx (4)

12-12: LGTM: Import addition promotes UI consistency

The addition of hoverShortTransitionTiming aligns with the broader effort to standardize hover effects across components.


22-22: LGTM: Proper margin management

Moving margin control to the parent container follows good CSS composition patterns.


43-47: LGTM: Enhanced hover effect and proper margin adjustment

The addition of hover transition and margin adjustment improves both UX and layout structure.


74-77: LGTM: Improved layout structure

The new wrapper component improves layout organization while maintaining clear semantics and functionality.

kleros-app/src/lib/atlas/providers/AtlasProvider.tsx (5)

28-28: Import statement alignment looks good.
The addition of "fetchRestrictions" and "Role" is well-organized and consistent with the file’s import structure.


78-78: Memo dependency updated for config.uri.
Adding "config.uri" to the dependency array ensures the memoized GraphQL client is rebuilt when the URI changes, preventing stale connections. This is correct and desirable.


147-161: Validate the presence of product before fetching restrictions.
The new React Query block to fetch role restrictions is well-structured. The "enabled" option checks "Boolean(config.product)" but ensure that "config.product" is indeed defined or non-null. The usage of "staleTime: Infinity" is appropriate if these restrictions remain valid indefinitely.

Could you confirm that "config.product" is always set as intended in consumer code?


277-286: Role-based file upload checks.
Good job verifying the existence of restrictions, role validity, MIME types, and file size. This thoroughly enforces the constraints.


Line range hint 341-357: Provider value includes the new roleRestrictions.
Exposing "roleRestrictions" via the provider is beneficial for hooking into role-based logic elsewhere. Make sure it follows the same naming convention across the codebase.

kleros-app/src/lib/atlas/utils/fetchRestrictions.ts (3)

1-10: Clear, structured "Role" type.
Defining "maxSize" and "allowedMimeTypes" ensures that usage sites have a known shape. Continue ensuring that types remain in sync with the server’s GraphQL schema.


16-26: GraphQL query is straightforward.
The query for roles is concise. Just ensure the back-end logic supports filtering by product if that’s indeed the expected parameter.


28-40: Robust fetch with error handling.
Catching errors and then rethrowing with a simplified message is a solid approach. Logging the “errors” object is useful for debugging.

web/src/context/Web3Provider.tsx (2)

6-6: LGTM: Chain imports are properly configured

The additional chain imports align with the multi-chain support requirements.


93-93: Verify chain configuration across environments

The default chain selection looks correct, but let's verify the configuration.

✅ Verification successful

Chain configuration is consistent across environments

The verification shows that:

  • The chain configuration is consistently implemented across the codebase
  • The default chain selection (arbitrum for production, arbitrumSepolia for non-production) is correctly used in Web3Provider components
  • The same pattern is followed in both the main web app (web/src/context/Web3Provider.tsx) and devtools (web-devtools/src/context/Web3Provider.tsx)
  • The configuration aligns with deployment artifacts found in contracts/deployments/ for both chains
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify chain configuration consistency across the codebase

# Check for chain references in configuration files
echo "Checking chain configuration consistency..."
rg -l "arbitrum|sepolia|gnosis|chiado" --type typescript

# Check for environment-specific chain configurations
echo "Checking environment-specific configurations..."
rg "isProduction.*chain" --type typescript

Length of output: 375


Script:

#!/bin/bash
# Description: Verify chain configuration consistency across the codebase

# Check for chain references in configuration files
echo "Checking chain references..."
rg -l "arbitrum|sepolia|gnosis|chiado"

# Check for environment-specific chain configurations
echo "Checking environment configurations..."
rg "isProduction.*chain"

# Check Web3Provider implementation
echo "Checking Web3Provider implementation..."
rg -A 5 "defaultChain"

Length of output: 4242

web/src/pages/Courts/index.tsx (2)

2-2: LGTM: Import organization is clean and purposeful.

The addition of the css import and reorganization of style imports improves code clarity.

Also applies to: 4-4


15-15: Consider maintaining responsive padding for mobile view.

While the landscape mode retains responsive sizing through responsiveSize, the default mobile view now uses fixed padding values. This might affect the component's appearance on various mobile screen sizes.

Let's check if this is consistent with other similar components:

Consider keeping the responsive padding for mobile view:

- padding: 32px 16px 40px;
+ padding: ${responsiveSize(32, 48)} ${responsiveSize(16, 32)} ${responsiveSize(40, 60)};

Also applies to: 18-23

web/src/pages/Dashboard/Courts/CourtCard/index.tsx (1)

18-18: LGTM: Consistent spacing values.

The updated padding and gap values align with the design system's spacing scale.

Also applies to: 21-21

web/src/pages/Home/TopJurors/Header/Coherence.tsx (1)

4-4: LGTM: Improved import organization.

The separation of styling imports and hooks improves code organization.

Also applies to: 6-6

web/src/pages/GetPnk/index.tsx (1)

2-2: LGTM: Import changes align with new styling requirements

The addition of the css import and landscapeStyle utility is consistent with the new styling approach being implemented across the application.

Also applies to: 4-4

web/src/pages/Dashboard/Courts/CourtCard/Stake.tsx (1)

15-15: LGTM: Improved spacing adjustments

The gap adjustments (8px default, 12px landscape) provide better visual hierarchy and spacing for both mobile and landscape views.

Also applies to: 23-23

web/src/pages/Home/TopJurors/Header/Rewards.tsx (1)

37-44: LGTM! Good use of responsive tooltip placement.

The implementation of device-specific tooltip placement improves the user experience by ensuring tooltips are visible and properly positioned on both mobile and desktop views.

web/src/pages/Home/Community/index.tsx (1)

29-29: Consider maintaining responsive padding for better mobile adaptability.

While fixed padding simplifies the styling, switching from responsiveSize to a fixed 16px might affect the component's adaptability on very small screens. However, if this change is part of a broader design system standardization, ensure it's been tested across all target device sizes.

Let's check if this is part of a broader pattern:

Consider keeping responsive padding for mobile:

-  padding: 16px;
+  padding: ${responsiveSize(12, 16)};
✅ Verification successful

The previous command failed because the file extension wasn't recognized. Let's try a broader search to understand the usage of responsiveSize and padding patterns in the codebase, particularly around the Community component.


Based on the search results, I can now provide a final response:

Fixed padding aligns with the design system and doesn't impact mobile experience

The change from responsiveSize to fixed 16px padding is appropriate because:

  • The component still maintains responsive behavior through other properties (margins and font sizes) that use responsiveSize
  • The fixed 16px padding is consistent with other components in the codebase
  • The Community component is part of a grid layout where consistent padding helps maintain visual harmony
  • Other critical responsive properties like margin-top, margin-bottom, and font-size are preserved using responsiveSize
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other responsive padding removals
rg "responsiveSize.*padding" --type tsx

Length of output: 69


Script:

#!/bin/bash
# Search for responsiveSize usage in all files
rg "responsiveSize.*padding"

# Also search for the responsiveSize function definition
rg "responsiveSize"

# Look for padding patterns in the specific component and its directory
fd "Community" --type f --exec cat {}

Length of output: 22016

web/src/pages/Cases/CaseDetails/Appeal/index.tsx (1)

16-22: LGTM! Consistent with design system patterns.

The padding changes align well with the broader styling updates across the application, maintaining appropriate spacing in both mobile and landscape orientations.

web/src/layout/Footer/index.tsx (1)

15-15: Verify the visual impact of footer spacing changes.

The adjustments to height, padding, and gap spacing create a more compact footer. While the changes seem reasonable, we should verify that:

  1. The reduced height (114px) accommodates all content without clipping
  2. The smaller gap (16px) maintains sufficient spacing between elements
  3. The content remains centered and visually balanced in both mobile and landscape modes

Let's check for any related footer styling changes:

Also applies to: 22-23, 30-30

✅ Verification successful

Footer styling changes are safe and consistent

The changes to the footer's height and spacing are well-considered:

  • The height reduction from 122px to 114px aligns with the component's content which consists of only two elements: the logo (24px) and social media icons (16px)
  • The 16px gap is consistently used across many components in the codebase
  • The landscape mode maintains proper responsiveness by switching to 64px height with horizontal layout
  • The component structure ensures content is properly centered and spaced
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other footer-related style changes
rg "height.*64px" --type tsx
rg "gap.*16px" --type tsx

Length of output: 114


Script:

#!/bin/bash
# Search for footer-related style changes with correct file type
rg "height.*(?:64|114|122)px" --type ts --type tsx --type-add 'tsx:*.tsx'
rg "gap.*(?:16|32)px" --type ts --type tsx --type-add 'tsx:*.tsx'

# Look for Footer component files and their style definitions
fd "Footer" --type f --extension tsx --extension ts --extension css

Length of output: 4150


Script:

#!/bin/bash
# Get the content of both Footer components to compare their structure
cat web/src/layout/Footer/index.tsx
cat web-devtools/src/layout/Footer/index.tsx

# Look for any media queries or responsive styles in the Footer
rg "@media.*\{" web/src/layout/Footer/index.tsx -A 5

Length of output: 3501

web/src/pages/Dashboard/Courts/index.tsx (1)

24-24: LGTM! Spacing improvements enhance readability.

The increased gap spacing (4px → 12px) improves the visual hierarchy and readability of the court cards.

web/src/components/DisputeView/DisputeCardView.tsx (1)

2-2: LGTM! Responsive design improvements.

The changes improve the component's responsive behavior by:

  • Using fixed padding values for better predictability
  • Adding landscape-specific styles for larger screens

Also applies to: 11-11, 27-27, 31-37

web/src/pages/Cases/AttachmentDisplay/Header.tsx (1)

37-37: LGTM: Color scheme update for paperclip icon

The change from primaryPurple to secondaryPurple with 69% opacity (B0) aligns with the UI styling updates across the application.

web/src/pages/Home/CourtOverview/ExtraStats.tsx (1)

2-2: LGTM: Styling standardization improvements

The changes standardize the component's responsive behavior by:

  1. Using fixed values for better predictability
  2. Adding landscape-specific styles for better adaptation
  3. Maintaining consistent spacing with other components

The modifications align well with the broader styling updates across the application.

Also applies to: 4-4, 18-18, 20-27

web/src/pages/Cases/CaseDetails/Appeal/OptionCard.tsx (1)

16-16: LGTM: Enhanced interaction feedback

The addition of the canBeSelected prop improves user interaction feedback by explicitly controlling the cursor style.

Also applies to: 19-19, 21-23

web/src/components/DisputeView/PeriodBanner.tsx (1)

24-24: LGTM: Improved layout consistency

The switch to fixed padding values and addition of landscape styles improves layout consistency and responsiveness.

Also applies to: 33-37

web/src/pages/Dashboard/index.tsx (1)

2-2: LGTM: Import changes look good

The addition of the css import and landscapeStyle utility is appropriate for the styling changes being made.

Also applies to: 15-15

web/src/pages/Home/CourtOverview/Stats.tsx (3)

26-31: LGTM: Grid layout improvements

The changes to the grid layout improve responsiveness while maintaining a clean presentation:

  • Reduced minimum column width from 152px to 120px allows better space utilization
  • Consistent gap spacing enhances visual rhythm

31-37: LGTM: Responsive padding implementation

The padding implementation with landscape mode support is well-structured and maintains consistency with other components.


54-54: LGTM: Consistent title capitalization

The capitalization changes in stat titles ("PNK Staked", "PNK Redistributed", "Active Jurors") improve visual consistency.

Also applies to: 72-72, 81-81

web/src/pages/Cases/CaseDetails/Voting/index.tsx (2)

2-2: LGTM: Import changes are appropriate

The addition of css and landscapeStyle imports aligns with the styling changes being made.

Also applies to: 21-21


31-37: LGTM: Responsive padding implementation

The padding implementation with landscape mode support is well-structured:

  • Mobile: 20px top, 16px sides and bottom
  • Landscape: 32px top and sides, 16px bottom
web/src/pages/Home/CourtOverview/Chart.tsx (1)

Line range hint 134-152: Consider edge cases in tooltip positioning logic

The custom tooltip positioner might not handle all edge cases effectively. Consider:

  • When tooltip is near chart boundaries
  • When chart area dimensions are very small
  • When multiple data points are close together
✅ Verification successful

Let me gather more context about the tooltip implementation to better assess the edge cases.


Let me check one more thing to understand how the tooltip interacts with the chart data points.


The tooltip positioning implementation is well-designed and handles edge cases appropriately

After analyzing the implementation and related configurations, the tooltip positioning logic is actually robust and well-implemented:

  1. The chart has proper interaction settings (intersect: false, axis: "x") that prevent tooltip conflicts when multiple data points are close.
  2. The custom positioner correctly handles:
    • Chart boundaries through isAtEnd check for x-axis
    • Vertical space constraints via isAtTop check
    • Automatic alignment switching (right/left/center for x, center/bottom for y) based on available space
  3. The tooltip is properly configured with styling and border to ensure visibility against any background.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar tooltip positioning implementations or related issues
rg -A 5 "Tooltip.positioners" 

Length of output: 495


Script:

#!/bin/bash
# Search for tooltip-related configurations and implementations
rg -B 5 -A 10 "tooltip" web/src/pages/Home/CourtOverview/Chart.tsx

# Look for chart configuration options that might affect tooltip behavior
ast-grep --pattern 'const $_ = {
  $$$
  plugins: {
    tooltip: {
      $$$
    }
  }
  $$$
}'

Length of output: 4461


Script:

#!/bin/bash
# Look for chart data structure and interaction settings
rg -A 10 "ChartData|interaction" web/src/pages/Home/CourtOverview/

Length of output: 11040

web/src/components/Verdict/FinalDecision.tsx (3)

38-38: LGTM: Gap adjustment in JuryContainer

The gap adjustment from 4px 7px to 5px 7px provides better visual spacing between elements.


51-51: LGTM: Simplified gap in VerdictContainer

The change from a responsive size function to a fixed 8px gap simplifies the styling while maintaining good spacing.


60-66: LGTM: Enhanced responsive design with landscape styles

The addition of landscape-specific styles for the divider improves the component's responsiveness across different screen orientations.

web/src/pages/Cases/CaseDetails/Voting/VotesDetails/index.tsx (3)

31-37: LGTM: Improved accordion spacing

The fixed padding values and margins create a more consistent visual hierarchy in the accordion.


39-48: LGTM: Enhanced responsive design

The addition of landscape-specific styles ensures consistent spacing across different screen orientations.


52-61: LGTM: Added hover feedback

The hover effect with transition timing provides better visual feedback for user interaction.

web/src/components/EvidenceCard.tsx (2)

33-33: LGTM: Improved content padding

The fixed padding values with landscape-specific adjustments create a more consistent layout across different screen sizes.

Also applies to: 49-53


60-60: LGTM: Enhanced visual hierarchy

The gap adjustment and secondary text color for the index improve readability and visual hierarchy.

Also applies to: 65-65

web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx (3)

71-71: LGTM: Court details integration

The integration of useCourtDetails hook is clean and properly used for minimum stake validation.


183-192: LGTM: Error handling for simulation failure

The added error handling for simulation failure is well-implemented with a clear user-friendly message.


260-263: LGTM: Simplified error handling

The error handling in the effect hook has been appropriately simplified, with the minimum stake check moved to the isDisabled memo where it logically belongs.

contracts/.solcover.js (2)

8-8: LGTM: Using lcov format improves CI integration

The switch to lcov reporter is a good choice as it's widely supported by CI tools and coverage platforms.


17-17: Verify mock contracts are correctly excluded

The expanded skipFiles list properly excludes test files and mocks. However, let's verify all mock contracts are consistently placed in these directories.

✅ Verification successful

Mock contracts are properly organized with one minor exception

The mock contracts are generally well-organized within the excluded directories (gateway/mock, proxy/mock, rng/mock), but there are two mock contracts in the test directory:

  • contracts/src/test/KlerosCoreMock.sol
  • contracts/src/test/SortitionModuleMock.sol

Since the test directory is already in the skipFiles list, all mock contracts are effectively excluded from coverage. The organization is consistent and working as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find any mock contracts that might be outside the excluded directories
fd -e sol -x grep -l "Mock" {} \; | grep -vE "(test|token|kleros-v1|proxy/mock|gateway/mock|rng/mock)"

Length of output: 105


Script:

#!/bin/bash
# Let's try a different approach to find mock contracts by searching for "Mock" in file names
fd -e sol ".*[Mm]ock.*"

Length of output: 292

web-devtools/src/consts/chains.ts (1)

3-3: Verify the production deployment check

Let's ensure the isProductionDeployment() function is properly implemented.

✅ Verification successful

isProductionDeployment implementation is correctly defined

The function is properly implemented in web-devtools/src/consts/index.ts and checks if process.env.NEXT_PUBLIC_DEPLOYMENT equals "mainnet" to determine if it's a production deployment. This is consistent with Next.js environment variable naming conventions and the expected functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find and check the implementation of isProductionDeployment
rg -A 5 "export function isProductionDeployment"

Length of output: 50


Script:

#!/bin/bash
# Let's try to find the implementation using ast-grep and a more flexible pattern
ast-grep --pattern 'export const isProductionDeployment'

# Also search for any definition of isProductionDeployment
rg "isProductionDeployment.*="

# Let's also check the index.ts file since it's imported from there
cat web-devtools/src/consts/index.ts

Length of output: 1371

web-devtools/src/utils/getDisputeRequestParamsFromTxn.ts (1)

4-4: Verify the wagmiConfig import change impact.

The wagmiConfig import source has changed from utils to context. Let's verify that all consumers of this configuration are updated consistently.

✅ Verification successful

Import change is correctly implemented

The verification shows that:

  • The wagmiConfig is now properly defined in context/Web3Provider.tsx and exported from there
  • All references to wagmiConfig across the codebase are importing it from the new location in context/Web3Provider
  • No remaining imports from the old utils/wagmiConfig path were found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining imports from the old path and verify consistent usage of the new path

# Check for any remaining old imports
echo "Checking for remaining old imports from utils/wagmiConfig:"
rg -l "from ['\"]utils/wagmiConfig['\"]"

# Check for new imports to ensure consistency
echo "Checking usage of new import path:"
rg -l "from ['\"]context/Web3Provider['\"].*wagmiConfig"

Length of output: 315


Script:

#!/bin/bash
# Let's try a broader search to understand the wagmiConfig usage and its import patterns

# Search for any wagmiConfig references
echo "Searching for wagmiConfig references:"
rg "wagmiConfig" -A 2

# Search for files in utils directory that might contain the old config
echo -e "\nSearching for potential config files in utils:"
fd "wagmi" --type f

# Search for files in context directory that might contain the new config
echo -e "\nSearching for potential config files in context:"
fd "Web3Provider" --type f

Length of output: 6843

contracts/src/libraries/Constants.sol (1)

36-37: LGTM: Clear and descriptive enum value addition

The new CannotStakeZeroWhenNoStake enum value follows the existing naming pattern and clearly describes its purpose.

contracts/scripts/coverage.sh (1)

48-48: Verify excluded directories

Please confirm that all excluded directories are intentional and no test coverage is being accidentally omitted.

✅ Verification successful

Let me try a different approach to verify the directory structure and test files.


Let me check the actual source files to verify the excluded directories.


Excluded directories are correctly configured

The excluded directories from coverage are appropriate as they contain:

  • Test mocks and helpers (src/test/)
  • Token contracts and test tokens (src/token/)
  • Legacy v1 contracts and interfaces (src/kleros-v1/)
  • Mock contracts for testing:
    • Proxy mocks (src/proxy/mock/)
    • Gateway mocks (src/gateway/mock/)
    • RNG mocks (src/rng/mock/)

These are all support files, test helpers, or legacy contracts that don't need coverage tracking.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# List all directories in src to compare against exclusions
fd --type d . src/

# Check if any test files exist in excluded directories
for dir in "src/test" "src/token" "src/kleros-v1" "src/proxy/mock" "src/gateway/mock" "src/rng/mock"; do
  echo "Checking $dir for test files:"
  fd -e sol -e ts . "$dir" || true
done

Length of output: 2080


Script:

#!/bin/bash
# List all directories and files in the repository root to understand the structure
ls -R

# Check the content of the coverage script to understand the context better
cat contracts/scripts/coverage.sh

Length of output: 35589


Script:

#!/bin/bash
# Check the contents and purpose of excluded directories
echo "Checking src/test directory:"
fd . "contracts/src/test"

echo -e "\nChecking src/token directory:"
fd . "contracts/src/token"

echo -e "\nChecking src/kleros-v1 directory:"
fd . "contracts/src/kleros-v1"

echo -e "\nChecking src/proxy/mock directory:"
fd . "contracts/src/proxy/mock"

echo -e "\nChecking src/gateway/mock directory:"
fd . "contracts/src/gateway/mock"

echo -e "\nChecking src/rng/mock directory:"
fd . "contracts/src/rng/mock"

Length of output: 2233

.github/workflows/contracts-testing.yml (2)

43-43: LGTM: Security improvements through action version pinning

Good practice pinning GitHub Actions to specific commit hashes instead of version tags. This prevents supply chain attacks through compromised action versions.

Also applies to: 47-49, 52-52, 77-77


72-74: Verify coverage command configuration

The coverage step runs yarn coverage in the contracts directory. Ensure this script is properly configured in the contracts package.json.

✅ Verification successful

Coverage command is properly configured and comprehensive

The coverage script is well-configured in contracts/package.json and points to an executable shell script that:

  • Generates coverage reports from both Hardhat and Foundry tests
  • Merges the reports using lcov
  • Filters out unnecessary contracts and test files
  • Provides HTML report generation for local development
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if coverage script exists in contracts/package.json
cat contracts/package.json | jq -r '.scripts.coverage'

Length of output: 74


Script:

#!/bin/bash
# Check if the coverage script exists and is executable
ls -l contracts/scripts/coverage.sh

# Display the content of the coverage script
cat contracts/scripts/coverage.sh

Length of output: 2029

package.json (1)

28-29: LGTM: New workspace addition

The addition of "kleros-app" to workspaces is straightforward and follows the existing pattern.

contracts/test/arbitration/index.ts (1)

33-33: Verify alignment with KlerosCoreBase contract changes

The test now expects supportedDisputeKits to be [1] instead of empty. Let's verify this aligns with the contract implementation.

✅ Verification successful

Let me search for the constant value of DISPUTE_KIT_CLASSIC to verify if it matches the test expectation.


Test expectation correctly aligns with contract implementation

The test expectation of [1] for supportedDisputeKits is correct as it matches the DISPUTE_KIT_CLASSIC constant value defined in Constants.sol. The contract enforces that every court must support the classic dispute kit (index 1) through the MustSupportDisputeKitClassic check in the createCourt function.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check KlerosCoreBase contract for supportedDisputeKits initialization
rg -A 5 "supportedDisputeKits" contracts/src/

Length of output: 15744


Script:

#!/bin/bash
# Search for DISPUTE_KIT_CLASSIC constant definition
rg "DISPUTE_KIT_CLASSIC\s*=\s*\d+" contracts/src/

Length of output: 179

web-devtools/src/context/Web3Provider.tsx (3)

Line range hint 13-18: Improved environment variable validation

Good addition of explicit validation for the Alchemy API key. This prevents silent failures and provides clear error messages.


Line range hint 33-40: Robust URL generation with error handling

The refactoring of alchemyURL into a proper function with error handling is a good improvement. The error message for unsupported chains is clear and helpful.


51-63: Transport configuration needs verification

The transport configuration looks correct but we should verify that all necessary chains are properly configured.

✅ Verification successful

Based on the search results, I can now provide a final response about the transport configuration verification:

Transport configuration is properly configured for all required chains

The transport configuration in Web3Provider.tsx correctly handles all necessary chains:

  • Production: Arbitrum mainnet with Alchemy transport, Gnosis with default transport
  • Development: Arbitrum Sepolia with Alchemy transport, Gnosis Chiado with default transport
  • Ethereum mainnet is always enabled with Alchemy transport for ENS resolution

The configuration aligns with the chain definitions in the codebase and provides appropriate fallback mechanisms using both HTTP and WebSocket transports.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if all chains in alchemyToViemChain are covered in transports
echo "Checking chain coverage in transport configuration..."
rg -A 5 "alchemyToViemChain.*=.*{" | rg -A 10 "\[.*\]:"

Length of output: 286


Script:

#!/bin/bash
# Let's try a different approach to find chain configurations
echo "Searching for chain configurations..."
# First, let's find chain imports and definitions
rg -l "import.*chain" --type typescript
rg "const.*Chain.*=.*{" --type typescript

# Then, let's look for transport configurations
rg -A 10 "transport.*=.*chain" --type typescript

Length of output: 391


Script:

#!/bin/bash
# Let's try without typescript file type and fix regex
echo "Searching for chain configurations..."
# Find chain imports
rg "import.*chain"

# Find transport configurations
rg -A 10 "transport.*chain"

# Find chain definitions and usage
rg "arbitrum|gnosis|mainnet|sepolia|chiado" "src/"

Length of output: 67116


Script:

#!/bin/bash
# Let's search in web-devtools directory since we found imports there
echo "Searching for chain configurations in web-devtools..."
# Find chain configurations and transport setup
rg -A 10 "transport.*chain" "web-devtools/"

# Find chain imports and usage
rg "arbitrum|gnosis|mainnet|sepolia|chiado" "web-devtools/"

# Find any other chain-related configurations
rg "Chain.*=.*{" "web-devtools/"

Length of output: 3769

web-devtools/src/app/(main)/dispute-template/FetchDisputeRequestInput.tsx (1)

47-51: Verify transaction hash validity

The preset's transaction hash needs verification to ensure it points to a valid dispute resolver compensation claim.

✅ Verification successful

Let me verify the chain ID validity with additional context before making the final response.


Based on the verification results, I can now provide the final response:

Transaction hash and chain ID are valid

The transaction hash follows the correct format (0x + 64 hex chars) and chain ID 42161 corresponds to Arbitrum One mainnet, which is a valid production network used in the codebase. The transaction hash appears to be unique to this preset entry.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the transaction hash format is valid and search for any references
echo "Checking transaction hash validity and references..."
TXHASH="0x01db1d330acef1a0df007b0f9dcb56b7a88aeb49687f95cb5c58d5c36526ef70"
echo "Transaction hash format check:"
echo $TXHASH | grep -E "^0x[a-fA-F0-9]{64}$" || echo "Invalid format"

# Search for references to this transaction in other files
echo "Searching for transaction hash references:"
rg "$TXHASH"

Length of output: 758


Script:

#!/bin/bash
# Search for references to chainId 42161 to understand its usage and validation
echo "Searching for chainId 42161 references:"
rg "42161" -A 2 -B 2

# Look for chain ID validation or configuration
echo -e "\nSearching for chain ID related configurations:"
rg -i "chainid|chain.*id" --type ts

Length of output: 67394

web-devtools/wagmi.config.ts (1)

7-8: Type imports improvement

Good use of explicit type imports for better type safety and bundle size optimization.

web-devtools/src/app/(main)/ruler/SelectArbitrable.tsx (1)

145-146: LGTM: Address display update

The update to use the extracted address in the Copiable component is correct and consistent with the chain validation changes.

contracts/package.json (1)

25-25: Verify coverage script setup

The addition of coverage script is good practice. Let's verify the script setup.

✅ Verification successful

Coverage script setup is properly configured

The verification confirms that:

  • The coverage script exists at contracts/scripts/coverage.sh
  • The required solidity-coverage dependency is present in package.json
  • The script path in package.json correctly points to the existing script location
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify coverage script existence and permissions
if [ -f "scripts/coverage.sh" ]; then
  echo "Coverage script exists"
  ls -l scripts/coverage.sh
else
  echo "Coverage script missing"
  exit 1
fi

# Check if required dependencies are present
if grep -q "solidity-coverage" package.json; then
  echo "solidity-coverage dependency found"
else
  echo "solidity-coverage dependency missing"
  exit 1
fi

Length of output: 98


Script:

#!/bin/bash
# Let's check the entire repository for coverage-related files
echo "Searching for coverage-related files:"
fd coverage

echo -e "\nChecking package.json for coverage-related dependencies:"
cat contracts/package.json | grep -i coverage

echo -e "\nChecking if coverage script exists in a different location:"
fd -t f coverage.sh

Length of output: 567

contracts/deployments/arbitrum/KlerosCoreRulerNeo_Proxy.json (1)

73-74: Verify proxy initialization parameters.

The proxy is initialized with:

  1. Implementation: 0x85093b5EDa4F2e2E2fEDae34Da91239D6a08e324
  2. Initialization data contains encoded parameters that should be verified
✅ Verification successful

Based on the findings, I can now generate the final response:

Initialization parameters appear to match the KlerosCoreRuler contract structure

The initialization data decodes to:

  • Governor: 0xf1c7c037891525e360c59f708739ac09a7670c59
  • PNK Token: 0x330bd769382cfc6d50175903434ccc8d206dcae5
  • Court Parameters: [0, 10000, 100000000000000000, 16]

The parameters align with the initialization function signature found in KlerosCoreRuler.sol, which expects a governor address, PNK token address, and court parameters array.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation contract and decode initialization parameters

# Check if implementation is verified
echo "Checking implementation contract verification status..."
curl -s "https://api.arbiscan.io/api/v1/contract/0x85093b5EDa4F2e2E2fEDae34Da91239D6a08e324/verify-status"

# Decode initialization parameters
echo "Decoding initialization data..."
cast 4byte-decode "0x05d3177d000000000000000000000000f1c7c037891525e360c59f708739ac09a7670c59000000000000000000000000330bd769382cfc6d50175903434ccc8d206dcae500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000000000000000010"

Length of output: 2056


Script:

#!/bin/bash
# Let's try to find the initialization function signature and parameters in the codebase

# Search for the initialization function signature (first 4 bytes: 0x05d3177d)
echo "Searching for initialization function..."
rg -l "05d3177d" --type-add 'sol:*.sol' --type sol

# Search for any references to the addresses in the initialization data
echo "Searching for address references..."
rg -i "f1c7c037891525e360c59f708739ac09a7670c59|330bd769382cfc6d50175903434ccc8d206dcae5" --type-add 'sol:*.sol' --type sol -A 2

# Look for initialization-related functions in Solidity files
echo "Searching for initialization functions..."
ast-grep --pattern 'function initialize($$$) {
  $$$
}'

Length of output: 504


Script:

#!/bin/bash
# Let's search for the contract implementation and initialization patterns

# Find all Solidity files that might contain the implementation
echo "Finding relevant Solidity files..."
fd -e sol

# Search for KlerosCoreRulerNeo contract definition
echo "Searching for KlerosCoreRulerNeo contract..."
ast-grep --pattern 'contract KlerosCoreRulerNeo $$$'

# Search for initialize function with specific parameters
echo "Searching for initialize function with governor and token parameters..."
ast-grep --pattern 'function initialize(address $_, address $_, $$$) {
  $$$
}'

Length of output: 4016


Script:

#!/bin/bash
# Let's check KlerosCoreNeo and related files since KlerosCoreRulerNeo seems to be a variant

# Check KlerosCoreNeo initialization
echo "Checking KlerosCoreNeo initialization..."
rg -A 10 "function initialize.*address.*address" contracts/src/arbitration/KlerosCoreNeo.sol

# Check for ruler-related files and implementations
echo "Checking for ruler implementations..."
rg -l "ruler" --type-add 'sol:*.sol' --type sol

# Check devtools ruler implementation
echo "Checking KlerosCoreRuler implementation..."
rg -A 10 "function initialize" contracts/src/arbitration/devtools/KlerosCoreRuler.sol

Length of output: 899

contracts/README.md (1)

17-17: Documentation updates are accurate and well-formatted.

The new contract entries are correctly added with proper links to Arbiscan:

  • DisputeResolverRulerNeo: 0xb3a5FdEAF461c42caCe148e978e6FBCa97bE6140
  • KlerosCoreRulerNeo: 0xc0169e0B19aE02ac4fADD689260CF038726DFE13

Also applies to: 21-21

contracts/src/arbitration/SortitionModuleBase.sol (2)

269-275: LGTM! Important validations for stake management.

The changes add crucial validations:

  1. Prevent exceeding MAX_STAKE_PATHS limit while allowing unstaking
  2. Prevent zero stakes when no current stake exists
  3. Clean up existing delayed stakes before proceeding

Let's verify the MAX_STAKE_PATHS constant and its usage:

Also applies to: 277-277

✅ Verification successful

The search results show that MAX_STAKE_PATHS is consistently defined as 4 across the codebase and is used in multiple places:

  1. In libraries/Constants.sol: uint256 constant MAX_STAKE_PATHS = 4; // The maximum number of stake paths a juror can have.
  2. In xKlerosLiquidV2.sol: uint256 public constant MAX_STAKE_PATHS = 4; // The maximum number of stake paths a juror can have.

The validation in the review is correctly using this constant to prevent staking beyond the maximum allowed paths while allowing unstaking. Let me verify the other staking validation patterns to ensure consistency.


Validation logic for stake management is correctly implemented

The code correctly implements stake management validations:

  1. Uses the consistent MAX_STAKE_PATHS = 4 constant across the codebase
  2. Properly prevents staking beyond MAX_STAKE_PATHS while allowing unstaking
  3. Prevents zero stakes when no current stake exists to avoid flaky behavior
  4. Returns appropriate StakingResult enums for each validation case
  5. Maintains consistent validation patterns across both SortitionModuleBase and SortitionModuleUniversity
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for MAX_STAKE_PATHS definition and usage
rg "MAX_STAKE_PATHS" -A 5 -B 5

# Search for other stake validation patterns
ast-grep --pattern 'if ($condition) { return ($value1, $value2, StakingResult.$result); }'

Length of output: 74503


Script:

#!/bin/bash
# Search for other stake validation patterns in SortitionModuleBase
rg "StakingResult\." -A 2 -B 2 contracts/src/arbitration/SortitionModuleBase.sol

# Search for stake validation in related files
rg "StakingResult\." -A 2 -B 2 contracts/src/arbitration/university/SortitionModuleUniversity.sol

Length of output: 1412


209-210: LGTM! Important fix for delayed stake execution.

The change prevents a potential race condition where a new delayed stake's index could be prematurely deleted if created during the execution of a current delayed stake for the same juror and court.

Let's verify there are no other instances where delayed stake indices might be deleted prematurely:

✅ Verification successful

Let me search for other instances where latestDelayedStakeIndex is modified by using ast-grep to get more precise matches:


Let me try a different pattern with ast-grep to catch assignments to latestDelayedStakeIndex:


Let me try one more search to find any other modifications to latestDelayedStakeIndex:


Based on the search results, I can now generate the final response:

LGTM! The nullification of latestDelayedStakeIndex is correctly implemented.

The code shows that latestDelayedStakeIndex is modified in three places with proper handling:

  1. In executeDelayedStakes: Nullifies the index before executing the stake to prevent interference
  2. In setStake: Sets new index when creating a delayed stake
  3. In _deleteDelayedStake: Properly cleans up old indices when removing delayed stakes

The implementation ensures that delayed stake indices are managed correctly throughout their lifecycle, preventing any race conditions or premature deletions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other places where latestDelayedStakeIndex is modified
rg "latestDelayedStakeIndex\[.*\]" -A 5 -B 5

Length of output: 65583


Script:

#!/bin/bash
# Search for modifications to latestDelayedStakeIndex using AST pattern matching
ast-grep --pattern 'latestDelayedStakeIndex[$_][$_] = $_'

Length of output: 59


Script:

#!/bin/bash
# Search for modifications to latestDelayedStakeIndex with a broader pattern
ast-grep --pattern 'latestDelayedStakeIndex'

# Also search with ripgrep to catch any modifications
rg "latestDelayedStakeIndex.*=" -A 3 -B 3

Length of output: 66354


Script:

#!/bin/bash
# Search for modifications to latestDelayedStakeIndex in the SortitionModuleBase.sol file
rg "latestDelayedStakeIndex" contracts/src/arbitration/SortitionModuleBase.sol -A 5 -B 5

Length of output: 3613

contracts/src/arbitration/KlerosCoreBase.sol (4)

116-116: LGTM: Type consistency improvement

The change from uint256 to uint96 for _courtID parameter aligns with the Court struct's parent field type, improving type consistency across the contract.


240-251: LGTM: Proper initialization of supported dispute kits

The changes correctly initialize the GENERAL_COURT with DISPUTE_KIT_CLASSIC support and emit the CourtCreated event with proper parameter types.


356-356: LGTM: Safe type casting and consistency

The changes to use uint96 for courtID in _enableDisputeKit and event emission maintain type consistency. The casting is safe as courts.length cannot exceed uint96 max value.

Also applies to: 375-375


1181-1181: LGTM: Enhanced error handling

The addition of StakingZeroWhenNoStake error improves error handling granularity by specifically identifying attempts to stake zero when no stake exists.

contracts/deployments/arbitrum/KlerosCoreRulerNeo.json (1)

1-1602: LGTM: Successful deployment with proper configuration

The KlerosCoreRulerNeo contract has been successfully deployed to Arbitrum with proper initialization parameters and configuration.

contracts/deployments/arbitrum/DisputeResolverRulerNeo.json (1)

1-522: LGTM: Successful deployment with proper configuration

The DisputeResolverRulerNeo contract has been successfully deployed to Arbitrum with proper initialization parameters and configuration.

web/src/pages/Home/TopJurors/Header/MobileHeader.tsx Outdated Show resolved Hide resolved
scripts/cancel-all-netlify-builds.sh Outdated Show resolved Hide resolved
contracts/scripts/coverage.sh Show resolved Hide resolved
web-devtools/wagmi.config.ts Show resolved Hide resolved
web-devtools/src/app/(main)/ruler/SelectArbitrable.tsx Outdated Show resolved Hide resolved
contracts/test/rng/index.ts Show resolved Hide resolved
contracts/test/rng/index.ts Show resolved Hide resolved
Copy link

netlify bot commented Dec 20, 2024

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit c106865
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/6765bb0b4b7991000871c73a
😎 Deploy Preview https://deploy-preview-1813--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 20, 2024

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit c106865
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/6765bb0bb5b283000863b79c
😎 Deploy Preview https://deploy-preview-1813--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

netlify bot commented Dec 20, 2024

Deploy Preview for kleros-v2-university ready!

Name Link
🔨 Latest commit c106865
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/6765bb0b9a68dd00080e1c43
😎 Deploy Preview https://deploy-preview-1813--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

netlify bot commented Dec 20, 2024

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

Name Link
🔨 Latest commit c106865
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet-devtools/deploys/6765bb0b544a5c000860b8c2
😎 Deploy Preview https://deploy-preview-1813--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 20, 2024

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

Name Link
🔨 Latest commit c106865
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo-devtools/deploys/6765bb0bb03391000847dc3f
😎 Deploy Preview https://deploy-preview-1813--kleros-v2-neo-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.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 20, 2024
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: 1

🧹 Nitpick comments (4)
scripts/cancel-all-netlify-builds.sh (4)

3-4: Improve function documentation.

Consider using a more standard documentation format that clearly describes the function's purpose, parameters, and return value.

-function cancelSiteDeploy() #siteId
+# Cancels all pending Netlify builds for a given site ID that match specific branch patterns
+# Parameters:
+#   $1 - siteId: The Netlify site ID to process
+function cancelSiteDeploy()

9-10: Separate variable declarations and assignments.

To prevent masking of command return values and improve error handling:

-    local name=$(jq -r .name <<< $build)
-    local branch=$(jq -r .branch <<< $build)
+    local name
+    local branch
+    name=$(jq -r .name <<< "$build")
+    branch=$(jq -r .branch <<< "$build")
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 9-9: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 10-10: Declare and assign separately to avoid masking return values.

(SC2155)


13-13: Fix potential word splitting issue.

Properly quote the command substitution to prevent word splitting:

-    netlify api cancelSiteDeploy -d '{ "deploy_id": "'$(jq -r .id <<< $build)'"}' > /dev/null
+    netlify api cancelSiteDeploy -d '{ "deploy_id": "'"$(jq -r .id <<< "$build")"'"}' > /dev/null
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 13-13: Quote this to prevent word splitting.

(SC2046)


19-32: Consider using environment variables for site IDs.

While the comments help identify each site, consider moving these IDs to environment variables or a configuration file. This would:

  • Make it easier to manage different environments
  • Prevent accidental commits of ID changes
  • Allow for easier updates across environments

Example approach:

# config.env
NETLIFY_V2_TESTNET_SITE_ID="86d94ae8-f655-46a4-a859-d68696173f3a"
NETLIFY_V2_DEVTOOLS_TESTNET_SITE_ID="7b25b1a8-5fd4-41f7-8fd0-7fe4202229fb"
# ... etc
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e1a0f5f and a46c19d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • scripts/cancel-all-netlify-builds.sh (1 hunks)
  • web-devtools/src/app/(main)/ruler/SelectArbitrable.tsx (1 hunks)
  • web/package.json (1 hunks)
  • web/src/pages/Home/TopJurors/Header/MobileHeader.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/package.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/src/pages/Home/TopJurors/Header/MobileHeader.tsx
  • web-devtools/src/app/(main)/ruler/SelectArbitrable.tsx
🧰 Additional context used
🪛 Shellcheck (0.10.0)
scripts/cancel-all-netlify-builds.sh

[warning] 9-9: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 10-10: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 13-13: Quote this to prevent word splitting.

(SC2046)

scripts/cancel-all-netlify-builds.sh Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 20, 2024
@jaybuidl jaybuidl merged commit aac794f into master Dec 20, 2024
32 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants