-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: upgrade transparent proxy #48
Changes from 3 commits
3304a5c
629ddb7
3cee8a7
9d9c5d1
147a15c
e8d7071
06f6a9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the pattern, similiar to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kk removed. As we have oz as a dependency, we should probably also remove most things from oz-common, but will defer to another pr. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,21 +16,16 @@ import {ProxyAdmin} from './ProxyAdmin.sol'; | |
**/ | ||
abstract contract TransparentProxyFactoryBase is ITransparentProxyFactory { | ||
/// @inheritdoc ITransparentProxyFactory | ||
function create( | ||
address logic, | ||
address admin, | ||
bytes calldata data | ||
) external returns (address) { | ||
function create(address logic, ProxyAdmin admin, bytes calldata data) external returns (address) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a bit debatable, that's why i asked for careful review 😅 My thinking was that if passing a non ProxyAdmin here would potentiall break things. It's simply assumed to pass a proxy admin. While an interface ofc is no perfect enforcement, the intention is to at least highlight what should be passed. |
||
address proxy = address(new TransparentUpgradeableProxy(logic, admin, data)); | ||
|
||
emit ProxyCreated(proxy, logic, admin); | ||
emit ProxyCreated(proxy, logic, address(admin)); | ||
return proxy; | ||
} | ||
|
||
/// @inheritdoc ITransparentProxyFactory | ||
function createProxyAdmin(address adminOwner) external returns (address) { | ||
address proxyAdmin = address(new ProxyAdmin()); | ||
IOwnable(proxyAdmin).transferOwnership(adminOwner); | ||
address proxyAdmin = address(new ProxyAdmin(adminOwner)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here return it as address, not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here i simply did not change anything as nothing really changed. |
||
|
||
emit ProxyAdminCreated(proxyAdmin, adminOwner); | ||
return proxyAdmin; | ||
|
@@ -39,23 +34,22 @@ abstract contract TransparentProxyFactoryBase is ITransparentProxyFactory { | |
/// @inheritdoc ITransparentProxyFactory | ||
function createDeterministic( | ||
address logic, | ||
address admin, | ||
ProxyAdmin admin, | ||
bytes calldata data, | ||
bytes32 salt | ||
) external returns (address) { | ||
address proxy = address(new TransparentUpgradeableProxy{salt: salt}(logic, admin, data)); | ||
|
||
emit ProxyDeterministicCreated(proxy, logic, admin, salt); | ||
emit ProxyDeterministicCreated(proxy, logic, address(admin), salt); | ||
return proxy; | ||
} | ||
|
||
/// @inheritdoc ITransparentProxyFactory | ||
function createDeterministicProxyAdmin(address adminOwner, bytes32 salt) | ||
external | ||
returns (address) | ||
{ | ||
address proxyAdmin = address(new ProxyAdmin{salt: salt}()); | ||
IOwnable(proxyAdmin).transferOwnership(adminOwner); | ||
function createDeterministicProxyAdmin( | ||
address adminOwner, | ||
bytes32 salt | ||
) external returns (address) { | ||
address proxyAdmin = address(new ProxyAdmin{salt: salt}(adminOwner)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, did not change as imo doesn't help in this case |
||
|
||
emit ProxyAdminDeterministicCreated(proxyAdmin, adminOwner, salt); | ||
return proxyAdmin; | ||
|
@@ -64,7 +58,7 @@ abstract contract TransparentProxyFactoryBase is ITransparentProxyFactory { | |
/// @inheritdoc ITransparentProxyFactory | ||
function predictCreateDeterministic( | ||
address logic, | ||
address admin, | ||
ProxyAdmin admin, | ||
bytes calldata data, | ||
bytes32 salt | ||
) public view returns (address) { | ||
|
@@ -73,13 +67,22 @@ abstract contract TransparentProxyFactoryBase is ITransparentProxyFactory { | |
address(this), | ||
salt, | ||
type(TransparentUpgradeableProxy).creationCode, | ||
abi.encode(logic, admin, data) | ||
abi.encode(logic, address(admin), data) | ||
); | ||
} | ||
|
||
/// @inheritdoc ITransparentProxyFactory | ||
function predictCreateDeterministicProxyAdmin(bytes32 salt) public view returns (address) { | ||
return _predictCreate2Address(address(this), salt, type(ProxyAdmin).creationCode, abi.encode()); | ||
function predictCreateDeterministicProxyAdmin( | ||
bytes32 salt, | ||
address initialOwner | ||
) public view returns (address) { | ||
return | ||
_predictCreate2Address( | ||
address(this), | ||
salt, | ||
type(ProxyAdmin).creationCode, | ||
abi.encode(initialOwner) | ||
); | ||
} | ||
|
||
function _predictCreate2Address( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just import from oz directly? As we have 0 diff atm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This:
import {ITransparentUpgradeableProxy} from './TransparentUpgradeableProxy.sol';
is the diff.I don't see a way without copying.