-
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.
Merge pull request #3 from openfort-xyz/development
Development
- Loading branch information
Showing
33 changed files
with
1,490 additions
and
133 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
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
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,31 +1,30 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.12; | ||
// 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 | ||
*/ | ||
contract ManagedOpenfortFactory is IBaseOpenfortFactory { | ||
address public immutable entrypointContract; | ||
address public immutable openfortBeacon; | ||
|
||
constructor(address _entrypoint, address _openfortBeacon) { | ||
if (_entrypoint == address(0) || _openfortBeacon == address(0)) { | ||
constructor(address _openfortBeacon) { | ||
if ( _openfortBeacon == address(0)) { | ||
revert ZeroAddressNotAllowed(); | ||
} | ||
entrypointContract = _entrypoint; | ||
openfortBeacon = _openfortBeacon; | ||
} | ||
|
||
|
@@ -42,9 +41,9 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { | |
|
||
emit AccountCreated(account, _admin); | ||
account = address( | ||
new BeaconProxy{salt: salt}( | ||
new OpenfortBeaconProxy{salt: salt}( | ||
openfortBeacon, | ||
abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, entrypointContract, _data)) | ||
abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, _data)) | ||
) | ||
); | ||
} | ||
|
@@ -65,9 +64,9 @@ contract ManagedOpenfortFactory is IBaseOpenfortFactory { | |
|
||
emit AccountCreated(account, _admin); | ||
account = address( | ||
new BeaconProxy{salt: salt}( | ||
new OpenfortBeaconProxy{salt: salt}( | ||
openfortBeacon, | ||
abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, entrypointContract, _data)) | ||
abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, _data)) | ||
) | ||
); | ||
} | ||
|
@@ -78,13 +77,13 @@ 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, entrypointContract, "")) | ||
abi.encodeCall(ManagedOpenfortAccount.initialize, (_admin, "")) | ||
) | ||
) | ||
) | ||
|
@@ -97,13 +96,13 @@ 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, entrypointContract, "")) | ||
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
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
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
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
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: UNLICENSED | ||
pragma solidity ^0.8.12; | ||
// 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)) | ||
) | ||
|
@@ -77,12 +77,12 @@ contract UpgradeableOpenfortFactory 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(ERC1967Proxy).creationCode, | ||
type(OpenfortUpgradeableProxy).creationCode, | ||
abi.encode( | ||
address(accountImplementation), | ||
accountImplementation, | ||
abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, "")) | ||
) | ||
) | ||
|
@@ -96,12 +96,12 @@ contract UpgradeableOpenfortFactory 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(ERC1967Proxy).creationCode, | ||
type(OpenfortUpgradeableProxy).creationCode, | ||
abi.encode( | ||
address(accountImplementation), | ||
accountImplementation, | ||
abi.encodeCall(UpgradeableOpenfortAccount.initialize, (_admin, entrypointContract, "")) | ||
) | ||
) | ||
|
Oops, something went wrong.