Implement extra suggestions from audit review of 4.9 (#4224)

This commit is contained in:
Ernesto García
2023-05-09 18:19:35 +02:00
committed by GitHub
parent 832c352c7d
commit 34d926dd7e
4 changed files with 16 additions and 8 deletions

View File

@ -174,6 +174,8 @@ contract TransparentUpgradeableProxy is ERC1967Proxy {
/** /**
* @dev Returns the current admin. * @dev Returns the current admin.
*
* CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.
*/ */
function _admin() internal view virtual returns (address) { function _admin() internal view virtual returns (address) {
return _getAdmin(); return _getAdmin();

View File

@ -234,7 +234,7 @@ library Checkpoints {
} }
/** /**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key. * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none.
*/ */
function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224) { function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length; uint256 len = self._checkpoints.length;
@ -243,7 +243,7 @@ library Checkpoints {
} }
/** /**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key. * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none.
* *
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high keys). * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high keys).
*/ */
@ -410,7 +410,7 @@ library Checkpoints {
} }
/** /**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key. * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none.
*/ */
function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160) { function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length; uint256 len = self._checkpoints.length;
@ -419,7 +419,7 @@ library Checkpoints {
} }
/** /**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key. * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none.
* *
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high keys). * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high keys).
*/ */

View File

@ -4,13 +4,18 @@ pragma solidity ^0.8.8;
import "./StorageSlot.sol"; import "./StorageSlot.sol";
// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
// | length | 0x BB |
type ShortString is bytes32; type ShortString is bytes32;
/** /**
* @dev This library provides functions to convert short memory strings * @dev This library provides functions to convert short memory strings
* into a `ShortString` type that can be used as an immutable variable. * into a `ShortString` type that can be used as an immutable variable.
* Strings of arbitrary length can be optimized if they are short enough by *
* the addition of a storage variable used as fallback. * Strings of arbitrary length can be optimized using this library if
* they are short enough (up to 31 bytes) by packing them with their
* length (1 byte) in a single EVM word (32 bytes). Additionally, a
* fallback mechanism can be used for every other case.
* *
* Usage example: * Usage example:
* *
@ -32,6 +37,7 @@ type ShortString is bytes32;
* ``` * ```
*/ */
library ShortStrings { library ShortStrings {
// Used as an identifier for strings longer than 31 bytes.
bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;
error StringTooLong(string str); error StringTooLong(string str);

View File

@ -55,7 +55,7 @@ function lowerLookup(${opts.historyTypeName} storage self, ${opts.keyTypeName} k
} }
/** /**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key. * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none.
*/ */
function upperLookup(${opts.historyTypeName} storage self, ${opts.keyTypeName} key) internal view returns (${opts.valueTypeName}) { function upperLookup(${opts.historyTypeName} storage self, ${opts.keyTypeName} key) internal view returns (${opts.valueTypeName}) {
uint256 len = self.${opts.checkpointFieldName}.length; uint256 len = self.${opts.checkpointFieldName}.length;
@ -64,7 +64,7 @@ function upperLookup(${opts.historyTypeName} storage self, ${opts.keyTypeName} k
} }
/** /**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key. * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none.
* *
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high keys). * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high keys).
*/ */