TUPProxy
Inherits: TransparentUpgradeableProxy, Freezable
Author: mortimr @ Kiln
This contract extends the Transparent Upgradeable proxy and adds a system wide pause feature. When the system is paused, the fallback will fail no matter what calls are made.
State Variables
_PAUSE_SLOT
EIP1967 slot to store the pause status value.
bytes32 private constant _PAUSE_SLOT = bytes32(uint256(keccak256("eip1967.proxy.pause")) - 1);
_PAUSER_SLOT
EIP1967 slot to store the pauser address value.
bytes32 private constant _PAUSER_SLOT = bytes32(uint256(keccak256("eip1967.proxy.pauser")) - 1);
Functions
ifAdminOrPauser
modifier ifAdminOrPauser();
constructor
constructor(address _logic, address admin_, bytes memory _data)
payable
TransparentUpgradeableProxy(_logic, admin_, _data);
Parameters
| Name | Type | Description |
|---|---|---|
_logic | address | The address of the implementation contract |
admin_ | address | The address of the admin account able to pause and upgrade the implementation |
_data | bytes | Extra data use to perform atomic initializations |
paused
Retrieves Paused state.
function paused() external ifAdminOrPauser returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | Paused state |
pause
Pauses system.
function pause() external ifAdminOrPauser notFrozen;
unpause
Unpauses system.
function unpause() external ifAdmin notFrozen;
freeze
Sets the freeze timeout.
function freeze(uint256 freezeTimeout) external ifAdmin;
cancelFreeze
Cancels the freeze process.
function cancelFreeze() external ifAdmin;
frozen
Retrieve the freeze status.
function frozen() external ifAdmin returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if frozen |
freezeTime
Retrieve the freeze timestamp.
function freezeTime() external ifAdmin returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The freeze timestamp |
pauser
Retrieve the dedicated pauser address.
function pauser() external ifAdminOrPauser returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The pauser address |
changePauser
Changes the dedicated pauser address.
Not callable when frozen
function changePauser(address newPauser) external ifAdmin notFrozen;
Parameters
| Name | Type | Description |
|---|---|---|
newPauser | address | The new pauser address |
changeAdmin
Changed the proxy admin.
Not callable when frozen
function changeAdmin(address newAdmin) external override ifAdmin notFrozen;
upgradeTo
Performs an upgrade without reinitialization.
function upgradeTo(address newImplementation) external override ifAdmin notFrozen;
Parameters
| Name | Type | Description |
|---|---|---|
newImplementation | address | The new implementation address |
upgradeToAndCall
Performs an upgrade with reinitialization.
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable override ifAdmin notFrozen;
Parameters
| Name | Type | Description |
|---|---|---|
newImplementation | address | The new implementation address |
data | bytes | The calldata to use atomically after the implementation upgrade |
_getPauser
Internal utility to retrieve the dedicated pauser from storage,
function _getPauser() internal view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The pauser address |
_changePauser
Internal utility to change the dedicated pauser.
function _changePauser(address newPauser) internal;
Parameters
| Name | Type | Description |
|---|---|---|
newPauser | address | The new pauser address |
_beforeFallback
Overrides the fallback method to check if system is not paused before.
Address Zero is allowed to perform calls even if system is paused. This allows view functions to be called when the system is paused as rpc providers can easily set the sender address to zero.
function _beforeFallback() internal override;
_getFreezer
Internal utility to retrieve the account allowed to freeze the contract.
function _getFreezer() internal view override returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The freezer account |
Events
PauserChanged
Emitted when the proxy dedicated pauser is changed.
event PauserChanged(address previousPauser, address newPauser);
Errors
CallWhenPaused
Thrown when a call was attempted and the proxy is paused.
error CallWhenPaused();