-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add ERC7821 to Account.sol #49
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
42906dc
Add batch execution in `Account.sol`
Amxx 2d1f99e
implement ERC7821
Amxx a97dc77
simplify tests
Amxx 6747217
documentation
Amxx d93e0b5
0.8.20 compliance
Amxx c397b8b
test naming
Amxx d306c57
Update AccountERC7821.sol
Amxx 02a2113
Review
ernestognw 8b9fcac
Fix tests
ernestognw b3d5152
revert lib
ernestognw c349719
Add changelog entry
ernestognw dce8151
Merge branch 'master' into aa/executeUserOp-delegate
ernestognw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import {ERC7579Utils, Mode, CallType, ExecType, ModeSelector} from "@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol"; | ||
import {IERC7821} from "../../interfaces/IERC7821.sol"; | ||
import {AccountCore} from "../AccountCore.sol"; | ||
|
||
/** | ||
* @dev Minimal batch executor following ERC7821. Only supports basic mode (no optional "opData"). | ||
*/ | ||
abstract contract AccountERC7821 is AccountCore, IERC7821 { | ||
using ERC7579Utils for *; | ||
|
||
error UnsupportedExecutionMode(); | ||
|
||
/// @inheritdoc IERC7821 | ||
function execute(bytes32 mode, bytes calldata executionData) public payable virtual onlyEntryPointOrSelf { | ||
if (!supportsExecutionMode(mode)) revert UnsupportedExecutionMode(); | ||
executionData.execBatch(ERC7579Utils.EXECTYPE_DEFAULT); | ||
} | ||
|
||
/// @inheritdoc IERC7821 | ||
function supportsExecutionMode(bytes32 mode) public view virtual returns (bool result) { | ||
(CallType callType, ExecType execType, ModeSelector modeSelector, ) = Mode.wrap(mode).decodeMode(); | ||
return | ||
callType == ERC7579Utils.CALLTYPE_BATCH && | ||
execType == ERC7579Utils.EXECTYPE_DEFAULT && | ||
modeSelector == ModeSelector.wrap(0x00000000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
/** | ||
* @dev Interface for minimal batch executor. | ||
*/ | ||
interface IERC7821 { | ||
/** | ||
* @dev Executes the calls in `executionData`. | ||
* Reverts and bubbles up error if any call fails. | ||
* | ||
* `executionData` encoding: | ||
* - If `opData` is empty, `executionData` is simply `abi.encode(calls)`. | ||
* - Else, `executionData` is `abi.encode(calls, opData)`. | ||
* See: https://eips.ethereum.org/EIPS/eip-7579 | ||
* | ||
* Supported modes: | ||
* - `bytes32(0x01000000000000000000...)`: does not support optional `opData`. | ||
* - `bytes32(0x01000000000078210001...)`: supports optional `opData`. | ||
* | ||
* Authorization checks: | ||
* - If `opData` is empty, the implementation SHOULD require that | ||
* `msg.sender == address(this)`. | ||
* - If `opData` is not empty, the implementation SHOULD use the signature | ||
* encoded in `opData` to determine if the caller can perform the execution. | ||
* | ||
* `opData` may be used to store additional data for authentication, | ||
* paymaster data, gas limits, etc. | ||
*/ | ||
function execute(bytes32 mode, bytes calldata executionData) external payable; | ||
|
||
/** | ||
* @dev This function is provided for frontends to detect support. | ||
* Only returns true for: | ||
* - `bytes32(0x01000000000000000000...)`: does not support optional `opData`. | ||
* - `bytes32(0x01000000000078210001...)`: supports optional `opData`. | ||
*/ | ||
function supportsExecutionMode(bytes32 mode) external view returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think the best option right now is to get rid of this function. The Account.sol won't be able to send individual calls anyway and the
IAccountExecute
interface is optional.I understand someone may want to use this function to validate userOp fields, but I don't see that as common. At this point I'd just remove it and leave ERC7821