From b2cd857a576219ad2012a7244381cf3ee07c5aaf Mon Sep 17 00:00:00 2001 From: cairo Date: Mon, 16 Sep 2024 18:05:05 +0200 Subject: [PATCH 1/3] Clarify mapping named parameters --- contracts/access/AccessControl.sol | 4 ++-- contracts/access/extensions/AccessControlEnumerable.sol | 2 +- contracts/access/manager/AccessManager.sol | 4 ++-- contracts/finance/VestingWallet.sol | 2 +- contracts/governance/Governor.sol | 2 +- contracts/governance/TimelockController.sol | 2 +- .../governance/extensions/GovernorCountingFractional.sol | 4 ++-- .../governance/extensions/GovernorCountingSimple.sol | 4 ++-- .../governance/extensions/GovernorPreventLateQuorum.sol | 2 +- contracts/governance/extensions/GovernorStorage.sol | 2 +- .../governance/extensions/GovernorTimelockAccess.sol | 6 +++--- .../governance/extensions/GovernorTimelockControl.sol | 2 +- contracts/governance/utils/Votes.sol | 4 ++-- contracts/token/ERC1155/ERC1155.sol | 4 ++-- contracts/token/ERC1155/extensions/ERC1155Supply.sol | 2 +- contracts/token/ERC1155/extensions/ERC1155URIStorage.sol | 2 +- contracts/token/ERC20/ERC20.sol | 4 ++-- contracts/token/ERC721/ERC721.sol | 8 ++++---- contracts/token/ERC721/extensions/ERC721Enumerable.sol | 8 ++++---- contracts/token/ERC721/extensions/ERC721URIStorage.sol | 2 +- contracts/token/common/ERC2981.sol | 2 +- contracts/utils/Nonces.sol | 2 +- contracts/utils/structs/BitMaps.sol | 2 +- contracts/utils/structs/DoubleEndedQueue.sol | 2 +- contracts/utils/structs/EnumerableMap.sol | 2 +- contracts/utils/structs/EnumerableSet.sol | 2 +- scripts/generate/templates/EnumerableMap.js | 2 +- scripts/generate/templates/EnumerableSet.js | 2 +- 28 files changed, 43 insertions(+), 43 deletions(-) diff --git a/contracts/access/AccessControl.sol b/contracts/access/AccessControl.sol index 3e3341e9cfd..7a7d688c2b9 100644 --- a/contracts/access/AccessControl.sol +++ b/contracts/access/AccessControl.sol @@ -48,11 +48,11 @@ import {ERC165} from "../utils/introspection/ERC165.sol"; */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { - mapping(address account => bool) hasRole; + mapping(address account => bool status) hasRole; bytes32 adminRole; } - mapping(bytes32 role => RoleData) private _roles; + mapping(bytes32 role => RoleData data) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; diff --git a/contracts/access/extensions/AccessControlEnumerable.sol b/contracts/access/extensions/AccessControlEnumerable.sol index 222490c9b30..586034f4f14 100644 --- a/contracts/access/extensions/AccessControlEnumerable.sol +++ b/contracts/access/extensions/AccessControlEnumerable.sol @@ -13,7 +13,7 @@ import {EnumerableSet} from "../../utils/structs/EnumerableSet.sol"; abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; - mapping(bytes32 role => EnumerableSet.AddressSet) private _roleMembers; + mapping(bytes32 role => EnumerableSet.AddressSet members) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. diff --git a/contracts/access/manager/AccessManager.sol b/contracts/access/manager/AccessManager.sol index a6e2d7aed0e..9684dc8c1b8 100644 --- a/contracts/access/manager/AccessManager.sol +++ b/contracts/access/manager/AccessManager.sol @@ -109,8 +109,8 @@ contract AccessManager is Context, Multicall, IAccessManager { uint64 public constant PUBLIC_ROLE = type(uint64).max; // 2**64-1 mapping(address target => TargetConfig mode) private _targets; - mapping(uint64 roleId => Role) private _roles; - mapping(bytes32 operationId => Schedule) private _schedules; + mapping(uint64 roleId => Role role) private _roles; + mapping(bytes32 operationId => Schedule schedule) private _schedules; // Used to identify operations that are currently being executed via {execute}. // This should be transient storage when supported by the EVM. diff --git a/contracts/finance/VestingWallet.sol b/contracts/finance/VestingWallet.sol index f472b66068b..bc89b79ef7f 100644 --- a/contracts/finance/VestingWallet.sol +++ b/contracts/finance/VestingWallet.sol @@ -32,7 +32,7 @@ contract VestingWallet is Context, Ownable { event ERC20Released(address indexed token, uint256 amount); uint256 private _released; - mapping(address token => uint256) private _erc20Released; + mapping(address token => uint256 amount) private _erc20Released; uint64 private immutable _start; uint64 private immutable _duration; diff --git a/contracts/governance/Governor.sol b/contracts/governance/Governor.sol index 453f2029088..346999bcd9d 100644 --- a/contracts/governance/Governor.sol +++ b/contracts/governance/Governor.sol @@ -46,7 +46,7 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72 bytes32 private constant ALL_PROPOSAL_STATES_BITMAP = bytes32((2 ** (uint8(type(ProposalState).max) + 1)) - 1); string private _name; - mapping(uint256 proposalId => ProposalCore) private _proposals; + mapping(uint256 proposalId => ProposalCore proposal) private _proposals; // This queue keeps track of the governor operating on itself. Calls to functions protected by the {onlyGovernance} // modifier needs to be whitelisted in this queue. Whitelisting is set in {execute}, consumed by the diff --git a/contracts/governance/TimelockController.sol b/contracts/governance/TimelockController.sol index 349d940fd50..2aed261c8b5 100644 --- a/contracts/governance/TimelockController.sol +++ b/contracts/governance/TimelockController.sol @@ -27,7 +27,7 @@ contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder { bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE"); uint256 internal constant _DONE_TIMESTAMP = uint256(1); - mapping(bytes32 id => uint256) private _timestamps; + mapping(bytes32 id => uint256 timestamp) private _timestamps; uint256 private _minDelay; enum OperationState { diff --git a/contracts/governance/extensions/GovernorCountingFractional.sol b/contracts/governance/extensions/GovernorCountingFractional.sol index 5a553fbdb44..048630c611b 100644 --- a/contracts/governance/extensions/GovernorCountingFractional.sol +++ b/contracts/governance/extensions/GovernorCountingFractional.sol @@ -37,13 +37,13 @@ abstract contract GovernorCountingFractional is Governor { uint256 againstVotes; uint256 forVotes; uint256 abstainVotes; - mapping(address voter => uint256) usedVotes; + mapping(address voter => uint256 amount) usedVotes; } /** * @dev Mapping from proposal ID to vote tallies for that proposal. */ - mapping(uint256 => ProposalVote) private _proposalVotes; + mapping(uint256 proposalId => ProposalVote votes) private _proposalVotes; /** * @dev A fractional vote params uses more votes than are available for that user. diff --git a/contracts/governance/extensions/GovernorCountingSimple.sol b/contracts/governance/extensions/GovernorCountingSimple.sol index def29e34e61..7a399e5e57a 100644 --- a/contracts/governance/extensions/GovernorCountingSimple.sol +++ b/contracts/governance/extensions/GovernorCountingSimple.sol @@ -22,10 +22,10 @@ abstract contract GovernorCountingSimple is Governor { uint256 againstVotes; uint256 forVotes; uint256 abstainVotes; - mapping(address voter => bool) hasVoted; + mapping(address voter => bool status) hasVoted; } - mapping(uint256 proposalId => ProposalVote) private _proposalVotes; + mapping(uint256 proposalId => ProposalVote votes) private _proposalVotes; /** * @dev See {IGovernor-COUNTING_MODE}. diff --git a/contracts/governance/extensions/GovernorPreventLateQuorum.sol b/contracts/governance/extensions/GovernorPreventLateQuorum.sol index ff80af648db..209ee9393eb 100644 --- a/contracts/governance/extensions/GovernorPreventLateQuorum.sol +++ b/contracts/governance/extensions/GovernorPreventLateQuorum.sol @@ -18,7 +18,7 @@ import {Math} from "../../utils/math/Math.sol"; abstract contract GovernorPreventLateQuorum is Governor { uint48 private _voteExtension; - mapping(uint256 proposalId => uint48) private _extendedDeadlines; + mapping(uint256 proposalId => uint48 deadline) private _extendedDeadlines; /// @dev Emitted when a proposal deadline is pushed back due to reaching quorum late in its voting period. event ProposalExtended(uint256 indexed proposalId, uint64 extendedDeadline); diff --git a/contracts/governance/extensions/GovernorStorage.sol b/contracts/governance/extensions/GovernorStorage.sol index 2547b553bc8..1cdb4eadb48 100644 --- a/contracts/governance/extensions/GovernorStorage.sol +++ b/contracts/governance/extensions/GovernorStorage.sol @@ -23,7 +23,7 @@ abstract contract GovernorStorage is Governor { } uint256[] private _proposalIds; - mapping(uint256 proposalId => ProposalDetails) private _proposalDetails; + mapping(uint256 proposalId => ProposalDetails details) private _proposalDetails; /** * @dev Hook into the proposing mechanism diff --git a/contracts/governance/extensions/GovernorTimelockAccess.sol b/contracts/governance/extensions/GovernorTimelockAccess.sol index 6e2c5b84e3d..8cb367a3485 100644 --- a/contracts/governance/extensions/GovernorTimelockAccess.sol +++ b/contracts/governance/extensions/GovernorTimelockAccess.sol @@ -50,15 +50,15 @@ abstract contract GovernorTimelockAccess is Governor { // We pack 8 operations' data in each bucket. Each uint32 value is set to 1 upon proposal creation if it has // to be scheduled and executed through the manager. Upon queuing, the value is set to nonce + 2, where the // nonce is received from the manager when scheduling the operation. - mapping(uint256 operationBucket => uint32[8]) managerData; + mapping(uint256 operationBucket => uint32[8] data) managerData; } // The meaning of the "toggle" set to true depends on the target contract. // If target == address(this), the manager is ignored by default, and a true toggle means it won't be ignored. // For all other target contracts, the manager is used by default, and a true toggle means it will be ignored. - mapping(address target => mapping(bytes4 selector => bool)) private _ignoreToggle; + mapping(address target => mapping(bytes4 selector => bool status)) private _ignoreToggle; - mapping(uint256 proposalId => ExecutionPlan) private _executionPlan; + mapping(uint256 proposalId => ExecutionPlan execution) private _executionPlan; uint32 private _baseDelay; diff --git a/contracts/governance/extensions/GovernorTimelockControl.sol b/contracts/governance/extensions/GovernorTimelockControl.sol index 52d4b429598..c3d0e258f96 100644 --- a/contracts/governance/extensions/GovernorTimelockControl.sol +++ b/contracts/governance/extensions/GovernorTimelockControl.sol @@ -24,7 +24,7 @@ import {SafeCast} from "../../utils/math/SafeCast.sol"; */ abstract contract GovernorTimelockControl is Governor { TimelockController private _timelock; - mapping(uint256 proposalId => bytes32) private _timelockIds; + mapping(uint256 proposalId => bytes32 id) private _timelockIds; /** * @dev Emitted when the timelock controller used for proposal execution is modified. diff --git a/contracts/governance/utils/Votes.sol b/contracts/governance/utils/Votes.sol index 2b4def2e0cb..03dfc0ff8ac 100644 --- a/contracts/governance/utils/Votes.sol +++ b/contracts/governance/utils/Votes.sol @@ -35,9 +35,9 @@ abstract contract Votes is Context, EIP712, Nonces, IERC5805 { bytes32 private constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); - mapping(address account => address) private _delegatee; + mapping(address account => address delegatee) private _delegatee; - mapping(address delegatee => Checkpoints.Trace208) private _delegateCheckpoints; + mapping(address delegatee => Checkpoints.Trace208 checkpoints) private _delegateCheckpoints; Checkpoints.Trace208 private _totalCheckpoints; diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index b0e7e547ab2..0cdbfb37b19 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -20,9 +20,9 @@ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IER using Arrays for uint256[]; using Arrays for address[]; - mapping(uint256 id => mapping(address account => uint256)) private _balances; + mapping(uint256 id => mapping(address account => uint256 amount)) private _balances; - mapping(address account => mapping(address operator => bool)) private _operatorApprovals; + mapping(address account => mapping(address operator => bool status)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; diff --git a/contracts/token/ERC1155/extensions/ERC1155Supply.sol b/contracts/token/ERC1155/extensions/ERC1155Supply.sol index 33c5b103a95..06ce7950828 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Supply.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Supply.sol @@ -22,7 +22,7 @@ import {Arrays} from "../../../utils/Arrays.sol"; abstract contract ERC1155Supply is ERC1155 { using Arrays for uint256[]; - mapping(uint256 id => uint256) private _totalSupply; + mapping(uint256 id => uint256 supply) private _totalSupply; uint256 private _totalSupplyAll; /** diff --git a/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol b/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol index e8436e830d7..c0d6a279ca3 100644 --- a/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol +++ b/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol @@ -17,7 +17,7 @@ abstract contract ERC1155URIStorage is ERC1155 { string private _baseURI = ""; // Optional mapping for token URIs - mapping(uint256 tokenId => string) private _tokenURIs; + mapping(uint256 tokenId => string uri) private _tokenURIs; /** * @dev See {IERC1155MetadataURI-uri}. diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 9885eaac996..cd1bd9c1c55 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -27,9 +27,9 @@ import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; * applications. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { - mapping(address account => uint256) private _balances; + mapping(address account => uint256 balance) private _balances; - mapping(address account => mapping(address spender => uint256)) private _allowances; + mapping(address account => mapping(address spender => uint256 allowance)) private _allowances; uint256 private _totalSupply; diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index df7ff50575d..f4dd04d83e6 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -25,13 +25,13 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Er // Token symbol string private _symbol; - mapping(uint256 tokenId => address) private _owners; + mapping(uint256 tokenId => address owner) private _owners; - mapping(address owner => uint256) private _balances; + mapping(address owner => uint256 balance) private _balances; - mapping(uint256 tokenId => address) private _tokenApprovals; + mapping(uint256 tokenId => address spender) private _tokenApprovals; - mapping(address owner => mapping(address operator => bool)) private _operatorApprovals; + mapping(address owner => mapping(address operator => bool status)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. diff --git a/contracts/token/ERC721/extensions/ERC721Enumerable.sol b/contracts/token/ERC721/extensions/ERC721Enumerable.sol index 1bd4375290d..12d15e4e861 100644 --- a/contracts/token/ERC721/extensions/ERC721Enumerable.sol +++ b/contracts/token/ERC721/extensions/ERC721Enumerable.sol @@ -15,11 +15,11 @@ import {IERC165} from "../../../utils/introspection/ERC165.sol"; * interfere with enumerability and should not be used together with {ERC721Enumerable}. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { - mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens; - mapping(uint256 tokenId => uint256) private _ownedTokensIndex; + mapping(address owner => mapping(uint256 index => uint256 amount)) private _ownedTokens; + mapping(uint256 tokenId => uint256 index) private _ownedTokensIndex; uint256[] private _allTokens; - mapping(uint256 tokenId => uint256) private _allTokensIndex; + mapping(uint256 tokenId => uint256 index) private _allTokensIndex; /** * @dev An `owner`'s token query was out of bounds for `index`. @@ -122,7 +122,7 @@ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { uint256 lastTokenIndex = balanceOf(from); uint256 tokenIndex = _ownedTokensIndex[tokenId]; - mapping(uint256 index => uint256) storage _ownedTokensByOwner = _ownedTokens[from]; + mapping(uint256 index => uint256 amount) storage _ownedTokensByOwner = _ownedTokens[from]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { diff --git a/contracts/token/ERC721/extensions/ERC721URIStorage.sol b/contracts/token/ERC721/extensions/ERC721URIStorage.sol index 562f815c0b8..92337a011e3 100644 --- a/contracts/token/ERC721/extensions/ERC721URIStorage.sol +++ b/contracts/token/ERC721/extensions/ERC721URIStorage.sol @@ -19,7 +19,7 @@ abstract contract ERC721URIStorage is IERC4906, ERC721 { bytes4 private constant ERC4906_INTERFACE_ID = bytes4(0x49064906); // Optional mapping for token URIs - mapping(uint256 tokenId => string) private _tokenURIs; + mapping(uint256 tokenId => string uri) private _tokenURIs; /** * @dev See {IERC165-supportsInterface} diff --git a/contracts/token/common/ERC2981.sol b/contracts/token/common/ERC2981.sol index 70e8f469144..e3532f7b015 100644 --- a/contracts/token/common/ERC2981.sol +++ b/contracts/token/common/ERC2981.sol @@ -26,7 +26,7 @@ abstract contract ERC2981 is IERC2981, ERC165 { } RoyaltyInfo private _defaultRoyaltyInfo; - mapping(uint256 tokenId => RoyaltyInfo) private _tokenRoyaltyInfo; + mapping(uint256 tokenId => RoyaltyInfo royaltyInfo) private _tokenRoyaltyInfo; /** * @dev The default royalty set is invalid (eg. (numerator / denominator) >= 1). diff --git a/contracts/utils/Nonces.sol b/contracts/utils/Nonces.sol index 37451ff93a5..0018d8464fc 100644 --- a/contracts/utils/Nonces.sol +++ b/contracts/utils/Nonces.sol @@ -11,7 +11,7 @@ abstract contract Nonces { */ error InvalidAccountNonce(address account, uint256 currentNonce); - mapping(address account => uint256) private _nonces; + mapping(address account => uint256 nonce) private _nonces; /** * @dev Returns the next unused nonce for an address. diff --git a/contracts/utils/structs/BitMaps.sol b/contracts/utils/structs/BitMaps.sol index 40cceb90bd4..649f4a938b1 100644 --- a/contracts/utils/structs/BitMaps.sol +++ b/contracts/utils/structs/BitMaps.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.20; */ library BitMaps { struct BitMap { - mapping(uint256 bucket => uint256) _data; + mapping(uint256 bucket => uint256 data) _data; } /** diff --git a/contracts/utils/structs/DoubleEndedQueue.sol b/contracts/utils/structs/DoubleEndedQueue.sol index 48f0d68c1eb..581ee5b177e 100644 --- a/contracts/utils/structs/DoubleEndedQueue.sol +++ b/contracts/utils/structs/DoubleEndedQueue.sol @@ -29,7 +29,7 @@ library DoubleEndedQueue { struct Bytes32Deque { uint128 _begin; uint128 _end; - mapping(uint128 index => bytes32) _data; + mapping(uint128 index => bytes32 data) _data; } /** diff --git a/contracts/utils/structs/EnumerableMap.sol b/contracts/utils/structs/EnumerableMap.sol index e61182e1fbd..3c22a4df916 100644 --- a/contracts/utils/structs/EnumerableMap.sol +++ b/contracts/utils/structs/EnumerableMap.sol @@ -65,7 +65,7 @@ library EnumerableMap { struct Bytes32ToBytes32Map { // Storage of keys EnumerableSet.Bytes32Set _keys; - mapping(bytes32 key => bytes32) _values; + mapping(bytes32 key => bytes32 value) _values; } /** diff --git a/contracts/utils/structs/EnumerableSet.sol b/contracts/utils/structs/EnumerableSet.sol index 90fcfa9d77b..ea0fb1ae924 100644 --- a/contracts/utils/structs/EnumerableSet.sol +++ b/contracts/utils/structs/EnumerableSet.sol @@ -53,7 +53,7 @@ library EnumerableSet { bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. - mapping(bytes32 value => uint256) _positions; + mapping(bytes32 value => uint256 position) _positions; } /** diff --git a/scripts/generate/templates/EnumerableMap.js b/scripts/generate/templates/EnumerableMap.js index 656d8463dec..a679cff72ee 100644 --- a/scripts/generate/templates/EnumerableMap.js +++ b/scripts/generate/templates/EnumerableMap.js @@ -68,7 +68,7 @@ error EnumerableMapNonexistentKey(bytes32 key); struct Bytes32ToBytes32Map { // Storage of keys EnumerableSet.Bytes32Set _keys; - mapping(bytes32 key => bytes32) _values; + mapping(bytes32 key => bytes32 value) _values; } /** diff --git a/scripts/generate/templates/EnumerableSet.js b/scripts/generate/templates/EnumerableSet.js index 351466b1313..685ac697a18 100644 --- a/scripts/generate/templates/EnumerableSet.js +++ b/scripts/generate/templates/EnumerableSet.js @@ -58,7 +58,7 @@ struct Set { bytes32[] _values; // Position is the index of the value in the \`values\` array plus 1. // Position 0 is used to mean a value is not in the set. - mapping(bytes32 value => uint256) _positions; + mapping(bytes32 value => uint256 position) _positions; } /** From b1be33295848918e24e4d4b6d056cab965bcee45 Mon Sep 17 00:00:00 2001 From: cairo Date: Wed, 18 Sep 2024 18:18:17 +0200 Subject: [PATCH 2/3] Revert unneeded changes --- contracts/access/AccessControl.sol | 4 ++-- contracts/access/extensions/AccessControlEnumerable.sol | 2 +- contracts/access/manager/AccessManager.sol | 4 ++-- contracts/finance/VestingWallet.sol | 2 +- contracts/governance/Governor.sol | 2 +- contracts/governance/TimelockController.sol | 2 +- .../governance/extensions/GovernorCountingFractional.sol | 2 +- .../governance/extensions/GovernorCountingSimple.sol | 4 ++-- .../governance/extensions/GovernorPreventLateQuorum.sol | 2 +- contracts/governance/extensions/GovernorStorage.sol | 2 +- .../governance/extensions/GovernorTimelockAccess.sol | 6 +++--- .../governance/extensions/GovernorTimelockControl.sol | 2 +- contracts/governance/utils/Votes.sol | 4 ++-- contracts/token/ERC1155/ERC1155.sol | 4 ++-- contracts/token/ERC1155/extensions/ERC1155Supply.sol | 2 +- contracts/token/ERC1155/extensions/ERC1155URIStorage.sol | 2 +- contracts/token/ERC20/ERC20.sol | 4 ++-- contracts/token/ERC721/ERC721.sol | 8 ++++---- contracts/token/ERC721/extensions/ERC721Enumerable.sol | 8 ++++---- contracts/token/ERC721/extensions/ERC721URIStorage.sol | 2 +- contracts/token/common/ERC2981.sol | 2 +- contracts/utils/Nonces.sol | 2 +- contracts/utils/structs/BitMaps.sol | 2 +- contracts/utils/structs/DoubleEndedQueue.sol | 2 +- contracts/utils/structs/EnumerableMap.sol | 2 +- contracts/utils/structs/EnumerableSet.sol | 2 +- scripts/generate/templates/EnumerableMap.js | 2 +- scripts/generate/templates/EnumerableSet.js | 2 +- 28 files changed, 42 insertions(+), 42 deletions(-) diff --git a/contracts/access/AccessControl.sol b/contracts/access/AccessControl.sol index 7a7d688c2b9..3e3341e9cfd 100644 --- a/contracts/access/AccessControl.sol +++ b/contracts/access/AccessControl.sol @@ -48,11 +48,11 @@ import {ERC165} from "../utils/introspection/ERC165.sol"; */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { - mapping(address account => bool status) hasRole; + mapping(address account => bool) hasRole; bytes32 adminRole; } - mapping(bytes32 role => RoleData data) private _roles; + mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; diff --git a/contracts/access/extensions/AccessControlEnumerable.sol b/contracts/access/extensions/AccessControlEnumerable.sol index 586034f4f14..222490c9b30 100644 --- a/contracts/access/extensions/AccessControlEnumerable.sol +++ b/contracts/access/extensions/AccessControlEnumerable.sol @@ -13,7 +13,7 @@ import {EnumerableSet} from "../../utils/structs/EnumerableSet.sol"; abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; - mapping(bytes32 role => EnumerableSet.AddressSet members) private _roleMembers; + mapping(bytes32 role => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. diff --git a/contracts/access/manager/AccessManager.sol b/contracts/access/manager/AccessManager.sol index 9684dc8c1b8..a6e2d7aed0e 100644 --- a/contracts/access/manager/AccessManager.sol +++ b/contracts/access/manager/AccessManager.sol @@ -109,8 +109,8 @@ contract AccessManager is Context, Multicall, IAccessManager { uint64 public constant PUBLIC_ROLE = type(uint64).max; // 2**64-1 mapping(address target => TargetConfig mode) private _targets; - mapping(uint64 roleId => Role role) private _roles; - mapping(bytes32 operationId => Schedule schedule) private _schedules; + mapping(uint64 roleId => Role) private _roles; + mapping(bytes32 operationId => Schedule) private _schedules; // Used to identify operations that are currently being executed via {execute}. // This should be transient storage when supported by the EVM. diff --git a/contracts/finance/VestingWallet.sol b/contracts/finance/VestingWallet.sol index bc89b79ef7f..f472b66068b 100644 --- a/contracts/finance/VestingWallet.sol +++ b/contracts/finance/VestingWallet.sol @@ -32,7 +32,7 @@ contract VestingWallet is Context, Ownable { event ERC20Released(address indexed token, uint256 amount); uint256 private _released; - mapping(address token => uint256 amount) private _erc20Released; + mapping(address token => uint256) private _erc20Released; uint64 private immutable _start; uint64 private immutable _duration; diff --git a/contracts/governance/Governor.sol b/contracts/governance/Governor.sol index 346999bcd9d..453f2029088 100644 --- a/contracts/governance/Governor.sol +++ b/contracts/governance/Governor.sol @@ -46,7 +46,7 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72 bytes32 private constant ALL_PROPOSAL_STATES_BITMAP = bytes32((2 ** (uint8(type(ProposalState).max) + 1)) - 1); string private _name; - mapping(uint256 proposalId => ProposalCore proposal) private _proposals; + mapping(uint256 proposalId => ProposalCore) private _proposals; // This queue keeps track of the governor operating on itself. Calls to functions protected by the {onlyGovernance} // modifier needs to be whitelisted in this queue. Whitelisting is set in {execute}, consumed by the diff --git a/contracts/governance/TimelockController.sol b/contracts/governance/TimelockController.sol index 2aed261c8b5..349d940fd50 100644 --- a/contracts/governance/TimelockController.sol +++ b/contracts/governance/TimelockController.sol @@ -27,7 +27,7 @@ contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder { bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE"); uint256 internal constant _DONE_TIMESTAMP = uint256(1); - mapping(bytes32 id => uint256 timestamp) private _timestamps; + mapping(bytes32 id => uint256) private _timestamps; uint256 private _minDelay; enum OperationState { diff --git a/contracts/governance/extensions/GovernorCountingFractional.sol b/contracts/governance/extensions/GovernorCountingFractional.sol index 048630c611b..dba37da5057 100644 --- a/contracts/governance/extensions/GovernorCountingFractional.sol +++ b/contracts/governance/extensions/GovernorCountingFractional.sol @@ -37,7 +37,7 @@ abstract contract GovernorCountingFractional is Governor { uint256 againstVotes; uint256 forVotes; uint256 abstainVotes; - mapping(address voter => uint256 amount) usedVotes; + mapping(address voter => uint256) usedVotes; } /** diff --git a/contracts/governance/extensions/GovernorCountingSimple.sol b/contracts/governance/extensions/GovernorCountingSimple.sol index 7a399e5e57a..def29e34e61 100644 --- a/contracts/governance/extensions/GovernorCountingSimple.sol +++ b/contracts/governance/extensions/GovernorCountingSimple.sol @@ -22,10 +22,10 @@ abstract contract GovernorCountingSimple is Governor { uint256 againstVotes; uint256 forVotes; uint256 abstainVotes; - mapping(address voter => bool status) hasVoted; + mapping(address voter => bool) hasVoted; } - mapping(uint256 proposalId => ProposalVote votes) private _proposalVotes; + mapping(uint256 proposalId => ProposalVote) private _proposalVotes; /** * @dev See {IGovernor-COUNTING_MODE}. diff --git a/contracts/governance/extensions/GovernorPreventLateQuorum.sol b/contracts/governance/extensions/GovernorPreventLateQuorum.sol index 209ee9393eb..ff80af648db 100644 --- a/contracts/governance/extensions/GovernorPreventLateQuorum.sol +++ b/contracts/governance/extensions/GovernorPreventLateQuorum.sol @@ -18,7 +18,7 @@ import {Math} from "../../utils/math/Math.sol"; abstract contract GovernorPreventLateQuorum is Governor { uint48 private _voteExtension; - mapping(uint256 proposalId => uint48 deadline) private _extendedDeadlines; + mapping(uint256 proposalId => uint48) private _extendedDeadlines; /// @dev Emitted when a proposal deadline is pushed back due to reaching quorum late in its voting period. event ProposalExtended(uint256 indexed proposalId, uint64 extendedDeadline); diff --git a/contracts/governance/extensions/GovernorStorage.sol b/contracts/governance/extensions/GovernorStorage.sol index 1cdb4eadb48..2547b553bc8 100644 --- a/contracts/governance/extensions/GovernorStorage.sol +++ b/contracts/governance/extensions/GovernorStorage.sol @@ -23,7 +23,7 @@ abstract contract GovernorStorage is Governor { } uint256[] private _proposalIds; - mapping(uint256 proposalId => ProposalDetails details) private _proposalDetails; + mapping(uint256 proposalId => ProposalDetails) private _proposalDetails; /** * @dev Hook into the proposing mechanism diff --git a/contracts/governance/extensions/GovernorTimelockAccess.sol b/contracts/governance/extensions/GovernorTimelockAccess.sol index 8cb367a3485..6e2c5b84e3d 100644 --- a/contracts/governance/extensions/GovernorTimelockAccess.sol +++ b/contracts/governance/extensions/GovernorTimelockAccess.sol @@ -50,15 +50,15 @@ abstract contract GovernorTimelockAccess is Governor { // We pack 8 operations' data in each bucket. Each uint32 value is set to 1 upon proposal creation if it has // to be scheduled and executed through the manager. Upon queuing, the value is set to nonce + 2, where the // nonce is received from the manager when scheduling the operation. - mapping(uint256 operationBucket => uint32[8] data) managerData; + mapping(uint256 operationBucket => uint32[8]) managerData; } // The meaning of the "toggle" set to true depends on the target contract. // If target == address(this), the manager is ignored by default, and a true toggle means it won't be ignored. // For all other target contracts, the manager is used by default, and a true toggle means it will be ignored. - mapping(address target => mapping(bytes4 selector => bool status)) private _ignoreToggle; + mapping(address target => mapping(bytes4 selector => bool)) private _ignoreToggle; - mapping(uint256 proposalId => ExecutionPlan execution) private _executionPlan; + mapping(uint256 proposalId => ExecutionPlan) private _executionPlan; uint32 private _baseDelay; diff --git a/contracts/governance/extensions/GovernorTimelockControl.sol b/contracts/governance/extensions/GovernorTimelockControl.sol index c3d0e258f96..52d4b429598 100644 --- a/contracts/governance/extensions/GovernorTimelockControl.sol +++ b/contracts/governance/extensions/GovernorTimelockControl.sol @@ -24,7 +24,7 @@ import {SafeCast} from "../../utils/math/SafeCast.sol"; */ abstract contract GovernorTimelockControl is Governor { TimelockController private _timelock; - mapping(uint256 proposalId => bytes32 id) private _timelockIds; + mapping(uint256 proposalId => bytes32) private _timelockIds; /** * @dev Emitted when the timelock controller used for proposal execution is modified. diff --git a/contracts/governance/utils/Votes.sol b/contracts/governance/utils/Votes.sol index 03dfc0ff8ac..2b4def2e0cb 100644 --- a/contracts/governance/utils/Votes.sol +++ b/contracts/governance/utils/Votes.sol @@ -35,9 +35,9 @@ abstract contract Votes is Context, EIP712, Nonces, IERC5805 { bytes32 private constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); - mapping(address account => address delegatee) private _delegatee; + mapping(address account => address) private _delegatee; - mapping(address delegatee => Checkpoints.Trace208 checkpoints) private _delegateCheckpoints; + mapping(address delegatee => Checkpoints.Trace208) private _delegateCheckpoints; Checkpoints.Trace208 private _totalCheckpoints; diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 0cdbfb37b19..b0e7e547ab2 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -20,9 +20,9 @@ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IER using Arrays for uint256[]; using Arrays for address[]; - mapping(uint256 id => mapping(address account => uint256 amount)) private _balances; + mapping(uint256 id => mapping(address account => uint256)) private _balances; - mapping(address account => mapping(address operator => bool status)) private _operatorApprovals; + mapping(address account => mapping(address operator => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; diff --git a/contracts/token/ERC1155/extensions/ERC1155Supply.sol b/contracts/token/ERC1155/extensions/ERC1155Supply.sol index 06ce7950828..33c5b103a95 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Supply.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Supply.sol @@ -22,7 +22,7 @@ import {Arrays} from "../../../utils/Arrays.sol"; abstract contract ERC1155Supply is ERC1155 { using Arrays for uint256[]; - mapping(uint256 id => uint256 supply) private _totalSupply; + mapping(uint256 id => uint256) private _totalSupply; uint256 private _totalSupplyAll; /** diff --git a/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol b/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol index c0d6a279ca3..e8436e830d7 100644 --- a/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol +++ b/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol @@ -17,7 +17,7 @@ abstract contract ERC1155URIStorage is ERC1155 { string private _baseURI = ""; // Optional mapping for token URIs - mapping(uint256 tokenId => string uri) private _tokenURIs; + mapping(uint256 tokenId => string) private _tokenURIs; /** * @dev See {IERC1155MetadataURI-uri}. diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index cd1bd9c1c55..9885eaac996 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -27,9 +27,9 @@ import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; * applications. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { - mapping(address account => uint256 balance) private _balances; + mapping(address account => uint256) private _balances; - mapping(address account => mapping(address spender => uint256 allowance)) private _allowances; + mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index f4dd04d83e6..df7ff50575d 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -25,13 +25,13 @@ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Er // Token symbol string private _symbol; - mapping(uint256 tokenId => address owner) private _owners; + mapping(uint256 tokenId => address) private _owners; - mapping(address owner => uint256 balance) private _balances; + mapping(address owner => uint256) private _balances; - mapping(uint256 tokenId => address spender) private _tokenApprovals; + mapping(uint256 tokenId => address) private _tokenApprovals; - mapping(address owner => mapping(address operator => bool status)) private _operatorApprovals; + mapping(address owner => mapping(address operator => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. diff --git a/contracts/token/ERC721/extensions/ERC721Enumerable.sol b/contracts/token/ERC721/extensions/ERC721Enumerable.sol index 12d15e4e861..1bd4375290d 100644 --- a/contracts/token/ERC721/extensions/ERC721Enumerable.sol +++ b/contracts/token/ERC721/extensions/ERC721Enumerable.sol @@ -15,11 +15,11 @@ import {IERC165} from "../../../utils/introspection/ERC165.sol"; * interfere with enumerability and should not be used together with {ERC721Enumerable}. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { - mapping(address owner => mapping(uint256 index => uint256 amount)) private _ownedTokens; - mapping(uint256 tokenId => uint256 index) private _ownedTokensIndex; + mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens; + mapping(uint256 tokenId => uint256) private _ownedTokensIndex; uint256[] private _allTokens; - mapping(uint256 tokenId => uint256 index) private _allTokensIndex; + mapping(uint256 tokenId => uint256) private _allTokensIndex; /** * @dev An `owner`'s token query was out of bounds for `index`. @@ -122,7 +122,7 @@ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { uint256 lastTokenIndex = balanceOf(from); uint256 tokenIndex = _ownedTokensIndex[tokenId]; - mapping(uint256 index => uint256 amount) storage _ownedTokensByOwner = _ownedTokens[from]; + mapping(uint256 index => uint256) storage _ownedTokensByOwner = _ownedTokens[from]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { diff --git a/contracts/token/ERC721/extensions/ERC721URIStorage.sol b/contracts/token/ERC721/extensions/ERC721URIStorage.sol index 92337a011e3..562f815c0b8 100644 --- a/contracts/token/ERC721/extensions/ERC721URIStorage.sol +++ b/contracts/token/ERC721/extensions/ERC721URIStorage.sol @@ -19,7 +19,7 @@ abstract contract ERC721URIStorage is IERC4906, ERC721 { bytes4 private constant ERC4906_INTERFACE_ID = bytes4(0x49064906); // Optional mapping for token URIs - mapping(uint256 tokenId => string uri) private _tokenURIs; + mapping(uint256 tokenId => string) private _tokenURIs; /** * @dev See {IERC165-supportsInterface} diff --git a/contracts/token/common/ERC2981.sol b/contracts/token/common/ERC2981.sol index e3532f7b015..70e8f469144 100644 --- a/contracts/token/common/ERC2981.sol +++ b/contracts/token/common/ERC2981.sol @@ -26,7 +26,7 @@ abstract contract ERC2981 is IERC2981, ERC165 { } RoyaltyInfo private _defaultRoyaltyInfo; - mapping(uint256 tokenId => RoyaltyInfo royaltyInfo) private _tokenRoyaltyInfo; + mapping(uint256 tokenId => RoyaltyInfo) private _tokenRoyaltyInfo; /** * @dev The default royalty set is invalid (eg. (numerator / denominator) >= 1). diff --git a/contracts/utils/Nonces.sol b/contracts/utils/Nonces.sol index 0018d8464fc..37451ff93a5 100644 --- a/contracts/utils/Nonces.sol +++ b/contracts/utils/Nonces.sol @@ -11,7 +11,7 @@ abstract contract Nonces { */ error InvalidAccountNonce(address account, uint256 currentNonce); - mapping(address account => uint256 nonce) private _nonces; + mapping(address account => uint256) private _nonces; /** * @dev Returns the next unused nonce for an address. diff --git a/contracts/utils/structs/BitMaps.sol b/contracts/utils/structs/BitMaps.sol index 649f4a938b1..40cceb90bd4 100644 --- a/contracts/utils/structs/BitMaps.sol +++ b/contracts/utils/structs/BitMaps.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.20; */ library BitMaps { struct BitMap { - mapping(uint256 bucket => uint256 data) _data; + mapping(uint256 bucket => uint256) _data; } /** diff --git a/contracts/utils/structs/DoubleEndedQueue.sol b/contracts/utils/structs/DoubleEndedQueue.sol index 581ee5b177e..48f0d68c1eb 100644 --- a/contracts/utils/structs/DoubleEndedQueue.sol +++ b/contracts/utils/structs/DoubleEndedQueue.sol @@ -29,7 +29,7 @@ library DoubleEndedQueue { struct Bytes32Deque { uint128 _begin; uint128 _end; - mapping(uint128 index => bytes32 data) _data; + mapping(uint128 index => bytes32) _data; } /** diff --git a/contracts/utils/structs/EnumerableMap.sol b/contracts/utils/structs/EnumerableMap.sol index 3c22a4df916..e61182e1fbd 100644 --- a/contracts/utils/structs/EnumerableMap.sol +++ b/contracts/utils/structs/EnumerableMap.sol @@ -65,7 +65,7 @@ library EnumerableMap { struct Bytes32ToBytes32Map { // Storage of keys EnumerableSet.Bytes32Set _keys; - mapping(bytes32 key => bytes32 value) _values; + mapping(bytes32 key => bytes32) _values; } /** diff --git a/contracts/utils/structs/EnumerableSet.sol b/contracts/utils/structs/EnumerableSet.sol index ea0fb1ae924..90fcfa9d77b 100644 --- a/contracts/utils/structs/EnumerableSet.sol +++ b/contracts/utils/structs/EnumerableSet.sol @@ -53,7 +53,7 @@ library EnumerableSet { bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. - mapping(bytes32 value => uint256 position) _positions; + mapping(bytes32 value => uint256) _positions; } /** diff --git a/scripts/generate/templates/EnumerableMap.js b/scripts/generate/templates/EnumerableMap.js index a679cff72ee..656d8463dec 100644 --- a/scripts/generate/templates/EnumerableMap.js +++ b/scripts/generate/templates/EnumerableMap.js @@ -68,7 +68,7 @@ error EnumerableMapNonexistentKey(bytes32 key); struct Bytes32ToBytes32Map { // Storage of keys EnumerableSet.Bytes32Set _keys; - mapping(bytes32 key => bytes32 value) _values; + mapping(bytes32 key => bytes32) _values; } /** diff --git a/scripts/generate/templates/EnumerableSet.js b/scripts/generate/templates/EnumerableSet.js index 685ac697a18..351466b1313 100644 --- a/scripts/generate/templates/EnumerableSet.js +++ b/scripts/generate/templates/EnumerableSet.js @@ -58,7 +58,7 @@ struct Set { bytes32[] _values; // Position is the index of the value in the \`values\` array plus 1. // Position 0 is used to mean a value is not in the set. - mapping(bytes32 value => uint256 position) _positions; + mapping(bytes32 value => uint256) _positions; } /** From 336d7f87681c71c4bfc6d9407ae23aba35e72c67 Mon Sep 17 00:00:00 2001 From: cairo Date: Wed, 18 Sep 2024 18:20:30 +0200 Subject: [PATCH 3/3] Remove redundant param name --- contracts/governance/extensions/GovernorCountingFractional.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/governance/extensions/GovernorCountingFractional.sol b/contracts/governance/extensions/GovernorCountingFractional.sol index dba37da5057..06e7897dc48 100644 --- a/contracts/governance/extensions/GovernorCountingFractional.sol +++ b/contracts/governance/extensions/GovernorCountingFractional.sol @@ -43,7 +43,7 @@ abstract contract GovernorCountingFractional is Governor { /** * @dev Mapping from proposal ID to vote tallies for that proposal. */ - mapping(uint256 proposalId => ProposalVote votes) private _proposalVotes; + mapping(uint256 proposalId => ProposalVote) private _proposalVotes; /** * @dev A fractional vote params uses more votes than are available for that user.