Skip to content

Commit

Permalink
document _requireZeroValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Jan 19, 2023
1 parent 7d5d56b commit 199d29f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions contracts/proxy/transparent/TransparentUpgradeableProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contract TransparentUpgradeableProxy is ERC1967Proxy {
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function admin() external payable ifAdmin returns (address admin_) {
_nonPayable();
_requireZeroValue();
admin_ = _getAdmin();
}

Expand All @@ -70,7 +70,7 @@ contract TransparentUpgradeableProxy is ERC1967Proxy {
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function implementation() external payable ifAdmin returns (address implementation_) {
_nonPayable();
_requireZeroValue();
implementation_ = _implementation();
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 199d29f

Please sign in to comment.