diff --git a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol index 5f071647fcf..155a22e01f7 100644 --- a/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +++ b/contracts/proxy/transparent/TransparentUpgradeableProxy.sol @@ -56,7 +56,7 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external payable ifAdmin returns (address admin_) { - _nonPayable(); + _requireZeroValue(); admin_ = _getAdmin(); } @@ -70,7 +70,7 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external payable ifAdmin returns (address implementation_) { - _nonPayable(); + _requireZeroValue(); implementation_ = _implementation(); } @@ -82,7 +82,7 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external payable virtual ifAdmin { - _nonPayable(); + _requireZeroValue(); _changeAdmin(newAdmin); } @@ -92,7 +92,7 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external payable ifAdmin { - _nonPayable(); + _requireZeroValue(); _upgradeToAndCall(newImplementation, bytes(""), false); } @@ -122,7 +122,11 @@ contract TransparentUpgradeableProxy is ERC1967Proxy { super._beforeFallback(); } - function _nonPayable() private { + /** + * @dev To keep this contract fully transparent, all `ifAdmin` functions must be payable. This helper is here to + * emulate some proxy functions being non-payable while still allowing value to pass through. + */ + function _requireZeroValue() private { require(msg.value == 0); } }