This file contains 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
function verify(bytes calldata signature, bytes32 hash, address claimedSigner) internal view { | |
bytes32 r; | |
bytes32 s; | |
uint8 v; | |
if (claimedSigner.code.length > 0) { | |
bytes4 magicValue = IERC1271(claimedSigner).isValidSignature(hash, signature); | |
if (magicValue != IERC1271.isValidSignature.selector) revert InvalidContractSignature(); | |
return; | |
} |
This file contains 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 { IERC20 } from "@openzeppelin/token/ERC20/IERC20.sol"; | |
/// @notice An interface for contracts that wrap native assets in ERC-20 form, such as WETH. | |
/// @dev A generic name is used instead of "WETH" to accommodate chains with different native assets. | |
interface IWrappedNativeAsset is IERC20 { | |
/// @notice Deposits native assets to receive ERC-20 wrapped assets. | |
function deposit() external payable; |
This file contains 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
import js from "@eslint/js"; | |
import globals from "globals"; | |
import prettierConfig from "eslint-config-prettier"; | |
import typescriptEslintRecommended from "@typescript-eslint/eslint-plugin/configs/recommended"; | |
import typescriptEslint from "@typescript-eslint/eslint-plugin"; | |
export default [ | |
js.configs.recommended, | |
typescriptEslintRecommended, | |
prettierConfig, |
This file contains 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 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 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 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 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 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 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]; |