diff --git a/src/SsoAccount.sol b/src/SsoAccount.sol index 0c1b95dc..7904a3d7 100644 --- a/src/SsoAccount.sol +++ b/src/SsoAccount.sol @@ -22,6 +22,8 @@ import { SignatureDecoder } from "./libraries/SignatureDecoder.sol"; import { ERC1271Handler } from "./handlers/ERC1271Handler.sol"; import { BatchCaller } from "./batch/BatchCaller.sol"; +import { BootloaderAuth } from "./auth/BootloaderAuth.sol"; + import { ISsoAccount } from "./interfaces/ISsoAccount.sol"; import { IModuleValidator } from "./interfaces/IModuleValidator.sol"; @@ -32,7 +34,15 @@ import { IModuleValidator } from "./interfaces/IModuleValidator.sol"; /// @notice This contract is a modular and extensible account implementation with support of /// multi-ownership, custom modules, validation/execution hooks and different signature validation formats. /// @dev Contract is expected to be used as Beacon proxy implementation. -contract SsoAccount is Initializable, HookManager, ERC1271Handler, TokenCallbackHandler, BatchCaller, ISsoAccount { +contract SsoAccount is + Initializable, + HookManager, + ERC1271Handler, + TokenCallbackHandler, + BatchCaller, + ISsoAccount, + BootloaderAuth +{ // Helper library for the Transaction struct using TransactionHelper for Transaction; diff --git a/src/auth/Auth.sol b/src/auth/Auth.sol deleted file mode 100644 index 2681b4bb..00000000 --- a/src/auth/Auth.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.24; - -import { BootloaderAuth } from "./BootloaderAuth.sol"; -import { SelfAuth } from "./SelfAuth.sol"; -import { HookAuth } from "./HookAuth.sol"; -import { Errors } from "../libraries/Errors.sol"; - -/** - * @title Auth - * @notice Abstract contract that organizes authentication logic for the contract - * @author https://getclave.io - */ -abstract contract Auth is BootloaderAuth, SelfAuth, HookAuth {} diff --git a/src/auth/HookAuth.sol b/src/auth/HookAuth.sol deleted file mode 100644 index 79389848..00000000 --- a/src/auth/HookAuth.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.24; - -import { Errors } from "../libraries/Errors.sol"; - -/** - * @title HookAuth - * @notice Abstract contract that allows only calls from hooks - * @author https://getclave.io - */ -abstract contract HookAuth { - function _isHook(address addr) internal view virtual returns (bool); - - modifier onlyHook() { - if (!_isHook(msg.sender)) { - revert Errors.NOT_FROM_HOOK(msg.sender); - } - _; - } -} diff --git a/src/handlers/ERC1271Handler.sol b/src/handlers/ERC1271Handler.sol index 57c36db4..9b45684f 100644 --- a/src/handlers/ERC1271Handler.sol +++ b/src/handlers/ERC1271Handler.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.24; import { IERC1271Upgradeable } from "@openzeppelin/contracts-upgradeable/interfaces/IERC1271Upgradeable.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import { Transaction } from "@matterlabs/zksync-contracts/l2/system-contracts/libraries/TransactionHelper.sol"; import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; import { SignatureDecoder } from "../libraries/SignatureDecoder.sol"; diff --git a/src/interfaces/ISsoAccount.sol b/src/interfaces/ISsoAccount.sol index b377843a..98acd274 100644 --- a/src/interfaces/ISsoAccount.sol +++ b/src/interfaces/ISsoAccount.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.24; import { IAccount } from "@matterlabs/zksync-contracts/l2/system-contracts/interfaces/IAccount.sol"; import { IERC1271Upgradeable } from "@openzeppelin/contracts-upgradeable/interfaces/IERC1271Upgradeable.sol"; -import { IERC777Recipient } from "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol"; import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; @@ -26,5 +25,5 @@ interface ISsoAccount is IValidatorManager, IAccount { - function initialize(bytes[] calldata initialValidators, address[] calldata k1Owners) external; + function initialize(bytes[] calldata initialValidators, address[] calldata initialK1Owners) external; } diff --git a/src/libraries/Errors.sol b/src/libraries/Errors.sol index b43275da..d0a6e2ef 100644 --- a/src/libraries/Errors.sol +++ b/src/libraries/Errors.sol @@ -16,7 +16,6 @@ library Errors { // Auth errors error NOT_FROM_BOOTLOADER(address notBootloader); - error NOT_FROM_HOOK(address notHook); error NOT_FROM_SELF(address notSelf); // Batch caller errors diff --git a/src/libraries/SignatureDecoder.sol b/src/libraries/SignatureDecoder.sol index bc52026f..7bf6853d 100644 --- a/src/libraries/SignatureDecoder.sol +++ b/src/libraries/SignatureDecoder.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.24; -import { Errors } from "../libraries/Errors.sol"; - library SignatureDecoder { // Decode transaction.signature into signature, validator and hook data function decodeSignature( diff --git a/src/managers/HookManager.sol b/src/managers/HookManager.sol index 46206a87..f26ce29c 100644 --- a/src/managers/HookManager.sol +++ b/src/managers/HookManager.sol @@ -6,7 +6,7 @@ import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableS import { Transaction } from "@matterlabs/zksync-contracts/l2/system-contracts/libraries/TransactionHelper.sol"; import { ExcessivelySafeCall } from "@nomad-xyz/excessively-safe-call/src/ExcessivelySafeCall.sol"; -import { Auth } from "../auth/Auth.sol"; +import { SelfAuth } from "../auth/SelfAuth.sol"; import { SsoStorage } from "../libraries/SsoStorage.sol"; import { Errors } from "../libraries/Errors.sol"; import { IExecutionHook, IValidationHook } from "../interfaces/IHook.sol"; @@ -19,7 +19,7 @@ import { IModule } from "../interfaces/IModule.sol"; * @dev Hook addresses are stored in a linked list * @author https://getclave.io */ -abstract contract HookManager is IHookManager, Auth { +abstract contract HookManager is IHookManager, SelfAuth { using EnumerableSet for EnumerableSet.AddressSet; // Interface helper library using ERC165Checker for address; @@ -124,7 +124,7 @@ abstract contract HookManager is IHookManager, Auth { emit HookRemoved(hook); } - function _isHook(address addr) internal view override returns (bool) { + function _isHook(address addr) internal view returns (bool) { return _validationHooks().contains(addr) || _executionHooks().contains(addr); } diff --git a/src/managers/OwnerManager.sol b/src/managers/OwnerManager.sol index 9275996c..7681f738 100644 --- a/src/managers/OwnerManager.sol +++ b/src/managers/OwnerManager.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.24; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { SsoStorage } from "../libraries/SsoStorage.sol"; import { Errors } from "../libraries/Errors.sol"; -import { Auth } from "../auth/Auth.sol"; +import { SelfAuth } from "../auth/SelfAuth.sol"; import { IOwnerManager } from "../interfaces/IOwnerManager.sol"; /** @@ -14,7 +14,7 @@ import { IOwnerManager } from "../interfaces/IOwnerManager.sol"; * @dev Owners are stored in a linked list * @author https://getclave.io */ -abstract contract OwnerManager is IOwnerManager, Auth { +abstract contract OwnerManager is IOwnerManager, SelfAuth { using EnumerableSet for EnumerableSet.AddressSet; /// @inheritdoc IOwnerManager diff --git a/src/managers/ValidatorManager.sol b/src/managers/ValidatorManager.sol index ff835ced..97c89576 100644 --- a/src/managers/ValidatorManager.sol +++ b/src/managers/ValidatorManager.sol @@ -5,7 +5,7 @@ import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC16 import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { ExcessivelySafeCall } from "@nomad-xyz/excessively-safe-call/src/ExcessivelySafeCall.sol"; -import { Auth } from "../auth/Auth.sol"; +import { SelfAuth } from "../auth/SelfAuth.sol"; import { Errors } from "../libraries/Errors.sol"; import { SsoStorage } from "../libraries/SsoStorage.sol"; import { IValidatorManager } from "../interfaces/IValidatorManager.sol"; @@ -18,7 +18,7 @@ import { IModule } from "../interfaces/IModule.sol"; * @dev Validators are stored in an enumerable set * @author https://getclave.io */ -abstract contract ValidatorManager is IValidatorManager, Auth { +abstract contract ValidatorManager is IValidatorManager, SelfAuth { using EnumerableSet for EnumerableSet.AddressSet; // Interface helper library using ERC165Checker for address;