Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions src/StdAssertions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract contract StdAssertions {
event log_named_array(string key, int256[] val);
event log_named_array(string key, address[] val);

bytes32 private constant FAILED_SLOT = bytes32("failed");
bytes32 private constant _FAILED_SLOT = bytes32("failed");

bool private _failed;

Expand All @@ -43,13 +43,13 @@ abstract contract StdAssertions {
if (_failed) {
return true;
} else {
return vm.load(address(vm), FAILED_SLOT) != bytes32(0);
return vm.load(address(vm), _FAILED_SLOT) != bytes32(0);
}
}

/// @notice Marks the test as failed and records the failure in storage.
function fail() internal virtual {
vm.store(address(vm), FAILED_SLOT, bytes32(uint256(1)));
vm.store(address(vm), _FAILED_SLOT, bytes32(uint256(1)));
_failed = true;
}

Expand Down
170 changes: 86 additions & 84 deletions src/StdChains.sol

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions src/StdCheats.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {Vm} from "./Vm.sol";
abstract contract StdCheatsSafe {
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));

uint256 private constant UINT256_MAX =
uint256 private constant _UINT256_MAX =
115792089237316195423570985008687907853269984665640564039457584007913129639935;

bool private gasMeteringOff;
bool private _gasMeteringOff;

// Data structures to parse Transaction objects from the broadcast artifact
// that conform to EIP1559. The Raw structs are what are parsed from the JSON
Expand Down Expand Up @@ -283,7 +283,7 @@ abstract contract StdCheatsSafe {
// implemented by `addr`, which should be taken into account when this function is used.
function _isPayable(address addr) private returns (bool) {
require(
addr.balance < UINT256_MAX,
addr.balance < _UINT256_MAX,
"StdCheats _isPayable(address): Balance equals max uint256, so it cannot receive any more funds"
);
uint256 origBalanceTest = address(this).balance;
Expand Down Expand Up @@ -629,14 +629,14 @@ abstract contract StdCheatsSafe {
// i.e. funcA() noGasMetering { funcB() }, where funcB has noGasMetering as well.
// funcA will have `gasStartedOff` as false, funcB will have it as true,
// so we only turn metering back on at the end of the funcA
bool gasStartedOff = gasMeteringOff;
gasMeteringOff = true;
bool gasStartedOff = _gasMeteringOff;
_gasMeteringOff = true;

_;

// if gas metering was on when this modifier was called, turn it back on at the end
if (!gasStartedOff) {
gasMeteringOff = false;
_gasMeteringOff = false;
vm.resumeGasMetering();
}
}
Expand Down Expand Up @@ -668,9 +668,9 @@ abstract contract StdCheatsSafe {
abstract contract StdCheats is StdCheatsSafe {
using stdStorage for StdStorage;

StdStorage private stdstore;
StdStorage private _stdstore;
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
address private constant _CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;

/// @notice Advances the block timestamp forward by `time` seconds.
function skip(uint256 time) internal virtual {
Expand Down Expand Up @@ -733,15 +733,15 @@ abstract contract StdCheats is StdCheatsSafe {
/// @notice Changes the active prank to `msgSender`.
/// @dev Deprecated. Use `vm.startPrank` instead.
function changePrank(address msgSender) internal virtual {
console2_log_StdCheats("changePrank is deprecated. Please use vm.startPrank instead.");
_console2_log_StdCheats("changePrank is deprecated. Please use vm.startPrank instead.");
vm.stopPrank();
vm.startPrank(msgSender);
}

/// @notice Changes the active prank to `msgSender` with `txOrigin` as `tx.origin`.
/// @dev Deprecated. Use `vm.startPrank` instead.
function changePrank(address msgSender, address txOrigin) internal virtual {
console2_log_StdCheats("changePrank is deprecated. Please use vm.startPrank instead.");
_console2_log_StdCheats("changePrank is deprecated. Please use vm.startPrank instead.");
vm.stopPrank();
vm.startPrank(msgSender, txOrigin);
}
Expand Down Expand Up @@ -828,7 +828,7 @@ abstract contract StdCheats is StdCheatsSafe {
uint256 prevBal = abi.decode(balData, (uint256));

// update balance
stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(give);
_stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(give);

// update total supply
if (adjust) {
Expand All @@ -839,7 +839,7 @@ abstract contract StdCheats is StdCheatsSafe {
} else {
totSup += (give - prevBal);
}
stdstore.target(token).sig(0x18160ddd).checked_write(totSup);
_stdstore.target(token).sig(0x18160ddd).checked_write(totSup);
}
}

Expand All @@ -850,7 +850,7 @@ abstract contract StdCheats is StdCheatsSafe {
uint256 prevBal = abi.decode(balData, (uint256));

// update balance
stdstore.target(token).sig(0x00fdd58e).with_key(to).with_key(id).checked_write(give);
_stdstore.target(token).sig(0x00fdd58e).with_key(to).with_key(id).checked_write(give);

// update total supply
if (adjust) {
Expand All @@ -865,7 +865,7 @@ abstract contract StdCheats is StdCheatsSafe {
} else {
totSup += (give - prevBal);
}
stdstore.target(token).sig(0xbd85b039).with_key(id).checked_write(totSup);
_stdstore.target(token).sig(0xbd85b039).with_key(id).checked_write(totSup);
}
}

Expand All @@ -885,11 +885,11 @@ abstract contract StdCheats is StdCheatsSafe {
uint256 toPrevBal = abi.decode(toBalData, (uint256));

// update balances
stdstore.target(token).sig(0x70a08231).with_key(abi.decode(ownerData, (address))).checked_write(--fromPrevBal);
stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(++toPrevBal);
_stdstore.target(token).sig(0x70a08231).with_key(abi.decode(ownerData, (address))).checked_write(--fromPrevBal);
_stdstore.target(token).sig(0x70a08231).with_key(to).checked_write(++toPrevBal);

// update owner
stdstore.target(token).sig(0x6352211e).with_key(id).checked_write(to);
_stdstore.target(token).sig(0x6352211e).with_key(id).checked_write(to);
}

/// @notice Etches the runtime bytecode of `what` (from the artifacts directory) at `where`.
Expand All @@ -915,8 +915,8 @@ abstract contract StdCheats is StdCheatsSafe {
}

// Used to prevent the compilation of console, which shortens the compilation time when console is not used elsewhere.
function console2_log_StdCheats(string memory p0) private view {
(bool status,) = address(CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature("log(string)", p0));
function _console2_log_StdCheats(string memory p0) private view {
(bool status,) = address(_CONSOLE2_ADDRESS).staticcall(abi.encodeWithSignature("log(string)", p0));
status;
}
}
4 changes: 2 additions & 2 deletions src/StdConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract StdConfig {
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));

/// @dev Types: `bool`, `address`, `bytes32`, `uint`, `int`, `string`, `bytes`.
uint8 private constant NUM_TYPES = 7;
uint8 private constant _NUM_TYPES = 7;

// -- ERRORS ---------------------------------------------------------------

Expand Down Expand Up @@ -114,7 +114,7 @@ contract StdConfig {
}

// Iterate through all the available `TypeKind`s (except `None`) to create the sub-section paths
for (uint8 t = 1; t <= NUM_TYPES; t++) {
for (uint8 t = 1; t <= _NUM_TYPES; t++) {
TypeKind ty = TypeKind(t);
string memory typePath = string.concat("$.", chain_key, ".", ty.toTomlKey());

Expand Down
5 changes: 3 additions & 2 deletions src/StdMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ pragma solidity >=0.8.13 <0.9.0;

/// @notice Mathematical utility functions for unsigned and signed integers.
library stdMath {
int256 private constant INT256_MIN = -57896044618658097711785492504343953926634992332820282019728792003956564819968;
int256 private constant _INT256_MIN =
-57896044618658097711785492504343953926634992332820282019728792003956564819968;

/// @notice Computes the absolute value of a signed integer.
/// @param a The signed integer to compute the absolute value of.
/// @return The absolute value as an unsigned integer.
function abs(int256 a) internal pure returns (uint256) {
// Required or it will fail when `a = type(int256).min`
if (a == INT256_MIN) {
if (a == _INT256_MIN) {
return 57896044618658097711785492504343953926634992332820282019728792003956564819968;
}

Expand Down
18 changes: 9 additions & 9 deletions src/StdStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ library stdStorageSafe {
/// @notice Returns the encoded call parameters (keys or raw calldata) for the configured target function.
function getCallParams(StdStorage storage self) internal view returns (bytes memory) {
if (self._calldata.length == 0) {
return flatten(self._keys);
return _flatten(self._keys);
} else {
return self._calldata;
}
Expand All @@ -46,7 +46,7 @@ library stdStorageSafe {
function callTarget(StdStorage storage self) internal view returns (bool, bytes32) {
bytes memory cd = abi.encodePacked(self._sig, getCallParams(self));
(bool success, bytes memory rdat) = self._target.staticcall(cd);
bytes32 result = bytesToBytes32(rdat, 32 * self._depth);
bytes32 result = _bytesToBytes32(rdat, 32 * self._depth);

return (success, result);
}
Expand Down Expand Up @@ -225,7 +225,7 @@ library stdStorageSafe {
return self;
}

function read(StdStorage storage self) private returns (bytes memory) {
function _read(StdStorage storage self) private returns (bytes memory) {
FindData storage data = find(self, false);
uint256 mask = getMaskByOffsets(data.offsetLeft, data.offsetRight);
uint256 value = (uint256(vm.load(self._target, bytes32(data.slot))) & mask) >> data.offsetRight;
Expand All @@ -235,7 +235,7 @@ library stdStorageSafe {

/// @notice Reads the found storage slot value as bytes32.
function read_bytes32(StdStorage storage self) internal returns (bytes32) {
return abi.decode(read(self), (bytes32));
return abi.decode(_read(self), (bytes32));
}

/// @notice Reads the found storage slot value as bool.
Expand All @@ -249,17 +249,17 @@ library stdStorageSafe {

/// @notice Reads the found storage slot value as address.
function read_address(StdStorage storage self) internal returns (address) {
return abi.decode(read(self), (address));
return abi.decode(_read(self), (address));
}

/// @notice Reads the found storage slot value as uint256.
function read_uint(StdStorage storage self) internal returns (uint256) {
return abi.decode(read(self), (uint256));
return abi.decode(_read(self), (uint256));
}

/// @notice Reads the found storage slot value as int256.
function read_int(StdStorage storage self) internal returns (int256) {
return abi.decode(read(self), (int256));
return abi.decode(_read(self), (int256));
}

/// @notice Returns the parent mapping slot index and the key used to reach the found slot.
Expand Down Expand Up @@ -299,7 +299,7 @@ library stdStorageSafe {
return uint256(root_slot);
}

function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {
function _bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32) {
bytes32 out;

// Cap read length by remaining bytes from `offset`, and at most 32 bytes to avoid out-of-bounds
Expand All @@ -313,7 +313,7 @@ library stdStorageSafe {
return out;
}

function flatten(bytes32[] memory b) private pure returns (bytes memory) {
function _flatten(bytes32[] memory b) private pure returns (bytes memory) {
bytes memory result = new bytes(b.length * 32);
for (uint256 i = 0; i < b.length; i++) {
bytes32 k = b[i];
Expand Down
24 changes: 12 additions & 12 deletions src/StdStyle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ library StdStyle {
string constant INVERSE = "\u001b[7m";
string constant RESET = "\u001b[0m";

function styleConcat(string memory style, string memory self) private pure returns (string memory) {
function _styleConcat(string memory style, string memory self) private pure returns (string memory) {
return string(abi.encodePacked(style, self, RESET));
}

/// @notice Returns `self` wrapped in red ANSI color codes.
function red(string memory self) internal pure returns (string memory) {
return styleConcat(RED, self);
return _styleConcat(RED, self);
}

/// @notice Returns the string representation of `self` wrapped in red ANSI color codes.
Expand Down Expand Up @@ -60,7 +60,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in green ANSI color codes.
function green(string memory self) internal pure returns (string memory) {
return styleConcat(GREEN, self);
return _styleConcat(GREEN, self);
}

/// @notice Returns the string representation of `self` wrapped in green ANSI color codes.
Expand Down Expand Up @@ -95,7 +95,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in yellow ANSI color codes.
function yellow(string memory self) internal pure returns (string memory) {
return styleConcat(YELLOW, self);
return _styleConcat(YELLOW, self);
}

/// @notice Returns the string representation of `self` wrapped in yellow ANSI color codes.
Expand Down Expand Up @@ -130,7 +130,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in blue ANSI color codes.
function blue(string memory self) internal pure returns (string memory) {
return styleConcat(BLUE, self);
return _styleConcat(BLUE, self);
}

/// @notice Returns the string representation of `self` wrapped in blue ANSI color codes.
Expand Down Expand Up @@ -165,7 +165,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in magenta ANSI color codes.
function magenta(string memory self) internal pure returns (string memory) {
return styleConcat(MAGENTA, self);
return _styleConcat(MAGENTA, self);
}

/// @notice Returns the string representation of `self` wrapped in magenta ANSI color codes.
Expand Down Expand Up @@ -200,7 +200,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in cyan ANSI color codes.
function cyan(string memory self) internal pure returns (string memory) {
return styleConcat(CYAN, self);
return _styleConcat(CYAN, self);
}

/// @notice Returns the string representation of `self` wrapped in cyan ANSI color codes.
Expand Down Expand Up @@ -235,7 +235,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in bold ANSI style codes.
function bold(string memory self) internal pure returns (string memory) {
return styleConcat(BOLD, self);
return _styleConcat(BOLD, self);
}

/// @notice Returns the string representation of `self` wrapped in bold ANSI style codes.
Expand Down Expand Up @@ -270,7 +270,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in dim ANSI style codes.
function dim(string memory self) internal pure returns (string memory) {
return styleConcat(DIM, self);
return _styleConcat(DIM, self);
}

/// @notice Returns the string representation of `self` wrapped in dim ANSI style codes.
Expand Down Expand Up @@ -305,7 +305,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in italic ANSI style codes.
function italic(string memory self) internal pure returns (string memory) {
return styleConcat(ITALIC, self);
return _styleConcat(ITALIC, self);
}

/// @notice Returns the string representation of `self` wrapped in italic ANSI style codes.
Expand Down Expand Up @@ -340,7 +340,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in underline ANSI style codes.
function underline(string memory self) internal pure returns (string memory) {
return styleConcat(UNDERLINE, self);
return _styleConcat(UNDERLINE, self);
}

/// @notice Returns the string representation of `self` wrapped in underline ANSI style codes.
Expand Down Expand Up @@ -375,7 +375,7 @@ library StdStyle {

/// @notice Returns `self` wrapped in inverse ANSI style codes.
function inverse(string memory self) internal pure returns (string memory) {
return styleConcat(INVERSE, self);
return _styleConcat(INVERSE, self);
}

/// @notice Returns the string representation of `self` wrapped in inverse ANSI style codes.
Expand Down
Loading