From da2134b4bf3e8174d28995cf4918a4d38ac71e4f Mon Sep 17 00:00:00 2001 From: Ethan Date: Fri, 23 Aug 2024 14:45:03 +0800 Subject: [PATCH] chores: lint contracts --- contracts/BSCGovernor.sol | 12 +++++-- contracts/StakeHub.sol | 70 ++++++++++++++------------------------- 2 files changed, 33 insertions(+), 49 deletions(-) diff --git a/contracts/BSCGovernor.sol b/contracts/BSCGovernor.sol index 766f90a4..2d12a97e 100644 --- a/contracts/BSCGovernor.sol +++ b/contracts/BSCGovernor.sol @@ -214,7 +214,9 @@ contract BSCGovernor is *@return `true` if the contract implements `interfaceID` and *`interfaceID` is not 0xffffffff, `false` otherwise */ - function supportsInterface(bytes4 interfaceId) + function supportsInterface( + bytes4 interfaceId + ) public view override(GovernorUpgradeable, IERC165Upgradeable, GovernorTimelockControlUpgradeable) @@ -227,7 +229,9 @@ contract BSCGovernor is * @notice module:core * @dev Current state of a proposal, following Compound's convention */ - function state(uint256 proposalId) + function state( + uint256 proposalId + ) public view override(GovernorUpgradeable, IGovernorUpgradeable, GovernorTimelockControlUpgradeable) @@ -253,7 +257,9 @@ contract BSCGovernor is * @dev Timepoint at which votes close. If using block number, votes close at the end of this block, so it is * possible to cast a vote during this block. */ - function proposalDeadline(uint256 proposalId) + function proposalDeadline( + uint256 proposalId + ) public view override(IGovernorUpgradeable, GovernorUpgradeable, GovernorPreventLateQuorumUpgradeable) diff --git a/contracts/StakeHub.sol b/contracts/StakeHub.sol index 8a03e5be..86f46e4b 100644 --- a/contracts/StakeHub.sol +++ b/contracts/StakeHub.sol @@ -416,12 +416,9 @@ contract StakeHub is SystemV2, Initializable, Protectable { /** * @param newConsensusAddress the new consensus address of the validator */ - function editConsensusAddress(address newConsensusAddress) - external - whenNotPaused - notInBlackList - validatorExist(_bep410MsgSender()) - { + function editConsensusAddress( + address newConsensusAddress + ) external whenNotPaused notInBlackList validatorExist(_bep410MsgSender()) { if (newConsensusAddress == address(0)) revert InvalidConsensusAddress(); if (consensusToOperator[newConsensusAddress] != address(0) || _legacyConsensusAddress[newConsensusAddress]) { revert DuplicateConsensusAddress(); @@ -442,12 +439,9 @@ contract StakeHub is SystemV2, Initializable, Protectable { /** * @param commissionRate the new commission rate of the validator */ - function editCommissionRate(uint64 commissionRate) - external - whenNotPaused - notInBlackList - validatorExist(_bep410MsgSender()) - { + function editCommissionRate( + uint64 commissionRate + ) external whenNotPaused notInBlackList validatorExist(_bep410MsgSender()) { address operatorAddress = _bep410MsgSender(); Validator storage valInfo = _validators[operatorAddress]; if (valInfo.updateTime + BREATHE_BLOCK_INTERVAL > block.timestamp) revert UpdateTooFrequently(); @@ -468,12 +462,9 @@ contract StakeHub is SystemV2, Initializable, Protectable { * @notice the moniker of the validator will be ignored as it is not editable * @param description the new description of the validator */ - function editDescription(Description memory description) - external - whenNotPaused - notInBlackList - validatorExist(_bep410MsgSender()) - { + function editDescription( + Description memory description + ) external whenNotPaused notInBlackList validatorExist(_bep410MsgSender()) { address operatorAddress = _bep410MsgSender(); Validator storage valInfo = _validators[operatorAddress]; if (valInfo.updateTime + BREATHE_BLOCK_INTERVAL > block.timestamp) revert UpdateTooFrequently(); @@ -952,11 +943,9 @@ contract StakeHub is SystemV2, Initializable, Protectable { * @return jailed whether the validator is jailed * @return jailUntil the jail time of the validator */ - function getValidatorBasicInfo(address operatorAddress) - external - view - returns (uint256 createdTime, bool jailed, uint256 jailUntil) - { + function getValidatorBasicInfo( + address operatorAddress + ) external view returns (uint256 createdTime, bool jailed, uint256 jailUntil) { Validator memory valInfo = _validators[operatorAddress]; createdTime = valInfo.createdTime; jailed = valInfo.jailed; @@ -968,12 +957,9 @@ contract StakeHub is SystemV2, Initializable, Protectable { * * @return the description of a validator */ - function getValidatorDescription(address operatorAddress) - external - view - validatorExist(operatorAddress) - returns (Description memory) - { + function getValidatorDescription( + address operatorAddress + ) external view validatorExist(operatorAddress) returns (Description memory) { return _validators[operatorAddress].description; } @@ -982,12 +968,9 @@ contract StakeHub is SystemV2, Initializable, Protectable { * * @return the commission of a validator */ - function getValidatorCommission(address operatorAddress) - external - view - validatorExist(operatorAddress) - returns (Commission memory) - { + function getValidatorCommission( + address operatorAddress + ) external view validatorExist(operatorAddress) returns (Commission memory) { return _validators[operatorAddress].commission; } @@ -996,12 +979,9 @@ contract StakeHub is SystemV2, Initializable, Protectable { * * @return the agent of a validator */ - function getValidatorAgent(address operatorAddress) - external - view - validatorExist(operatorAddress) - returns (address) - { + function getValidatorAgent( + address operatorAddress + ) external view validatorExist(operatorAddress) returns (address) { return _validators[operatorAddress].agent; } @@ -1051,11 +1031,9 @@ contract StakeHub is SystemV2, Initializable, Protectable { } /*----------------- internal functions -----------------*/ - function _decodeMigrationSynPackage(bytes memory msgBytes) - internal - pure - returns (StakeMigrationPackage memory, bool) - { + function _decodeMigrationSynPackage( + bytes memory msgBytes + ) internal pure returns (StakeMigrationPackage memory, bool) { StakeMigrationPackage memory migrationPackage; RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator();