Skip to content

Commit

Permalink
feat: update spec for v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypaik committed Jan 23, 2024
1 parent 1869bd4 commit 894d3e7
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 178 deletions.
4 changes: 2 additions & 2 deletions src/account/PluginManagerInternals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ abstract contract PluginManagerInternals is IPluginManager {
function _installPlugin(
address plugin,
bytes32 manifestHash,
bytes memory pluginInitData,
bytes memory pluginInstallData,
FunctionReference[] memory dependencies
) internal {
AccountStorage storage _storage = getAccountStorage();
Expand Down Expand Up @@ -430,7 +430,7 @@ abstract contract PluginManagerInternals is IPluginManager {

// 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 @@ -261,10 +261,10 @@ contract UpgradeableModularAccount is
function installPlugin(
address plugin,
bytes32 manifestHash,
bytes calldata pluginInitData,
bytes calldata pluginInstallData,
FunctionReference[] calldata dependencies
) external override wrapNativeFunction {
_installPlugin(plugin, manifestHash, pluginInitData, dependencies);
_installPlugin(plugin, manifestHash, pluginInstallData, dependencies);
}

/// @inheritdoc IPluginManager
Expand Down
32 changes: 16 additions & 16 deletions src/interfaces/IAccountLoupe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ pragma solidity ^0.8.19;
import {FunctionReference} from "../helpers/FunctionReferenceLib.sol";

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 @@ -41,7 +41,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);
}
42 changes: 22 additions & 20 deletions src/interfaces/IPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ import {UserOperation} from "@eth-infinitism/account-abstraction/interfaces/User
// so annotating here to prevent that.
// forgefmt: disable-start
enum ManifestAssociatedFunctionType {
/// @notice Function is not defined.
// Function is not defined.
NONE,
/// @notice Function belongs to this plugin.
// Function belongs to this plugin.
SELF,
/// @notice Function belongs to an external plugin provided as a dependency during plugin installation.
// Function belongs to an external plugin provided as a dependency during plugin installation.
DEPENDENCY,
/// @notice Resolves to a magic value to always bypass runtime validation for a given function.
/// This is only assignable on runtime validation functions. If it were to be used on a user op validationFunction,
/// it would risk burning gas from the account. When used as a hook in any hook location, it is equivalent to not
/// setting a hook and is therefore disallowed.
// Resolves to a magic value to always bypass runtime validation for a given function.
// This is only assignable on runtime validation functions. If it were to be used on a user op validationFunction,
// it would risk burning gas from the account. When used as a hook in any hook location, it is equivalent to not
// setting a hook and is therefore disallowed.
RUNTIME_VALIDATION_ALWAYS_ALLOW,
/// @notice Resolves to a magic value to always fail in a hook for a given function.
/// This is only assignable to pre hooks (pre validation and pre execution). It should not be used on
/// validation functions themselves, because this is equivalent to leaving the validation functions unset.
/// It should not be used in post-exec hooks, because if it is known to always revert, that should happen
/// as early as possible to save gas.
// Resolves to a magic value to always fail in a hook for a given function.
// This is only assignable to pre hooks (pre validation and pre execution). It should not be used on
// validation functions themselves, because this is equivalent to leaving the validation functions unset.
// It should not be used in post-exec hooks, because if it is known to always revert, that should happen
// as early as possible to save gas.
PRE_HOOK_ALWAYS_DENY
}
// forgefmt: disable-end

// For functions of type `ManifestAssociatedFunctionType.DEPENDENCY`, the MSCA MUST find the plugin address
// of the function at `dependencies[dependencyIndex]` during the call to `installPlugin(config)`.
/// @dev For functions of type `ManifestAssociatedFunctionType.DEPENDENCY`, the MSCA MUST find the plugin address
/// of the function at `dependencies[dependencyIndex]` during the call to `installPlugin(config)`.
struct ManifestFunction {
ManifestAssociatedFunctionType functionType;
uint8 functionId;
Expand Down Expand Up @@ -73,19 +73,21 @@ struct PluginMetadata {

/// @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.
// 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 and/or hooks, 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.
// 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 contract addresses.
// 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.
// 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;
Expand Down
22 changes: 12 additions & 10 deletions src/interfaces/IPluginExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
pragma solidity ^0.8.19;

interface IPluginExecutor {
/// @notice Executes a call from a plugin to another plugin.
/// @dev Permissions must be granted to the calling plugin for the call to go through.
/// @param data calldata to send to the plugin
/// @return The result of 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 Executes a call from a plugin to a non-plugin address.
/// @dev Permissions must be granted to the calling plugin for the call to go through.
/// @param target address of the target to call
/// @param value value to send with the call
/// @param data calldata to send to the target
/// @return The result of the call
/// @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.
/// @param target The address to be called.
/// @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
12 changes: 6 additions & 6 deletions src/interfaces/IPluginManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ pragma solidity ^0.8.19;

import {FunctionReference} from "../helpers/FunctionReferenceLib.sol";

/// @title Plugin Manager Interface
interface IPluginManager {
event PluginInstalled(address indexed plugin, bytes32 manifestHash, FunctionReference[] dependencies);

event PluginUninstalled(address indexed plugin, bool indexed callbacksSucceeded);
event PluginUninstalled(address indexed plugin, bool indexed onUninstallSucceeded);

/// @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
13 changes: 6 additions & 7 deletions src/interfaces/IStandardExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
pragma solidity ^0.8.19;

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
Loading

0 comments on commit 894d3e7

Please sign in to comment.