This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [alias] | |
| # Copy message of provided commit: git cm COMMIT_SHA | |
| cm = !"git rev-list --format=%B --max-count=1 $1 | tail +2 | pbcopy" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity >=0.8.19; | |
| contract Contract { | |
| function foo(bytes32 seed) external view returns (bytes memory) { | |
| return abi.encode(tx.origin, seed); | |
| } | |
| function getBytes32(uint256 number) external pure returns (bytes32) { | |
| return bytes32(number); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity >=0.8.19; | |
| import { Script } from "forge-std/Script.sol"; | |
| abstract contract BaseScript is Script { | |
| /// @dev Included to enable compilation of the script without a $MNEMONIC environment variable. | |
| string internal constant TEST_MNEMONIC = "test test test test test test test test test test test junk"; | |
| /// @dev Needed for the deterministic deployments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity >=0.8.18; | |
| import { PRBTest } from "@prb/test/PRBTest.sol"; | |
| contract Foo is PRBTest { | |
| function test_RevertWhen_CallerNotOwner() external { | |
| vm.expectRevert(); | |
| // ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity >=0.8.18; | |
| import { Test } from "forge-std/Test.sol"; | |
| import { arange } from "solidity-generators/Generators.sol"; | |
| contract MyTest is Test { | |
| function testFuzz_OrderedArr(uint256[] memory arr) internal view { | |
| vm.assume(arr.length != 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity >=0.8.17; | |
| import { PRBTest } from "@prb/test/PRBTest.sol"; | |
| contract ForgeTestNamingConvention is PRBTest { | |
| // Standard tests | |
| function test_Description() external {} | |
| // Tests expecting a revert |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity =0.8.17; | |
| function quickSort(uint40[] memory arr, uint40 left, uint40 right) internal pure { | |
| if (left >= right) { | |
| return; | |
| } | |
| unchecked { | |
| // p = the pivot element | |
| uint40 p = arr[(left + right) / 2]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - name: "Cache RPC Responses" | |
| uses: "actions/cache@v3" | |
| with: | |
| path: "~/.foundry/cache/rpc/mainnet/16183456" | |
| key: "${{ runner.os }}-mainnet-16183456" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity >=0.8.13; | |
| import "@prb/math/SD59x18.sol"; | |
| function allMathFunctions(SD59x18 x, SD59x18 y) pure { | |
| abs(x); | |
| avg(x, y); | |
| ceil(x); | |
| div(x, y); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// @notice Finds the zero-based index of the first 1 in the binary representation of x. | |
| /// @dev See the note on msb in the "Find First Set" Wikipedia article https://en.wikipedia.org/wiki/Find_first_set | |
| /// @param x The uint256 number for which to find the index of the most significant bit. | |
| /// @return result The index of the most significant bit as an uint256. | |
| function msb(uint256 x) pure returns (uint256 result) { | |
| unchecked { | |
| if (x >= 2 ** 128) { | |
| x >>= 128; | |
| result += 128; | |
| } |