Skip to content

Commit

Permalink
fix: transparent factory natspec correction (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Jan 26, 2025
1 parent a440288 commit 01bf257
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {TransparentProxyFactoryBase} from './TransparentProxyFactoryBase.sol';
* @notice Factory contract to create transparent proxies, both with CREATE and CREATE2
* @dev `create()` and `createDeterministic()` are not unified for clearer interface, and at the same
* time allowing `createDeterministic()` with salt == 0
* @dev Highly recommended to pass as `admin` on creation an OZ ProxyAdmin instance
**/
contract TransparentProxyFactory is TransparentProxyFactoryBase {
function _predictCreate2Address(
Expand Down
29 changes: 14 additions & 15 deletions src/contracts/transparent-proxy/TransparentProxyFactoryBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {ITransparentProxyFactory} from './interfaces/ITransparentProxyFactory.so
* @notice Factory contract to create transparent proxies, both with CREATE and CREATE2
* @dev `create()` and `createDeterministic()` are not unified for clearer interface, and at the same
* time allowing `createDeterministic()` with salt == 0
* @dev Highly recommended to pass as `admin` on creation an OZ ProxyAdmin instance
**/
abstract contract TransparentProxyFactoryBase is ITransparentProxyFactory {
mapping(address proxy => address admin) internal _proxyToAdmin;
Expand All @@ -23,54 +22,54 @@ abstract contract TransparentProxyFactoryBase is ITransparentProxyFactory {
/// @inheritdoc ITransparentProxyFactory
function create(
address logic,
address adminOwner,
address initialOwner,
bytes calldata data
) external returns (address) {
address proxy = address(new TransparentUpgradeableProxy(logic, adminOwner, data));
address proxy = address(new TransparentUpgradeableProxy(logic, initialOwner, data));
_storeProxyInRegistry(proxy);

emit ProxyCreated(proxy, logic, adminOwner);
emit ProxyCreated(proxy, logic, initialOwner);

return proxy;
}

/// @inheritdoc ITransparentProxyFactory
function createProxyAdmin(address adminOwner) external returns (address) {
address proxyAdmin = address(new ProxyAdmin(adminOwner));
function createProxyAdmin(address initialOwner) external returns (address) {
address proxyAdmin = address(new ProxyAdmin(initialOwner));

emit ProxyAdminCreated(proxyAdmin, adminOwner);
emit ProxyAdminCreated(proxyAdmin, initialOwner);
return proxyAdmin;
}

/// @inheritdoc ITransparentProxyFactory
function createDeterministic(
address logic,
address adminOwner,
address initialOwner,
bytes calldata data,
bytes32 salt
) external returns (address) {
address proxy = address(new TransparentUpgradeableProxy{salt: salt}(logic, adminOwner, data));
address proxy = address(new TransparentUpgradeableProxy{salt: salt}(logic, initialOwner, data));
_storeProxyInRegistry(proxy);

emit ProxyDeterministicCreated(proxy, logic, adminOwner, salt);
emit ProxyDeterministicCreated(proxy, logic, initialOwner, salt);
return proxy;
}

/// @inheritdoc ITransparentProxyFactory
function createDeterministicProxyAdmin(
address adminOwner,
address initialOwner,
bytes32 salt
) external returns (address) {
address proxyAdmin = address(new ProxyAdmin{salt: salt}(adminOwner));
address proxyAdmin = address(new ProxyAdmin{salt: salt}(initialOwner));

emit ProxyAdminDeterministicCreated(proxyAdmin, adminOwner, salt);
emit ProxyAdminDeterministicCreated(proxyAdmin, initialOwner, salt);
return proxyAdmin;
}

/// @inheritdoc ITransparentProxyFactory
function predictCreateDeterministic(
address logic,
address admin,
address initialOwner,
bytes calldata data,
bytes32 salt
) public view returns (address) {
Expand All @@ -79,7 +78,7 @@ abstract contract TransparentProxyFactoryBase is ITransparentProxyFactory {
address(this),
salt,
type(TransparentUpgradeableProxy).creationCode,
abi.encode(logic, admin, data)
abi.encode(logic, initialOwner, data)
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;


interface ITransparentProxyFactory {
event ProxyCreated(address proxy, address indexed logic, address indexed proxyAdmin);
event ProxyAdminCreated(address proxyAdmin, address indexed adminOwner);
event ProxyCreated(address proxy, address indexed logic, address indexed initialOwner);
event ProxyAdminCreated(address proxyAdmin, address indexed initialOwner);
event ProxyDeterministicCreated(
address proxy,
address indexed logic,
address indexed admin,
address indexed initialOwner,
bytes32 indexed salt
);
event ProxyAdminDeterministicCreated(
address proxyAdmin,
address indexed adminOwner,
address indexed initialOwner,
bytes32 indexed salt
);

/**
* @notice Creates a transparent proxy instance, doing the first initialization in construction
* @dev Version using CREATE
* @param logic The address of the implementation contract
* @param admin The admin of the proxy.
* @param initialOwner The initial owner of the admin of the proxy.
* @param data abi encoded call to the function with `initializer` (or `reinitializer`) modifier.
* E.g. `abi.encodeWithSelector(mockImpl.initialize.selector, 2)`
* for an `initialize` function being `function initialize(uint256 foo) external initializer;`
* @return address The address of the proxy deployed
**/
function create(address logic, address admin, bytes memory data) external returns (address);
function create(
address logic,
address initialOwner,
bytes memory data
) external returns (address);

/**
* @notice Creates a proxyAdmin instance, and transfers ownership to provided owner
* @dev Version using CREATE
* @param adminOwner The owner of the proxyAdmin deployed.
* @param initialOwner The initial owner of the proxyAdmin deployed.
* @return address The address of the proxyAdmin deployed
**/
function createProxyAdmin(address adminOwner) external returns (address);
function createProxyAdmin(address initialOwner) external returns (address);

/**
* @notice Creates a transparent proxy instance, doing the first initialization in construction
* @dev Version using CREATE2, so deterministic
* @param logic The address of the implementation contract
* @param admin The admin of the proxy.
* @param initialOwner The initial owner of the admin of the proxy.
* @param data abi encoded call to the function with `initializer` (or `reinitializer`) modifier.
* E.g. `abi.encodeWithSelector(mockImpl.initialize.selector, 2)`
* for an `initialize` function being `function initialize(uint256 foo) external initializer;`
Expand All @@ -50,7 +53,7 @@ interface ITransparentProxyFactory {
**/
function createDeterministic(
address logic,
address admin,
address initialOwner,
bytes memory data,
bytes32 salt
) external returns (address);
Expand All @@ -70,7 +73,7 @@ interface ITransparentProxyFactory {
/**
* @notice Pre-calculates and return the address on which `createDeterministic` will deploy a proxy
* @param logic The address of the implementation contract
* @param admin The admin of the proxy
* @param initialOwner The initial owner of the admin of the proxy.
* @param data abi encoded call to the function with `initializer` (or `reinitializer`) modifier.
* E.g. `abi.encodeWithSelector(mockImpl.initialize.selector, 2)`
* for an `initialize` function being `function initialize(uint256 foo) external initializer;`
Expand All @@ -79,7 +82,7 @@ interface ITransparentProxyFactory {
**/
function predictCreateDeterministic(
address logic,
address admin,
address initialOwner,
bytes calldata data,
bytes32 salt
) external view returns (address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {ITransparentProxyFactoryZkSync} from './interfaces/ITransparentProxyFact
* @notice Factory contract specific to zkSync to create transparent proxies, both with CREATE and CREATE2
* @dev `create()` and `createDeterministic()` are not unified for clearer interface, and at the same
* time allowing `createDeterministic()` with salt == 0
* @dev Highly recommended to pass as `admin` on creation an OZ ProxyAdmin instance
**/
contract TransparentProxyFactoryZkSync is
TransparentProxyFactoryBase,
Expand Down

0 comments on commit 01bf257

Please sign in to comment.