diff --git a/src/MSAAdvanced.sol b/src/MSAAdvanced.sol index e1de95c..42b5444 100644 --- a/src/MSAAdvanced.sol +++ b/src/MSAAdvanced.sol @@ -10,6 +10,7 @@ import { IERC7579Account } from "./interfaces/IERC7579Account.sol"; import { IMSA } from "./interfaces/IMSA.sol"; import { ModuleManager } from "./core/ModuleManager.sol"; import { HookManager } from "./core/HookManager.sol"; +import { RegistryAdapter } from "./core/RegistryAdapter.sol"; /** * @author zeroknots.eth | rhinestone.wtf @@ -18,7 +19,7 @@ import { HookManager } from "./core/HookManager.sol"; * This account implements ExecType: DEFAULT and TRY. * Hook support is implemented */ -contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager { +contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager, RegistryAdapter { using ExecutionLib for bytes; using ModeLib for ModeCode; @@ -85,6 +86,7 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager { payable onlyExecutorModule withHook + withRegistry(msg.sender, MODULE_TYPE_EXECUTOR) returns ( bytes[] memory returnData // TODO returnData is not used ) @@ -162,6 +164,7 @@ contract MSAAdvanced is IMSA, ExecutionHelper, ModuleManager, HookManager { payable onlyEntryPointOrSelf withHook + withRegistry(module, moduleTypeId) { if (!IModule(module).isModuleType(moduleTypeId)) revert MismatchModuleTypeId(moduleTypeId); diff --git a/src/core/RegistryAdapter.sol b/src/core/RegistryAdapter.sol new file mode 100644 index 0000000..e263fe8 --- /dev/null +++ b/src/core/RegistryAdapter.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.23; + +import { IERC7484 } from "../interfaces/IERC7484.sol"; +import { AccountBase } from "./AccountBase.sol"; + +/** + * @title RegistryAdapter + * @author kopy-kat | rhinestone.wtf + * @dev This contract uses ERC-7484 to check if a module is attested to and exposes a modifier to + * use it. + */ +abstract contract RegistryAdapter is AccountBase { + event ERC7484RegistryConfigured(address indexed smartAccount, address indexed registry); + + IERC7484 internal $registry; + + modifier withRegistry(address module, uint256 moduleTypeId) { + IERC7484 registry = $registry; + if (address(registry) != address(0)) { + registry.check(module, moduleTypeId); + } + _; + } + + function setRegistry( + IERC7484 registry, + address[] calldata attesters, + uint8 threshold + ) + external + onlyEntryPointOrSelf + { + $registry = registry; + if (attesters.length > 0) { + registry.trustAttesters(threshold, attesters); + } + } +} diff --git a/src/interfaces/IERC7484.sol b/src/interfaces/IERC7484.sol new file mode 100644 index 0000000..f8cc48e --- /dev/null +++ b/src/interfaces/IERC7484.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +interface IERC7484 { + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ + /* Check with Registry internal attesters */ + /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ + function check(address module) external view; + + function checkForAccount(address smartAccount, address module) external view; + + function check(address module, uint256 moduleType) external view; + + function checkForAccount( + address smartAccount, + address module, + uint256 moduleType + ) + external + view; + + /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ + /* Check with external attester(s) */ + /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ + + function check(address module, address attester) external view; + + function check(address module, uint256 moduleType, address attester) external view; + + function checkN( + address module, + address[] calldata attesters, + uint256 threshold + ) + external + view; + + function checkN( + address module, + uint256 moduleType, + address[] calldata attesters, + uint256 threshold + ) + external + view; + + function trustAttesters(uint8 threshold, address[] calldata attesters) external; +}