-
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
8 changed files
with
458 additions
and
16 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; | ||
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; | ||
// Smart wallet implementation to use | ||
import {ManagedOpenfortAccount} from "./ManagedOpenfortAccount.sol"; | ||
import {OpenfortBeacon} from "./OpenfortBeacon.sol"; | ||
import {OpenfortBeaconProxy} from "./OpenfortBeaconProxy.sol"; | ||
|
||
// Interfaces | ||
import {IBaseOpenfortFactory} from "../../interfaces/IBaseOpenfortFactory.sol"; | ||
|
||
/** | ||
* @title ManagedOpenfortFactory (Non-upgradeable) | ||
* @author Eloi<[email protected]> | ||
* @notice Contract to create an on-chain factory to deploy new ManagedOpenfortAccounts. | ||
* It uses OpenZeppelin's Create2 and BeaconProxy libraries. | ||
* It uses OpenZeppelin's Create2 and OpenfortBeaconProxy libraries. | ||
* It inherits from: | ||
* - IBaseOpenfortFactory | ||
*/ | ||
|
@@ -40,7 +41,7 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { | |
|
||
emit AccountCreated(account, _admin); | ||
account = address( | ||
new BeaconProxy{salt: salt}( | ||
new OpenfortBeaconProxy{salt: salt}( | ||
openfortBeacon, | ||
abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, _data)) | ||
) | ||
|
@@ -63,7 +64,7 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { | |
|
||
emit AccountCreated(account, _admin); | ||
account = address( | ||
new BeaconProxy{salt: salt}( | ||
new OpenfortBeaconProxy{salt: salt}( | ||
openfortBeacon, | ||
abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, _data)) | ||
) | ||
|
@@ -76,10 +77,10 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { | |
function getAddress(address _admin) public view returns (address) { | ||
bytes32 salt = keccak256(abi.encode(_admin)); | ||
return Create2.computeAddress( | ||
bytes32(salt), | ||
salt, | ||
keccak256( | ||
abi.encodePacked( | ||
type(BeaconProxy).creationCode, | ||
type(OpenfortBeaconProxy).creationCode, | ||
abi.encode( | ||
openfortBeacon, | ||
abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, "")) | ||
|
@@ -95,10 +96,10 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { | |
function getAddressWithNonce(address _admin, uint256 nonce) public view returns (address) { | ||
bytes32 salt = keccak256(abi.encode(_admin, nonce)); | ||
return Create2.computeAddress( | ||
bytes32(salt), | ||
salt, | ||
keccak256( | ||
abi.encodePacked( | ||
type(BeaconProxy).creationCode, | ||
type(OpenfortBeaconProxy).creationCode, | ||
abi.encode( | ||
openfortBeacon, | ||
abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, "")) | ||
|
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,15 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; | ||
|
||
/** | ||
* @title OpenfortBeaconProxy (Non-upgradeable) | ||
* @author Eloi<[email protected]> | ||
* @notice Contract to create the Beacon to determine implementation contract, which is where they will delegate all function calls. | ||
* It inherits from: | ||
* - BeaconProxy | ||
*/ | ||
contract OpenfortBeaconProxy is BeaconProxy { | ||
constructor(address beacon, bytes memory data) BeaconProxy(beacon, data) {} | ||
} |
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,15 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
|
||
/** | ||
* @title OpenfortUpgradeableProxy (Non-upgradeable) | ||
* @author Eloi<[email protected]> | ||
* @notice Contract to create the proxies | ||
* It inherits from: | ||
* - ERC1967Proxy | ||
*/ | ||
contract OpenfortUpgradeableProxy is ERC1967Proxy { | ||
constructor(address _logic, bytes memory _data) ERC1967Proxy(_logic, _data) {} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; | ||
// Smart wallet implementation to use | ||
import {UpgradeableOpenfortAccount} from "./UpgradeableOpenfortAccount.sol"; | ||
import {OpenfortUpgradeableProxy} from "./OpenfortUpgradeableProxy.sol"; | ||
// Interfaces | ||
import {IBaseOpenfortFactory} from "../../interfaces/IBaseOpenfortFactory.sol"; | ||
|
||
/** | ||
* @title UpgradeableOpenfortFactory (Non-upgradeable) | ||
* @author Eloi<[email protected]> | ||
* @notice Contract to create an on-chain factory to deploy new UpgradeableOpenfortAccounts. | ||
* It uses OpenZeppelin's Create2 and ERC1967Proxy libraries. | ||
* It uses OpenZeppelin's Create2 and OpenfortUpgradeableProxy libraries. | ||
* It inherits from: | ||
* - IBaseOpenfortFactory | ||
*/ | ||
|
@@ -41,7 +41,7 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { | |
|
||
emit AccountCreated(account, _admin); | ||
account = address( | ||
new ERC1967Proxy{salt: salt}( | ||
new OpenfortUpgradeableProxy{salt: salt}( | ||
accountImplementation, | ||
abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, _data)) | ||
) | ||
|
@@ -64,7 +64,7 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { | |
|
||
emit AccountCreated(account, _admin); | ||
account = address( | ||
new ERC1967Proxy{salt: salt}( | ||
new OpenfortUpgradeableProxy{salt: salt}( | ||
accountImplementation, | ||
abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, _data)) | ||
) | ||
|
@@ -80,7 +80,7 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { | |
salt, | ||
keccak256( | ||
abi.encodePacked( | ||
type(ERC1967Proxy).creationCode, | ||
type(OpenfortUpgradeableProxy).creationCode, | ||
abi.encode( | ||
accountImplementation, | ||
abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, "")) | ||
|
@@ -99,7 +99,7 @@ contract UpgradeableOpenfortFactory is IBaseOpenfortFactory { | |
salt, | ||
keccak256( | ||
abi.encodePacked( | ||
type(ERC1967Proxy).creationCode, | ||
type(OpenfortUpgradeableProxy).creationCode, | ||
abi.encode( | ||
accountImplementation, | ||
abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, "")) | ||
|
Oops, something went wrong.