-
Notifications
You must be signed in to change notification settings - Fork 49
Refactor/evidence refactors #1634
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
Conversation
WalkthroughThe changes across various modules and files center around updating the way evidence is handled in the arbitration system. Instead of using IPFS paths, the system now expects a stringified JSON object containing fields like "name", "description", and "fileURI". Additionally, full-text search capabilities have been introduced, and several components were refactored to support these updates. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant SmartContract
participant IPFS
User->>Frontend: SubmitEvidence (name, description, fileURI)
Frontend->>IPFS: Upload file
IPFS-->>Frontend: fileURI
Frontend->>SmartContract: submitEvidence(externalDisputeID, evidenceJSON)
SmartContract->>Frontend: Emit Evidence Event
Frontend->>Frontend: handleEvidenceEvent
Frontend->>Database: Save Evidence (parsed JSON)
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
✅ Deploy Preview for kleros-v2 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for kleros-v2-neo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for kleros-v2-university ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range and nitpick comments (1)
web/src/components/EvidenceCard.tsx (1)
Line range hint
140-166
: Optimize rendering and add error handling for file links.The
EvidenceCard
component can be optimized to prevent unnecessary re-renders and should handle potential errors or edge cases, such as missing or malformedfileURI
.- {fileURI && ( - <StyledLink to={`attachment/?url=${getIpfsUrl(fileURI)}`}> - <AttachmentIcon /> - <AttachedFileText /> - </StyledLink> - )} + {fileURI ? ( + <StyledLink to={`attachment/?url=${getIpfsUrl(fileURI)}`}> + <AttachmentIcon /> + <AttachedFileText /> + </StyledLink> + ) : ( + <p>No file attached</p> + )}
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (11)
- contracts/src/arbitration/evidence/EvidenceModule.sol (1 hunks)
- contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol (2 hunks)
- contracts/src/arbitration/interfaces/IEvidence.sol (1 hunks)
- subgraph/core/schema.graphql (2 hunks)
- subgraph/core/src/EvidenceModule.ts (1 hunks)
- subgraph/package.json (1 hunks)
- subgraph/utils/index.ts (1 hunks)
- web/src/components/EvidenceCard.tsx (3 hunks)
- web/src/hooks/queries/useEvidences.ts (2 hunks)
- web/src/pages/Cases/CaseDetails/Evidence/SubmitEvidenceModal.tsx (2 hunks)
- web/src/pages/Cases/CaseDetails/Evidence/index.tsx (1 hunks)
Files not reviewed due to errors (2)
- subgraph/core/schema.graphql (no review received)
- contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol (no review received)
Files skipped from review due to trivial changes (1)
- subgraph/package.json
Additional comments not posted (6)
contracts/src/arbitration/interfaces/IEvidence.sol (1)
10-10
: Updated event parameter to handle structured data.The change from an IPFS path to a JSON string for
_evidence
is a significant improvement as it allows for richer data handling. However, it would be beneficial to update the natspec comments further to explain the expected structure of the JSON object in more detail.subgraph/utils/index.ts (1)
3-26
: Robust handling of JSON values to strings.The introduction of
JSONValueToMaybeString
improves security by addressing potential vulnerabilities where crafted JSON objects could bypass UI checks. This is a crucial update for maintaining data integrity in the subgraph.web/src/hooks/queries/useEvidences.ts (1)
18-21
: Enhanced GraphQL query to include new evidence fields.The inclusion of
name
,description
,fileURI
, andfileTypeExtension
in the GraphQL query allows for richer data to be fetched and displayed, enhancing the user experience significantly.web/src/pages/Cases/CaseDetails/Evidence/index.tsx (1)
65-71
: UI Enhancement to display additional evidence properties.Passing new properties like
name
,description
, andfileURI
to theEvidenceCard
component improves the display and accessibility of evidence details, enhancing user interaction.subgraph/core/src/EvidenceModule.ts (1)
24-59
: Robust parsing and handling of JSON structured evidence.The update to parse and handle JSON structured evidence effectively addresses potential data integrity issues. Consider enhancing the error messages to include more details about the failure, which would aid in debugging and maintenance.
contracts/src/arbitration/evidence/EvidenceModule.sol (1)
67-67
: Ensure JSON string is properly formatted and escaped.The function now accepts a JSON string for evidence. It's crucial to ensure that the input is properly formatted and escaped to prevent injection attacks or parsing errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- web/src/hooks/queries/useEvidences.ts (2 hunks)
Additional comments not posted (2)
web/src/hooks/queries/useEvidences.ts (2)
31-31
: Type parameter added touseQuery
.The addition of the type parameter
<EvidencesQuery>
touseQuery
improves type safety and developer experience.
19-22
: New fields added to the GraphQL query.The fields
name
,description
,fileURI
, andfileTypeExtension
have been correctly added to theevidencesQuery
.However, ensure that these new fields are used correctly in the codebase.
Code Climate has analyzed commit d1b6fe2 and detected 15 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
web/src/assets/svgs/icons/arrow-down.svg
is excluded by!**/*.svg
Files selected for processing (10)
- subgraph/core-neo/subgraph.yaml (1 hunks)
- subgraph/core-university/subgraph.yaml (1 hunks)
- subgraph/core/schema.graphql (3 hunks)
- subgraph/core/src/EvidenceModule.ts (1 hunks)
- subgraph/core/subgraph.yaml (1 hunks)
- subgraph/package.json (1 hunks)
- web/src/components/EvidenceCard.tsx (4 hunks)
- web/src/hooks/queries/useEvidences.ts (1 hunks)
- web/src/pages/Cases/CaseDetails/Evidence/EvidenceSearch.tsx (1 hunks)
- web/src/pages/Cases/CaseDetails/Evidence/index.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- web/src/hooks/queries/useEvidences.ts
Additional comments not posted (20)
web/src/pages/Cases/CaseDetails/Evidence/EvidenceSearch.tsx (4)
1-14
: LGTM! Imports are appropriate.The imports are necessary for the functionality provided in this file.
16-31
: LGTM! Styled components are well-defined.The styled components use responsive design principles and are appropriately defined.
33-37
: LGTM! Interface is appropriately defined.The interface defines the props for the
EvidenceSearch
component correctly.
39-69
: LGTM! Functional component is well-structured.The
EvidenceSearch
component is well-structured and uses appropriate hooks and styled components. The logic is clear and concise.subgraph/core/src/EvidenceModule.ts (2)
1-7
: LGTM! Imports are appropriate.The imports are necessary for the functionality provided in this file.
9-61
: LGTM! Function is well-structured.The
handleEvidenceEvent
function is well-structured and includes appropriate error handling. The logic for JSON parsing and extracting fields is clear.web/src/pages/Cases/CaseDetails/Evidence/index.tsx (3)
1-19
: LGTM! Imports are appropriate.The imports are necessary for the functionality provided in this file.
Line range hint
21-55
:
LGTM! Styled components are well-defined.The styled components use responsive design principles and are appropriately defined.
Line range hint
56-118
:
LGTM! Functional component is well-structured.The
Evidence
component is well-structured and uses appropriate hooks and styled components. The logic is clear and concise.web/src/components/EvidenceCard.tsx (3)
Line range hint
1-17
:
LGTM! Imports are appropriate.The imports are necessary for the functionality provided in this file.
126-129
: LGTM! Interface is appropriately defined.The interface defines the props for the
EvidenceCard
component correctly.
Line range hint
131-175
:
LGTM! Functional component is well-structured.The
EvidenceCard
component is well-structured and uses appropriate hooks and styled components. The logic is clear and concise.subgraph/core-university/subgraph.yaml (1)
4-6
: Addition offullTextSearch
feature looks good.The
fullTextSearch
feature has been correctly added to thefeatures
section.subgraph/core-neo/subgraph.yaml (1)
4-6
: Addition offullTextSearch
feature looks good.The
fullTextSearch
feature has been correctly added to thefeatures
section.subgraph/core/subgraph.yaml (1)
4-6
: Addition offullTextSearch
feature looks good.The
fullTextSearch
feature has been correctly added to thefeatures
section.subgraph/core/schema.graphql (3)
55-62
: Addition of new fields toEvidence
type looks good.The new fields
evidenceIndex
,senderAddress
,name
,description
,fileURI
, andfileTypeExtension
have been correctly added to theEvidence
type.
301-312
: Addition of new fields toClassicEvidence
type and immutability looks good.The new fields
evidenceIndex
,senderAddress
,name
,description
,fileURI
, andfileTypeExtension
have been correctly added to theClassicEvidence
type. The immutability of theClassicEvidence
type has been correctly specified.
327-333
: Addition of full-text search schema_Schema_
looks good.The full-text search schema
_Schema_
has been correctly added for searching evidence-related fields.subgraph/package.json (2)
3-3
: Verify the version bump.The version has been updated from
0.5.1
to0.7.0
. Ensure that this aligns with semantic versioning principles and reflects the scope of changes made.
5-5
: LGTM! New script addition.The new script for updating core components related to Arbitrum Sepolia Devnet is correctly defined and consistent with other similar scripts.
more info and context : https://hackmd.io/@-cmxt73kRVi2uFMhhabm4A/BkGylT58R
To be done :-
PR-Codex overview
This PR updates the Kleros v2 subgraph, adds full-text search feature, improves evidence submission handling, and enhances UI components.
Detailed summary
Summary by CodeRabbit
New Features
name
,description
,fileURI
,fileTypeExtension
) to evidence handling.EvidenceSearch
component for enhanced evidence search and submission.Refactor
EvidenceCard
and related components to utilize new evidence fields.Chores
@kleros/kleros-v2-subgraph
from0.5.1
to0.7.0
.