Skip to content

Commit

Permalink
Make some functions overridable.
Browse files Browse the repository at this point in the history
  • Loading branch information
matjazv committed Feb 19, 2024
1 parent a2be87e commit 41c3f34
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/L2/L2VotingPower.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ contract L2VotingPower is ERC20VotesUpgradeable, OwnableUpgradeable, UUPSUpgrade
/// @notice Ensures that only the owner can authorize a contract upgrade. It reverts if called by any address other
/// than the contract owner.
/// @param _newImplementation The address of the new contract implementation to which the proxy will be upgraded.
function _authorizeUpgrade(address _newImplementation) internal override onlyOwner { }
function _authorizeUpgrade(address _newImplementation) internal virtual override onlyOwner { }

/// @notice Calculates the voting power of a locking position.
/// @param position Locking position.
/// @return Voting power of the locking position.
function votingPower(LockingPosition memory position) internal pure returns (uint256) {
function votingPower(LockingPosition memory position) internal pure virtual returns (uint256) {
uint256 powerDuringLocking = position.amount * (position.unlockingDuration + HEADSTART);
if (position.expDate == 0) {
return powerDuringLocking;
Expand All @@ -83,37 +83,38 @@ contract L2VotingPower is ERC20VotesUpgradeable, OwnableUpgradeable, UUPSUpgrade
LockingPosition memory positionAfter
)
public
virtual
onlyStakingContract
{
_mint(ownerAddress, votingPower(positionAfter));
_burn(ownerAddress, votingPower(positionBefore));
}

/// @notice Overrides clock() function to make the token & governor timestamp-based
function clock() public view override returns (uint48) {
function clock() public view virtual override returns (uint48) {
return uint48(block.timestamp);
}

/// @notice Overrides CLOCK_MODE() function to make the token & governor timestamp-based
function CLOCK_MODE() public pure override returns (string memory) {
function CLOCK_MODE() public pure virtual override returns (string memory) {
return "mode=timestamp";
}

/// @notice Always reverts to disable ERC20 token transfer feature.
/// @dev This function always reverts.
function approve(address, uint256) public pure override(ERC20Upgradeable) returns (bool) {
function approve(address, uint256) public pure virtual override(ERC20Upgradeable) returns (bool) {
revert ApproveDisabled();
}

/// @notice Always reverts to disable ERC20 token transfer feature.
/// @dev This function always reverts.
function transfer(address, uint256) public pure override(ERC20Upgradeable) returns (bool) {
function transfer(address, uint256) public pure virtual override(ERC20Upgradeable) returns (bool) {
revert TransferDisabled();
}

/// @notice Always reverts to disable ERC20 token transfer feature.
/// @dev This function always reverts.
function transferFrom(address, address, uint256) public pure override(ERC20Upgradeable) returns (bool) {
function transferFrom(address, address, uint256) public pure virtual override(ERC20Upgradeable) returns (bool) {
revert TransferDisabled();
}
}

0 comments on commit 41c3f34

Please sign in to comment.