Add Prettier for linting and fix Solhint config (#2697)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
@ -43,8 +43,7 @@ library EnumerableMap {
|
||||
struct Map {
|
||||
// Storage of keys
|
||||
EnumerableSet.Bytes32Set _keys;
|
||||
|
||||
mapping (bytes32 => bytes32) _values;
|
||||
mapping(bytes32 => bytes32) _values;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +53,11 @@ library EnumerableMap {
|
||||
* Returns true if the key was added to the map, that is if it was not
|
||||
* already present.
|
||||
*/
|
||||
function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
|
||||
function _set(
|
||||
Map storage map,
|
||||
bytes32 key,
|
||||
bytes32 value
|
||||
) private returns (bool) {
|
||||
map._values[key] = value;
|
||||
return map._keys.add(key);
|
||||
}
|
||||
@ -83,16 +86,16 @@ library EnumerableMap {
|
||||
return map._keys.length();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of entries inside the
|
||||
* array, and it may change when more entries are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
/**
|
||||
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of entries inside the
|
||||
* array, and it may change when more entries are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
|
||||
bytes32 key = map._keys.at(index);
|
||||
return (key, map._values[key]);
|
||||
@ -130,7 +133,11 @@ library EnumerableMap {
|
||||
* CAUTION: This function is deprecated because it requires allocating memory for the error
|
||||
* message unnecessarily. For custom revert reasons use {_tryGet}.
|
||||
*/
|
||||
function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
|
||||
function _get(
|
||||
Map storage map,
|
||||
bytes32 key,
|
||||
string memory errorMessage
|
||||
) private view returns (bytes32) {
|
||||
bytes32 value = map._values[key];
|
||||
require(value != 0 || _contains(map, key), errorMessage);
|
||||
return value;
|
||||
@ -149,7 +156,11 @@ library EnumerableMap {
|
||||
* Returns true if the key was added to the map, that is if it was not
|
||||
* already present.
|
||||
*/
|
||||
function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
|
||||
function set(
|
||||
UintToAddressMap storage map,
|
||||
uint256 key,
|
||||
address value
|
||||
) internal returns (bool) {
|
||||
return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
|
||||
}
|
||||
|
||||
@ -176,15 +187,15 @@ library EnumerableMap {
|
||||
return _length(map._inner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the element stored at position `index` in the set. O(1).
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
/**
|
||||
* @dev Returns the element stored at position `index` in the set. O(1).
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
|
||||
(bytes32 key, bytes32 value) = _at(map._inner, index);
|
||||
return (uint256(key), address(uint160(uint256(value))));
|
||||
@ -218,7 +229,11 @@ library EnumerableMap {
|
||||
* CAUTION: This function is deprecated because it requires allocating memory for the error
|
||||
* message unnecessarily. For custom revert reasons use {tryGet}.
|
||||
*/
|
||||
function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
|
||||
function get(
|
||||
UintToAddressMap storage map,
|
||||
uint256 key,
|
||||
string memory errorMessage
|
||||
) internal view returns (address) {
|
||||
return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,10 +39,9 @@ library EnumerableSet {
|
||||
struct Set {
|
||||
// Storage of set values
|
||||
bytes32[] _values;
|
||||
|
||||
// Position of the value in the `values` array, plus 1 because index 0
|
||||
// means a value is not in the set.
|
||||
mapping (bytes32 => uint256) _indexes;
|
||||
mapping(bytes32 => uint256) _indexes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,7 +72,8 @@ library EnumerableSet {
|
||||
// We read and store the value's index to prevent multiple reads from the same storage slot
|
||||
uint256 valueIndex = set._indexes[value];
|
||||
|
||||
if (valueIndex != 0) { // Equivalent to contains(set, value)
|
||||
if (valueIndex != 0) {
|
||||
// Equivalent to contains(set, value)
|
||||
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
|
||||
// the array, and then remove the last element (sometimes called as 'swap and pop').
|
||||
// This modifies the order of the array, as noted in {at}.
|
||||
@ -116,16 +116,16 @@ library EnumerableSet {
|
||||
return set._values.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the value stored at position `index` in the set. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
/**
|
||||
* @dev Returns the value stored at position `index` in the set. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
function _at(Set storage set, uint256 index) private view returns (bytes32) {
|
||||
return set._values[index];
|
||||
}
|
||||
@ -170,16 +170,16 @@ library EnumerableSet {
|
||||
return _length(set._inner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the value stored at position `index` in the set. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
/**
|
||||
* @dev Returns the value stored at position `index` in the set. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
|
||||
return _at(set._inner, index);
|
||||
}
|
||||
@ -224,21 +224,20 @@ library EnumerableSet {
|
||||
return _length(set._inner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the value stored at position `index` in the set. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
/**
|
||||
* @dev Returns the value stored at position `index` in the set. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
function at(AddressSet storage set, uint256 index) internal view returns (address) {
|
||||
return address(uint160(uint256(_at(set._inner, index))));
|
||||
}
|
||||
|
||||
|
||||
// UintSet
|
||||
|
||||
struct UintSet {
|
||||
@ -279,16 +278,16 @@ library EnumerableSet {
|
||||
return _length(set._inner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the value stored at position `index` in the set. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
/**
|
||||
* @dev Returns the value stored at position `index` in the set. O(1).
|
||||
*
|
||||
* Note that there are no guarantees on the ordering of values inside the
|
||||
* array, and it may change when more values are added or removed.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - `index` must be strictly less than {length}.
|
||||
*/
|
||||
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
|
||||
return uint256(_at(set._inner, index));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user