-
Notifications
You must be signed in to change notification settings - Fork 27
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
fix: Rename plugin to module #106
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -5,16 +5,16 @@ import {EnumerableMap} from "@openzeppelin/contracts/utils/structs/EnumerableMap | |
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; | ||
|
||
import {ExecutionHook} from "../interfaces/IAccountLoupe.sol"; | ||
import {PluginEntity} from "../interfaces/IPluginManager.sol"; | ||
import {ModuleEntity} from "../interfaces/IModuleManager.sol"; | ||
|
||
// bytes = keccak256("ERC6900.UpgradeableModularAccount.Storage") | ||
bytes32 constant _ACCOUNT_STORAGE_SLOT = 0x9f09680beaa4e5c9f38841db2460c401499164f368baef687948c315d9073e40; | ||
|
||
// Represents data associated with a specifc function selector. | ||
struct SelectorData { | ||
// The plugin that implements this execution function. | ||
// The module that implements this execution function. | ||
// If this is a native function, the address must remain address(0). | ||
address plugin; | ||
address module; | ||
// Whether or not the function needs runtime validation, or can be called by anyone. The function can still be | ||
// state changing if this flag is set to true. | ||
// Note that even if this is set to true, user op validation will still be required, otherwise anyone could | ||
|
@@ -32,7 +32,7 @@ struct ValidationData { | |
// Whether or not this validation is a signature validator. | ||
bool isSignatureValidation; | ||
// The pre validation hooks for this validation function. | ||
PluginEntity[] preValidationHooks; | ||
ModuleEntity[] preValidationHooks; | ||
// Permission hooks for this validation function. | ||
EnumerableSet.Bytes32Set permissionHooks; | ||
// The set of selectors that may be validated by this validation function. | ||
|
@@ -43,11 +43,11 @@ struct AccountStorage { | |
// AccountStorageInitializable variables | ||
uint8 initialized; | ||
bool initializing; | ||
// Plugin metadata storage | ||
EnumerableMap.AddressToUintMap pluginManifestHashes; | ||
// Module metadata storage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is outdated, todo: update |
||
EnumerableMap.AddressToUintMap moduleManifestHashes; | ||
// Execution functions and their associated functions | ||
mapping(bytes4 => SelectorData) selectorData; | ||
mapping(PluginEntity validationFunction => ValidationData) validationData; | ||
mapping(ModuleEntity validationFunction => ValidationData) validationData; | ||
// For ERC165 introspection | ||
mapping(bytes4 => uint256) supportedIfaces; | ||
} | ||
|
@@ -60,30 +60,30 @@ function getAccountStorage() pure returns (AccountStorage storage _storage) { | |
|
||
using EnumerableSet for EnumerableSet.Bytes32Set; | ||
|
||
function toSetValue(PluginEntity pluginEntity) pure returns (bytes32) { | ||
return bytes32(PluginEntity.unwrap(pluginEntity)); | ||
function toSetValue(ModuleEntity moduleEntity) pure returns (bytes32) { | ||
return bytes32(ModuleEntity.unwrap(moduleEntity)); | ||
} | ||
|
||
function toPluginEntity(bytes32 setValue) pure returns (PluginEntity) { | ||
return PluginEntity.wrap(bytes24(setValue)); | ||
function toModuleEntity(bytes32 setValue) pure returns (ModuleEntity) { | ||
return ModuleEntity.wrap(bytes24(setValue)); | ||
} | ||
|
||
// ExecutionHook layout: | ||
// 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF______________________ Hook Plugin Entity | ||
// 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF______________________ Hook Module Entity | ||
// 0x________________________________________________AA____________________ is pre hook | ||
// 0x__________________________________________________BB__________________ is post hook | ||
|
||
function toSetValue(ExecutionHook memory executionHook) pure returns (bytes32) { | ||
return bytes32(PluginEntity.unwrap(executionHook.hookFunction)) | ||
return bytes32(ModuleEntity.unwrap(executionHook.hookFunction)) | ||
| bytes32(executionHook.isPreHook ? uint256(1) << 56 : 0) | ||
| bytes32(executionHook.isPostHook ? uint256(1) << 48 : 0); | ||
} | ||
|
||
function toExecutionHook(bytes32 setValue) | ||
pure | ||
returns (PluginEntity hookFunction, bool isPreHook, bool isPostHook) | ||
returns (ModuleEntity hookFunction, bool isPreHook, bool isPostHook) | ||
{ | ||
hookFunction = PluginEntity.wrap(bytes24(setValue)); | ||
hookFunction = ModuleEntity.wrap(bytes24(setValue)); | ||
isPreHook = (uint256(setValue) >> 56) & 0xFF == 1; | ||
isPostHook = (uint256(setValue) >> 48) & 0xFF == 1; | ||
} | ||
|
@@ -97,12 +97,12 @@ function toSelector(bytes32 setValue) pure returns (bytes4) { | |
} | ||
|
||
/// @dev Helper function to get all elements of a set into memory. | ||
function toPluginEntityArray(EnumerableSet.Bytes32Set storage set) view returns (PluginEntity[] memory) { | ||
function toModuleEntityArray(EnumerableSet.Bytes32Set storage set) view returns (ModuleEntity[] memory) { | ||
uint256 length = set.length(); | ||
PluginEntity[] memory result = new PluginEntity[](length); | ||
ModuleEntity[] memory result = new ModuleEntity[](length); | ||
for (uint256 i = 0; i < length; ++i) { | ||
bytes32 key = set.at(i); | ||
result[i] = PluginEntity.wrap(bytes24(key)); | ||
result[i] = ModuleEntity.wrap(bytes24(key)); | ||
} | ||
return result; | ||
} |
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.
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.
Minor note/todo: we should consider if having modules be on this repo is the way to go, or if we should split them out into another repo (long term)
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.
Yeah I think we've already started encouraging people to put these in their own repos or in https://github.com/erc6900/sample-plugins, to make the maintenance load easier. The README has some other out-of-date things, too.
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.
Yeah, gonna remove the add modules part.