From 395b409fbfb4f675f7e7fc03c896b5f3a0309ed4 Mon Sep 17 00:00:00 2001 From: ernestognw Date: Wed, 2 Aug 2023 13:32:33 -0600 Subject: [PATCH] Fix R-04 --- .../proxy/transparent/TransparentUpgradeableProxy.sol | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol index 413f46ecf7d..b64365c35f4 100644 --- a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +++ b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol @@ -78,14 +78,21 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) { _admin = address(new ProxyAdmin(initialOwner)); // Set the storage value and emit an event for ERC-1967 compatibility - ERC1967Utils.changeAdmin(_admin); + ERC1967Utils.changeAdmin(_proxyAdmin()); + } + + /** + * @dev Returns the admin of this proxy. + */ + function _proxyAdmin() internal virtual returns (address) { + return _admin; } /** * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior. */ function _fallback() internal virtual override { - if (msg.sender == _admin) { + if (msg.sender == _proxyAdmin()) { if (msg.sig == ITransparentUpgradeableProxy.upgradeToAndCall.selector) { _dispatchUpgradeToAndCall(); } else {