-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
contracts/core/upgradeable/UpgradeableOpenfortProxy7702.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} | ||
} |