Skip to content

feat(Escrow): add custom buyer to universal contract #121

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 7 commits into from
Aug 2, 2025

Conversation

unknownunknown1
Copy link
Contributor

@unknownunknown1 unknownunknown1 commented Jul 31, 2025

Redo of #117 to make custom buyer the default implementation.

In addition there is a fix for the externalDisputeID to be computed from the hash(contract address, txID) to avoid collision between deployments.

PR-Codex overview

This PR focuses on the removal of the EscrowCustomBuyer contract and related files, along with updates to the EscrowUniversal contract to accommodate changes in transaction creation, specifically allowing custom buyers.

Detailed summary

  • Deleted EscrowCustomBuyer.sol, EscrowCustomBuyer.t.sol, and related deployment files.
  • Updated subgraph.yaml with new address and start block for EscrowUniversal.
  • Modified IEscrow interface to include _buyer parameter in transaction functions.
  • Adjusted EscrowUniversal to use _buyer instead of msg.sender for transactions.
  • Updated tests in EscrowUniversalTest to reflect changes in transaction creation with custom buyers.
  • Incremented version in package.json to 2.2.0.

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

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

Summary by CodeRabbit

  • Improvements

    • All escrow transaction creation now requires explicit buyer and seller addresses, providing greater flexibility in transaction setup.
    • Dispute events now include a unique external dispute identifier for better tracking.
  • Bug Fixes

    • Standardized transaction creation and dispute event emission for improved consistency.
  • Tests

    • Added and updated tests to cover custom buyer scenarios and ensure correct behavior.
    • Removed outdated tests related to the previous custom buyer contract.
  • Chores

    • Removed support and deployment for the separate custom buyer escrow contract.
    • Updated documentation and deployment scripts to reflect removal of the custom buyer contract.

Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for kleros-escrow-v2 ready!

Name Link
🔨 Latest commit 0145664
🔍 Latest deploy log https://app.netlify.com/projects/kleros-escrow-v2/deploys/688d59e50a6f9100080ad077
😎 Deploy Preview https://deploy-preview-121--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 project configuration.

Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

This change removes the EscrowCustomBuyer contract and its associated tests, and instead updates the EscrowUniversal contract and interface to support specifying the buyer address directly in transaction creation functions. All relevant tests are updated to use the new explicit buyer parameter, and event emissions are adjusted for dispute requests.

Changes

Cohort / File(s) Change Summary
Remove EscrowCustomBuyer contract and tests
contracts/src/EscrowCustomBuyer.sol, contracts/test/EscrowCustomBuyer.t.sol
Deleted the EscrowCustomBuyer contract and its test suite, removing all logic and tests related to custom buyer transaction creation.
Update EscrowUniversal to support explicit buyer
contracts/src/EscrowUniversal.sol
Modified transaction creation functions to accept an explicit _buyer parameter instead of using msg.sender. Updated dispute event emission to use a computed externalDisputeID.
Update IEscrow interface
contracts/src/interfaces/IEscrow.sol
Updated function signatures to include an explicit _buyer parameter for transaction creation functions. Added documentation for the new parameter.
Update and extend EscrowUniversal tests
contracts/test/EscrowUniversal.t.sol
Updated all transaction creation calls to pass both buyer and seller addresses. Added new tests for custom buyer scenarios. Adjusted dispute event assertions to use externalDisputeID.
Remove deployment and config for EscrowCustomBuyer
contracts/deploy/00-escrow-custom-buyer.ts, contracts/deploy/shared.ts, contracts/deploy/utils/getContracts.ts
Removed deployment script and configuration entries related to EscrowCustomBuyer. Removed references to EscrowCustomBuyer contract instances in contract fetching utilities.
Update scripts and documentation
contracts/scripts/setDisputeTemplate.ts, contracts/scripts/changeArbitrator.ts, contracts/README.md, contracts/README.md.template
Removed references and deployment instructions related to EscrowCustomBuyer. Simplified scripts to exclude EscrowCustomBuyer. Updated README to reflect removal and new deployed addresses.
Add new deployment artifact
contracts/deployments/arbitrum/PNK.json
Added new deployment JSON for the PNK token contract on Arbitrum, including full ABI and address.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant EscrowUniversal as EscrowUniversal Contract

    Caller->>EscrowUniversal: createNativeTransaction(_deadline, _transactionUri, _buyer, _seller)
    EscrowUniversal->>EscrowUniversal: Store transaction with explicit _buyer and _seller
    EscrowUniversal-->>Caller: Return transactionID

    Caller->>EscrowUniversal: createERC20Transaction(_amount, _token, _deadline, _transactionUri, _buyer, _seller)
    EscrowUniversal->>EscrowUniversal: Transfer tokens, store transaction with _buyer and _seller
    EscrowUniversal-->>Caller: Return transactionID
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Type: Maintenance :construction:, Package: Contracts

Suggested reviewers

  • kemuru

Poem

A hop and a skip, the custom buyer’s gone,
Now universal escrow hops boldly on!
With buyers named clear, not just the sender,
Our carrots are safe—transactions more tender.
Rabbits rejoice, for code is concise,
Explicit is better (that’s rabbit advice)!
🥕✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b2eab81 and 0145664.

📒 Files selected for processing (2)
  • subgraph/package.json (1 hunks)
  • subgraph/subgraph.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • subgraph/package.json
  • subgraph/subgraph.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Redirect rules - kleros-escrow-v2
  • GitHub Check: Redirect rules - kleros-escrow-v2
  • GitHub Check: Header rules - kleros-escrow-v2
  • GitHub Check: Header rules - kleros-escrow-v2
  • GitHub Check: Pages changed - kleros-escrow-v2
  • GitHub Check: Pages changed - kleros-escrow-v2
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/custom-buyer2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 31, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 2, 2025
@jaybuidl jaybuidl merged commit 9fcb1de into dev Aug 2, 2025
5 of 7 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.

2 participants