Skip to content

Commit

Permalink
Modified proxy names
Browse files Browse the repository at this point in the history
  • Loading branch information
eloi010 committed May 31, 2023
1 parent 8f9e818 commit 788fd33
Show file tree
Hide file tree
Showing 8 changed files with 458 additions and 16 deletions.
17 changes: 9 additions & 8 deletions contracts/core/managed/ManagedOpenfortFactory.sol
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
*/
Expand All @@ -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))
)
Expand All @@ -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))
)
Expand All @@ -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, ""))
Expand All @@ -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, ""))
Expand Down
15 changes: 15 additions & 0 deletions contracts/core/managed/OpenfortBeaconProxy.sol
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) {}
}
15 changes: 15 additions & 0 deletions contracts/core/upgradeable/OpenfortUpgradeableProxy.sol
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) {}
}
12 changes: 6 additions & 6 deletions contracts/core/upgradeable/UpgradeableOpenfortFactory.sol
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
*/
Expand Down Expand Up @@ -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))
)
Expand All @@ -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))
)
Expand All @@ -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, ""))
Expand All @@ -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, ""))
Expand Down
Loading

0 comments on commit 788fd33

Please sign in to comment.