Skip to content

feat: handle new (hash) type of ruling options #203

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

Merged
merged 16 commits into from
Jun 29, 2025

Conversation

0xferit
Copy link
Member

@0xferit 0xferit commented Jun 28, 2025

No description provided.

@0xferit 0xferit requested a review from Copilot June 28, 2025 19:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new ruling option by adding a "hash" type and bumps the version of the "@reality.eth/reality-eth-lib" dependency. Key changes include:

  • Adding a "hash" entry to the QuestionTypes enumeration.
  • Inserting a console.log statement in the convertToRealitioFormat function for debugging purposes.
  • Upgrading the "@reality.eth/reality-eth-lib" dependency and adding a resolutions block for "html-to-text".

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/components/disputeDetails.js Added support for a new "hash" ruling option and a debugging log
package.json Upgraded dependency versions and added resolutions configuration
Comments suppressed due to low confidence (1)

src/components/disputeDetails.js:25

  • [nitpick] Ensure that the new 'hash' type is properly processed in the convertToRealitioFormat function, and add unit tests to verify its behavior alongside other types.
  hash: "Hash"

Comment on lines 150 to 151

console.log({currentRuling,metaEvidenceJSON})
Copy link
Preview

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove or disable the console.log debug statement before merging to production to prevent exposing internal state.

Suggested change
console.log({currentRuling,metaEvidenceJSON})

Copilot uses AI. Check for mistakes.

@0xferit
Copy link
Member Author

0xferit commented Jun 28, 2025

bugbot run

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

…oFormat

- Add proper hex character validation for hash type rulings
- Apply -1 offset to hash types for consistency with numeric types
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

- Fixed precision loss in hash type rulings by conditionally applying parseInt()
- For hash types, preserve raw string value to maintain full precision
- For other types, continue using parseInt() as before
- Added descriptive error for scientific notation edge cases

Fixes issue where large hash values like 0x0386adbca7661db55f3ecfc221735565459a4ed5722db980ff536fda79f1b384
were being converted to scientific notation (1.5948951406472317e+75) causing precision loss
cursor[bot]

This comment was marked as outdated.

0xferit added 3 commits June 28, 2025 22:27
- Removed console.log/console.debug statements from production code
- Removed unused debug import from prettier/doc
- Improved error message for better user experience
- Added documentation comments explaining hash precision preservation
- Cleaned up component lifecycle methods

Code is now production-ready with proper error handling and documentation.
Improves code quality by using const for immutable variables.
- Extracted helper methods for hash value processing
- Created renderDecisionAlerts helper to reduce nested conditionals
- Created renderCrowdfundingCards helper for different question types
- Created renderVariableTypeCrowdfundingCards for variable type rulings
- Simplified main render method with early return pattern
- Reduced maximum nesting from 5+ levels to 3 levels max

Improves code readability and maintainability by eliminating 'spaghetti code'.
cursor[bot]

This comment was marked as outdated.

- Added parentheses around single parameters for consistency
- Fixed loose equality operators (== to ===) for better type safety
- Ensured consistent spacing around arrow functions
- Applied consistent formatting across all arrow functions

Improves code readability, predictability, and maintainability by
following shared coding conventions for arrow function usage.
cursor[bot]

This comment was marked as outdated.

- Extract magic numbers to improve code readability and maintainability
- Add constants for precision scaling, percentage calculations, dispute periods
- Replace hardcoded values in disputeDetails.js, app.js, and disputeTimeline.js
- Complies with javascript:S109 rule while preserving existing functionality
cursor[bot]

This comment was marked as outdated.

0xferit added 2 commits June 28, 2025 23:16
Fixed bug where Object.keys(contributions) string keys were not properly
compared with numeric currentRuling, causing duplicate crowdfunding cards.
Convert currentRuling to string for proper comparison.
- Add 'hash' to isVariableType check in renderVariableTypeCrowdfundingCards
- This allows users to contribute to appeals for hash-type rulings
- Hash types should be treated as variable input types like uint, int, string, datetime
cursor[bot]

This comment was marked as outdated.

…ty bug

Fixed bit comparison from bit === 1 to bit === '1' since bit is a string from binary representation split, not a number. This was preventing correct mapping of bits to titles in multiple-select questions.
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@0xferit 0xferit merged commit 5525475 into master Jun 29, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant