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

chore: update mappings in create transaction flow #67

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

kemuru
Copy link
Contributor

@kemuru kemuru commented Jun 25, 2024

PR-Codex overview

The PR updates the Escrow Universal contracts and subgraph for Arbitrum Sepolia.

Detailed summary

  • Updated contract addresses and start block in subgraph
  • Removed templateData and templateDataMappings from contracts
  • Updated version in package.json
  • Updated transaction URIs in code
  • Updated contract addresses in deployment files

The following files were skipped due to too many changes: contracts/deployments/arbitrumSepoliaDevnet/EscrowUniversal.json

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

Summary by CodeRabbit

  • New Features

    • Updated transaction handling to support new dispute template and data mappings for escrow transactions.
  • Bug Fixes

    • Corrected the link for the EscrowUniversal contract in the Arbitrum Sepolia section.
  • Documentation

    • Updated contract addresses in the documentation to reflect new changes.
  • Refactor

    • Removed old templateData and templateDataMappings fields from multiple components and contracts.
    • Enhanced the formatting of template URIs for better clarity and consistency.
  • Chores

    • Upgraded the @kleros/escrow-v2-subgraph package version from 2.0.3 to 2.0.4.

Copy link
Contributor

coderabbitai bot commented Jun 25, 2024

Walkthrough

The recent modifications encompass significant updates to the escrow dispute handling, including the restructuring of dispute templates and data mappings, removal of certain fields from the transaction structure, and updates to various associated files. These changes aim to enhance the processing of transaction disputes by streamlining the data structure and improving the integration of dispute templates.

Changes

Files/Paths Change Summary
web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx Transitioned from templateData to disputeTemplate and dataMappings, updating the structure accordingly.
contracts/deploy/00-escrow.ts Adjusted template URIs and extraData formatting, along with whitespace modifications.
contracts/README.md Updated EscrowUniversal contract link in the Arbitrum Sepolia section.
contracts/src/EscrowUniversal.sol Removed assignments to transaction.templateData and transaction.templateDataMappings in two functions.
contracts/src/interfaces/Types.sol Removed templateData and templateDataMappings fields from the Transaction struct.
subgraph/mappings/escrow.ts Removed assignments of templateData and templateDataMappings in the createEscrow function.
subgraph/package.json Updated the version from "2.0.3" to "2.0.4".
subgraph/schema.graphql Removed templateData and templateDataMappings fields from the Escrow type.
subgraph/subgraph.yaml Updated address and startBlock values for the EscrowUniversal data source.
web/src/hooks/queries/useTransactionsQuery.ts Removed templateData and templateDataMappings fields from the transactionFragment query.

Possibly related issues

Poem

In fields of code where data flows,
Template lands where dispute grows.
Changes made to streamline fate,
Mappings trim and forms update.
Escrow’s path now clearer, bright,
Transactions sail in dispute's light.

~ CodeRabbit 🐇💻


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?

Share
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jun 25, 2024

Deploy Preview for kleros-escrow-v2 ready!

Name Link
🔨 Latest commit e258943
🔍 Latest deploy log https://app.netlify.com/sites/kleros-escrow-v2/deploys/667bef83a886b100083281cb
😎 Deploy Preview https://deploy-preview-67--kleros-escrow-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

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

Outside diff range and nitpick comments (1)
web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (1)

120-137: Review and Optimize dataMappings Configuration

The dataMappings configuration includes GraphQL and IPFS fetch types, which are crucial for fetching and populating data in the escrow transaction. Ensure that:

  1. The GraphQL endpoint and IPFS URI are securely configured and not susceptible to injection attacks.
  2. The populate and seek fields are correctly implemented to map the necessary data without redundancy or errors.

Consider adding error handling for the data fetch operations to manage cases where the external data sources might not be available or return errors.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9a56ba0 and e8bbece.

Files selected for processing (1)
  • web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (2 hunks)
Additional context used
Learnings (1)
web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (2)
User: kemuru
PR: kleros/escrow-v2#60
File: web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx:180-180
Timestamp: 2024-06-11T17:11:32.906Z
Learning: The `refetchAllowance` function call is necessary in the `DepositPaymentButton` component to ensure the frontend updates correctly after an approval action.
User: kemuru
PR: kleros/escrow-v2#60
File: web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx:63-64
Timestamp: 2024-06-11T17:14:13.327Z
Learning: Errors in the `useContractRead` hook for ERC20 token allowance checks in the `DepositPaymentButton` component are managed by the `wrapWithToast()` function, which logs errors in a notification popup. Additionally, the quantity for the approval is pre-validated and stored in the context of the NewTransactionContext.

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

Outside diff range and nitpick comments (1)
web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (1)

120-137: Review and Optimize dataMappings Configuration

The dataMappings configuration includes GraphQL and IPFS fetch types, which are crucial for fetching and populating data in the escrow transaction. Ensure that:

  1. The GraphQL endpoint and IPFS URI are securely configured and not susceptible to injection attacks.
  2. The populate and seek fields are correctly implemented to map the necessary data without redundancy or errors.

Consider adding error handling for the data fetch operations to manage cases where the external data sources might not be available or return errors.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9a56ba0 and e8bbece.

Files selected for processing (1)
  • web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (2 hunks)
Additional context used
Learnings (1)
web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (2)
User: kemuru
PR: kleros/escrow-v2#60
File: web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx:180-180
Timestamp: 2024-06-11T17:11:32.906Z
Learning: The `refetchAllowance` function call is necessary in the `DepositPaymentButton` component to ensure the frontend updates correctly after an approval action.
User: kemuru
PR: kleros/escrow-v2#60
File: web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx:63-64
Timestamp: 2024-06-11T17:14:13.327Z
Learning: Errors in the `useContractRead` hook for ERC20 token allowance checks in the `DepositPaymentButton` component are managed by the `wrapWithToast()` function, which logs errors in a notification popup. Additionally, the quantity for the approval is pre-validated and stored in the context of the NewTransactionContext.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 25, 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e8bbece and 7949f22.

Files selected for processing (2)
  • contracts/deploy/00-escrow.ts (4 hunks)
  • web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (2 hunks)
Files not reviewed due to errors (1)
  • web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (no review received)
Files skipped from review due to trivial changes (1)
  • contracts/deploy/00-escrow.ts
Additional context used
Learnings (1)
web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (2)
User: kemuru
PR: kleros/escrow-v2#60
File: web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx:180-180
Timestamp: 2024-06-11T17:11:32.906Z
Learning: The `refetchAllowance` function call is necessary in the `DepositPaymentButton` component to ensure the frontend updates correctly after an approval action.
User: kemuru
PR: kleros/escrow-v2#60
File: web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx:63-64
Timestamp: 2024-06-11T17:14:13.327Z
Learning: Errors in the `useContractRead` hook for ERC20 token allowance checks in the `DepositPaymentButton` component are managed by the `wrapWithToast()` function, which logs errors in a notification popup. Additionally, the quantity for the approval is pre-validated and stored in the context of the NewTransactionContext.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 25, 2024
@kemuru kemuru requested a review from jaybuidl June 25, 2024 14:13
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (3)
contracts/src/EscrowUniversal.sol (3)

Line range hint 56-71: Review of Constructor Initialization and Event Emission

The constructor correctly initializes contract state variables and sets the initial dispute template. However, the event ParameterUpdated is emitted with potentially uninitialized values. Consider ensuring all parameters are initialized before emitting this event to provide accurate and meaningful logs.

+ emit ParameterUpdated(_feeTimeout, _settlementTimeout, _arbitratorExtraData);
- emit ParameterUpdated(feeTimeout, settlementTimeout, arbitratorExtraData);

Line range hint 156-178: Review of Native Currency Transaction Creation: createNativeTransaction

This method is well-implemented with clear logic for creating a native transaction. It correctly handles the initialization and emits relevant events. However, consider checking for reentrancy attacks as native currency transfers are involved.

Consider using the nonReentrant modifier from OpenZeppelin's contracts to guard against reentrancy vulnerabilities.


Line range hint 270-298: Critical Review of Transaction Execution Logic: executeTransaction

The method executeTransaction correctly checks transaction deadlines and dispute status before proceeding. This is crucial for avoiding execution in invalid states. However, the direct use of .send for ether transfers is risky and might lead to unexpected failures.

Consider using .transfer for safer ETH transfers or better yet, the call method with proper checks as recommended by recent Solidity patterns to prevent issues related to gas stipends.

- transaction.seller.send(amount);
+ (bool sent, ) = transaction.seller.call{value: amount}("");
+ require(sent, "Failed to send Ether");
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7949f22 and e258943.

Files selected for processing (9)
  • contracts/README.md (1 hunks)
  • contracts/src/EscrowUniversal.sol (2 hunks)
  • contracts/src/interfaces/Types.sol (1 hunks)
  • subgraph/mappings/escrow.ts (1 hunks)
  • subgraph/package.json (1 hunks)
  • subgraph/schema.graphql (1 hunks)
  • subgraph/subgraph.yaml (1 hunks)
  • web/src/hooks/queries/useTransactionsQuery.ts (1 hunks)
  • web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (2 hunks)
Files not reviewed due to errors (1)
  • subgraph/mappings/escrow.ts (no review received)
Files skipped from review due to trivial changes (3)
  • subgraph/package.json
  • subgraph/schema.graphql
  • web/src/hooks/queries/useTransactionsQuery.ts
Additional context used
Learnings (1)
web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx (2)
User: kemuru
PR: kleros/escrow-v2#60
File: web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx:180-180
Timestamp: 2024-06-11T17:11:32.906Z
Learning: The `refetchAllowance` function call is necessary in the `DepositPaymentButton` component to ensure the frontend updates correctly after an approval action.
User: kemuru
PR: kleros/escrow-v2#60
File: web/src/pages/NewTransaction/NavigationButtons/DepositPaymentButton.tsx:63-64
Timestamp: 2024-06-11T17:14:13.327Z
Learning: Errors in the `useContractRead` hook for ERC20 token allowance checks in the `DepositPaymentButton` component are managed by the `wrapWithToast()` function, which logs errors in a notification popup. Additionally, the quantity for the approval is pre-validated and stored in the context of the NewTransactionContext.
LanguageTool
contracts/README.md

[uncategorized] ~69-~69: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... env vars are required: - PRIVATE_KEY: the private key of the deployer account...


[uncategorized] ~70-~70: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...or the testnets. - MAINNET_PRIVATE_KEY: the private key of the deployer account...


[uncategorized] ~71-~71: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...unt used for Mainnet. - INFURA_API_KEY: the API key for infura. The ones below...


[uncategorized] ~75-~75: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...low are optional: - ETHERSCAN_API_KEY: to verify the source of the newly deplo...


[uncategorized] ~76-~76: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...s on Etherscan. - ARBISCAN_API_KEY: to verify the source of the newly deplo...


[uncategorized] ~77-~77: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... on Arbitrum. - GNOSISSCAN_API_KEY: to verify the source of the newly deplo...


[uncategorized] ~81-~81: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE_2)
Context: ...ed for the kleros-v2 contracts currently so this would fail. For now consider deplo...


[typographical] ~81-~81: Consider adding a comma here. (FOR_NOW_COMMA)
Context: ...contracts currently so this would fail. For now consider deploying to a testnet fork (n...


[grammar] ~89-~89: The word ‘deploy’ is a verb. Did you mean the noun “deployment” (= release, placement)? (PREPOSITION_VERB)
Context: ...node --tags nothing **Shell 2: the deploy script** bash yarn deploy --network...


[grammar] ~105-~105: The word ‘deploy’ is a verb. Did you mean the noun “deployment” (= release, placement)? (PREPOSITION_VERB)
Context: ... start-testnet-fork **Shell 2: the deploy script** bash yarn deploy-devnet-fo...

Markdownlint
contracts/README.md

12-12: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


15-15: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


9-9: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


10-10: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


16-16: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


17-17: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


83-83: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


89-89: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


97-97: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


105-105: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


127-127: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading


133-133: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading

Additional comments not posted (1)
contracts/src/EscrowUniversal.sol (1)

Line range hint 74-76: Governance Method Review: changeGovernor

The implementation of changeGovernor is secure and follows best practices by using the onlyByGovernor modifier to restrict access.

@jaybuidl jaybuidl merged commit 6e3fbb7 into master Jun 26, 2024
6 checks passed
@jaybuidl jaybuidl deleted the chore/update-mappings-in-create-transaction-flow branch June 26, 2024 10:51
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.

2 participants