Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify mapping named parameters #5204

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/access/AccessControl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion contracts/access/extensions/AccessControlEnumerable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
4 changes: 2 additions & 2 deletions contracts/access/manager/AccessManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
cairoeth marked this conversation as resolved.
Show resolved Hide resolved

// Used to identify operations that are currently being executed via {execute}.
// This should be transient storage when supported by the EVM.
Expand Down
2 changes: 1 addition & 1 deletion contracts/finance/VestingWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/TimelockController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions contracts/governance/extensions/GovernorCountingSimple.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/extensions/GovernorStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions contracts/governance/extensions/GovernorTimelockAccess.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions contracts/governance/utils/Votes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions contracts/token/ERC1155/ERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC1155/extensions/ERC1155Supply.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC1155/extensions/ERC1155URIStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/ERC20/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions contracts/token/ERC721/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions contracts/token/ERC721/extensions/ERC721Enumerable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC721/extensions/ERC721URIStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/common/ERC2981.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/Nonces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/structs/BitMaps.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pragma solidity ^0.8.20;
*/
library BitMaps {
struct BitMap {
mapping(uint256 bucket => uint256) _data;
mapping(uint256 bucket => uint256 data) _data;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/structs/DoubleEndedQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ library DoubleEndedQueue {
struct Bytes32Deque {
uint128 _begin;
uint128 _end;
mapping(uint128 index => bytes32) _data;
mapping(uint128 index => bytes32 data) _data;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/structs/EnumerableMap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/structs/EnumerableSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate/templates/EnumerableMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate/templates/EnumerableSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down