InverterBeacon_v1.sol
Inherits: IInverterBeacon_v1, ERC165, Ownable2Step
Author: Inverter Network
Manages upgrades and versioning for smart contract implementations, allowing contract administrators to dynamically change contract logic while maintaining the state. Supports emergency shutdown mechanisms to halt operations if needed.
Extends {ERC165} for interface detection and implements both {IInverterBeacon_v1} and {IBeacon}. Uses modifiers to enforce constraints on implementation upgrades. Unique features include emergency mode control and strict version handling with major, minor and patch version concepts.
State Variables
_reverterAddress
The address of the contract that will revert all transactions. Can only be set via the constructor()
function.
address internal _reverterAddress;
_implementationAddress
The InverterBeacon_v1's implementation address. Can only be changed via the _setImplementation()
function.
address internal _implementationAddress;
_implementationPointer
The {InverterBeacon_v1}'s current implementation pointer. In case of emergency can be set to _reverterAddress
to pause functionality.
address internal _implementationPointer;
_emergencyMode
Is the {InverterBeacon_v1} shut down / in emergency mode.
bool internal _emergencyMode;
majorVersion
The major version of the implementation.
uint internal majorVersion;
minorVersion
The minor version of the implementation.
uint internal minorVersion;
patchVersion
The patch version of the implementation.
uint internal patchVersion;
Functions
supportsInterface
See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool);
validImplementation
Modifier to ensure the implementation is valid.
modifier validImplementation(address newImplementation);
validNewMinorOrPatchVersion
Modifier to ensure the new minor or patch version is valid.
modifier validNewMinorOrPatchVersion(
uint newMinorVersion,
uint newPatchVersion
);
constructor
constructor(
address reverter,
address owner,
uint _majorVersion,
address _implementation,
uint _newMinorVersion,
uint _newPatchVersion
) Ownable(owner);
implementation
Must return an address that can be used as a delegate call target. {UpgradeableBeacon} will check that this address is a contract.
function implementation() public view virtual override returns (address);
getReverterAddress
Returns the {InverterReverter_v1} of the {InverterBeacon_v1}.
function getReverterAddress() external view virtual returns (address);
Returns
<none>
address
ReverterAddress The address of the reverter contract.
getImplementationAddress
Returns the implementation address of the {InverterBeacon_v1}.
function getImplementationAddress() external view virtual returns (address);
Returns
<none>
address
ImplementationAddress The address of the implementation.
emergencyModeActive
Returns wether the {InverterBeacon_v1} is in emergency mode or not.
function emergencyModeActive() external view returns (bool);
Returns
<none>
bool
emergencyModeActive Is the beacon in emergency mode.
version
Returns the version of the linked implementation.
function version() external view returns (uint, uint, uint);
Returns
<none>
uint256
Major version.
<none>
uint256
Minor version.
<none>
uint256
Patch version.
upgradeTo
Upgrades the {InverterBeacon_v1} to a new implementation address.
Only callable by owner.
function upgradeTo(
address newImplementation,
uint newMinorVersion,
uint newPatchVersion,
bool overrideShutdown
)
public
onlyOwner
validNewMinorOrPatchVersion(newMinorVersion, newPatchVersion);
Parameters
newImplementation
address
The new implementation address.
newMinorVersion
uint256
The new minor version of the implementation contract.
newPatchVersion
uint256
The new patch version of the implementation contract.
overrideShutdown
bool
Flag to enable upgradeTo function to override the shutdown.
shutDownImplementation
Shuts down the {InverterBeacon_v1} and stops the system.
Only callable by owner.
function shutDownImplementation() external onlyOwner;
restartImplementation
Restarts the {InverterBeacon_v1} and the system.
Only callable by owner.
function restartImplementation() external onlyOwner;
_upgradeTo
Internal function to upgrade the implementation.
function _upgradeTo(
address newImplementation,
uint newMinorVersion,
uint newPatchVersion,
bool overrideShutdown
) internal;
Parameters
newImplementation
address
The new implementation address.
newMinorVersion
uint256
The new minor version.
newPatchVersion
uint256
The new patch version.
overrideShutdown
bool
If the upgrade process should override the shutdown.
_setImplementation
Internal function to set the implementation.
function _setImplementation(address newImplementation, bool overrideShutdown)
internal
virtual
validImplementation(newImplementation);
Parameters
newImplementation
address
The new implementation address.
overrideShutdown
bool
If the upgrade process should override the shutdown.
Last updated