-
Notifications
You must be signed in to change notification settings - Fork 14
feat: Use custom errors when receiveApproval fails and set callbackgas to 200k #331
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
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.
Pull request overview
This PR modernizes error handling in the receiveApproval flow by replacing string-based revert messages with custom Solidity errors, improving gas efficiency and error handling clarity. It also refactors utility functions for better code organization, removing the deprecated encodeOrders helper in favor of using ethers.js's built-in populateTransaction method.
Key Changes:
- Introduced three custom errors (
UnsupportedOperation,OperationFailed,CallerIsNotTheRequester) to replace string-based reverts in the escrow token functionality - Refactored
signStructto return the signature string directly instead of mutating and returning the message object - Removed the
encodeOrdersutility function and replaced its usage with a cleanermatchOrdersCalldatahelper function in tests
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/odb-tools.ts | Simplified signStruct to return signature directly; removed unused encodeOrders function and eth_signTypedData wrapper |
| utils/createOrders.ts | Updated signOrder and signOrderOperation to mutate objects in-place rather than returning new objects |
| test/byContract/IexecEscrow/IexecEscrowToken-receiveApproval.test.ts | Updated all test assertions to use revertedWithCustomError; added matchOrdersCalldata helper to replace encodeOrders |
| contracts/interfaces/IexecEscrowToken.sol | Added three custom error definitions for improved error handling |
| contracts/facets/IexecEscrowTokenFacet.sol | Replaced string-based reverts with custom errors; improved code formatting and documentation clarity |
| abis/human-readable-abis/contracts/interfaces/IexecEscrowToken.sol/IexecEscrowToken.json | Added custom error entries to human-readable ABI |
| abis/human-readable-abis/contracts/facets/IexecEscrowTokenFacet.sol/IexecEscrowTokenFacet.json | Added custom error entries to human-readable ABI |
| abis/human-readable-abis/contracts/IexecInterfaceToken.sol/IexecInterfaceToken.json | Added custom error entries to human-readable ABI |
| abis/contracts/interfaces/IexecEscrowToken.json | Added full custom error definitions to standard ABI |
| abis/contracts/facets/IexecEscrowTokenFacet.json | Added full custom error definitions to standard ABI |
| abis/contracts/IexecInterfaceToken.json | Added full custom error definitions to standard ABI |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/byContract/IexecEscrow/IexecEscrowToken-receiveApproval.test.ts
Outdated
Show resolved
Hide resolved
test/byContract/IexecEscrow/IexecEscrowToken-receiveApproval.test.ts
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #331 +/- ##
=======================================
Coverage 96.38% 96.39%
=======================================
Files 33 33
Lines 1135 1136 +1
Branches 214 214
=======================================
+ Hits 1094 1095 +1
Misses 41 41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.