From 8913f628cb65521e1e94d39d831c5795d6c85f5f Mon Sep 17 00:00:00 2001 From: Pierre Hay Date: Thu, 10 Oct 2024 18:15:37 +0200 Subject: [PATCH] feat: eip-7702 proxy --- .../UpgradeableOpenfortProxy7702.sol | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 contracts/core/upgradeable/UpgradeableOpenfortProxy7702.sol diff --git a/contracts/core/upgradeable/UpgradeableOpenfortProxy7702.sol b/contracts/core/upgradeable/UpgradeableOpenfortProxy7702.sol new file mode 100644 index 0000000..68064cf --- /dev/null +++ b/contracts/core/upgradeable/UpgradeableOpenfortProxy7702.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity =0.8.19; + +import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import {UpgradeableOpenfortAccount} from "./UpgradeableOpenfortAccount.sol"; + +/** + * @title UpgradeableOpenfortProxy7702 (Non-upgradeable) + * @notice Proxy contract that support 7702 initialization + * It inherits from: + * - ERC1967Proxy + */ +contract UpgradeableOpenfortProxy7702 is ERC1967Proxy { + constructor(address _logic, bytes memory _data) ERC1967Proxy(_logic, _data) {} + + function implementation() external view returns (address) { + return _implementation(); + } + + function initializeAccount( + address _implementation, + address _entrypoint, + uint256 _recoveryPeriod, + uint256 _securityPeriod, + uint256 _securityWindow, + uint256 _lockPeriod, + address _initialGuardian + ) public { + // only callable by the EOA itself in an eip-7702 delegation + require(msg.sender == address(this)); + + // set implementation in the storage of the EOA + _upgradeTo(_implementation); + + UpgradeableOpenfortAccount(payable(address(this))).initialize( + msg.sender, _entrypoint, _recoveryPeriod, _securityPeriod, _securityWindow, _lockPeriod, _initialGuardian + ); + } +}