Skip to content

Commit

Permalink
fix: update interface comments and pluginInitData parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypaik committed Jan 23, 2024
1 parent e68ad9a commit f7fb5ff
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 128 deletions.
4 changes: 2 additions & 2 deletions src/account/PluginManagerInternals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ abstract contract PluginManagerInternals is IPluginManager, AccountStorageV1 {
function _installPlugin(
address plugin,
bytes32 manifestHash,
bytes memory pluginInitData,
bytes memory pluginInstallData,
FunctionReference[] memory dependencies
) internal {
AccountStorage storage storage_ = _getAccountStorage();
Expand Down Expand Up @@ -469,7 +469,7 @@ abstract contract PluginManagerInternals is IPluginManager, AccountStorageV1 {

// Initialize the plugin storage for the account.
// solhint-disable-next-line no-empty-blocks
try IPlugin(plugin).onInstall(pluginInitData) {}
try IPlugin(plugin).onInstall(pluginInstallData) {}
catch (bytes memory revertReason) {
revert PluginInstallCallbackFailed(plugin, revertReason);
}
Expand Down
4 changes: 2 additions & 2 deletions src/account/UpgradeableModularAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ contract UpgradeableModularAccount is
function installPlugin(
address plugin,
bytes32 manifestHash,
bytes calldata pluginInitData,
bytes calldata pluginInstallData,
FunctionReference[] calldata dependencies
) external override {
(FunctionReference[][] memory postExecHooks, bytes[] memory postHookArgs) = _preNativeFunction();
_installPlugin(plugin, manifestHash, pluginInitData, dependencies);
_installPlugin(plugin, manifestHash, pluginInstallData, dependencies);
_postNativeFunction(postExecHooks, postHookArgs);
}

Expand Down
8 changes: 4 additions & 4 deletions src/interfaces/IAccountInitializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity ^0.8.22;

/// @title Account Initializable Interface
interface IAccountInitializable {
/// @notice Initializes the account with a set of plugins
/// @dev No dependencies or hooks can be injected with this installation
/// @param plugins The plugins to install
/// @param pluginInitData The plugin init data for each plugin
/// @notice Initialize the account with a set of plugins.
/// @dev No dependencies or hooks can be injected with this installation.
/// @param plugins The plugins to install.
/// @param pluginInitData The plugin init data for each plugin.
function initialize(address[] calldata plugins, bytes calldata pluginInitData) external;
}
32 changes: 16 additions & 16 deletions src/interfaces/IAccountLoupe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@ import {FunctionReference} from "./IPluginManager.sol";

/// @title Account Loupe Interface
interface IAccountLoupe {
/// @notice Config for an execution function, given a selector
/// @notice Config for an execution function, given a selector.
struct ExecutionFunctionConfig {
address plugin;
FunctionReference userOpValidationFunction;
FunctionReference runtimeValidationFunction;
}

/// @notice Pre and post hooks for a given selector
/// @dev It's possible for one of either `preExecHook` or `postExecHook` to be empty
/// @notice Pre and post hooks for a given selector.
/// @dev It's possible for one of either `preExecHook` or `postExecHook` to be empty.
struct ExecutionHooks {
FunctionReference preExecHook;
FunctionReference postExecHook;
}

/// @notice Gets the validation functions and plugin address for a selector
/// @dev If the selector is a native function, the plugin address will be the address of the account
/// @param selector The selector to get the configuration for
/// @return The configuration for this selector
/// @notice Get the validation functions and plugin address for a selector.
/// @dev If the selector is a native function, the plugin address will be the address of the account.
/// @param selector The selector to get the configuration for.
/// @return The configuration for this selector.
function getExecutionFunctionConfig(bytes4 selector) external view returns (ExecutionFunctionConfig memory);

/// @notice Gets the pre and post execution hooks for a selector
/// @param selector The selector to get the hooks for
/// @return The pre and post execution hooks for this selector
/// @notice Get the pre and post execution hooks for a selector.
/// @param selector The selector to get the hooks for.
/// @return The pre and post execution hooks for this selector.
function getExecutionHooks(bytes4 selector) external view returns (ExecutionHooks[] memory);

/// @notice Gets the pre user op and runtime validation hooks associated with a selector
/// @param selector The selector to get the hooks for
/// @return preUserOpValidationHooks The pre user op validation hooks for this selector
/// @return preRuntimeValidationHooks The pre runtime validation hooks for this selector
/// @notice Get the pre user op and runtime validation hooks associated with a selector.
/// @param selector The selector to get the hooks for.
/// @return preUserOpValidationHooks The pre user op validation hooks for this selector.
/// @return preRuntimeValidationHooks The pre runtime validation hooks for this selector.
function getPreValidationHooks(bytes4 selector)
external
view
Expand All @@ -42,7 +42,7 @@ interface IAccountLoupe {
FunctionReference[] memory preRuntimeValidationHooks
);

/// @notice Gets an array of all installed plugins
/// @return The addresses of all installed plugins
/// @notice Get an array of all installed plugins.
/// @return The addresses of all installed plugins.
function getInstalledPlugins() external view returns (address[] memory);
}
6 changes: 3 additions & 3 deletions src/interfaces/IAccountView.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {IEntryPoint} from "./erc4337/IEntryPoint.sol";

/// @title Account View Interface
interface IAccountView {
/// @notice Gets the entry point for this account
/// @return entryPoint The entry point for this account
/// @notice Get the entry point for this account.
/// @return entryPoint The entry point for this account.
function entryPoint() external view returns (IEntryPoint);

/// @notice Get the account nonce.
/// @dev uses key 0
/// @dev Uses key 0.
/// @return nonce The next account nonce.
function getNonce() external view returns (uint256);
}
52 changes: 27 additions & 25 deletions src/interfaces/IPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,9 @@ struct ManifestExternalCallPermission {
bytes4[] selectors;
}

/// @dev A struct describing how the plugin should be installed on a modular account.
struct PluginManifest {
// List of ERC-165 interfaceIds to add to account to support introspection checks.
bytes4[] interfaceIds;
// If this plugin depends on other plugins' validation functions, the interface IDs of
// those plugins MUST be provided here, with its position in the array matching the `dependencyIndex`
// members of `ManifestFunction` structs used in the manifest.
bytes4[] dependencyInterfaceIds;
// Execution functions defined in this plugin to be installed on the MSCA.
bytes4[] executionFunctions;
// Plugin execution functions already installed on the MSCA that this plugin will be able to call.
bytes4[] permittedExecutionSelectors;
// External addresses that this plugin will be able to call.
bool permitAnyExternalAddress;
// boolean to indicate whether the plugin needs access to spend native tokens of the account
bool canSpendNativeToken;
ManifestExternalCallPermission[] permittedExternalCalls;
ManifestAssociatedFunction[] userOpValidationFunctions;
ManifestAssociatedFunction[] runtimeValidationFunctions;
ManifestAssociatedFunction[] preUserOpValidationHooks;
ManifestAssociatedFunction[] preRuntimeValidationHooks;
ManifestExecutionHook[] executionHooks;
struct SelectorPermission {
bytes4 functionSelector;
string permissionDescription;
}

/// @dev A struct holding fields to describe the plugin in a purely view context. Intended for front end clients.
Expand All @@ -90,9 +71,30 @@ struct PluginMetadata {
SelectorPermission[] permissionDescriptors;
}

struct SelectorPermission {
bytes4 functionSelector;
string permissionDescription;
/// @dev A struct describing how the plugin should be installed on a modular account.
struct PluginManifest {
// List of ERC-165 interface IDs to add to account to support introspection checks. This MUST NOT include
// IPlugin's interface ID.
bytes4[] interfaceIds;
// If this plugin depends on other plugins' validation functions, the interface IDs of those plugins MUST be
// provided here, with its position in the array matching the `dependencyIndex` members of `ManifestFunction`
// structs used in the manifest.
bytes4[] dependencyInterfaceIds;
// Execution functions defined in this plugin to be installed on the MSCA.
bytes4[] executionFunctions;
// Plugin execution functions already installed on the MSCA that this plugin will be able to call.
bytes4[] permittedExecutionSelectors;
// Boolean to indicate whether the plugin can call any external address.
bool permitAnyExternalAddress;
// Boolean to indicate whether the plugin needs access to spend native tokens of the account. If false, the
// plugin MUST still be able to spend up to the balance that it sends to the account in the same call.
bool canSpendNativeToken;
ManifestExternalCallPermission[] permittedExternalCalls;
ManifestAssociatedFunction[] userOpValidationFunctions;
ManifestAssociatedFunction[] runtimeValidationFunctions;
ManifestAssociatedFunction[] preUserOpValidationHooks;
ManifestAssociatedFunction[] preRuntimeValidationHooks;
ManifestExecutionHook[] executionHooks;
}

/// @title Plugin Interface
Expand Down
18 changes: 9 additions & 9 deletions src/interfaces/IPluginExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ pragma solidity ^0.8.22;

/// @title Plugin Executor Interface
interface IPluginExecutor {
/// @notice Method from calls made from plugins to other plugin execution functions. Plugins are not allowed to
/// call accounts native functions.
/// @dev Permissions must be granted to the calling plugin for the call to go through
/// @param data The call data for the call.
/// @notice Execute a call from a plugin to another plugin, via an execution function installed on the account.
/// @dev Plugins are not allowed to call native functions on the account. Permissions must be granted to the
/// calling plugin for the call to go through.
/// @param data The calldata to send to the plugin.
/// @return The return data from the call.
function executeFromPlugin(bytes calldata data) external payable returns (bytes memory);

/// @notice Method from calls made from plugins to external addresses.
/// @notice Execute a call from a plugin to a non-plugin address.
/// @dev If the target is a plugin, the call SHOULD revert. Permissions must be granted to the calling plugin
/// for the call to go through
/// for the call to go through.
/// @param target The address to be called.
/// @param value The value to pass.
/// @param data The data to pass.
/// @return The result of the call
/// @param value The value to send with the call.
/// @param data The calldata to send to the target.
/// @return The return data from the call.
function executeFromPluginExternal(address target, uint256 value, bytes calldata data)
external
payable
Expand Down
10 changes: 5 additions & 5 deletions src/interfaces/IPluginManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ type FunctionReference is bytes21;
interface IPluginManager {
event PluginInstalled(address indexed plugin, bytes32 manifestHash, FunctionReference[] dependencies);
event PluginUninstalled(address indexed plugin, bool indexed callbacksSucceeded);
event PluginIgnoredHookUnapplyCallbackFailure(address indexed plugin, address indexed providingPlugin);
event PluginIgnoredUninstallCallbackFailure(address indexed plugin);

/// @notice Install a plugin to the modular account.
/// @param plugin The plugin to install.
/// @param manifestHash The hash of the plugin manifest.
/// @param pluginInitData Optional data to be decoded and used by the plugin to setup initial plugin data for
/// the modular account.
/// @param dependencies The dependencies of the plugin, as described in the manifest.
/// @param pluginInstallData Optional data to be decoded and used by the plugin to setup initial plugin data
/// for the modular account.
/// @param dependencies The dependencies of the plugin, as described in the manifest. Each FunctionReference
/// MUST be composed of an installed plugin's address and a function ID of its validation function.
function installPlugin(
address plugin,
bytes32 manifestHash,
bytes calldata pluginInitData,
bytes calldata pluginInstallData,
FunctionReference[] calldata dependencies
) external;

Expand Down
12 changes: 6 additions & 6 deletions src/interfaces/IStandardExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
pragma solidity ^0.8.22;

struct Call {
// The target address for account to call.
// The target address for the account to call.
address target;
// The value sent with the call.
uint256 value;
// The call data for the call.
// The calldata for the call.
bytes data;
}

/// @title Standard Executor Interface
interface IStandardExecutor {
/// @notice Standard execute method.
/// @dev If the target is a plugin, the call SHOULD revert.
/// @param target The target address for account to call.
/// @param target The target address for the account to call.
/// @param value The value sent with the call.
/// @param data The call data for the call.
/// @param data The calldata for the call.
/// @return The return data from the call.
function execute(address target, uint256 value, bytes calldata data) external payable returns (bytes memory);

/// @notice Standard executeBatch method.
/// @dev If the target is a plugin, the call SHOULD revert. If any of the transactions revert, the entire batch
/// reverts
/// @dev If the target is a plugin, the call SHOULD revert. If any of the calls revert, the entire batch MUST
/// revert.
/// @param calls The array of calls.
/// @return An array containing the return data from the calls.
function executeBatch(Call[] calldata calls) external payable returns (bytes[] memory);
Expand Down
4 changes: 2 additions & 2 deletions test/account/AccountExecHooks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ contract UpgradeableModularAccountExecHooksTest is Test {
account1.installPlugin({
plugin: address(mockPlugin1),
manifestHash: manifestHash1,
pluginInitData: bytes(""),
pluginInstallData: bytes(""),
dependencies: new FunctionReference[](0)
});

Expand Down Expand Up @@ -486,7 +486,7 @@ contract UpgradeableModularAccountExecHooksTest is Test {
account1.installPlugin({
plugin: address(mockPlugin2),
manifestHash: manifestHash2,
pluginInitData: bytes(""),
pluginInstallData: bytes(""),
dependencies: dependencies
});

Expand Down
8 changes: 4 additions & 4 deletions test/account/AccountPreValidationHooks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ contract UpgradeableModularAccountPreValidationHooksTest is Test {
account1.installPlugin({
plugin: address(mockPlugin1),
manifestHash: manifestHash1,
pluginInitData: bytes(""),
pluginInstallData: bytes(""),
dependencies: new FunctionReference[](0)
});

Expand Down Expand Up @@ -597,7 +597,7 @@ contract UpgradeableModularAccountPreValidationHooksTest is Test {
account1.installPlugin({
plugin: address(mockPlugin2),
manifestHash: manifestHash2,
pluginInitData: bytes(""),
pluginInstallData: bytes(""),
dependencies: dependencies
});

Expand Down Expand Up @@ -634,7 +634,7 @@ contract UpgradeableModularAccountPreValidationHooksTest is Test {
account1.installPlugin({
plugin: address(mockPlugin1),
manifestHash: manifestHash1,
pluginInitData: bytes(""),
pluginInstallData: bytes(""),
dependencies: dependencies
});
}
Expand All @@ -659,7 +659,7 @@ contract UpgradeableModularAccountPreValidationHooksTest is Test {
account1.installPlugin({
plugin: address(mockPlugin2),
manifestHash: manifestHash2,
pluginInitData: bytes(""),
pluginInstallData: bytes(""),
dependencies: dependencies
});
}
Expand Down
4 changes: 2 additions & 2 deletions test/account/AccountReturnData.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ contract AccountReturnDataTest is Test {
account.installPlugin({
plugin: address(resultCreatorPlugin),
manifestHash: resultCreatorManifestHash,
pluginInitData: "",
pluginInstallData: "",
dependencies: new FunctionReference[](0)
});
// Add the result consumer plugin to the account
bytes32 resultConsumerManifestHash = keccak256(abi.encode(resultConsumerPlugin.pluginManifest()));
account.installPlugin({
plugin: address(resultConsumerPlugin),
manifestHash: resultConsumerManifestHash,
pluginInitData: "",
pluginInstallData: "",
dependencies: new FunctionReference[](0)
});
}
Expand Down
10 changes: 5 additions & 5 deletions test/account/ExecuteFromPluginPermissions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ contract ExecuteFromPluginPermissionsTest is Test {
account.installPlugin({
plugin: address(resultCreatorPlugin),
manifestHash: resultCreatorManifestHash,
pluginInitData: "",
pluginInstallData: "",
dependencies: new FunctionReference[](0)
});
// Add the EFP caller plugin to the account
bytes32 efpCallerManifestHash = keccak256(abi.encode(efpCallerPlugin.pluginManifest()));
account.installPlugin({
plugin: address(efpCallerPlugin),
manifestHash: efpCallerManifestHash,
pluginInitData: "",
pluginInstallData: "",
dependencies: new FunctionReference[](0)
});

Expand All @@ -107,7 +107,7 @@ contract ExecuteFromPluginPermissionsTest is Test {
account.installPlugin({
plugin: address(efpCallerPluginAnyExternal),
manifestHash: efpCallerAnyExternalManifestHash,
pluginInitData: "",
pluginInstallData: "",
dependencies: new FunctionReference[](0)
});

Expand All @@ -117,7 +117,7 @@ contract ExecuteFromPluginPermissionsTest is Test {
account.installPlugin({
plugin: address(efpCallerPluginAnyExternalCanSpendNativeToken),
manifestHash: efpCallerAnyExternalCanSpendNativeTokenManifestHash,
pluginInitData: "",
pluginInstallData: "",
dependencies: new FunctionReference[](0)
});

Expand All @@ -126,7 +126,7 @@ contract ExecuteFromPluginPermissionsTest is Test {
account.installPlugin({
plugin: address(efpExecutionHookPlugin),
manifestHash: efpExecutionHookPluginManifestHash,
pluginInitData: "",
pluginInstallData: "",
dependencies: new FunctionReference[](0)
});
}
Expand Down
Loading

0 comments on commit f7fb5ff

Please sign in to comment.