From d44dcb58430e6a23c8b9acd28a3485b688315f73 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Mon, 21 Oct 2024 17:14:10 +1000 Subject: [PATCH] Fix prettier issues --- contracts/staking/StakeHolder.sol | 42 +++++++-------- .../token/erc1155/abstract/ERC1155Permit.sol | 53 +++++-------------- .../erc1155/abstract/ImmutableERC1155Base.sol | 1 - .../erc721/abstract/ImmutableERC721Base.sol | 8 +-- .../abstract/ImmutableERC721HybridBase.sol | 8 +-- 5 files changed, 34 insertions(+), 78 deletions(-) diff --git a/contracts/staking/StakeHolder.sol b/contracts/staking/StakeHolder.sol index f6a45113..57901c8a 100644 --- a/contracts/staking/StakeHolder.sol +++ b/contracts/staking/StakeHolder.sol @@ -3,8 +3,7 @@ pragma solidity ^0.8.20; import {UUPSUpgradeable} from "openzeppelin-contracts-upgradeable-4.9.3/proxy/utils/UUPSUpgradeable.sol"; -import {AccessControlEnumerableUpgradeable, IAccessControlUpgradeable, AccessControlUpgradeable} from - "openzeppelin-contracts-upgradeable-4.9.3/access/AccessControlEnumerableUpgradeable.sol"; +import {AccessControlEnumerableUpgradeable, IAccessControlUpgradeable, AccessControlUpgradeable} from "openzeppelin-contracts-upgradeable-4.9.3/access/AccessControlEnumerableUpgradeable.sol"; /// @notice Struct to combine an account and an amount. struct AccountAmount { @@ -56,9 +55,9 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable { /// @notice Holds staking information for a single staker. struct StakeInfo { /// @notice Amount of stake. - uint256 stake; + uint256 stake; /// @notice True if this account has ever staked. - bool hasStaked; + bool hasStaked; } /// @notice The amount of value owned by each staker @@ -66,7 +65,7 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable { mapping(address staker => StakeInfo stakeInfo) private balances; /// @notice A list of all stakers who have ever staked. - /// @dev The list make contain stakers who have completely unstaked (that is, have + /// @dev The list make contain stakers who have completely unstaked (that is, have /// a balance of 0). This array is never re-ordered. As such, off-chain services /// could cache the results of getStakers(). // solhint-disable-next-line private-vars-leading-underscore @@ -91,11 +90,11 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable { /** * @notice Function to be called when upgrading this contract. * @dev Call this function as part of upgradeToAndCall(). - * This initial version of this function reverts. There is no situation + * This initial version of this function reverts. There is no situation * in which it makes sense to upgrade to the V0 storage layout. - * Note that this function is permissionless. Future versions must - * compare the code version and the storage version and upgrade - * appropriately. As such, the code will revert if an attacker calls + * Note that this function is permissionless. Future versions must + * compare the code version and the storage version and upgrade + * appropriately. As such, the code will revert if an attacker calls * this function attempting a malicious upgrade. * @ param _data ABI encoded data to be used as part of the contract storage upgrade. */ @@ -139,15 +138,12 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable { /** * @notice Any account can distribute tokens to any set of accounts. * @dev The total amount to distribute must match msg.value. - * This function does not need re-entrancy guard as the distribution mechanism + * This function does not need re-entrancy guard as the distribution mechanism * does not call out to another contract. - * @param _recipientsAndAmounts An array of recipients to distribute value to and + * @param _recipientsAndAmounts An array of recipients to distribute value to and * amounts to be distributed to each recipient. */ - function distributeRewards(AccountAmount[] calldata _recipientsAndAmounts) - external - payable - { + function distributeRewards(AccountAmount[] calldata _recipientsAndAmounts) external payable { // Initial validity checks if (msg.value == 0) { revert MustDistributeMoreThanZero(); @@ -160,7 +156,7 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable { AccountAmount calldata accountAmount = _recipientsAndAmounts[i]; uint256 amount = accountAmount.amount; // Add stake, but require the acount to either currently be staking or have - // previously staked. + // previously staked. _addStake(accountAmount.account, amount, true); total += amount; } @@ -192,9 +188,9 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable { /** * @notice Get the length of the stakers array. - * @dev This will be equal to the number of staker accounts that have ever staked. + * @dev This will be equal to the number of staker accounts that have ever staked. * Some of the accounts might have a zero balance, having staked and then - * unstaked. + * unstaked. * @return _len The length of the stakers array. */ function getNumStakers() external view returns (uint256 _len) { @@ -213,11 +209,10 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable { * @param _numberToReturn The number of accounts to return. * @return _stakers A subset of the stakers array. */ - function getStakers(uint256 _startOffset, uint256 _numberToReturn) - external - view - returns (address[] memory _stakers) - { + function getStakers( + uint256 _startOffset, + uint256 _numberToReturn + ) external view returns (address[] memory _stakers) { address[] memory stakerPartialArray = new address[](_numberToReturn); for (uint256 i = 0; i < _numberToReturn; i++) { stakerPartialArray[i] = stakers[_startOffset + i]; @@ -251,7 +246,6 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable { // solhint-disable-next-line no-empty-blocks function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADE_ROLE) {} - /** * @notice Prevent revoke or renounce role for the last DEFAULT_ADMIN_ROLE / the last role admin. * @param _role The role to be renounced. diff --git a/contracts/token/erc1155/abstract/ERC1155Permit.sol b/contracts/token/erc1155/abstract/ERC1155Permit.sol index c522fe84..f804a047 100644 --- a/contracts/token/erc1155/abstract/ERC1155Permit.sol +++ b/contracts/token/erc1155/abstract/ERC1155Permit.sol @@ -10,16 +10,12 @@ import "./IERC1155Permit.sol"; import {IImmutableERC1155Errors} from "../../../errors/Errors.sol"; abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImmutableERC1155Errors { - bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,bool approved,uint256 nonce,uint256 deadline)"); mapping(address => uint256) private _nonces; - constructor(string memory name, string memory uri) - ERC1155(uri) - EIP712(name, "1") - {} + constructor(string memory name, string memory uri) ERC1155(uri) EIP712(name, "1") {} function permit(address owner, address spender, bool approved, uint256 deadline, bytes memory sig) external { if (deadline < block.timestamp) { @@ -30,7 +26,7 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm // smart contract signature validation if (_isValidERC1271Signature(owner, digest, sig)) { - _setApprovalForAll(owner, spender, approved); + _setApprovalForAll(owner, spender, approved); return; } @@ -63,9 +59,7 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm * @param owner The address for which to retrieve the nonce. * @return Current nonce of the given token. */ - function nonces( - address owner - ) external view returns (uint256) { + function nonces(address owner) external view returns (uint256) { return _nonces[owner]; } @@ -82,16 +76,10 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm * @param interfaceId The interface identifier, which is a 4-byte selector. * @return True if the contract implements `interfaceId` and the call doesn't revert, otherwise false. */ - function supportsInterface(bytes4 interfaceId) - public - view - virtual - override(ERC1155) - returns (bool) - { - return - interfaceId == type(IERC1155Permit).interfaceId || // 0x9e3ae8e4 - super.supportsInterface(interfaceId); + function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155) returns (bool) { + return + interfaceId == type(IERC1155Permit).interfaceId || // 0x9e3ae8e4 + super.supportsInterface(interfaceId); } /** @@ -107,18 +95,10 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm bool approved, uint256 deadline ) internal returns (bytes32) { - return _hashTypedDataV4( - keccak256( - abi.encode( - _PERMIT_TYPEHASH, - owner, - spender, - approved, - _nonces[owner]++, - deadline - ) - ) - ); + return + _hashTypedDataV4( + keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, approved, _nonces[owner]++, deadline)) + ); } /** @@ -128,14 +108,10 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm * @param sig The actual signature bytes. * @return True if the signature is valid according to EIP-1271, otherwise false. */ - function _isValidERC1271Signature(address spender, bytes32 digest, bytes memory sig) private view returns(bool) { + function _isValidERC1271Signature(address spender, bytes32 digest, bytes memory sig) private view returns (bool) { // slither-disable-next-line low-level-calls (bool success, bytes memory res) = spender.staticcall( - abi.encodeWithSelector( - IERC1271.isValidSignature.selector, - digest, - sig - ) + abi.encodeWithSelector(IERC1271.isValidSignature.selector, digest, sig) ); if (success && res.length == 32) { @@ -154,8 +130,7 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm * @param owner The owner of the tokens. * @return True if the signature is from an approved operator or owner, otherwise false. */ - function _isValidEOASignature(address recoveredSigner, address owner) private pure returns(bool) { + function _isValidEOASignature(address recoveredSigner, address owner) private pure returns (bool) { return recoveredSigner != address(0) && recoveredSigner == owner; } - } diff --git a/contracts/token/erc1155/abstract/ImmutableERC1155Base.sol b/contracts/token/erc1155/abstract/ImmutableERC1155Base.sol index 5fc6b72a..92212571 100644 --- a/contracts/token/erc1155/abstract/ImmutableERC1155Base.sol +++ b/contracts/token/erc1155/abstract/ImmutableERC1155Base.sol @@ -10,7 +10,6 @@ import {OperatorAllowlistEnforced} from "../../../allowlist/OperatorAllowlistEnf import {AccessControlEnumerable, MintingAccessControl} from "../../../access/MintingAccessControl.sol"; - abstract contract ImmutableERC1155Base is OperatorAllowlistEnforced, ERC1155Permit, ERC2981, MintingAccessControl { /// @dev Contract level metadata string public contractURI; diff --git a/contracts/token/erc721/abstract/ImmutableERC721Base.sol b/contracts/token/erc721/abstract/ImmutableERC721Base.sol index 14c708ec..d9dac8b5 100644 --- a/contracts/token/erc721/abstract/ImmutableERC721Base.sol +++ b/contracts/token/erc721/abstract/ImmutableERC721Base.sol @@ -197,13 +197,7 @@ abstract contract ImmutableERC721Base is OperatorAllowlistEnforced, MintingAcces */ function supportsInterface( bytes4 interfaceId - ) - public - view - virtual - override(ERC721Permit, ERC2981, AccessControlEnumerable) - returns (bool) - { + ) public view virtual override(ERC721Permit, ERC2981, AccessControlEnumerable) returns (bool) { return super.supportsInterface(interfaceId); } diff --git a/contracts/token/erc721/abstract/ImmutableERC721HybridBase.sol b/contracts/token/erc721/abstract/ImmutableERC721HybridBase.sol index 942d0a02..154277e1 100644 --- a/contracts/token/erc721/abstract/ImmutableERC721HybridBase.sol +++ b/contracts/token/erc721/abstract/ImmutableERC721HybridBase.sol @@ -52,13 +52,7 @@ abstract contract ImmutableERC721HybridBase is /// @dev Returns the supported interfaces function supportsInterface( bytes4 interfaceId - ) - public - view - virtual - override(ERC721HybridPermit, ERC2981, AccessControlEnumerable) - returns (bool) - { + ) public view virtual override(ERC721HybridPermit, ERC2981, AccessControlEnumerable) returns (bool) { return super.supportsInterface(interfaceId); }