Skip to content

Commit

Permalink
feat: eip-7702 proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Haypierre committed Oct 10, 2024
1 parent 75d1342 commit 8913f62
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions contracts/core/upgradeable/UpgradeableOpenfortProxy7702.sol
Original file line number Diff line number Diff line change
@@ -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
);
}
}

0 comments on commit 8913f62

Please sign in to comment.