├── .cargo └── config.toml ├── .codespellrc ├── .config └── nextest.toml ├── .devcontainer ├── Dockerfile.dev └── devcontainer.json ├── .dockerignore ├── .git-blame-ignore-revs ├── .gitattributes ├── .github ├── CODEOWNERS ├── INTEGRATION_FAILURE.md ├── ISSUE_TEMPLATE │ ├── BUG-FORM.yml │ ├── FEATURE-FORM.yml │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── RELEASE_FAILURE_ISSUE_TEMPLATE.md ├── assets │ ├── banner.png │ ├── build_benchmark_openzeppelin_dark.png │ ├── build_benchmark_openzeppelin_light.png │ ├── build_benchmark_solady_dark.png │ ├── build_benchmark_solady_light.png │ └── demo.gif ├── changelog.json ├── compilation-benchmark.png ├── scripts │ ├── create-tag.js │ ├── format.sh │ ├── matrices.py │ ├── move-tag.js │ └── prune-prereleases.js └── workflows │ ├── bump-forge-std.yml │ ├── dependencies.yml │ ├── docker-publish.yml │ ├── nextest.yml │ ├── release.yml │ ├── test-isolate.yml │ └── test.yml ├── .gitignore ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── Dockerfile.cross ├── FUNDING.json ├── LICENSE-APACHE ├── LICENSE-MIT ├── Makefile ├── README.md ├── SECURITY.md ├── clippy.toml ├── crates ├── anvil │ ├── Cargo.toml │ ├── bin │ │ └── main.rs │ ├── core │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── eth │ │ │ ├── block.rs │ │ │ ├── mod.rs │ │ │ ├── serde_helpers.rs │ │ │ ├── subscription.rs │ │ │ ├── transaction │ │ │ │ └── mod.rs │ │ │ └── wallet.rs │ │ │ ├── lib.rs │ │ │ └── types.rs │ ├── rpc │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── error.rs │ │ │ ├── lib.rs │ │ │ ├── request.rs │ │ │ └── response.rs │ ├── server │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── config.rs │ │ │ ├── error.rs │ │ │ ├── handler.rs │ │ │ ├── ipc.rs │ │ │ ├── lib.rs │ │ │ ├── pubsub.rs │ │ │ └── ws.rs │ ├── src │ │ ├── args.rs │ │ ├── cmd.rs │ │ ├── config.rs │ │ ├── eth │ │ │ ├── api.rs │ │ │ ├── backend │ │ │ │ ├── cheats.rs │ │ │ │ ├── db.rs │ │ │ │ ├── env.rs │ │ │ │ ├── executor.rs │ │ │ │ ├── fork.rs │ │ │ │ ├── genesis.rs │ │ │ │ ├── info.rs │ │ │ │ ├── mem │ │ │ │ │ ├── cache.rs │ │ │ │ │ ├── fork_db.rs │ │ │ │ │ ├── in_memory_db.rs │ │ │ │ │ ├── inspector.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── state.rs │ │ │ │ │ └── storage.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── notifications.rs │ │ │ │ ├── time.rs │ │ │ │ └── validate.rs │ │ │ ├── error.rs │ │ │ ├── fees.rs │ │ │ ├── macros.rs │ │ │ ├── miner.rs │ │ │ ├── mod.rs │ │ │ ├── otterscan │ │ │ │ ├── api.rs │ │ │ │ └── mod.rs │ │ │ ├── pool │ │ │ │ ├── mod.rs │ │ │ │ └── transactions.rs │ │ │ ├── sign.rs │ │ │ └── util.rs │ │ ├── evm.rs │ │ ├── filter.rs │ │ ├── hardfork.rs │ │ ├── lib.rs │ │ ├── logging.rs │ │ ├── opts.rs │ │ ├── pubsub.rs │ │ ├── server │ │ │ ├── error.rs │ │ │ ├── handler.rs │ │ │ └── mod.rs │ │ ├── service.rs │ │ ├── shutdown.rs │ │ └── tasks │ │ │ ├── block_listener.rs │ │ │ └── mod.rs │ ├── test-data │ │ ├── SimpleStorage.json │ │ ├── SimpleStorage.sol │ │ ├── emit_logs.json │ │ ├── emit_logs.sol │ │ ├── greeter.json │ │ ├── multicall.json │ │ ├── multicall.sol │ │ ├── state-dump-legacy-stress.json │ │ ├── state-dump-legacy.json │ │ ├── state-dump.json │ │ └── storage_sample.json │ └── tests │ │ └── it │ │ ├── abi.rs │ │ ├── anvil.rs │ │ ├── anvil_api.rs │ │ ├── api.rs │ │ ├── eip4844.rs │ │ ├── eip7702.rs │ │ ├── fork.rs │ │ ├── gas.rs │ │ ├── genesis.rs │ │ ├── ipc.rs │ │ ├── logs.rs │ │ ├── main.rs │ │ ├── optimism.rs │ │ ├── otterscan.rs │ │ ├── proof.rs │ │ ├── pubsub.rs │ │ ├── revert.rs │ │ ├── sign.rs │ │ ├── simulate.rs │ │ ├── state.rs │ │ ├── traces.rs │ │ ├── transaction.rs │ │ ├── txpool.rs │ │ ├── utils.rs │ │ └── wsapi.rs ├── cast │ ├── Cargo.toml │ ├── bin │ │ └── main.rs │ ├── src │ │ ├── args.rs │ │ ├── base.rs │ │ ├── cmd │ │ │ ├── access_list.rs │ │ │ ├── artifact.rs │ │ │ ├── bind.rs │ │ │ ├── call.rs │ │ │ ├── constructor_args.rs │ │ │ ├── create2.rs │ │ │ ├── creation_code.rs │ │ │ ├── da_estimate.rs │ │ │ ├── estimate.rs │ │ │ ├── find_block.rs │ │ │ ├── interface.rs │ │ │ ├── logs.rs │ │ │ ├── mktx.rs │ │ │ ├── mod.rs │ │ │ ├── rpc.rs │ │ │ ├── run.rs │ │ │ ├── send.rs │ │ │ ├── storage.rs │ │ │ ├── txpool.rs │ │ │ └── wallet │ │ │ │ ├── list.rs │ │ │ │ ├── mod.rs │ │ │ │ └── vanity.rs │ │ ├── errors.rs │ │ ├── lib.rs │ │ ├── opts.rs │ │ ├── rlp_converter.rs │ │ └── tx.rs │ └── tests │ │ ├── cli │ │ ├── main.rs │ │ └── selectors.rs │ │ └── fixtures │ │ ├── ERC20Artifact.json │ │ ├── cast_logs.stdout │ │ ├── interface.json │ │ ├── keystore │ │ ├── UTC--2022-10-30T06-51-20.130356000Z--560d246fcddc9ea98a8b032c9a2f474efb493c28 │ │ ├── UTC--2022-12-20T10-30-43.591916000Z--ec554aeafe75601aaab43bd4621a22284db566c2 │ │ ├── password │ │ └── password-ec554 │ │ ├── sign_typed_data.json │ │ ├── storage_layout_complex.json │ │ └── storage_layout_simple.json ├── cheatcodes │ ├── Cargo.toml │ ├── README.md │ ├── assets │ │ ├── cheatcodes.json │ │ └── cheatcodes.schema.json │ ├── spec │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── cheatcode.rs │ │ │ ├── function.rs │ │ │ ├── items.rs │ │ │ ├── lib.rs │ │ │ └── vm.rs │ └── src │ │ ├── base64.rs │ │ ├── config.rs │ │ ├── crypto.rs │ │ ├── env.rs │ │ ├── error.rs │ │ ├── evm.rs │ │ ├── evm │ │ ├── fork.rs │ │ ├── mapping.rs │ │ ├── mock.rs │ │ ├── prank.rs │ │ └── record_debug_step.rs │ │ ├── fs.rs │ │ ├── inspector.rs │ │ ├── inspector │ │ └── utils.rs │ │ ├── json.rs │ │ ├── lib.rs │ │ ├── script.rs │ │ ├── string.rs │ │ ├── test.rs │ │ ├── test │ │ ├── assert.rs │ │ ├── assume.rs │ │ ├── expect.rs │ │ └── revert_handlers.rs │ │ ├── toml.rs │ │ ├── utils.rs │ │ └── version.rs ├── chisel │ ├── Cargo.toml │ ├── assets │ │ ├── preview.gif │ │ └── preview.tape │ ├── bin │ │ └── main.rs │ ├── src │ │ ├── args.rs │ │ ├── cmd.rs │ │ ├── dispatcher.rs │ │ ├── executor.rs │ │ ├── history.rs │ │ ├── lib.rs │ │ ├── opts.rs │ │ ├── runner.rs │ │ ├── session.rs │ │ ├── session_source.rs │ │ └── solidity_helper.rs │ └── tests │ │ └── cache.rs ├── cli │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── handler.rs │ │ ├── lib.rs │ │ ├── opts │ │ ├── build │ │ │ ├── core.rs │ │ │ ├── mod.rs │ │ │ └── paths.rs │ │ ├── chain.rs │ │ ├── dependency.rs │ │ ├── global.rs │ │ ├── mod.rs │ │ ├── rpc.rs │ │ └── transaction.rs │ │ └── utils │ │ ├── abi.rs │ │ ├── allocator.rs │ │ ├── cmd.rs │ │ ├── mod.rs │ │ └── suggestions.rs ├── common │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── fmt │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── console.rs │ │ │ ├── dynamic.rs │ │ │ ├── exp.rs │ │ │ ├── lib.rs │ │ │ └── ui.rs │ └── src │ │ ├── abi.rs │ │ ├── calc.rs │ │ ├── compile.rs │ │ ├── constants.rs │ │ ├── contracts.rs │ │ ├── errors │ │ ├── artifacts.rs │ │ ├── fs.rs │ │ └── mod.rs │ │ ├── evm.rs │ │ ├── fs.rs │ │ ├── io │ │ ├── macros.rs │ │ ├── mod.rs │ │ ├── shell.rs │ │ ├── stdin.rs │ │ └── style.rs │ │ ├── lib.rs │ │ ├── preprocessor │ │ ├── data.rs │ │ ├── deps.rs │ │ └── mod.rs │ │ ├── provider │ │ ├── mod.rs │ │ └── runtime_transport.rs │ │ ├── reports.rs │ │ ├── retry.rs │ │ ├── selectors.rs │ │ ├── serde_helpers.rs │ │ ├── term.rs │ │ ├── traits.rs │ │ ├── transactions.rs │ │ ├── utils.rs │ │ └── version.rs ├── config │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── bind_json.rs │ │ ├── cache.rs │ │ ├── compilation.rs │ │ ├── doc.rs │ │ ├── endpoints.rs │ │ ├── error.rs │ │ ├── etherscan.rs │ │ ├── filter.rs │ │ ├── fix.rs │ │ ├── fmt.rs │ │ ├── fs_permissions.rs │ │ ├── fuzz.rs │ │ ├── inline │ │ ├── mod.rs │ │ └── natspec.rs │ │ ├── invariant.rs │ │ ├── lib.rs │ │ ├── lint.rs │ │ ├── macros.rs │ │ ├── providers │ │ ├── ext.rs │ │ ├── mod.rs │ │ ├── remappings.rs │ │ └── warnings.rs │ │ ├── resolve.rs │ │ ├── soldeer.rs │ │ ├── utils.rs │ │ ├── vyper.rs │ │ └── warning.rs ├── debugger │ ├── Cargo.toml │ └── src │ │ ├── builder.rs │ │ ├── debugger.rs │ │ ├── dump.rs │ │ ├── lib.rs │ │ ├── node.rs │ │ ├── op.rs │ │ └── tui │ │ ├── context.rs │ │ ├── draw.rs │ │ └── mod.rs ├── doc │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── builder.rs │ │ ├── document.rs │ │ ├── helpers.rs │ │ ├── lib.rs │ │ ├── parser │ │ │ ├── comment.rs │ │ │ ├── error.rs │ │ │ ├── item.rs │ │ │ └── mod.rs │ │ ├── preprocessor │ │ │ ├── contract_inheritance.rs │ │ │ ├── deployments.rs │ │ │ ├── git_source.rs │ │ │ ├── infer_hyperlinks.rs │ │ │ ├── inheritdoc.rs │ │ │ └── mod.rs │ │ └── writer │ │ │ ├── as_doc.rs │ │ │ ├── buf_writer.rs │ │ │ ├── markdown.rs │ │ │ ├── mod.rs │ │ │ └── traits.rs │ └── static │ │ ├── book.css │ │ ├── book.toml │ │ └── solidity.min.js ├── evm │ ├── abi │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── Console.json │ │ │ ├── console.py │ │ │ ├── console │ │ │ ├── ds.rs │ │ │ ├── hh.rs │ │ │ └── mod.rs │ │ │ └── lib.rs │ ├── core │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── backend │ │ │ │ ├── cow.rs │ │ │ │ ├── diagnostic.rs │ │ │ │ ├── error.rs │ │ │ │ ├── in_memory_db.rs │ │ │ │ ├── mod.rs │ │ │ │ └── snapshot.rs │ │ │ ├── buffer.rs │ │ │ ├── constants.rs │ │ │ ├── decode.rs │ │ │ ├── either_evm.rs │ │ │ ├── env.rs │ │ │ ├── evm.rs │ │ │ ├── fork │ │ │ │ ├── database.rs │ │ │ │ ├── init.rs │ │ │ │ ├── mod.rs │ │ │ │ └── multi.rs │ │ │ ├── ic.rs │ │ │ ├── lib.rs │ │ │ ├── opcodes.rs │ │ │ ├── opts.rs │ │ │ ├── precompiles.rs │ │ │ ├── state_snapshot.rs │ │ │ └── utils.rs │ │ └── test-data │ │ │ └── storage.json │ ├── coverage │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── analysis.rs │ │ │ ├── anchors.rs │ │ │ ├── inspector.rs │ │ │ └── lib.rs │ ├── evm │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── executors │ │ │ ├── builder.rs │ │ │ ├── fuzz │ │ │ │ ├── mod.rs │ │ │ │ └── types.rs │ │ │ ├── invariant │ │ │ │ ├── error.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── replay.rs │ │ │ │ ├── result.rs │ │ │ │ └── shrink.rs │ │ │ ├── mod.rs │ │ │ └── trace.rs │ │ │ ├── inspectors │ │ │ ├── chisel_state.rs │ │ │ ├── custom_printer.rs │ │ │ ├── logs.rs │ │ │ ├── mod.rs │ │ │ ├── revert_diagnostic.rs │ │ │ ├── script.rs │ │ │ └── stack.rs │ │ │ └── lib.rs │ ├── fuzz │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── error.rs │ │ │ ├── inspector.rs │ │ │ ├── invariant │ │ │ ├── call_override.rs │ │ │ ├── filters.rs │ │ │ └── mod.rs │ │ │ ├── lib.rs │ │ │ └── strategies │ │ │ ├── calldata.rs │ │ │ ├── int.rs │ │ │ ├── invariants.rs │ │ │ ├── mod.rs │ │ │ ├── param.rs │ │ │ ├── state.rs │ │ │ └── uint.rs │ ├── test-data │ │ └── solc-obj.json │ └── traces │ │ ├── Cargo.toml │ │ └── src │ │ ├── debug │ │ ├── mod.rs │ │ └── sources.rs │ │ ├── decoder │ │ ├── mod.rs │ │ └── precompiles.rs │ │ ├── folded_stack_trace.rs │ │ ├── identifier │ │ ├── etherscan.rs │ │ ├── local.rs │ │ ├── mod.rs │ │ └── signatures.rs │ │ └── lib.rs ├── fmt │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── buffer.rs │ │ ├── chunk.rs │ │ ├── comments.rs │ │ ├── formatter.rs │ │ ├── helpers.rs │ │ ├── inline_config.rs │ │ ├── lib.rs │ │ ├── macros.rs │ │ ├── solang_ext │ │ │ ├── ast_eq.rs │ │ │ ├── loc.rs │ │ │ ├── mod.rs │ │ │ └── safe_unwrap.rs │ │ ├── string.rs │ │ └── visit.rs │ ├── testdata │ │ ├── Annotation │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ArrayExpressions │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── BlockComments │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── BlockCommentsFunction │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ConditionalOperatorExpression │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ConstructorDefinition │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ConstructorModifierStyle │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ContractDefinition │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── contract-new-lines.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── DoWhileStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── DocComments │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ └── wrap-comments.fmt.sol │ │ ├── EmitStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── EnumDefinition │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── EnumVariants │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ErrorDefinition │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── EventDefinition │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ForStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── FunctionCall │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── FunctionCallArgsStatement │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── FunctionDefinition │ │ │ ├── all-params.fmt.sol │ │ │ ├── all.fmt.sol │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── override-spacing.fmt.sol │ │ │ ├── params-first.fmt.sol │ │ │ └── params-multi.fmt.sol │ │ ├── FunctionDefinitionWithFunctionReturns │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── FunctionType │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── HexUnderscore │ │ │ ├── bytes.fmt.sol │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve.fmt.sol │ │ │ └── remove.fmt.sol │ │ ├── IfStatement │ │ │ ├── block-multi.fmt.sol │ │ │ ├── block-single.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── IfStatement2 │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ImportDirective │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve-quote.fmt.sol │ │ │ └── single-quote.fmt.sol │ │ ├── InlineDisable │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── IntTypes │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve.fmt.sol │ │ │ └── short.fmt.sol │ │ ├── LiteralExpression │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve-quote.fmt.sol │ │ │ └── single-quote.fmt.sol │ │ ├── MappingType │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ModifierDefinition │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ └── override-spacing.fmt.sol │ │ ├── NamedFunctionCallExpression │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── NonKeywords │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── NumberLiteralUnderscore │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve.fmt.sol │ │ │ ├── remove.fmt.sol │ │ │ └── thousands.fmt.sol │ │ ├── OperatorExpressions │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── PragmaDirective │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── Repros │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ReturnStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── RevertNamedArgsStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── RevertStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── SimpleComments │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ └── wrap-comments.fmt.sol │ │ ├── SortedImports │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── StatementBlock │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── StructDefinition │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ThisExpression │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── TrailingComma │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── TryStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── TypeDefinition │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── UnitExpression │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── UsingDirective │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── VariableAssignment │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── VariableDefinition │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ └── override-spacing.fmt.sol │ │ ├── WhileStatement │ │ │ ├── block-multi.fmt.sol │ │ │ ├── block-single.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── Yul │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ └── YulStrings │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve-quote.fmt.sol │ │ │ └── single-quote.fmt.sol │ └── tests │ │ └── formatter.rs ├── forge │ ├── Cargo.toml │ ├── assets │ │ ├── .gitignoreTemplate │ │ ├── CounterTemplate.s.sol │ │ ├── CounterTemplate.sol │ │ ├── CounterTemplate.t.sol │ │ ├── README.md │ │ ├── generated │ │ │ └── TestTemplate.t.sol │ │ └── workflowTemplate.yml │ ├── bin │ │ └── main.rs │ ├── src │ │ ├── args.rs │ │ ├── cmd │ │ │ ├── bind.rs │ │ │ ├── bind_json.rs │ │ │ ├── build.rs │ │ │ ├── cache.rs │ │ │ ├── clone.rs │ │ │ ├── compiler.rs │ │ │ ├── config.rs │ │ │ ├── coverage.rs │ │ │ ├── create.rs │ │ │ ├── doc │ │ │ │ ├── mod.rs │ │ │ │ └── server.rs │ │ │ ├── eip712.rs │ │ │ ├── flatten.rs │ │ │ ├── fmt.rs │ │ │ ├── geiger.rs │ │ │ ├── generate │ │ │ │ └── mod.rs │ │ │ ├── init.rs │ │ │ ├── inspect.rs │ │ │ ├── install.rs │ │ │ ├── lint.rs │ │ │ ├── mod.rs │ │ │ ├── remappings.rs │ │ │ ├── remove.rs │ │ │ ├── selectors.rs │ │ │ ├── snapshot.rs │ │ │ ├── soldeer.rs │ │ │ ├── test │ │ │ │ ├── filter.rs │ │ │ │ ├── mod.rs │ │ │ │ └── summary.rs │ │ │ ├── tree.rs │ │ │ ├── update.rs │ │ │ └── watch.rs │ │ ├── coverage.rs │ │ ├── gas_report.rs │ │ ├── lib.rs │ │ ├── multi_runner.rs │ │ ├── opts.rs │ │ ├── progress.rs │ │ ├── result.rs │ │ └── runner.rs │ └── tests │ │ ├── cli │ │ ├── bind_json.rs │ │ ├── build.rs │ │ ├── cache.rs │ │ ├── cmd.rs │ │ ├── compiler.rs │ │ ├── config.rs │ │ ├── constants.rs │ │ ├── context.rs │ │ ├── coverage.rs │ │ ├── create.rs │ │ ├── debug.rs │ │ ├── doc.rs │ │ ├── eip712.rs │ │ ├── ext_integration.rs │ │ ├── failure_assertions.rs │ │ ├── geiger.rs │ │ ├── inline_config.rs │ │ ├── lint.rs │ │ ├── main.rs │ │ ├── multi_script.rs │ │ ├── script.rs │ │ ├── soldeer.rs │ │ ├── svm.rs │ │ ├── test_cmd.rs │ │ ├── test_optimizer.rs │ │ ├── utils.rs │ │ ├── verify.rs │ │ ├── verify_bytecode.rs │ │ └── version.rs │ │ ├── fixtures │ │ ├── ExpectCallFailures.t.sol │ │ ├── ExpectCreateFailures.t.sol │ │ ├── ExpectEmitFailures.t.sol │ │ ├── ExpectRevertFailures.t.sol │ │ ├── MemSafetyFailures.t.sol │ │ ├── ScriptVerify.sol │ │ ├── SimpleContractTestNonVerbose.json │ │ ├── SimpleContractTestVerbose.json │ │ └── colored_traces.svg │ │ ├── it │ │ ├── cheats.rs │ │ ├── config.rs │ │ ├── core.rs │ │ ├── fork.rs │ │ ├── fs.rs │ │ ├── fuzz.rs │ │ ├── inline.rs │ │ ├── invariant.rs │ │ ├── main.rs │ │ ├── repros.rs │ │ ├── spec.rs │ │ ├── test_helpers.rs │ │ └── vyper.rs │ │ ├── rpc-cache-keyfile │ │ └── ui.rs ├── linking │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── lint │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── lib.rs │ │ ├── linter.rs │ │ └── sol │ │ │ ├── gas │ │ │ ├── keccak.rs │ │ │ └── mod.rs │ │ │ ├── high │ │ │ ├── incorrect_shift.rs │ │ │ └── mod.rs │ │ │ ├── info │ │ │ ├── mixed_case.rs │ │ │ ├── mod.rs │ │ │ ├── pascal_case.rs │ │ │ └── screaming_snake_case.rs │ │ │ ├── macros.rs │ │ │ ├── med │ │ │ ├── div_mul.rs │ │ │ └── mod.rs │ │ │ └── mod.rs │ └── testdata │ │ ├── DivideBeforeMultiply.sol │ │ ├── DivideBeforeMultiply.stderr │ │ ├── IncorrectShift.sol │ │ ├── IncorrectShift.stderr │ │ ├── Keccak256.sol │ │ ├── Keccak256.stderr │ │ ├── MixedCase.sol │ │ ├── MixedCase.stderr │ │ ├── ScreamingSnakeCase.sol │ │ ├── ScreamingSnakeCase.stderr │ │ ├── StructPascalCase.sol │ │ └── StructPascalCase.stderr ├── macros │ ├── Cargo.toml │ └── src │ │ ├── cheatcodes.rs │ │ ├── console_fmt.rs │ │ └── lib.rs ├── script-sequence │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── reader.rs │ │ ├── sequence.rs │ │ └── transaction.rs ├── script │ ├── Cargo.toml │ └── src │ │ ├── broadcast.rs │ │ ├── build.rs │ │ ├── execute.rs │ │ ├── lib.rs │ │ ├── multi_sequence.rs │ │ ├── progress.rs │ │ ├── providers.rs │ │ ├── receipts.rs │ │ ├── runner.rs │ │ ├── sequence.rs │ │ ├── simulate.rs │ │ ├── transaction.rs │ │ └── verify.rs ├── sol-macro-gen │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ └── sol_macro_gen.rs ├── test-utils │ ├── Cargo.toml │ └── src │ │ ├── fd_lock.rs │ │ ├── filter.rs │ │ ├── lib.rs │ │ ├── macros.rs │ │ ├── rpc.rs │ │ ├── script.rs │ │ ├── ui_runner.rs │ │ └── util.rs ├── verify │ ├── Cargo.toml │ └── src │ │ ├── bytecode.rs │ │ ├── etherscan │ │ ├── flatten.rs │ │ ├── mod.rs │ │ └── standard_json.rs │ │ ├── lib.rs │ │ ├── provider.rs │ │ ├── retry.rs │ │ ├── sourcify.rs │ │ ├── types.rs │ │ ├── utils.rs │ │ └── verify.rs └── wallets │ ├── Cargo.toml │ └── src │ ├── error.rs │ ├── lib.rs │ ├── multi_wallet.rs │ ├── raw_wallet.rs │ ├── utils.rs │ ├── wallet.rs │ └── wallet_signer.rs ├── deny.toml ├── docs └── dev │ ├── README.md │ ├── architecture.md │ ├── cheatcodes.md │ ├── debugging.md │ ├── lintrules.md │ └── scripting.md ├── flake.lock ├── flake.nix ├── foundryup ├── README.md ├── foundryup └── install ├── rustfmt.toml └── testdata ├── .gitignore ├── README.md ├── cheats └── Vm.sol ├── default ├── cheats │ ├── AccessList.t.sol │ ├── Addr.t.sol │ ├── ArbitraryStorage.t.sol │ ├── Assert.t.sol │ ├── Assume.t.sol │ ├── AssumeNoRevert.t.sol │ ├── AttachBlob.t.sol │ ├── AttachDelegation.t.sol │ ├── Bank.t.sol │ ├── Base64.t.sol │ ├── BlobBaseFee.t.sol │ ├── Blobhashes.t.sol │ ├── Broadcast.t.sol │ ├── BroadcastRawTransaction.t.sol │ ├── ChainId.t.sol │ ├── CloneAccount.t.sol │ ├── Cool.t.sol │ ├── CopyStorage.t.sol │ ├── Deal.t.sol │ ├── DeployCode.t.sol │ ├── Derive.t.sol │ ├── EnsNamehash.t.sol │ ├── Env.t.sol │ ├── Etch.t.sol │ ├── ExpectCall.t.sol │ ├── ExpectCreate.t.sol │ ├── ExpectEmit.t.sol │ ├── ExpectRevert.t.sol │ ├── Fee.t.sol │ ├── Ffi.t.sol │ ├── Fork.t.sol │ ├── Fork2.t.sol │ ├── Fs.t.sol │ ├── GasMetering.t.sol │ ├── GetArtifactPath.t.sol │ ├── GetBlockTimestamp.t.sol │ ├── GetChain.t.sol │ ├── GetCode.t.sol │ ├── GetDeployedCode.t.sol │ ├── GetFoundryVersion.t.sol │ ├── GetLabel.t.sol │ ├── GetNonce.t.sol │ ├── Json.t.sol │ ├── Label.t.sol │ ├── Load.t.sol │ ├── Mapping.t.sol │ ├── MemSafety.t.sol │ ├── MockCall.t.sol │ ├── MockCalls.t.sol │ ├── MockFunction.t.sol │ ├── Nonce.t.sol │ ├── Parse.t.sol │ ├── Prank.t.sol │ ├── Prevrandao.t.sol │ ├── ProjectRoot.t.sol │ ├── Prompt.t.sol │ ├── RandomAddress.t.sol │ ├── RandomBytes.t.sol │ ├── RandomCheatcodes.t.sol │ ├── RandomUint.t.sol │ ├── ReadCallers.t.sol │ ├── Record.t.sol │ ├── RecordAccountAccesses.t.sol │ ├── RecordDebugTrace.t.sol │ ├── RecordLogs.t.sol │ ├── Remember.t.sol │ ├── ResetNonce.t.sol │ ├── Roll.t.sol │ ├── RpcUrls.t.sol │ ├── SetBlockhash.t.sol │ ├── SetNonce.t.sol │ ├── SetNonceUnsafe.t.sol │ ├── Setup.t.sol │ ├── Sign.t.sol │ ├── SignP256.t.sol │ ├── Skip.t.sol │ ├── Sleep.t.sol │ ├── Sort.t.sol │ ├── StateSnapshots.t.sol │ ├── StorageSlotState.t.sol │ ├── Store.t.sol │ ├── StringUtils.t.sol │ ├── ToString.t.sol │ ├── Toml.t.sol │ ├── Travel.t.sol │ ├── TryFfi.sol │ ├── UnixTime.t.sol │ ├── Wallet.t.sol │ ├── Warp.t.sol │ ├── dumpState.t.sol │ ├── getBlockNumber.t.sol │ └── loadAllocs.t.sol ├── core │ ├── Abstract.t.sol │ ├── BadSigAfterInvariant.t.sol │ ├── ContractEnvironment.t.sol │ ├── FailingTestAfterFailedSetup.t.sol │ ├── LegacyAssertions.t.sol │ ├── PaymentFailure.t.sol │ ├── Reverting.t.sol │ └── SetupConsistency.t.sol ├── fork │ ├── DssExecLib.sol │ ├── ForkSame_1.t.sol │ ├── ForkSame_2.t.sol │ └── LaunchFork.t.sol ├── fs │ ├── Default.t.sol │ └── Disabled.t.sol ├── fuzz │ ├── Fuzz.t.sol │ ├── FuzzCollection.t.sol │ ├── FuzzFailurePersist.t.sol │ ├── FuzzInt.t.sol │ ├── FuzzPositive.t.sol │ ├── FuzzUint.t.sol │ └── invariant │ │ ├── common │ │ ├── InvariantAfterInvariant.t.sol │ │ ├── InvariantAssume.t.sol │ │ ├── InvariantCalldataDictionary.t.sol │ │ ├── InvariantCustomError.t.sol │ │ ├── InvariantExcludedSenders.t.sol │ │ ├── InvariantFixtures.t.sol │ │ ├── InvariantHandlerFailure.t.sol │ │ ├── InvariantInnerContract.t.sol │ │ ├── InvariantPreserveState.t.sol │ │ ├── InvariantReentrancy.t.sol │ │ ├── InvariantRollFork.t.sol │ │ ├── InvariantScrapeValues.t.sol │ │ ├── InvariantSequenceNoReverts.t.sol │ │ ├── InvariantShrinkBigSequence.t.sol │ │ ├── InvariantShrinkFailOnRevert.t.sol │ │ ├── InvariantShrinkWithAssert.t.sol │ │ └── InvariantTest1.t.sol │ │ ├── storage │ │ └── InvariantStorageTest.t.sol │ │ ├── target │ │ ├── ExcludeContracts.t.sol │ │ ├── ExcludeSelectors.t.sol │ │ ├── ExcludeSenders.t.sol │ │ ├── FuzzedTargetContracts.t.sol │ │ ├── TargetContracts.t.sol │ │ ├── TargetInterfaces.t.sol │ │ ├── TargetSelectors.t.sol │ │ └── TargetSenders.t.sol │ │ └── targetAbi │ │ ├── ExcludeArtifacts.t.sol │ │ ├── TargetArtifactSelectors.t.sol │ │ ├── TargetArtifactSelectors2.t.sol │ │ └── TargetArtifacts.t.sol ├── inline │ ├── FuzzInlineConf.t.sol │ └── InvariantInlineConf.t.sol ├── linking │ ├── cycle │ │ └── Cycle.t.sol │ ├── duplicate │ │ └── Duplicate.t.sol │ ├── nested │ │ └── Nested.t.sol │ └── simple │ │ └── Simple.t.sol ├── logs │ ├── DebugLogs.t.sol │ ├── HardhatLogs.t.sol │ └── console.sol ├── repros │ ├── Issue10302.t.sol │ ├── Issue10477.t.sol │ ├── Issue10527.t.sol │ ├── Issue10552.t.sol │ ├── Issue10586.t.sol │ ├── Issue2623.t.sol │ ├── Issue2629.t.sol │ ├── Issue2723.t.sol │ ├── Issue2851.t.sol │ ├── Issue2898.t.sol │ ├── Issue2956.t.sol │ ├── Issue2984.t.sol │ ├── Issue3055.t.sol │ ├── Issue3077.t.sol │ ├── Issue3110.t.sol │ ├── Issue3119.t.sol │ ├── Issue3189.t.sol │ ├── Issue3190.t.sol │ ├── Issue3192.t.sol │ ├── Issue3220.t.sol │ ├── Issue3221.t.sol │ ├── Issue3223.t.sol │ ├── Issue3347.t.sol │ ├── Issue3437.t.sol │ ├── Issue3596.t.sol │ ├── Issue3653.t.sol │ ├── Issue3661.t.sol │ ├── Issue3674.t.sol │ ├── Issue3685.t.sol │ ├── Issue3703.t.sol │ ├── Issue3708.t.sol │ ├── Issue3723.t.sol │ ├── Issue3753.t.sol │ ├── Issue3792.t.sol │ ├── Issue4232.t.sol │ ├── Issue4402.t.sol │ ├── Issue4586.t.sol │ ├── Issue4630.t.sol │ ├── Issue4640.t.sol │ ├── Issue4832.t.sol │ ├── Issue5038.t.sol │ ├── Issue5529.t.sol │ ├── Issue5739.t.sol │ ├── Issue5808.t.sol │ ├── Issue5929.t.sol │ ├── Issue5935.t.sol │ ├── Issue5948.t.sol │ ├── Issue6006.t.sol │ ├── Issue6032.t.sol │ ├── Issue6070.t.sol │ ├── Issue6115.t.sol │ ├── Issue6170.t.sol │ ├── Issue6180.t.sol │ ├── Issue6293.t.sol │ ├── Issue6355.t.sol │ ├── Issue6437.t.sol │ ├── Issue6501.t.sol │ ├── Issue6538.t.sol │ ├── Issue6554.t.sol │ ├── Issue6616.t.sol │ ├── Issue6634.t.sol │ ├── Issue6643.t.sol │ ├── Issue6759.t.sol │ ├── Issue6966.t.sol │ ├── Issue7238.t.sol │ ├── Issue7457.t.sol │ ├── Issue7481.t.sol │ ├── Issue8004.t.sol │ ├── Issue8006.t.sol │ ├── Issue8168.t.sol │ ├── Issue8277.t.sol │ ├── Issue8287.t.sol │ ├── Issue8383.t.sol │ ├── Issue8566.t.sol │ ├── Issue8639.t.sol │ ├── Issue8971.t.sol │ └── Issue9643.t.sol ├── script │ ├── broadcast │ │ └── deploy.sol │ │ │ └── 31337 │ │ │ └── run-latest.json │ └── deploy.sol ├── spec │ └── ShanghaiCompat.t.sol ├── trace │ ├── ConflictingSignatures.t.sol │ └── Trace.t.sol └── vyper │ ├── Counter.vy │ ├── CounterTest.vy │ └── ICounter.vyi ├── etherscan ├── 0x044b75f554b886A065b9567891e45c79542d7357 │ ├── creation_data.json │ └── metadata.json ├── 0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193 │ ├── creation_data.json │ └── metadata.json ├── 0x3a23F943181408EAC424116Af7b7790c94Cb97a5 │ ├── creation_data.json │ └── metadata.json ├── 0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05 │ ├── creation_data.json │ └── metadata.json ├── 0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545 │ ├── creation_data.json │ └── metadata.json ├── 0x9AB6b21cDF116f611110b048987E58894786C244 │ ├── creation_data.json │ └── metadata.json ├── 0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F │ ├── creation_data.json │ └── metadata.json └── 0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec │ ├── creation_data.json │ └── metadata.json ├── fixtures ├── Derive │ ├── mnemonic_chinese_simplified.txt │ ├── mnemonic_chinese_traditional.txt │ ├── mnemonic_czech.txt │ ├── mnemonic_english.txt │ ├── mnemonic_french.txt │ ├── mnemonic_italian.txt │ ├── mnemonic_japanese.txt │ ├── mnemonic_korean.txt │ ├── mnemonic_portuguese.txt │ └── mnemonic_spanish.txt ├── Dir │ ├── depth1 │ └── nested │ │ ├── depth2 │ │ └── nested2 │ │ └── depth3 ├── File │ ├── read.txt │ └── symlink ├── GetCode │ ├── HardhatWorkingContract.json │ ├── HuffWorkingContract.json │ ├── Override.json │ ├── Override.sol │ ├── UnlinkedContract.sol │ ├── WorkingContract.json │ └── WorkingContract.sol ├── Json │ ├── Issue4402.json │ ├── Issue4630.json │ ├── nested_json_struct.json │ ├── test.json │ ├── test_allocs.json │ ├── whole_json.json │ ├── write_complex_test.json │ └── write_test.json ├── Rpc │ ├── README.md │ ├── balance_params.json │ └── eth_getLogs.json ├── SolidityGeneration │ ├── Fastlane.json │ ├── GaugeController.json │ ├── GeneratedFastLane.sol │ ├── GeneratedGaugeController.sol │ ├── GeneratedLiquidityGaugeV4.sol │ ├── GeneratedNamedInterface.sol │ ├── GeneratedUnnamedInterface.sol │ ├── InterfaceABI.json │ ├── LiquidityGaugeV4.json │ ├── WithStructs.json │ └── WithStructs.sol ├── Toml │ ├── Issue4402.toml │ ├── nested_toml_struct.toml │ ├── test.toml │ ├── whole_toml.toml │ ├── write_complex_test.toml │ └── write_test.toml ├── broadcast.log.json └── broadcast.sensitive.log.json ├── forge-std-rev ├── foundry.toml ├── lib └── ds-test │ └── src │ └── test.sol ├── multi-version ├── Counter.sol ├── Importer.sol └── cheats │ ├── GetCode.t.sol │ └── GetCode17.t.sol └── paris ├── cheats ├── Fork.t.sol ├── GasSnapshots.t.sol └── LastCallGas.t.sol ├── core └── BeforeTest.t.sol ├── fork └── Transact.t.sol └── spec └── ShanghaiCompat.t.sol /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | cheats = "test -p foundry-cheatcodes-spec --features schema tests::" 3 | test-debugger = "test -p forge --test cli manual_debug_setup -- --include-ignored --nocapture" 4 | 5 | # Increase the stack size to 10MB for Windows targets, which is in line with Linux 6 | # (whereas default for Windows is 1MB). 7 | [target.x86_64-pc-windows-msvc] 8 | rustflags = ["-Clink-arg=/STACK:10000000"] 9 | 10 | [target.i686-pc-windows-msvc] 11 | rustflags = ["-Clink-arg=/STACK:10000000"] 12 | -------------------------------------------------------------------------------- /.codespellrc: -------------------------------------------------------------------------------- 1 | [codespell] 2 | skip = .git,target,testdata,Cargo.toml,Cargo.lock 3 | ignore-words-list = crate,ser,ratatui,Caf,froms,strat 4 | -------------------------------------------------------------------------------- /.config/nextest.toml: -------------------------------------------------------------------------------- 1 | [test-groups] 2 | chisel-serial = { max-threads = 1 } 3 | 4 | [profile.default] 5 | retries = { backoff = "exponential", count = 2, delay = "5s", jitter = true } 6 | slow-timeout = { period = "1m", terminate-after = 3 } 7 | 8 | [[profile.default.overrides]] 9 | filter = "test(/ext_integration|can_test_forge_std/)" 10 | slow-timeout = { period = "5m", terminate-after = 4 } 11 | 12 | [[profile.default.overrides]] 13 | filter = "package(foundry-cheatcodes-spec)" 14 | retries = 0 15 | 16 | [[profile.default.overrides]] 17 | filter = "package(chisel)" 18 | test-group = "chisel-serial" 19 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | target 2 | .github 3 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Since version 2.23 (released in August 2019), git-blame has a feature 2 | # to ignore or bypass certain commits. 3 | # 4 | # This file contains a list of commits that are not likely what you 5 | # are looking for in a blame, such as mass reformatting or renaming. 6 | # You can set this file as a default ignore file for blame by running 7 | # the following command. 8 | # 9 | # $ git config blame.ignoreRevsFile .git-blame-ignore-revs 10 | 11 | # fmt: all (#3398) 12 | 860d083183b51a6f8d865408ef1a44aa694d6862 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | crates/cheatcodes/assets/*.json linguist-generated 2 | testdata/cheats/Vm.sol linguist-generated 3 | 4 | # See 5 | *.rs diff=rust 6 | crates/lint/testdata/* text eol=lf 7 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @danipopes @klkvr @mattsse @grandizzy @yash-atreya @zerosnacks 2 | -------------------------------------------------------------------------------- /.github/INTEGRATION_FAILURE.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "bug: long-running integration tests failed" 3 | labels: P-high, T-bug 4 | --- 5 | 6 | The heavy (long-running) integration tests have failed. This indicates a regression in Foundry. 7 | 8 | Check the [heavy integration tests workflow page]({{ env.WORKFLOW_URL }}) for details. 9 | 10 | This issue was raised by the workflow at `.github/workflows/heavy-integration.yml`. 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Support 4 | url: https://t.me/foundry_support 5 | about: This issue tracker is only for bugs and feature requests. Support is available on Telegram! 6 | -------------------------------------------------------------------------------- /.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "bug: release workflow failed" 3 | labels: P-high, T-bug 4 | --- 5 | 6 | The release workflow has failed. Some or all binaries might have not been published correctly. 7 | 8 | Check the [release workflow page]({{ env.WORKFLOW_URL }}) for details. 9 | 10 | This issue was raised by the workflow at `.github/workflows/release.yml`. 11 | -------------------------------------------------------------------------------- /.github/assets/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/.github/assets/banner.png -------------------------------------------------------------------------------- /.github/assets/build_benchmark_openzeppelin_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/.github/assets/build_benchmark_openzeppelin_dark.png -------------------------------------------------------------------------------- /.github/assets/build_benchmark_openzeppelin_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/.github/assets/build_benchmark_openzeppelin_light.png -------------------------------------------------------------------------------- /.github/assets/build_benchmark_solady_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/.github/assets/build_benchmark_solady_dark.png -------------------------------------------------------------------------------- /.github/assets/build_benchmark_solady_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/.github/assets/build_benchmark_solady_light.png -------------------------------------------------------------------------------- /.github/assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/.github/assets/demo.gif -------------------------------------------------------------------------------- /.github/compilation-benchmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/.github/compilation-benchmark.png -------------------------------------------------------------------------------- /.github/scripts/create-tag.js: -------------------------------------------------------------------------------- 1 | module.exports = async ({ github, context }, tagName) => { 2 | try { 3 | await github.rest.git.createRef({ 4 | owner: context.repo.owner, 5 | repo: context.repo.repo, 6 | ref: `refs/tags/${tagName}`, 7 | sha: context.sha, 8 | force: true, 9 | }); 10 | } catch (err) { 11 | console.error(`Failed to create tag: ${tagName}`); 12 | console.error(err); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /.github/scripts/format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | # We have to ignore at shell level because testdata/ is not a valid Foundry project, 5 | # so running `forge fmt` with `--root testdata` won't actually check anything 6 | cargo run --bin forge -- fmt "$@" \ 7 | $(find testdata -name '*.sol' ! -name Vm.sol ! -name console.sol) 8 | -------------------------------------------------------------------------------- /.github/scripts/move-tag.js: -------------------------------------------------------------------------------- 1 | module.exports = async ({ github, context }, tagName) => { 2 | try { 3 | await github.rest.git.updateRef({ 4 | owner: context.repo.owner, 5 | repo: context.repo.repo, 6 | ref: `tags/${tagName}`, 7 | sha: context.sha, 8 | force: true, 9 | }); 10 | } catch (err) { 11 | console.error(`Failed to move nightly tag.`); 12 | console.error(`This should only happen the first time.`); 13 | console.error(err); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /.github/workflows/dependencies.yml: -------------------------------------------------------------------------------- 1 | # Runs `cargo update` periodically. 2 | 3 | name: dependencies 4 | 5 | on: 6 | schedule: 7 | # Run weekly 8 | - cron: "0 0 * * SUN" 9 | workflow_dispatch: 10 | # Needed so we can run it manually 11 | 12 | permissions: 13 | contents: write 14 | pull-requests: write 15 | 16 | jobs: 17 | update: 18 | uses: ithacaxyz/ci/.github/workflows/cargo-update-pr.yml@main 19 | secrets: 20 | token: ${{ secrets.GITHUB_TOKEN }} 21 | -------------------------------------------------------------------------------- /.github/workflows/test-isolate.yml: -------------------------------------------------------------------------------- 1 | # Daily CI job to run tests with isolation mode enabled by default 2 | 3 | name: test-isolate 4 | 5 | on: 6 | schedule: 7 | - cron: "0 0 * * *" 8 | workflow_dispatch: 9 | 10 | jobs: 11 | nextest: 12 | uses: ./.github/workflows/nextest.yml 13 | with: 14 | profile: isolate 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | /target* 3 | out/ 4 | snapshots/ 5 | out.json 6 | .idea 7 | .vscode 8 | -------------------------------------------------------------------------------- /FUNDING.json: -------------------------------------------------------------------------------- 1 | { 2 | "drips": { 3 | "ethereum": { 4 | "ownedBy": "0x86308c59a6005d012C51Eef104bBc21786aC5D2E" 5 | } 6 | }, 7 | "opRetro": { 8 | "projectId": "0x4562c0630907577f433cad78c7e2cc03349d918b6c14ef982f11a2678f5999ad" 9 | } 10 | } -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Contact [security@ithaca.xyz](mailto:security@ithaca.xyz). 6 | -------------------------------------------------------------------------------- /clippy.toml: -------------------------------------------------------------------------------- 1 | msrv = "1.86" 2 | 3 | # `bytes::Bytes` is included by default and `alloy_primitives::Bytes` is a wrapper around it, 4 | # so it is safe to ignore it as well. 5 | ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] 6 | 7 | disallowed-macros = [ 8 | # See `foundry_common::shell`. 9 | { path = "std::print", reason = "use `sh_print` or similar macros instead" }, 10 | { path = "std::eprint", reason = "use `sh_eprint` or similar macros instead" }, 11 | { path = "std::println", reason = "use `sh_println` or similar macros instead" }, 12 | { path = "std::eprintln", reason = "use `sh_eprintln` or similar macros instead" }, 13 | ] 14 | -------------------------------------------------------------------------------- /crates/anvil/bin/main.rs: -------------------------------------------------------------------------------- 1 | //! The `anvil` CLI: a fast local Ethereum development node, akin to Hardhat Network, Tenderly. 2 | 3 | use anvil::args::run; 4 | 5 | #[global_allocator] 6 | static ALLOC: foundry_cli::utils::Allocator = foundry_cli::utils::new_allocator(); 7 | 8 | fn main() { 9 | if let Err(err) = run() { 10 | let _ = foundry_common::sh_err!("{err:?}"); 11 | std::process::exit(1); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/anvil/core/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # anvil-core 2 | //! 3 | //! Core Ethereum types for Anvil. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | /// Various Ethereum types 9 | pub mod eth; 10 | 11 | /// Additional useful types 12 | pub mod types; 13 | -------------------------------------------------------------------------------- /crates/anvil/core/src/types.rs: -------------------------------------------------------------------------------- 1 | use alloy_primitives::Bytes; 2 | use alloy_rpc_types::TransactionRequest; 3 | use serde::Deserialize; 4 | 5 | /// Represents the options used in `anvil_reorg` 6 | #[derive(Debug, Clone, Deserialize)] 7 | pub struct ReorgOptions { 8 | // The depth of the reorg 9 | pub depth: u64, 10 | // List of transaction requests and blocks pairs to be mined into the new chain 11 | pub tx_block_pairs: Vec<(TransactionData, u64)>, 12 | } 13 | 14 | #[derive(Debug, Clone, Deserialize)] 15 | #[serde(untagged)] 16 | #[expect(clippy::large_enum_variant)] 17 | pub enum TransactionData { 18 | JSON(TransactionRequest), 19 | Raw(Bytes), 20 | } 21 | -------------------------------------------------------------------------------- /crates/anvil/rpc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "anvil-rpc" 3 | 4 | version.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | authors.workspace = true 8 | license.workspace = true 9 | homepage.workspace = true 10 | repository.workspace = true 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | serde.workspace = true 17 | serde_json.workspace = true 18 | -------------------------------------------------------------------------------- /crates/anvil/rpc/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # anvil-rpc 2 | //! 3 | //! JSON-RPC types. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | /// JSON-RPC request bindings 9 | pub mod request; 10 | 11 | /// JSON-RPC response bindings 12 | pub mod response; 13 | 14 | /// JSON-RPC error bindings 15 | pub mod error; 16 | -------------------------------------------------------------------------------- /crates/anvil/server/src/error.rs: -------------------------------------------------------------------------------- 1 | //! Error variants used to unify different connection streams 2 | 3 | /// An error that can occur when reading an incoming request 4 | #[derive(Debug, thiserror::Error)] 5 | pub enum RequestError { 6 | #[error(transparent)] 7 | Axum(#[from] axum::Error), 8 | #[error(transparent)] 9 | Serde(#[from] serde_json::Error), 10 | #[error(transparent)] 11 | Io(#[from] std::io::Error), 12 | #[error("Disconnect")] 13 | Disconnect, 14 | } 15 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/backend/mod.rs: -------------------------------------------------------------------------------- 1 | //! blockchain Backend 2 | 3 | /// [revm](foundry_evm::revm) related types 4 | pub mod db; 5 | /// In-memory Backend 6 | pub mod mem; 7 | 8 | pub mod cheats; 9 | pub mod time; 10 | 11 | pub mod env; 12 | pub mod executor; 13 | pub mod fork; 14 | pub mod genesis; 15 | pub mod info; 16 | pub mod notifications; 17 | pub mod validate; 18 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/backend/notifications.rs: -------------------------------------------------------------------------------- 1 | //! Notifications emitted from the backed 2 | 3 | use alloy_consensus::Header; 4 | use alloy_primitives::B256; 5 | use futures::channel::mpsc::UnboundedReceiver; 6 | use std::sync::Arc; 7 | 8 | /// A notification that's emitted when a new block was imported 9 | #[derive(Clone, Debug)] 10 | pub struct NewBlockNotification { 11 | /// Hash of the imported block 12 | pub hash: B256, 13 | /// block header 14 | pub header: Arc
, 15 | } 16 | 17 | /// Type alias for a receiver that receives [NewBlockNotification] 18 | pub type NewBlockNotifications = UnboundedReceiver; 19 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/macros.rs: -------------------------------------------------------------------------------- 1 | /// A `info!` helper macro that emits to the target, the node logger listens for 2 | macro_rules! node_info { 3 | ($($arg:tt)*) => { 4 | tracing::info!(target: $crate::logging::NODE_USER_LOG_TARGET, $($arg)*); 5 | }; 6 | } 7 | 8 | pub(crate) use node_info; 9 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod api; 2 | pub mod otterscan; 3 | pub mod sign; 4 | pub use api::EthApi; 5 | 6 | pub mod backend; 7 | 8 | pub mod error; 9 | 10 | pub mod fees; 11 | pub(crate) mod macros; 12 | pub mod miner; 13 | pub mod pool; 14 | pub mod util; 15 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/otterscan/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod api; 2 | -------------------------------------------------------------------------------- /crates/anvil/src/server/error.rs: -------------------------------------------------------------------------------- 1 | /// Result alias 2 | pub type NodeResult = Result; 3 | 4 | /// An error that can occur when launching a anvil instance 5 | #[derive(Debug, thiserror::Error)] 6 | pub enum NodeError { 7 | #[error(transparent)] 8 | Hyper(#[from] hyper::Error), 9 | #[error(transparent)] 10 | Io(#[from] std::io::Error), 11 | } 12 | -------------------------------------------------------------------------------- /crates/anvil/test-data/emit_logs.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.24; 2 | 3 | contract SimpleStorage { 4 | 5 | event ValueChanged(address indexed author, string oldValue, string newValue); 6 | 7 | string _value; 8 | 9 | constructor(string memory value) public { 10 | _value = value; 11 | } 12 | 13 | function getValue() view public returns (string memory) { 14 | return _value; 15 | } 16 | 17 | function setValue(string memory value) public { 18 | emit ValueChanged(msg.sender, _value, value); 19 | _value = value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /crates/anvil/tests/it/main.rs: -------------------------------------------------------------------------------- 1 | mod abi; 2 | mod anvil; 3 | mod anvil_api; 4 | mod api; 5 | mod eip4844; 6 | mod eip7702; 7 | mod fork; 8 | mod gas; 9 | mod genesis; 10 | mod ipc; 11 | mod logs; 12 | mod optimism; 13 | mod otterscan; 14 | mod proof; 15 | mod pubsub; 16 | mod revert; 17 | mod sign; 18 | mod simulate; 19 | mod state; 20 | mod traces; 21 | mod transaction; 22 | mod txpool; 23 | pub mod utils; 24 | mod wsapi; 25 | 26 | pub(crate) fn init_tracing() { 27 | let _ = tracing_subscriber::FmtSubscriber::builder() 28 | .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) 29 | .try_init(); 30 | } 31 | 32 | fn main() {} 33 | -------------------------------------------------------------------------------- /crates/cast/bin/main.rs: -------------------------------------------------------------------------------- 1 | //! The `cast` CLI: a Swiss Army knife for interacting with EVM smart contracts, sending 2 | //! transactions and getting chain data. 3 | 4 | use cast::args::run; 5 | 6 | #[global_allocator] 7 | static ALLOC: foundry_cli::utils::Allocator = foundry_cli::utils::new_allocator(); 8 | 9 | fn main() { 10 | if let Err(err) = run() { 11 | let _ = foundry_common::sh_err!("{err:?}"); 12 | std::process::exit(1); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/cast/src/cmd/mod.rs: -------------------------------------------------------------------------------- 1 | //! `cast` subcommands. 2 | //! 3 | //! All subcommands should respect the `foundry_config::Config`. 4 | //! If a subcommand accepts values that are supported by the `Config`, then the subcommand should 5 | //! implement `figment::Provider` which allows the subcommand to override the config's defaults, see 6 | //! [`foundry_config::Config`]. 7 | 8 | pub mod access_list; 9 | pub mod artifact; 10 | pub mod bind; 11 | pub mod call; 12 | pub mod constructor_args; 13 | pub mod create2; 14 | pub mod creation_code; 15 | pub mod da_estimate; 16 | pub mod estimate; 17 | pub mod find_block; 18 | pub mod interface; 19 | pub mod logs; 20 | pub mod mktx; 21 | pub mod rpc; 22 | pub mod run; 23 | pub mod send; 24 | pub mod storage; 25 | pub mod txpool; 26 | pub mod wallet; 27 | -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/cast_logs.stdout: -------------------------------------------------------------------------------- 1 | - address: 0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE 2 | blockHash: 0x439b61565dacbc09a6d54378dff60d9b0400496d7a5a060cfdfdd899262f466c 3 | blockNumber: 12421182 4 | data: 0x000000000000000000000000000000000000027fd7b375dda5ef932dac18d302 5 | logIndex: 15 6 | removed: false 7 | topics: [ 8 | 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef 9 | 0x000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b 10 | 0x00000000000000000000000068a99f89e475a078645f4bac491360afe255dff1 11 | ] 12 | transactionHash: 0xb65bcbb85c1633b0ab4e4886c3cd8eeaeb63edbb39cacdb9223fdcf4454fd2c7 13 | transactionIndex: 8 14 | -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/keystore/UTC--2022-10-30T06-51-20.130356000Z--560d246fcddc9ea98a8b032c9a2f474efb493c28: -------------------------------------------------------------------------------- 1 | {"address":"560d246fcddc9ea98a8b032c9a2f474efb493c28","crypto":{"cipher":"aes-128-ctr","ciphertext":"0b0012edfc7a1b22c7c616a78562807c363482490359ae23858c49d6a369b2ff","cipherparams":{"iv":"9d72960fe04dd987300e91c101c890b8"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"f7d24eae5e746700a1fdc0e0886801b0e7aff7e298f9409f74355a5387827181"},"mac":"981cae42a43ce975b9ff13d19a99ae755ad3f6125c94a4da517c50067ca87f07"},"id":"852dbcfc-726a-416e-9321-29f9b5d7e2de","version":3} -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/keystore/UTC--2022-12-20T10-30-43.591916000Z--ec554aeafe75601aaab43bd4621a22284db566c2: -------------------------------------------------------------------------------- 1 | {"address":"ec554aeafe75601aaab43bd4621a22284db566c2","crypto":{"cipher":"aes-128-ctr","ciphertext":"f4e11a2667d97f42ad820f2aa735cd557ff608f47e2738d763a834b889611e18","cipherparams":{"iv":"99c3e2f1c98ccac50cb19f0a148e02ee"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"81f3033ffcc9fec9939eaec246a4037d9bc0c47cfb33247c98132b7d477b7e64"},"mac":"13bb4eac9a8d8f72905bca0c6f947c440d990baa649b0697b2083f3ab57d2cc5"},"id":"279ce8c3-dd94-43a8-aa46-15c3a45adbd1","version":3} -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/keystore/password: -------------------------------------------------------------------------------- 1 | this is keystore password 2 | -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/keystore/password-ec554: -------------------------------------------------------------------------------- 1 | keystorepassword -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/sign_typed_data.json: -------------------------------------------------------------------------------- 1 | {"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Message":[{"name":"data","type":"string"}]},"primaryType":"Message","domain":{"name":"example.metamask.io","version":"1","chainId":"1","verifyingContract":"0x0000000000000000000000000000000000000000"},"message":{"data":"Hello!"}} -------------------------------------------------------------------------------- /crates/cheatcodes/spec/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-cheatcodes-spec" 3 | description = "Foundry cheatcodes specification" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | exclude.workspace = true 13 | 14 | [lints] 15 | workspace = true 16 | 17 | [dependencies] 18 | foundry-macros.workspace = true 19 | alloy-sol-types = { workspace = true, features = ["json"] } 20 | serde.workspace = true 21 | 22 | # schema 23 | schemars = { version = "0.8", optional = true } 24 | 25 | [dev-dependencies] 26 | serde_json.workspace = true 27 | 28 | [features] 29 | schema = ["dep:schemars"] 30 | -------------------------------------------------------------------------------- /crates/chisel/assets/preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/crates/chisel/assets/preview.gif -------------------------------------------------------------------------------- /crates/chisel/bin/main.rs: -------------------------------------------------------------------------------- 1 | //! The `chisel` CLI: a fast, utilitarian, and verbose Solidity REPL. 2 | 3 | use chisel::args::run; 4 | 5 | #[global_allocator] 6 | static ALLOC: foundry_cli::utils::Allocator = foundry_cli::utils::new_allocator(); 7 | 8 | fn main() { 9 | if let Err(err) = run() { 10 | let _ = foundry_common::sh_err!("{err:?}"); 11 | std::process::exit(1); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/chisel/src/history.rs: -------------------------------------------------------------------------------- 1 | //! chisel history file 2 | 3 | use std::path::PathBuf; 4 | 5 | /// The name of the chisel history file 6 | pub const CHISEL_HISTORY_FILE_NAME: &str = ".chisel_history"; 7 | 8 | /// Returns the path to foundry's global toml file that's stored at `~/.foundry/.chisel_history` 9 | pub fn chisel_history_file() -> Option { 10 | foundry_config::Config::foundry_dir().map(|p| p.join(CHISEL_HISTORY_FILE_NAME)) 11 | } 12 | -------------------------------------------------------------------------------- /crates/chisel/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Chisel is a fast, utilitarian, and verbose Solidity REPL. 2 | 3 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 4 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 5 | 6 | #[macro_use] 7 | extern crate foundry_common; 8 | 9 | pub mod args; 10 | pub mod cmd; 11 | pub mod dispatcher; 12 | pub mod executor; 13 | pub mod history; 14 | pub mod opts; 15 | pub mod runner; 16 | pub mod session; 17 | pub mod session_source; 18 | pub mod solidity_helper; 19 | 20 | pub mod prelude { 21 | pub use crate::{ 22 | cmd::*, dispatcher::*, runner::*, session::*, session_source::*, solidity_helper::*, 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /crates/cli/README.md: -------------------------------------------------------------------------------- 1 | # Foundry CLIs 2 | 3 | The CLIs are written using [clap's](https://docs.rs/clap) [derive feature](https://docs.rs/clap/latest/clap/_derive). 4 | 5 | ## Installation 6 | 7 | See [Installation](../../README.md#Installation). 8 | 9 | ## Usage 10 | 11 | Read the [📖 Foundry Book][foundry-book] 12 | 13 | ## Debugging 14 | 15 | Debug logs are printed with 16 | [`tracing`](https://docs.rs/tracing/latest/tracing/). You can configure the 17 | verbosity level via the 18 | [`RUST_LOG`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/index.html#filtering-events-with-environment-variables) 19 | environment variable, on a per package level, 20 | e.g.:`RUST_LOG=forge,foundry_evm forge test` 21 | 22 | [foundry-book]: https://book.getfoundry.sh 23 | -------------------------------------------------------------------------------- /crates/cli/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-cli 2 | //! 3 | //! Common CLI utilities. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate foundry_common; 10 | 11 | #[macro_use] 12 | extern crate tracing; 13 | 14 | pub mod handler; 15 | pub mod opts; 16 | pub mod utils; 17 | -------------------------------------------------------------------------------- /crates/cli/src/opts/mod.rs: -------------------------------------------------------------------------------- 1 | mod build; 2 | mod chain; 3 | mod dependency; 4 | mod global; 5 | mod rpc; 6 | mod transaction; 7 | 8 | pub use build::*; 9 | pub use chain::*; 10 | pub use dependency::*; 11 | pub use global::*; 12 | pub use rpc::*; 13 | pub use transaction::*; 14 | -------------------------------------------------------------------------------- /crates/common/README.md: -------------------------------------------------------------------------------- 1 | Common utilities for building and using foundry's tools. 2 | -------------------------------------------------------------------------------- /crates/common/fmt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-common-fmt" 3 | description = "Common formatting utilities for Foundry" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | alloy-primitives.workspace = true 18 | alloy-dyn-abi = { workspace = true, features = ["eip712"] } 19 | 20 | # ui 21 | alloy-consensus.workspace = true 22 | alloy-network.workspace = true 23 | alloy-rpc-types = { workspace = true, features = ["eth"] } 24 | alloy-serde.workspace = true 25 | serde.workspace = true 26 | serde_json.workspace = true 27 | chrono.workspace = true 28 | revm.workspace = true 29 | yansi.workspace = true 30 | 31 | [dev-dependencies] 32 | foundry-macros.workspace = true 33 | similar-asserts.workspace = true 34 | -------------------------------------------------------------------------------- /crates/common/fmt/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Helpers for formatting Ethereum types. 2 | 3 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 4 | 5 | mod console; 6 | pub use console::{console_format, ConsoleFmt, FormatSpec}; 7 | 8 | mod dynamic; 9 | pub use dynamic::{format_token, format_token_raw, format_tokens, format_tokens_raw, parse_tokens}; 10 | 11 | mod exp; 12 | pub use exp::{format_int_exp, format_uint_exp, to_exp_notation}; 13 | 14 | mod ui; 15 | pub use ui::{get_pretty_block_attr, get_pretty_tx_attr, EthValue, UIfmt}; 16 | -------------------------------------------------------------------------------- /crates/common/src/errors/artifacts.rs: -------------------------------------------------------------------------------- 1 | //! Errors that can occur when working with `solc` artifacts 2 | 3 | /// Error when encountering unlinked code 4 | #[derive(Clone, Debug, thiserror::Error)] 5 | pub enum UnlinkedByteCode { 6 | /// `bytecode` is unlinked 7 | #[error("Contract `{0}` has unlinked bytecode. Please check all libraries settings.")] 8 | Bytecode(String), 9 | /// `deployedBytecode` is unlinked 10 | #[error("Contract `{0}` has unlinked deployed Bytecode. Please check all libraries settings.")] 11 | DeployedBytecode(String), 12 | } 13 | -------------------------------------------------------------------------------- /crates/common/src/io/mod.rs: -------------------------------------------------------------------------------- 1 | //! Utilities for working with standard input, output, and error. 2 | 3 | #[macro_use] 4 | mod macros; 5 | 6 | pub mod shell; 7 | pub mod stdin; 8 | pub mod style; 9 | 10 | #[doc(no_inline)] 11 | pub use shell::Shell; 12 | -------------------------------------------------------------------------------- /crates/common/src/io/style.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use anstyle::*; 3 | 4 | pub const ERROR: Style = AnsiColor::Red.on_default().effects(Effects::BOLD); 5 | pub const WARN: Style = AnsiColor::Yellow.on_default().effects(Effects::BOLD); 6 | -------------------------------------------------------------------------------- /crates/common/src/reports.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | use crate::shell; 4 | 5 | #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] 6 | pub enum ReportKind { 7 | #[default] 8 | Text, 9 | JSON, 10 | } 11 | 12 | /// Determine the kind of report to generate based on the current shell. 13 | pub fn report_kind() -> ReportKind { 14 | if shell::is_json() { 15 | ReportKind::JSON 16 | } else { 17 | ReportKind::Text 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /crates/config/src/bind_json.rs: -------------------------------------------------------------------------------- 1 | use crate::filter::GlobMatcher; 2 | use serde::{Deserialize, Serialize}; 3 | use std::path::PathBuf; 4 | 5 | /// Contains the config for `forge bind-json` 6 | #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] 7 | pub struct BindJsonConfig { 8 | /// Path for the generated bindings file. 9 | pub out: PathBuf, 10 | /// Globs to include. 11 | /// 12 | /// If provided, only the files matching the globs will be included. Otherwise, defaults to 13 | /// including all project files. 14 | pub include: Vec, 15 | /// Globs to ignore 16 | pub exclude: Vec, 17 | } 18 | 19 | impl Default for BindJsonConfig { 20 | fn default() -> Self { 21 | Self { 22 | out: PathBuf::from("utils/JsonBindings.sol"), 23 | exclude: Vec::new(), 24 | include: Vec::new(), 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /crates/config/src/providers/mod.rs: -------------------------------------------------------------------------------- 1 | //! Config providers. 2 | 3 | mod ext; 4 | pub use ext::*; 5 | 6 | mod remappings; 7 | pub use remappings::*; 8 | 9 | mod warnings; 10 | pub use warnings::*; 11 | -------------------------------------------------------------------------------- /crates/config/src/vyper.rs: -------------------------------------------------------------------------------- 1 | //! Vyper specific configuration types. 2 | 3 | use foundry_compilers::artifacts::vyper::VyperOptimizationMode; 4 | use serde::{Deserialize, Serialize}; 5 | use std::path::PathBuf; 6 | 7 | #[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] 8 | pub struct VyperConfig { 9 | /// Vyper optimization mode. "gas", "none" or "codesize" 10 | #[serde(default, skip_serializing_if = "Option::is_none")] 11 | pub optimize: Option, 12 | /// The Vyper instance to use if any. 13 | #[serde(default, skip_serializing_if = "Option::is_none")] 14 | pub path: Option, 15 | /// Optionally enables experimental Venom pipeline 16 | #[serde(default, skip_serializing_if = "Option::is_none")] 17 | pub experimental_codegen: Option, 18 | } 19 | -------------------------------------------------------------------------------- /crates/debugger/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-debugger" 3 | 4 | version.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | authors.workspace = true 8 | license.workspace = true 9 | homepage.workspace = true 10 | repository.workspace = true 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | foundry-common.workspace = true 17 | foundry-compilers.workspace = true 18 | foundry-evm-traces.workspace = true 19 | foundry-evm-core.workspace = true 20 | revm-inspectors.workspace = true 21 | 22 | alloy-primitives.workspace = true 23 | 24 | crossterm = "0.28" 25 | eyre.workspace = true 26 | ratatui = { version = "0.29", default-features = false, features = [ 27 | "crossterm", 28 | ] } 29 | revm.workspace = true 30 | tracing.workspace = true 31 | serde.workspace = true 32 | -------------------------------------------------------------------------------- /crates/debugger/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-debugger 2 | //! 3 | //! Interactive Solidity TUI debugger and debugger data file dumper 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate foundry_common; 10 | 11 | #[macro_use] 12 | extern crate tracing; 13 | 14 | mod op; 15 | 16 | mod builder; 17 | mod debugger; 18 | mod dump; 19 | mod tui; 20 | 21 | mod node; 22 | 23 | pub use node::DebugNode; 24 | 25 | pub use builder::DebuggerBuilder; 26 | pub use debugger::Debugger; 27 | pub use tui::{ExitReason, TUI}; 28 | -------------------------------------------------------------------------------- /crates/doc/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! The module for generating Solidity documentation. 2 | //! 3 | //! See [`DocBuilder`]. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate foundry_common; 10 | 11 | #[macro_use] 12 | extern crate tracing; 13 | 14 | mod builder; 15 | pub use builder::DocBuilder; 16 | 17 | mod document; 18 | pub use document::Document; 19 | 20 | mod helpers; 21 | 22 | mod parser; 23 | pub use parser::{ 24 | error, Comment, CommentTag, Comments, CommentsRef, ParseItem, ParseSource, Parser, 25 | }; 26 | 27 | mod preprocessor; 28 | pub use preprocessor::*; 29 | 30 | mod writer; 31 | pub use writer::{AsDoc, AsDocResult, BufWriter, Markdown}; 32 | 33 | pub use mdbook; 34 | -------------------------------------------------------------------------------- /crates/doc/src/parser/error.rs: -------------------------------------------------------------------------------- 1 | use forge_fmt::FormatterError; 2 | use thiserror::Error; 3 | 4 | /// The parser error. 5 | #[derive(Debug, Error)] 6 | #[error(transparent)] 7 | pub enum ParserError { 8 | /// Formatter error. 9 | #[error(transparent)] 10 | Formatter(#[from] FormatterError), 11 | /// Internal parser error. 12 | #[error(transparent)] 13 | Internal(#[from] eyre::Error), 14 | } 15 | 16 | /// The parser result. 17 | pub type ParserResult = std::result::Result; 18 | -------------------------------------------------------------------------------- /crates/doc/src/writer/mod.rs: -------------------------------------------------------------------------------- 1 | //! The module for writing and formatting various parse tree items. 2 | 3 | mod as_doc; 4 | mod buf_writer; 5 | mod markdown; 6 | 7 | pub use as_doc::{AsDoc, AsDocResult}; 8 | pub use buf_writer::BufWriter; 9 | pub use markdown::Markdown; 10 | 11 | mod traits; 12 | -------------------------------------------------------------------------------- /crates/doc/static/book.css: -------------------------------------------------------------------------------- 1 | table { 2 | margin: 0 auto; 3 | border-collapse: collapse; 4 | width: 100%; 5 | } 6 | 7 | table td:first-child { 8 | width: 15%; 9 | } 10 | 11 | table td:nth-child(2) { 12 | width: 25%; 13 | } -------------------------------------------------------------------------------- /crates/doc/static/book.toml: -------------------------------------------------------------------------------- 1 | # For more configuration see https://rust-lang.github.io/mdBook/format/configuration/index.html 2 | [book] 3 | src = "src" 4 | 5 | [output.html] 6 | no-section-label = true 7 | additional-js = ["solidity.min.js"] 8 | additional-css = ["book.css"] 9 | mathjax-support = true 10 | 11 | [output.html.fold] 12 | enable = true 13 | -------------------------------------------------------------------------------- /crates/evm/abi/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-evm-abi" 3 | description = "Solidity ABI-related utilities and `sol!` definitions" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | foundry-common-fmt.workspace = true 18 | foundry-macros.workspace = true 19 | 20 | alloy-primitives.workspace = true 21 | alloy-sol-types = { workspace = true, features = ["json"] } 22 | 23 | derive_more.workspace = true 24 | itertools.workspace = true -------------------------------------------------------------------------------- /crates/evm/abi/src/console/hh.rs: -------------------------------------------------------------------------------- 1 | //! Hardhat `console.sol` interface. 2 | 3 | use alloy_sol_types::sol; 4 | use foundry_common_fmt::*; 5 | use foundry_macros::ConsoleFmt; 6 | 7 | sol!( 8 | #[sol(abi)] 9 | #[derive(ConsoleFmt)] 10 | Console, 11 | "src/Console.json" 12 | ); 13 | 14 | pub use Console::*; 15 | -------------------------------------------------------------------------------- /crates/evm/abi/src/console/mod.rs: -------------------------------------------------------------------------------- 1 | use alloy_primitives::{I256, U256}; 2 | 3 | pub mod ds; 4 | pub mod hh; 5 | 6 | pub fn format_units_int(x: &I256, decimals: &U256) -> String { 7 | let (sign, x) = x.into_sign_and_abs(); 8 | format!("{sign}{}", format_units_uint(&x, decimals)) 9 | } 10 | 11 | pub fn format_units_uint(x: &U256, decimals: &U256) -> String { 12 | match alloy_primitives::utils::Unit::new(decimals.saturating_to::()) { 13 | Some(units) => alloy_primitives::utils::ParseUnits::U256(*x).format_units(units), 14 | None => x.to_string(), 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/evm/abi/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Solidity ABI-related utilities and [`sol!`](alloy_sol_types::sol) definitions. 2 | 3 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 4 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 5 | 6 | pub mod console; 7 | -------------------------------------------------------------------------------- /crates/evm/core/src/fork/mod.rs: -------------------------------------------------------------------------------- 1 | use super::opts::EvmOpts; 2 | use crate::Env; 3 | 4 | mod init; 5 | pub use init::{configure_env, environment}; 6 | 7 | pub mod database; 8 | 9 | mod multi; 10 | pub use multi::{ForkId, MultiFork, MultiForkHandler}; 11 | 12 | /// Represents a _fork_ of a remote chain whose data is available only via the `url` endpoint. 13 | #[derive(Clone, Debug)] 14 | pub struct CreateFork { 15 | /// Whether to enable rpc storage caching for this fork 16 | pub enable_caching: bool, 17 | /// The URL to a node for fetching remote state 18 | pub url: String, 19 | /// The env to create this fork, main purpose is to provide some metadata for the fork 20 | pub env: Env, 21 | /// All env settings as configured by the user 22 | pub evm_opts: EvmOpts, 23 | } 24 | -------------------------------------------------------------------------------- /crates/evm/core/src/opcodes.rs: -------------------------------------------------------------------------------- 1 | //! Opcode utils 2 | 3 | use revm::bytecode::opcode::OpCode; 4 | 5 | /// Returns true if the opcode modifies memory. 6 | /// 7 | /// 8 | #[inline] 9 | pub const fn modifies_memory(opcode: OpCode) -> bool { 10 | matches!( 11 | opcode, 12 | OpCode::EXTCODECOPY | 13 | OpCode::MLOAD | 14 | OpCode::MSTORE | 15 | OpCode::MSTORE8 | 16 | OpCode::MCOPY | 17 | OpCode::CODECOPY | 18 | OpCode::CALLDATACOPY | 19 | OpCode::RETURNDATACOPY | 20 | OpCode::CALL | 21 | OpCode::CALLCODE | 22 | OpCode::DELEGATECALL | 23 | OpCode::STATICCALL 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /crates/evm/core/test-data/storage.json: -------------------------------------------------------------------------------- 1 | {"meta":{"cfg_env":{"chain_id":1,"spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295,"perf_analyse_created_bytecodes":"Analyse","limit_contract_code_size":24576,"disable_coinbase_tip":false},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}} -------------------------------------------------------------------------------- /crates/evm/coverage/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-evm-coverage" 3 | description = "EVM bytecode coverage analysis" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | foundry-common.workspace = true 18 | foundry-compilers.workspace = true 19 | foundry-evm-core.workspace = true 20 | 21 | alloy-primitives.workspace = true 22 | eyre.workspace = true 23 | revm.workspace = true 24 | semver.workspace = true 25 | tracing.workspace = true 26 | rayon.workspace = true 27 | -------------------------------------------------------------------------------- /crates/evm/evm/src/inspectors/mod.rs: -------------------------------------------------------------------------------- 1 | //! EVM inspectors. 2 | 3 | pub use foundry_cheatcodes::{self as cheatcodes, Cheatcodes, CheatsConfig}; 4 | pub use foundry_evm_coverage::CoverageCollector; 5 | pub use foundry_evm_fuzz::Fuzzer; 6 | pub use foundry_evm_traces::{StackSnapshotType, TracingInspector, TracingInspectorConfig}; 7 | 8 | pub use revm_inspectors::access_list::AccessListInspector; 9 | 10 | mod custom_printer; 11 | pub use custom_printer::CustomPrintTracer; 12 | 13 | mod chisel_state; 14 | pub use chisel_state::ChiselState; 15 | 16 | mod logs; 17 | pub use logs::LogCollector; 18 | 19 | mod script; 20 | pub use script::ScriptExecutionInspector; 21 | 22 | mod stack; 23 | pub use stack::{InspectorData, InspectorStack, InspectorStackBuilder}; 24 | 25 | mod revert_diagnostic; 26 | pub use revert_diagnostic::RevertDiagnostic; 27 | -------------------------------------------------------------------------------- /crates/evm/evm/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-evm 2 | //! 3 | //! Main Foundry EVM backend abstractions. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate tracing; 10 | 11 | pub mod executors; 12 | pub mod inspectors; 13 | 14 | pub use foundry_evm_core::{ 15 | backend, constants, decode, fork, opts, utils, Env, EnvMut, EvmEnv, InspectorExt, 16 | }; 17 | pub use foundry_evm_coverage as coverage; 18 | pub use foundry_evm_fuzz as fuzz; 19 | pub use foundry_evm_traces as traces; 20 | 21 | // TODO: We should probably remove these, but it's a pretty big breaking change. 22 | #[doc(hidden)] 23 | pub use revm; 24 | -------------------------------------------------------------------------------- /crates/evm/fuzz/src/error.rs: -------------------------------------------------------------------------------- 1 | //! Errors related to fuzz tests. 2 | 3 | use proptest::test_runner::Reason; 4 | 5 | /// Possible errors when running fuzz tests 6 | #[derive(Debug, thiserror::Error)] 7 | pub enum FuzzError { 8 | #[error("`vm.assume` reject")] 9 | AssumeReject, 10 | #[error("`vm.assume` rejected too many inputs ({0} allowed)")] 11 | TooManyRejects(u32), 12 | } 13 | 14 | impl From for Reason { 15 | fn from(error: FuzzError) -> Self { 16 | error.to_string().into() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /crates/evm/fuzz/src/strategies/mod.rs: -------------------------------------------------------------------------------- 1 | mod int; 2 | pub use int::IntStrategy; 3 | 4 | mod uint; 5 | pub use uint::UintStrategy; 6 | 7 | mod param; 8 | pub use param::{fuzz_param, fuzz_param_from_state, fuzz_param_with_fixtures}; 9 | 10 | mod calldata; 11 | pub use calldata::{fuzz_calldata, fuzz_calldata_from_state}; 12 | 13 | mod state; 14 | pub use state::EvmFuzzState; 15 | 16 | mod invariants; 17 | pub use invariants::{fuzz_contract_with_calldata, invariant_strat, override_call_strat}; 18 | -------------------------------------------------------------------------------- /crates/fmt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "forge-fmt" 3 | 4 | version.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | authors.workspace = true 8 | license.workspace = true 9 | homepage.workspace = true 10 | repository.workspace = true 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | foundry-config.workspace = true 17 | 18 | alloy-primitives.workspace = true 19 | 20 | ariadne = "0.5" 21 | itertools.workspace = true 22 | solang-parser.workspace = true 23 | thiserror.workspace = true 24 | tracing.workspace = true 25 | 26 | [dev-dependencies] 27 | itertools.workspace = true 28 | similar-asserts.workspace = true 29 | toml.workspace = true 30 | tracing-subscriber = { workspace = true, features = ["env-filter"] } 31 | -------------------------------------------------------------------------------- /crates/fmt/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 3 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 4 | 5 | #[macro_use] 6 | extern crate tracing; 7 | 8 | mod buffer; 9 | pub mod chunk; 10 | mod comments; 11 | mod formatter; 12 | mod helpers; 13 | pub mod inline_config; 14 | mod macros; 15 | pub mod solang_ext; 16 | mod string; 17 | pub mod visit; 18 | 19 | pub use foundry_config::fmt::*; 20 | 21 | pub use comments::Comments; 22 | pub use formatter::{Formatter, FormatterError}; 23 | pub use helpers::{ 24 | format, format_diagnostics_report, format_to, offset_to_line_column, parse, parse2, Parsed, 25 | }; 26 | pub use inline_config::InlineConfig; 27 | pub use visit::{Visitable, Visitor}; 28 | -------------------------------------------------------------------------------- /crates/fmt/testdata/Annotation/fmt.sol: -------------------------------------------------------------------------------- 1 | // Support for Solana/Substrate annotations 2 | contract A { 3 | @selector([1, 2, 3, 4]) 4 | function foo() public {} 5 | 6 | @selector("another one") 7 | function bar() public {} 8 | 9 | @first("") 10 | @second("") 11 | function foobar() public {} 12 | } 13 | 14 | @topselector(2) 15 | contract B {} 16 | -------------------------------------------------------------------------------- /crates/fmt/testdata/Annotation/original.sol: -------------------------------------------------------------------------------- 1 | // Support for Solana/Substrate annotations 2 | contract A { 3 | @selector([1,2,3,4]) 4 | function foo() public {} 5 | 6 | @selector("another one") 7 | function bar() public {} 8 | 9 | @first("") 10 | @second("") 11 | function foobar() public {} 12 | } 13 | 14 | @topselector(2) 15 | contract B {} 16 | -------------------------------------------------------------------------------- /crates/fmt/testdata/BlockComments/fmt.sol: -------------------------------------------------------------------------------- 1 | contract CounterTest is Test { 2 | /** 3 | * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. 4 | */ 5 | constructor(string memory name_, string memory symbol_) { 6 | _name = name_; 7 | _symbol = symbol_; 8 | } 9 | 10 | /** 11 | * @dev See {IERC721-balanceOf}. 12 | */ 13 | function test_Increment() public { 14 | counter.increment(); 15 | assertEq(counter.number(), 1); 16 | } 17 | 18 | /** 19 | * @dev See {IERC165-supportsInterface}. 20 | */ 21 | function test_Increment() public { 22 | counter.increment(); 23 | assertEq(counter.number(), 1); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/BlockComments/original.sol: -------------------------------------------------------------------------------- 1 | contract CounterTest is Test { 2 | /** 3 | * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. 4 | */ 5 | 6 | constructor(string memory name_, string memory symbol_) { 7 | _name = name_; 8 | _symbol = symbol_; 9 | } 10 | 11 | /** 12 | * @dev See {IERC721-balanceOf}. 13 | */ 14 | function test_Increment() public { 15 | counter.increment(); 16 | assertEq(counter.number(), 1); 17 | } 18 | 19 | /** 20 | * @dev See {IERC165-supportsInterface}. 21 | */ function test_Increment() public { 22 | counter.increment(); 23 | assertEq(counter.number(), 1); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/BlockCommentsFunction/fmt.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | Counter public counter; 3 | /** 4 | * TODO: this fuzz use too much time to execute 5 | * function testGetFuzz(bytes[2][] memory kvs) public { 6 | * for (uint256 i = 0; i < kvs.length; i++) { 7 | * bytes32 root = trie.update(kvs[i][0], kvs[i][1]); 8 | * console.logBytes32(root); 9 | * } 10 | * 11 | * for (uint256 i = 0; i < kvs.length; i++) { 12 | * (bool exist, bytes memory value) = trie.get(kvs[i][0]); 13 | * console.logBool(exist); 14 | * console.logBytes(value); 15 | * require(exist); 16 | * require(BytesSlice.equal(value, trie.getRaw(kvs[i][0]))); 17 | * } 18 | * } 19 | */ 20 | } 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/BlockCommentsFunction/original.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | Counter public counter; 3 | /** 4 | * TODO: this fuzz use too much time to execute 5 | function testGetFuzz(bytes[2][] memory kvs) public { 6 | for (uint256 i = 0; i < kvs.length; i++) { 7 | bytes32 root = trie.update(kvs[i][0], kvs[i][1]); 8 | console.logBytes32(root); 9 | } 10 | 11 | for (uint256 i = 0; i < kvs.length; i++) { 12 | (bool exist, bytes memory value) = trie.get(kvs[i][0]); 13 | console.logBool(exist); 14 | console.logBytes(value); 15 | require(exist); 16 | require(BytesSlice.equal(value, trie.getRaw(kvs[i][0]))); 17 | } 18 | } 19 | */ 20 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ConstructorDefinition/original.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.5.2; 4 | 5 | // comment block starts here 6 | // comment block continues 7 | // 8 | 9 | // comment block 2 starts here 10 | // comment block 2 continues 11 | 12 | contract Constructors is Ownable, Changeable { 13 | function Constructors(variable1) public Changeable(variable1) Ownable() onlyOwner { 14 | } 15 | 16 | constructor(variable1, variable2, variable3, variable4, variable5, variable6, variable7) public Changeable(variable1, variable2, variable3, variable4, variable5, variable6, variable7) Ownable() onlyOwner {} 17 | } 18 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ConstructorModifierStyle/fmt.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.5.2; 4 | 5 | import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; 6 | import {ERC1155} from "solmate/tokens/ERC1155.sol"; 7 | 8 | import {IAchievements} from "./interfaces/IAchievements.sol"; 9 | import {SoulBound1155} from "./abstracts/SoulBound1155.sol"; 10 | 11 | contract Achievements is IAchievements, SoulBound1155, Ownable { 12 | constructor(address owner) Ownable() ERC1155() {} 13 | } 14 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ConstructorModifierStyle/original.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.5.2; 4 | 5 | import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; 6 | import {ERC1155} from "solmate/tokens/ERC1155.sol"; 7 | 8 | import {IAchievements} from "./interfaces/IAchievements.sol"; 9 | import {SoulBound1155} from "./abstracts/SoulBound1155.sol"; 10 | 11 | contract Achievements is IAchievements, SoulBound1155, Ownable { 12 | constructor(address owner) Ownable() ERC1155() {} 13 | } 14 | -------------------------------------------------------------------------------- /crates/fmt/testdata/DoWhileStatement/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | contract DoWhileStatement { 4 | function test() external { 5 | uint256 i; 6 | do { 7 | "test"; 8 | } while (i != 0); 9 | 10 | do {} while (i != 0); 11 | 12 | bool someVeryVeryLongCondition; 13 | do { 14 | "test"; 15 | } while ( 16 | someVeryVeryLongCondition && !someVeryVeryLongCondition 17 | && !someVeryVeryLongCondition && someVeryVeryLongCondition 18 | ); 19 | 20 | do { 21 | i++; 22 | } while (i < 10); 23 | 24 | do { 25 | do { 26 | i++; 27 | } while (i < 30); 28 | } while (i < 20); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /crates/fmt/testdata/DoWhileStatement/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | contract DoWhileStatement { 4 | function test() external { 5 | uint256 i; 6 | do { "test"; } while (i != 0); 7 | 8 | do 9 | {} 10 | while 11 | ( 12 | i != 0); 13 | 14 | bool someVeryVeryLongCondition; 15 | do { "test"; } while( 16 | someVeryVeryLongCondition && !someVeryVeryLongCondition && 17 | !someVeryVeryLongCondition && 18 | someVeryVeryLongCondition); 19 | 20 | do i++; while(i < 10); 21 | 22 | do do i++; while (i < 30); while(i < 20); 23 | } 24 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/EmitStatement/fmt.sol: -------------------------------------------------------------------------------- 1 | // config: line_length = 80 2 | event NewEvent( 3 | address beneficiary, uint256 index, uint64 timestamp, uint64 endTimestamp 4 | ); 5 | 6 | function emitEvent() { 7 | emit NewEvent( 8 | beneficiary, 9 | _vestingBeneficiaries.length - 1, 10 | uint64(block.timestamp), 11 | endTimestamp 12 | ); 13 | 14 | emit NewEvent( 15 | /* beneficiary */ 16 | beneficiary, 17 | /* index */ 18 | _vestingBeneficiaries.length - 1, 19 | /* timestamp */ 20 | uint64(block.timestamp), 21 | /* end timestamp */ 22 | endTimestamp 23 | ); 24 | 25 | emit NewEvent( 26 | beneficiary, // beneficiary 27 | _vestingBeneficiaries.length - 1, // index 28 | uint64(block.timestamp), // timestamp 29 | endTimestamp // end timestamp 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EmitStatement/original.sol: -------------------------------------------------------------------------------- 1 | event NewEvent(address beneficiary, uint256 index, uint64 timestamp, uint64 endTimestamp); 2 | 3 | function emitEvent() { 4 | emit NewEvent( 5 | beneficiary, 6 | _vestingBeneficiaries.length - 1, 7 | uint64(block.timestamp), 8 | endTimestamp 9 | ); 10 | 11 | emit 12 | NewEvent( 13 | /* beneficiary */ beneficiary, 14 | /* index */ _vestingBeneficiaries.length - 1, 15 | /* timestamp */ uint64(block.timestamp), 16 | /* end timestamp */ endTimestamp); 17 | 18 | emit NewEvent( 19 | beneficiary, // beneficiary 20 | _vestingBeneficiaries.length - 1, // index 21 | uint64(block.timestamp), // timestamp 22 | endTimestamp // end timestamp 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumDefinition/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | contract EnumDefinitions { 3 | enum Empty { } 4 | enum ActionChoices { 5 | GoLeft, 6 | GoRight, 7 | GoStraight, 8 | SitStill 9 | } 10 | enum States { 11 | State1, 12 | State2, 13 | State3, 14 | State4, 15 | State5, 16 | State6, 17 | State7, 18 | State8, 19 | State9 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | contract EnumDefinitions { 2 | enum Empty {} 3 | enum ActionChoices { 4 | GoLeft, 5 | GoRight, 6 | GoStraight, 7 | SitStill 8 | } 9 | enum States { 10 | State1, 11 | State2, 12 | State3, 13 | State4, 14 | State5, 15 | State6, 16 | State7, 17 | State8, 18 | State9 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumDefinition/original.sol: -------------------------------------------------------------------------------- 1 | contract EnumDefinitions { 2 | enum Empty { 3 | 4 | } 5 | enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } 6 | enum States { State1, State2, State3, State4, State5, State6, State7, State8, State9 } 7 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumVariants/fmt.sol: -------------------------------------------------------------------------------- 1 | interface I { 2 | enum Empty {} 3 | 4 | /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. 5 | enum CallerMode { 6 | /// No caller modification is currently active. 7 | None 8 | } 9 | 10 | /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. 11 | enum CallerMode2 { 12 | /// No caller modification is currently active. 13 | None, 14 | /// No caller modification is currently active2. 15 | Some 16 | } 17 | 18 | function bar() public {} 19 | } 20 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumVariants/original.sol: -------------------------------------------------------------------------------- 1 | interface I { 2 | enum Empty { 3 | 4 | } 5 | 6 | /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. 7 | enum CallerMode 8 | {/// No caller modification is currently active. 9 | None 10 | } 11 | 12 | /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. 13 | enum CallerMode2 14 | {/// No caller modification is currently active. 15 | None,/// No caller modification is currently active2. 16 | 17 | Some 18 | } 19 | 20 | function bar() public { 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ErrorDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.4; 2 | 3 | error TopLevelCustomError(); 4 | error TopLevelCustomErrorWithArg(uint256 x); 5 | error TopLevelCustomErrorArgWithoutName(string); 6 | error Error1( 7 | uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256 8 | ); 9 | 10 | contract Errors { 11 | error ContractCustomError(); 12 | error ContractCustomErrorWithArg(uint256 x); 13 | error ContractCustomErrorArgWithoutName(string); 14 | } 15 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ErrorDefinition/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.4; 2 | 3 | error 4 | TopLevelCustomError(); 5 | error TopLevelCustomErrorWithArg(uint x) ; 6 | error TopLevelCustomErrorArgWithoutName (string); 7 | error Error1(uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256); 8 | 9 | contract Errors { 10 | error 11 | ContractCustomError(); 12 | error ContractCustomErrorWithArg(uint x) ; 13 | error ContractCustomErrorArgWithoutName (string); 14 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ForStatement/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | contract ForStatement { 4 | function test() external { 5 | for (uint256 i1; i1 < 10; i1++) { 6 | i1++; 7 | } 8 | 9 | uint256 i2; 10 | for (++i2; i2 < 10; i2++) {} 11 | 12 | uint256 veryLongVariableName = 1000; 13 | for ( 14 | uint256 i3; 15 | i3 < 10 && veryLongVariableName > 999 && veryLongVariableName < 1001; 16 | i3++ 17 | ) { 18 | i3++; 19 | } 20 | 21 | for (type(uint256).min;;) {} 22 | 23 | for (;;) { 24 | "test"; 25 | } 26 | 27 | for (uint256 i4; i4 < 10; i4++) { 28 | i4++; 29 | } 30 | 31 | for (uint256 i5;;) { 32 | for (uint256 i6 = 10; i6 > i5; i6--) { 33 | i5++; 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ForStatement/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | contract ForStatement { 4 | function test() external { 5 | for 6 | (uint256 i1 7 | ; i1 < 10; i1++) 8 | { 9 | i1++; 10 | } 11 | 12 | uint256 i2; 13 | for(++i2;i2<10;i2++) 14 | 15 | {} 16 | 17 | uint256 veryLongVariableName = 1000; 18 | for ( uint256 i3; i3 < 10 19 | && veryLongVariableName>999 && veryLongVariableName< 1001 20 | ; i3++) 21 | { i3 ++ ; } 22 | 23 | for (type(uint256).min;;) {} 24 | 25 | for (;;) { "test" ; } 26 | 27 | for (uint256 i4; i4< 10; i4++) i4++; 28 | 29 | for (uint256 i5; ;) 30 | for (uint256 i6 = 10; i6 > i5; i6--) 31 | i5++; 32 | } 33 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.17; 3 | 4 | contract ReturnFnFormat { 5 | function returnsFunction() 6 | internal 7 | pure 8 | returns ( 9 | function() 10 | internal pure returns (uint256) 11 | ) 12 | {} 13 | } 14 | 15 | // https://github.com/foundry-rs/foundry/issues/7920 16 | contract ReturnFnDisableFormat { 17 | // forgefmt: disable-next-line 18 | function disableFnFormat() external returns (uint256) { 19 | return 0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.17; 3 | 4 | contract ReturnFnFormat { 5 | function returnsFunction() 6 | internal 7 | pure 8 | returns ( 9 | function() 10 | internal pure returns (uint256) 11 | ) 12 | {} 13 | } 14 | 15 | // https://github.com/foundry-rs/foundry/issues/7920 16 | contract ReturnFnDisableFormat { 17 | // forgefmt: disable-next-line 18 | function disableFnFormat() external returns (uint256) { 19 | return 0; 20 | } 21 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/FunctionType/original.sol: -------------------------------------------------------------------------------- 1 | library ArrayUtils { 2 | function map(uint[] memory self, function (uint) pure returns (uint) f) 3 | internal 4 | pure 5 | returns ( 6 | uint[] memory r 7 | ) 8 | { 9 | r = new uint[]( self.length); 10 | for (uint i = 0; i < self.length; i++) { 11 | r[i] = f(self[i]); 12 | } 13 | } 14 | 15 | function reduce( 16 | uint[] memory self, 17 | function (uint, uint) pure returns (uint) f 18 | ) internal pure returns (uint256 r) { 19 | r = self[0]; 20 | for (uint i = 1; i < self.length; i++) { 21 | r = f(r, self[i]); 22 | } 23 | } 24 | 25 | function range(uint256 length) internal pure returns (uint[] memory r) { 26 | r = new uint256[](length ); 27 | for (uint i = 0; i < r.length; i++) { 28 | r[i] = i; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/bytes.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: hex_underscore = "bytes" 2 | contract HexLiteral { 3 | function test() external { 4 | hex"01_23_00_00"; 5 | hex"01_23_00_00"; 6 | hex"01_23_00_00"; 7 | hex""; 8 | hex"60_01_60_02_53"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/fmt.sol: -------------------------------------------------------------------------------- 1 | contract HexLiteral { 2 | function test() external { 3 | hex"01230000"; 4 | hex"01230000"; 5 | hex"01230000"; 6 | hex""; 7 | hex"6001600253"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/original.sol: -------------------------------------------------------------------------------- 1 | contract HexLiteral { 2 | function test() external { 3 | hex"0123_0000"; 4 | hex"01230000"; 5 | hex"0123_00_00"; 6 | hex""; 7 | hex"6001_6002_53"; 8 | } 9 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/preserve.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: hex_underscore = "preserve" 2 | contract HexLiteral { 3 | function test() external { 4 | hex"0123_0000"; 5 | hex"01230000"; 6 | hex"0123_00_00"; 7 | hex""; 8 | hex"6001_6002_53"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/remove.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: hex_underscore = "remove" 2 | contract HexLiteral { 3 | function test() external { 4 | hex"01230000"; 5 | hex"01230000"; 6 | hex"01230000"; 7 | hex""; 8 | hex"6001600253"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IfStatement2/fmt.sol: -------------------------------------------------------------------------------- 1 | contract IfStatement { 2 | function test() external { 3 | bool anotherLongCondition; 4 | 5 | if (condition && ((condition || anotherLongCondition))) execute(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IfStatement2/original.sol: -------------------------------------------------------------------------------- 1 | contract IfStatement { 2 | 3 | function test() external { 4 | bool anotherLongCondition; 5 | 6 | if (condition && ((condition || anotherLongCondition) 7 | ) 8 | ) execute(); 9 | } 10 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | import "SomeFile.sol"; 3 | import "SomeFile.sol"; 4 | import "SomeFile.sol" as SomeOtherFile; 5 | import "SomeFile.sol" as SomeOtherFile; 6 | import "AnotherFile.sol" as SomeSymbol; 7 | import "AnotherFile.sol" as SomeSymbol; 8 | import { symbol1 as alias, symbol2 } from "File.sol"; 9 | import { symbol1 as alias, symbol2 } from "File.sol"; 10 | import { 11 | symbol1 as alias1, 12 | symbol2 as alias2, 13 | symbol3 as alias3, 14 | symbol4 15 | } from "File2.sol"; 16 | import { 17 | symbol1 as alias1, 18 | symbol2 as alias2, 19 | symbol3 as alias3, 20 | symbol4 21 | } from "File2.sol"; 22 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/fmt.sol: -------------------------------------------------------------------------------- 1 | import "SomeFile.sol"; 2 | import "SomeFile.sol"; 3 | import "SomeFile.sol" as SomeOtherFile; 4 | import "SomeFile.sol" as SomeOtherFile; 5 | import "AnotherFile.sol" as SomeSymbol; 6 | import "AnotherFile.sol" as SomeSymbol; 7 | import {symbol1 as alias, symbol2} from "File.sol"; 8 | import {symbol1 as alias, symbol2} from "File.sol"; 9 | import { 10 | symbol1 as alias1, 11 | symbol2 as alias2, 12 | symbol3 as alias3, 13 | symbol4 14 | } from "File2.sol"; 15 | import { 16 | symbol1 as alias1, 17 | symbol2 as alias2, 18 | symbol3 as alias3, 19 | symbol4 20 | } from "File2.sol"; 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/original.sol: -------------------------------------------------------------------------------- 1 | import "SomeFile.sol"; 2 | import 'SomeFile.sol'; 3 | import "SomeFile.sol" as SomeOtherFile; 4 | import 'SomeFile.sol' as SomeOtherFile; 5 | import * as SomeSymbol from "AnotherFile.sol"; 6 | import * as SomeSymbol from 'AnotherFile.sol'; 7 | import {symbol1 as alias, symbol2} from "File.sol"; 8 | import {symbol1 as alias, symbol2} from 'File.sol'; 9 | import {symbol1 as alias1, symbol2 as alias2, symbol3 as alias3, symbol4} from "File2.sol"; 10 | import {symbol1 as alias1, symbol2 as alias2, symbol3 as alias3, symbol4} from 'File2.sol'; 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/preserve-quote.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: quote_style = "preserve" 2 | import "SomeFile.sol"; 3 | import 'SomeFile.sol'; 4 | import "SomeFile.sol" as SomeOtherFile; 5 | import 'SomeFile.sol' as SomeOtherFile; 6 | import "AnotherFile.sol" as SomeSymbol; 7 | import 'AnotherFile.sol' as SomeSymbol; 8 | import {symbol1 as alias, symbol2} from "File.sol"; 9 | import {symbol1 as alias, symbol2} from 'File.sol'; 10 | import { 11 | symbol1 as alias1, 12 | symbol2 as alias2, 13 | symbol3 as alias3, 14 | symbol4 15 | } from "File2.sol"; 16 | import { 17 | symbol1 as alias1, 18 | symbol2 as alias2, 19 | symbol3 as alias3, 20 | symbol4 21 | } from 'File2.sol'; 22 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/single-quote.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: quote_style = "single" 2 | import 'SomeFile.sol'; 3 | import 'SomeFile.sol'; 4 | import 'SomeFile.sol' as SomeOtherFile; 5 | import 'SomeFile.sol' as SomeOtherFile; 6 | import 'AnotherFile.sol' as SomeSymbol; 7 | import 'AnotherFile.sol' as SomeSymbol; 8 | import {symbol1 as alias, symbol2} from 'File.sol'; 9 | import {symbol1 as alias, symbol2} from 'File.sol'; 10 | import { 11 | symbol1 as alias1, 12 | symbol2 as alias2, 13 | symbol3 as alias3, 14 | symbol4 15 | } from 'File2.sol'; 16 | import { 17 | symbol1 as alias1, 18 | symbol2 as alias2, 19 | symbol3 as alias3, 20 | symbol4 21 | } from 'File2.sol'; 22 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IntTypes/fmt.sol: -------------------------------------------------------------------------------- 1 | contract Contract { 2 | uint256 constant UINT256_IMPL = 0; 3 | uint8 constant UINT8 = 1; 4 | uint128 constant UINT128 = 2; 5 | uint256 constant UINT256_EXPL = 3; 6 | 7 | int256 constant INT256_IMPL = 4; 8 | int8 constant INT8 = 5; 9 | int128 constant INT128 = 6; 10 | int256 constant INT256_EXPL = 7; 11 | 12 | function test( 13 | uint256 uint256_impl, 14 | uint8 uint8_var, 15 | uint128 uint128_var, 16 | uint256 uint256_expl, 17 | int256 int256_impl, 18 | int8 int8_var, 19 | int128 int128_var, 20 | int256 int256_expl 21 | ) public { 22 | // do something 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IntTypes/original.sol: -------------------------------------------------------------------------------- 1 | contract Contract { 2 | uint constant UINT256_IMPL = 0; 3 | uint8 constant UINT8 = 1; 4 | uint128 constant UINT128 = 2; 5 | uint256 constant UINT256_EXPL = 3; 6 | 7 | int constant INT256_IMPL = 4; 8 | int8 constant INT8 = 5; 9 | int128 constant INT128 = 6; 10 | int256 constant INT256_EXPL = 7; 11 | 12 | function test( 13 | uint uint256_impl, 14 | uint8 uint8_var, 15 | uint128 uint128_var, 16 | uint256 uint256_expl, 17 | int int256_impl, 18 | int8 int8_var, 19 | int128 int128_var, 20 | int256 int256_expl 21 | ) public { 22 | // do something 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IntTypes/preserve.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: int_types = "preserve" 2 | contract Contract { 3 | uint constant UINT256_IMPL = 0; 4 | uint8 constant UINT8 = 1; 5 | uint128 constant UINT128 = 2; 6 | uint256 constant UINT256_EXPL = 3; 7 | 8 | int constant INT256_IMPL = 4; 9 | int8 constant INT8 = 5; 10 | int128 constant INT128 = 6; 11 | int256 constant INT256_EXPL = 7; 12 | 13 | function test( 14 | uint uint256_impl, 15 | uint8 uint8_var, 16 | uint128 uint128_var, 17 | uint256 uint256_expl, 18 | int int256_impl, 19 | int8 int8_var, 20 | int128 int128_var, 21 | int256 int256_expl 22 | ) public { 23 | // do something 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IntTypes/short.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: int_types = "short" 2 | contract Contract { 3 | uint constant UINT256_IMPL = 0; 4 | uint8 constant UINT8 = 1; 5 | uint128 constant UINT128 = 2; 6 | uint constant UINT256_EXPL = 3; 7 | 8 | int constant INT256_IMPL = 4; 9 | int8 constant INT8 = 5; 10 | int128 constant INT128 = 6; 11 | int constant INT256_EXPL = 7; 12 | 13 | function test( 14 | uint uint256_impl, 15 | uint8 uint8_var, 16 | uint128 uint128_var, 17 | uint uint256_expl, 18 | int int256_impl, 19 | int8 int8_var, 20 | int128 int128_var, 21 | int int256_expl 22 | ) public { 23 | // do something 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/MappingType/original.sol: -------------------------------------------------------------------------------- 1 | contract X { 2 | type Y is bytes32; 3 | } 4 | 5 | type SomeVeryLongTypeName is uint256; 6 | 7 | contract Mapping { 8 | mapping(uint256 => X.Y) mapping1; 9 | mapping(uint256 key => uint256 value) mapping2; 10 | mapping(uint256 veryLongKeyName => uint256 veryLongValueName) mapping3; 11 | mapping(string anotherVeryLongKeyName => uint256 anotherVeryLongValueName) mapping4; 12 | mapping(SomeVeryLongTypeName anotherVeryLongKeyName => uint256 anotherVeryLongValueName) mapping5; 13 | 14 | mapping( 15 | 16 | // comment1 17 | uint256 key => uint256 value 18 | // comment2 19 | ) mapping6; 20 | mapping( /* comment3 */ 21 | uint256 /* comment4 */ key /* comment5 */ => /* comment6 */ uint256 /* comment7 */ value /* comment8 */ /* comment9 */ 22 | ) /* comment10 */ mapping7; 23 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ModifierDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | // config: line_length = 60 2 | contract ModifierDefinitions { 3 | modifier noParams() {} 4 | modifier oneParam(uint256 a) {} 5 | modifier twoParams(uint256 a, uint256 b) {} 6 | modifier threeParams(uint256 a, uint256 b, uint256 c) {} 7 | modifier fourParams( 8 | uint256 a, 9 | uint256 b, 10 | uint256 c, 11 | uint256 d 12 | ) {} 13 | modifier overridden() override(Base1, Base2) {} 14 | } 15 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ModifierDefinition/original.sol: -------------------------------------------------------------------------------- 1 | contract ModifierDefinitions { 2 | modifier noParams() {} 3 | modifier oneParam(uint a) {} 4 | modifier twoParams(uint a,uint b) {} 5 | modifier threeParams(uint a,uint b ,uint c) {} 6 | modifier fourParams(uint a,uint b ,uint c, uint d) {} 7 | modifier overridden ( 8 | ) override ( Base1 , Base2) {} 9 | } 10 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ModifierDefinition/override-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: line_length = 60 2 | // config: override_spacing = true 3 | contract ModifierDefinitions { 4 | modifier noParams() {} 5 | modifier oneParam(uint256 a) {} 6 | modifier twoParams(uint256 a, uint256 b) {} 7 | modifier threeParams(uint256 a, uint256 b, uint256 c) {} 8 | modifier fourParams( 9 | uint256 a, 10 | uint256 b, 11 | uint256 c, 12 | uint256 d 13 | ) {} 14 | modifier overridden() override (Base1, Base2) {} 15 | } 16 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NonKeywords/fmt.sol: -------------------------------------------------------------------------------- 1 | struct S { 2 | uint256 error; 3 | uint256 layout; 4 | uint256 at; 5 | } 6 | // uint256 transient; 7 | 8 | function f() { 9 | uint256 error = 0; 10 | uint256 layout = 0; 11 | uint256 at = 0; 12 | // uint256 transient = 0; 13 | 14 | error = 0; 15 | // layout = 0; 16 | at = 0; 17 | // transient = 0; 18 | 19 | S memory x = S({ 20 | // format 21 | error: 0, 22 | layout: 0, 23 | at: 0 24 | }); 25 | // transient: 0 26 | 27 | x.error = 0; 28 | x.layout = 0; 29 | x.at = 0; 30 | // x.transient = 0; 31 | 32 | assembly { 33 | let error := 0 34 | let layout := 0 35 | let at := 0 36 | // let transient := 0 37 | 38 | error := 0 39 | layout := 0 40 | at := 0 41 | // transient := 0 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NonKeywords/original.sol: -------------------------------------------------------------------------------- 1 | struct S { 2 | uint256 error; 3 | uint256 layout; 4 | uint256 at; 5 | // uint256 transient; 6 | } 7 | 8 | function f() { 9 | uint256 error = 0; 10 | uint256 layout = 0; 11 | uint256 at = 0; 12 | // uint256 transient = 0; 13 | 14 | error = 0; 15 | // layout = 0; 16 | at = 0; 17 | // transient = 0; 18 | 19 | S memory x = S({ 20 | // format 21 | error: 0, 22 | layout: 0, 23 | at: 0 24 | // transient: 0 25 | }); 26 | 27 | x.error = 0; 28 | x.layout = 0; 29 | x.at = 0; 30 | // x.transient = 0; 31 | 32 | assembly { 33 | let error := 0 34 | let layout := 0 35 | let at := 0 36 | // let transient := 0 37 | 38 | error := 0 39 | layout := 0 40 | at := 0 41 | // transient := 0 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/fmt.sol: -------------------------------------------------------------------------------- 1 | contract NumberLiteral { 2 | function test() external { 3 | 1; 4 | 123_000; 5 | 1_2e345_678; 6 | -1; 7 | 2e-10; 8 | 0.1; 9 | 1.3; 10 | 2.5e1; 11 | 1.23454; 12 | 1.2e34_5_678; 13 | 134411.2e34_5_678; 14 | 13431.134112e34_135_678; 15 | 13431.0134112; 16 | 13431.134112e-139_3141340; 17 | 134411.2e34_5_6780; 18 | 13431.134112e34_135_6780; 19 | 0.134112; 20 | 1.0; 21 | 13431.134112e-139_3141340; 22 | 123e456; 23 | 1_000; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/original.sol: -------------------------------------------------------------------------------- 1 | contract NumberLiteral { 2 | function test() external { 3 | 1; 4 | 123_000; 5 | 1_2e345_678; 6 | -1; 7 | 2e-10; 8 | .1; 9 | 1.3; 10 | 2.5e1; 11 | 1.23454e0; 12 | 1.2e34_5_678; 13 | 134411.2e34_5_678; 14 | 13431.134112e34_135_678; 15 | 13431.0134112; 16 | 13431.134112e-139_3141340; 17 | 00134411.200e0034_5_6780; 18 | 013431.13411200e34_135_6780; 19 | 00.1341120000; 20 | 1.0000; 21 | 0013431.13411200e-00139_3141340; 22 | 123E456; 23 | 1_000; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/preserve.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: number_underscore = "preserve" 2 | contract NumberLiteral { 3 | function test() external { 4 | 1; 5 | 123_000; 6 | 1_2e345_678; 7 | -1; 8 | 2e-10; 9 | 0.1; 10 | 1.3; 11 | 2.5e1; 12 | 1.23454; 13 | 1.2e34_5_678; 14 | 134411.2e34_5_678; 15 | 13431.134112e34_135_678; 16 | 13431.0134112; 17 | 13431.134112e-139_3141340; 18 | 134411.2e34_5_6780; 19 | 13431.134112e34_135_6780; 20 | 0.134112; 21 | 1.0; 22 | 13431.134112e-139_3141340; 23 | 123e456; 24 | 1_000; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/remove.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: number_underscore = "remove" 2 | contract NumberLiteral { 3 | function test() external { 4 | 1; 5 | 123000; 6 | 12e345678; 7 | -1; 8 | 2e-10; 9 | 0.1; 10 | 1.3; 11 | 2.5e1; 12 | 1.23454; 13 | 1.2e345678; 14 | 134411.2e345678; 15 | 13431.134112e34135678; 16 | 13431.0134112; 17 | 13431.134112e-1393141340; 18 | 134411.2e3456780; 19 | 13431.134112e341356780; 20 | 0.134112; 21 | 1.0; 22 | 13431.134112e-1393141340; 23 | 123e456; 24 | 1000; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/thousands.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: number_underscore = "thousands" 2 | contract NumberLiteral { 3 | function test() external { 4 | 1; 5 | 123_000; 6 | 12e345_678; 7 | -1; 8 | 2e-10; 9 | 0.1; 10 | 1.3; 11 | 2.5e1; 12 | 1.23454; 13 | 1.2e345_678; 14 | 134_411.2e345_678; 15 | 13_431.134112e34_135_678; 16 | 13_431.0134112; 17 | 13_431.134112e-1_393_141_340; 18 | 134_411.2e3_456_780; 19 | 13_431.134112e341_356_780; 20 | 0.134112; 21 | 1.0; 22 | 13_431.134112e-1_393_141_340; 23 | 123e456; 24 | 1000; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/PragmaDirective/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.17; 2 | pragma experimental ABIEncoderV2; 3 | 4 | contract Contract {} 5 | 6 | // preserves lines 7 | pragma solidity 0.8.17; 8 | 9 | pragma experimental ABIEncoderV2; 10 | -------------------------------------------------------------------------------- /crates/fmt/testdata/PragmaDirective/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.17; 2 | pragma experimental ABIEncoderV2; 3 | 4 | contract Contract {} 5 | 6 | // preserves lines 7 | pragma solidity 0.8.17; 8 | 9 | pragma experimental ABIEncoderV2; -------------------------------------------------------------------------------- /crates/fmt/testdata/SortedImports/original.sol: -------------------------------------------------------------------------------- 1 | import "SomeFile3.sol"; 2 | import "SomeFile2.sol"; 3 | import "SomeFile1.sol" as SomeOtherFile; 4 | import "SomeFile0.sol" as SomeOtherFile; 5 | 6 | import "AnotherFile2.sol" as SomeSymbol; 7 | import "AnotherFile1.sol" as SomeSymbol; 8 | 9 | import {symbol2, symbol1 as alias} from "File3.sol"; 10 | import {symbol2, symbol1 as alias} from "File2.sol"; 11 | import {symbol2 as alias2, symbol1 as alias1, symbol3 as alias3, symbol4} from "File6.sol"; 12 | import {symbol3 as alias1, symbol2 as alias2, symbol1 as alias3, symbol4} from "File0.sol"; 13 | 14 | uint256 constant someConstant = 10; 15 | 16 | import {Something3, Something2} from "someFile.sol"; 17 | 18 | // This is a comment 19 | import {Something3, Something2} from "someFile.sol"; 20 | 21 | import {symbol2, symbol1 as alias} from "File3.sol"; 22 | // comment inside group is treated as a separator for now 23 | import {symbol2, symbol1 as alias} from "File2.sol"; -------------------------------------------------------------------------------- /crates/fmt/testdata/StatementBlock/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | contract Contract { 3 | function test() { 4 | unchecked { 5 | a += 1; 6 | } 7 | 8 | unchecked { 9 | a += 1; 10 | } 11 | 2 + 2; 12 | 13 | unchecked { 14 | a += 1; 15 | } 16 | unchecked { } 17 | 18 | 1 + 1; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/StatementBlock/fmt.sol: -------------------------------------------------------------------------------- 1 | contract Contract { 2 | function test() { 3 | unchecked { 4 | a += 1; 5 | } 6 | 7 | unchecked { 8 | a += 1; 9 | } 10 | 2 + 2; 11 | 12 | unchecked { 13 | a += 1; 14 | } 15 | unchecked {} 16 | 17 | 1 + 1; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /crates/fmt/testdata/StatementBlock/original.sol: -------------------------------------------------------------------------------- 1 | contract Contract { 2 | function test() { unchecked { a += 1; } 3 | 4 | unchecked { 5 | a += 1; 6 | } 7 | 2 + 2; 8 | 9 | unchecked { a += 1; 10 | } 11 | unchecked {} 12 | 13 | 1 + 1; 14 | 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/StructDefinition/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | struct Foo { } 3 | 4 | struct Bar { 5 | uint256 foo; 6 | string bar; 7 | } 8 | 9 | struct MyStruct { 10 | // first 1 11 | // first 2 12 | uint256 field1; 13 | // second 14 | uint256 field2; 15 | } 16 | -------------------------------------------------------------------------------- /crates/fmt/testdata/StructDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | struct Foo {} 2 | 3 | struct Bar { 4 | uint256 foo; 5 | string bar; 6 | } 7 | 8 | struct MyStruct { 9 | // first 1 10 | // first 2 11 | uint256 field1; 12 | // second 13 | uint256 field2; 14 | } 15 | -------------------------------------------------------------------------------- /crates/fmt/testdata/StructDefinition/original.sol: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | } struct Bar { uint foo ;string bar ; } 3 | 4 | struct MyStruct { 5 | // first 1 6 | // first 2 7 | uint256 field1; 8 | // second 9 | uint256 field2; 10 | } 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ThisExpression/fmt.sol: -------------------------------------------------------------------------------- 1 | contract ThisExpression { 2 | function someFunc() public {} 3 | function someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword() 4 | public 5 | {} 6 | 7 | function test() external { 8 | this.someFunc(); 9 | this.someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword(); 10 | this // comment1 11 | .someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword(); 12 | address(this).balance; 13 | 14 | address thisAddress = address( 15 | // comment2 16 | /* comment3 */ 17 | this // comment 4 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ThisExpression/original.sol: -------------------------------------------------------------------------------- 1 | contract ThisExpression { 2 | function someFunc() public {} 3 | function someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword() public {} 4 | 5 | function test() external { 6 | this.someFunc(); 7 | this.someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword(); 8 | this // comment1 9 | .someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword(); 10 | address(this).balance; 11 | 12 | address thisAddress = address( 13 | // comment2 14 | /* comment3 */ this // comment 4 15 | ); 16 | } 17 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/TrailingComma/fmt.sol: -------------------------------------------------------------------------------- 1 | contract C is Contract { 2 | modifier m(uint256) {} 3 | // invalid solidity code, but valid pt 4 | modifier m2(uint256) returns (uint256) {} 5 | 6 | function f(uint256 a) external {} 7 | function f2(uint256 a, bytes32 b) external returns (uint256) {} 8 | 9 | function f3() external { 10 | try some.invoke() returns (uint256, uint256) {} catch {} 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/fmt/testdata/TrailingComma/original.sol: -------------------------------------------------------------------------------- 1 | contract C is Contract { 2 | modifier m(uint256, ,,, ) {} 3 | // invalid solidity code, but valid pt 4 | modifier m2(uint256) returns (uint256,,,) {} 5 | 6 | function f(uint256 a, ) external {} 7 | function f2(uint256 a, , , ,bytes32 b) external returns (uint256,,,,) {} 8 | 9 | function f3() external { 10 | try some.invoke() returns (uint256,,,uint256) {} catch {} 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/fmt/testdata/TypeDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | type Hello is uint256; 4 | 5 | contract TypeDefinition { 6 | event Moon(Hello world); 7 | 8 | function demo(Hello world) public { 9 | world = Hello.wrap(Hello.unwrap(world) + 1337); 10 | emit Moon(world); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/fmt/testdata/TypeDefinition/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | type Hello is uint; 4 | 5 | contract TypeDefinition { 6 | event Moon(Hello world); 7 | 8 | function demo(Hello world) public { 9 | world = Hello.wrap(Hello.unwrap(world) + 1337); 10 | emit Moon(world); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/fmt/testdata/UnitExpression/fmt.sol: -------------------------------------------------------------------------------- 1 | contract UnitExpression { 2 | function test() external { 3 | uint256 timestamp; 4 | timestamp = 1 seconds; 5 | timestamp = 1 minutes; 6 | timestamp = 1 hours; 7 | timestamp = 1 days; 8 | timestamp = 1 weeks; 9 | 10 | uint256 value; 11 | value = 1 wei; 12 | value = 1 gwei; 13 | value = 1 ether; 14 | 15 | uint256 someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue; 16 | 17 | value = someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue 18 | * 1 /* comment1 */ ether; // comment2 19 | 20 | value = 1 // comment3 21 | // comment4 22 | ether; // comment5 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/fmt/testdata/UnitExpression/original.sol: -------------------------------------------------------------------------------- 1 | contract UnitExpression { 2 | function test() external { 3 | uint256 timestamp; 4 | timestamp = 1 seconds; 5 | timestamp = 1 minutes; 6 | timestamp = 1 hours; 7 | timestamp = 1 days; 8 | timestamp = 1 weeks; 9 | 10 | uint256 value; 11 | value = 1 wei; 12 | value = 1 gwei; 13 | value = 1 ether; 14 | 15 | uint256 someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue; 16 | 17 | value = someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2 18 | 19 | value = 1 // comment3 20 | // comment4 21 | ether; // comment5 22 | } 23 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/UsingDirective/original.sol: -------------------------------------------------------------------------------- 1 | contract UsingExampleContract { 2 | using UsingExampleLibrary for * ; 3 | using UsingExampleLibrary for uint; 4 | using Example.UsingExampleLibrary for uint; 5 | using { M.g, M.f} for uint; 6 | using UsingExampleLibrary for uint global; 7 | using { These, Are, MultipleLibraries, ThatNeedToBePut, OnSeparateLines } for uint; 8 | using { This.isareally.longmember.access.expression.that.needs.to.besplit.into.lines } for uint; 9 | using {and as &, or as |, xor as ^, cpl as ~} for Bitmap global; 10 | using {eq as ==, ne as !=, lt as <, lte as <=, gt as >, gte as >=} for Bitmap global; 11 | } 12 | -------------------------------------------------------------------------------- /crates/fmt/testdata/VariableAssignment/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | contract TestContract { 3 | function aLongerTestFunctionName(uint256 input) 4 | public 5 | view 6 | returns (uint256 num) 7 | { 8 | (, uint256 second) = (1, 2); 9 | (uint256 listItem001) = 1; 10 | (uint256 listItem002, uint256 listItem003) = (10, 20); 11 | (uint256 listItem004, uint256 listItem005, uint256 listItem006) = 12 | (10, 20, 30); 13 | ( 14 | uint256 listItem007, 15 | uint256 listItem008, 16 | uint256 listItem009, 17 | uint256 listItem010 18 | ) = (10, 20, 30, 40); 19 | return 1; 20 | } 21 | 22 | function test() external { 23 | uint256 value = map[key]; 24 | uint256 allowed = allowance[from][msg.sender]; 25 | allowance[from][msg.sender] = allowed; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /crates/fmt/testdata/VariableAssignment/fmt.sol: -------------------------------------------------------------------------------- 1 | contract TestContract { 2 | function aLongerTestFunctionName(uint256 input) 3 | public 4 | view 5 | returns (uint256 num) 6 | { 7 | (, uint256 second) = (1, 2); 8 | (uint256 listItem001) = 1; 9 | (uint256 listItem002, uint256 listItem003) = (10, 20); 10 | (uint256 listItem004, uint256 listItem005, uint256 listItem006) = 11 | (10, 20, 30); 12 | ( 13 | uint256 listItem007, 14 | uint256 listItem008, 15 | uint256 listItem009, 16 | uint256 listItem010 17 | ) = (10, 20, 30, 40); 18 | return 1; 19 | } 20 | 21 | function test() external { 22 | uint256 value = map[key]; 23 | uint256 allowed = allowance[from][msg.sender]; 24 | allowance[from][msg.sender] = allowed; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/VariableAssignment/original.sol: -------------------------------------------------------------------------------- 1 | contract TestContract { 2 | function aLongerTestFunctionName(uint256 input) 3 | public 4 | view 5 | returns (uint256 num) 6 | { 7 | (, uint256 second) = (1, 2); 8 | (uint256 listItem001) = 1; 9 | (uint256 listItem002, uint256 listItem003) = (10, 20); 10 | (uint256 listItem004, uint256 listItem005, uint256 listItem006) = 11 | (10, 20, 30); 12 | ( 13 | uint256 listItem007, 14 | uint256 listItem008, 15 | uint256 listItem009, 16 | uint256 listItem010 17 | ) = (10, 20, 30, 40); 18 | return 1; 19 | } 20 | 21 | function test() external { 22 | uint256 value = map[key]; 23 | uint256 allowed = allowance[from][msg.sender]; 24 | allowance[from][msg.sender] = allowed; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/YulStrings/fmt.sol: -------------------------------------------------------------------------------- 1 | contract Yul { 2 | function test() external { 3 | assembly { 4 | let a := "abc" 5 | let b := "abc" 6 | let c := "abc":u32 7 | let d := "abc":u32 8 | let e := hex"deadbeef" 9 | let f := hex"deadbeef" 10 | let g := hex"deadbeef":u32 11 | let h := hex"deadbeef":u32 12 | datacopy(0, dataoffset("runtime"), datasize("runtime")) 13 | return(0, datasize("runtime")) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/fmt/testdata/YulStrings/original.sol: -------------------------------------------------------------------------------- 1 | contract Yul { 2 | function test() external { 3 | assembly { 4 | let a := "abc" 5 | let b := 'abc' 6 | let c := "abc":u32 7 | let d := 'abc':u32 8 | let e := hex"deadbeef" 9 | let f := hex'deadbeef' 10 | let g := hex"deadbeef":u32 11 | let h := hex'deadbeef':u32 12 | datacopy(0, dataoffset('runtime'), datasize("runtime")) 13 | return(0, datasize("runtime")) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/fmt/testdata/YulStrings/preserve-quote.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: quote_style = "preserve" 2 | contract Yul { 3 | function test() external { 4 | assembly { 5 | let a := "abc" 6 | let b := 'abc' 7 | let c := "abc":u32 8 | let d := 'abc':u32 9 | let e := hex"deadbeef" 10 | let f := hex'deadbeef' 11 | let g := hex"deadbeef":u32 12 | let h := hex'deadbeef':u32 13 | datacopy(0, dataoffset('runtime'), datasize("runtime")) 14 | return(0, datasize("runtime")) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /crates/fmt/testdata/YulStrings/single-quote.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: quote_style = "single" 2 | contract Yul { 3 | function test() external { 4 | assembly { 5 | let a := 'abc' 6 | let b := 'abc' 7 | let c := 'abc':u32 8 | let d := 'abc':u32 9 | let e := hex'deadbeef' 10 | let f := hex'deadbeef' 11 | let g := hex'deadbeef':u32 12 | let h := hex'deadbeef':u32 13 | datacopy(0, dataoffset('runtime'), datasize('runtime')) 14 | return(0, datasize('runtime')) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /crates/forge/assets/.gitignoreTemplate: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | 5 | # Ignores development broadcast logs 6 | !/broadcast 7 | /broadcast/*/31337/ 8 | /broadcast/**/dry-run/ 9 | 10 | # Docs 11 | docs/ 12 | 13 | # Dotenv file 14 | .env 15 | -------------------------------------------------------------------------------- /crates/forge/assets/CounterTemplate.s.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import {Script, console} from "forge-std/Script.sol"; 5 | import {Counter} from "../src/Counter.sol"; 6 | 7 | contract CounterScript is Script { 8 | Counter public counter; 9 | 10 | function setUp() public {} 11 | 12 | function run() public { 13 | vm.startBroadcast(); 14 | 15 | counter = new Counter(); 16 | 17 | vm.stopBroadcast(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /crates/forge/assets/CounterTemplate.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | contract Counter { 5 | uint256 public number; 6 | 7 | function setNumber(uint256 newNumber) public { 8 | number = newNumber; 9 | } 10 | 11 | function increment() public { 12 | number++; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/forge/assets/CounterTemplate.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import {Test, console} from "forge-std/Test.sol"; 5 | import {Counter} from "../src/Counter.sol"; 6 | 7 | contract CounterTest is Test { 8 | Counter public counter; 9 | 10 | function setUp() public { 11 | counter = new Counter(); 12 | counter.setNumber(0); 13 | } 14 | 15 | function test_Increment() public { 16 | counter.increment(); 17 | assertEq(counter.number(), 1); 18 | } 19 | 20 | function testFuzz_SetNumber(uint256 x) public { 21 | counter.setNumber(x); 22 | assertEq(counter.number(), x); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/forge/assets/generated/TestTemplate.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import {Test, console} from "forge-std/Test.sol"; 5 | import {{contract_name}} from "../src/{contract_name}.sol"; 6 | 7 | contract {contract_name}Test is Test { 8 | {contract_name} public {instance_name}; 9 | 10 | function setUp() public { 11 | {instance_name} = new {contract_name}(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/forge/assets/workflowTemplate.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | 8 | env: 9 | FOUNDRY_PROFILE: ci 10 | 11 | jobs: 12 | check: 13 | name: Foundry project 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | with: 18 | submodules: recursive 19 | 20 | - name: Install Foundry 21 | uses: foundry-rs/foundry-toolchain@v1 22 | 23 | - name: Show Forge version 24 | run: | 25 | forge --version 26 | 27 | - name: Run Forge fmt 28 | run: | 29 | forge fmt --check 30 | id: fmt 31 | 32 | - name: Run Forge build 33 | run: | 34 | forge build --sizes 35 | id: build 36 | 37 | - name: Run Forge tests 38 | run: | 39 | forge test -vvv 40 | id: test 41 | -------------------------------------------------------------------------------- /crates/forge/bin/main.rs: -------------------------------------------------------------------------------- 1 | //! The `forge` CLI: build, test, fuzz, debug and deploy Solidity contracts, like Hardhat, Brownie, 2 | //! Ape. 3 | 4 | use forge::args::run; 5 | 6 | #[global_allocator] 7 | static ALLOC: foundry_cli::utils::Allocator = foundry_cli::utils::new_allocator(); 8 | 9 | fn main() { 10 | if let Err(err) = run() { 11 | let _ = foundry_common::sh_err!("{err:?}"); 12 | std::process::exit(1); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/forge/src/cmd/mod.rs: -------------------------------------------------------------------------------- 1 | //! `forge` subcommands. 2 | //! 3 | //! All subcommands should respect the `foundry_config::Config`. 4 | //! If a subcommand accepts values that are supported by the `Config`, then the subcommand should 5 | //! implement `figment::Provider` which allows the subcommand to override the config's defaults, see 6 | //! [`foundry_config::Config`]. 7 | 8 | pub mod bind; 9 | pub mod bind_json; 10 | pub mod build; 11 | pub mod cache; 12 | pub mod clone; 13 | pub mod compiler; 14 | pub mod config; 15 | pub mod coverage; 16 | pub mod create; 17 | pub mod doc; 18 | pub mod eip712; 19 | pub mod flatten; 20 | pub mod fmt; 21 | pub mod geiger; 22 | pub mod generate; 23 | pub mod init; 24 | pub mod inspect; 25 | pub mod install; 26 | pub mod lint; 27 | pub mod remappings; 28 | pub mod remove; 29 | pub mod selectors; 30 | pub mod snapshot; 31 | pub mod soldeer; 32 | pub mod test; 33 | pub mod tree; 34 | pub mod update; 35 | pub mod watch; 36 | -------------------------------------------------------------------------------- /crates/forge/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Forge is a fast and flexible Ethereum testing framework. 2 | 3 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 4 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 5 | 6 | #[macro_use] 7 | extern crate foundry_common; 8 | 9 | #[macro_use] 10 | extern crate tracing; 11 | 12 | pub mod args; 13 | pub mod cmd; 14 | pub mod opts; 15 | 16 | pub mod coverage; 17 | 18 | pub mod gas_report; 19 | 20 | pub mod multi_runner; 21 | pub use multi_runner::{MultiContractRunner, MultiContractRunnerBuilder}; 22 | 23 | mod runner; 24 | pub use runner::ContractRunner; 25 | 26 | mod progress; 27 | pub mod result; 28 | 29 | // TODO: remove 30 | pub use foundry_common::traits::TestFilter; 31 | pub use foundry_evm::*; 32 | -------------------------------------------------------------------------------- /crates/forge/tests/cli/cache.rs: -------------------------------------------------------------------------------- 1 | //! Tests for various cache command. 2 | 3 | forgetest!(can_list_cache, |_prj, cmd| { 4 | cmd.args(["cache", "ls"]); 5 | cmd.assert_success(); 6 | }); 7 | 8 | forgetest!(can_list_cache_all, |_prj, cmd| { 9 | cmd.args(["cache", "ls", "all"]); 10 | cmd.assert_success(); 11 | }); 12 | 13 | forgetest!(can_list_specific_chain, |_prj, cmd| { 14 | cmd.args(["cache", "ls", "mainnet"]); 15 | cmd.assert_success(); 16 | }); 17 | 18 | forgetest_init!(can_test_no_cache, |prj, cmd| { 19 | prj.clear_cache(); 20 | 21 | cmd.args(["test", "--no-cache"]).assert_success(); 22 | assert!(!prj.cache().exists(), "cache file should not exist"); 23 | 24 | cmd.forge_fuse().arg("test").assert_success(); 25 | assert!(prj.cache().exists(), "cache file should exist"); 26 | }); 27 | -------------------------------------------------------------------------------- /crates/forge/tests/cli/constants.rs: -------------------------------------------------------------------------------- 1 | //! various constants 2 | 3 | pub const TEMPLATE_CONTRACT: &str = "Counter"; 4 | 5 | pub const TEMPLATE_TEST_CONTRACT: &str = "CounterTest"; 6 | 7 | pub const TEMPLATE_CONTRACT_ARTIFACT_BASE: &str = "Counter.sol/Counter"; 8 | 9 | pub const TEMPLATE_CONTRACT_ARTIFACT_JSON: &str = "Counter.sol/Counter.json"; 10 | 11 | pub const TEMPLATE_TEST_CONTRACT_ARTIFACT_JSON: &str = "Counter.t.sol/CounterTest.json"; 12 | -------------------------------------------------------------------------------- /crates/forge/tests/cli/doc.rs: -------------------------------------------------------------------------------- 1 | use foundry_test_utils::util::{setup_forge_remote, RemoteProject}; 2 | 3 | #[test] 4 | fn can_generate_solmate_docs() { 5 | let (prj, _) = 6 | setup_forge_remote(RemoteProject::new("transmissions11/solmate").set_build(false)); 7 | prj.forge_command().args(["doc", "--build"]).assert_success(); 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/cli/main.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate foundry_test_utils; 3 | 4 | pub mod constants; 5 | pub mod utils; 6 | 7 | mod bind_json; 8 | mod build; 9 | mod cache; 10 | mod cmd; 11 | mod compiler; 12 | mod config; 13 | mod context; 14 | mod coverage; 15 | mod create; 16 | mod debug; 17 | mod doc; 18 | mod eip712; 19 | mod failure_assertions; 20 | mod geiger; 21 | mod inline_config; 22 | mod lint; 23 | mod multi_script; 24 | mod script; 25 | mod soldeer; 26 | mod svm; 27 | mod test_cmd; 28 | mod verify; 29 | mod verify_bytecode; 30 | mod version; 31 | 32 | mod ext_integration; 33 | mod test_optimizer; 34 | -------------------------------------------------------------------------------- /crates/forge/tests/cli/version.rs: -------------------------------------------------------------------------------- 1 | use foundry_test_utils::{forgetest, str}; 2 | 3 | forgetest!(print_short_version, |_prj, cmd| { 4 | cmd.arg("-V").assert_success().stdout_eq(str![[r#" 5 | forge [..]-[..] ([..] [..]) 6 | 7 | "#]]); 8 | }); 9 | 10 | forgetest!(print_long_version, |_prj, cmd| { 11 | cmd.arg("--version").assert_success().stdout_eq(str![[r#" 12 | forge Version: [..] 13 | Commit SHA: [..] 14 | Build Timestamp: [..] 15 | Build Profile: [..] 16 | 17 | "#]]); 18 | }); 19 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/SimpleContractTestNonVerbose.json: -------------------------------------------------------------------------------- 1 | { 2 | "src/Simple.t.sol:SimpleContractTest": { 3 | "duration": "{...}", 4 | "test_results": { 5 | "test()": { 6 | "status": "Success", 7 | "reason": null, 8 | "counterexample": null, 9 | "logs": [], 10 | "decoded_logs": [], 11 | "kind": { 12 | "Unit": { 13 | "gas": "{...}" 14 | } 15 | }, 16 | "traces": [], 17 | "labeled_addresses": {}, 18 | "duration": "{...}", 19 | "breakpoints": {}, 20 | "gas_snapshots": {} 21 | } 22 | }, 23 | "warnings": [] 24 | } 25 | } -------------------------------------------------------------------------------- /crates/forge/tests/it/main.rs: -------------------------------------------------------------------------------- 1 | pub mod config; 2 | pub mod test_helpers; 3 | 4 | mod cheats; 5 | mod core; 6 | mod fork; 7 | mod fs; 8 | mod fuzz; 9 | mod inline; 10 | mod invariant; 11 | mod repros; 12 | mod spec; 13 | mod vyper; 14 | -------------------------------------------------------------------------------- /crates/forge/tests/it/spec.rs: -------------------------------------------------------------------------------- 1 | //! Integration tests for EVM specifications. 2 | 3 | use crate::{config::*, test_helpers::TEST_DATA_PARIS}; 4 | use foundry_test_utils::Filter; 5 | use revm::primitives::hardfork::SpecId; 6 | 7 | #[tokio::test(flavor = "multi_thread")] 8 | async fn test_shanghai_compat() { 9 | let filter = Filter::new("", "ShanghaiCompat", ".*spec"); 10 | TestConfig::with_filter(TEST_DATA_PARIS.runner(), filter).spec_id(SpecId::SHANGHAI).run().await; 11 | } 12 | -------------------------------------------------------------------------------- /crates/forge/tests/it/vyper.rs: -------------------------------------------------------------------------------- 1 | //! Integration tests for EVM specifications. 2 | 3 | use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; 4 | use foundry_test_utils::Filter; 5 | 6 | #[tokio::test(flavor = "multi_thread")] 7 | async fn test_basic_vyper_test() { 8 | let filter = Filter::new("", "CounterTest", ".*vyper"); 9 | TestConfig::with_filter(TEST_DATA_DEFAULT.runner(), filter).run().await; 10 | } 11 | -------------------------------------------------------------------------------- /crates/forge/tests/rpc-cache-keyfile: -------------------------------------------------------------------------------- 1 | This file serves as the key for the github actions/cache 2 | 3 | Any change in this file will invalidate the cache in CI that stores RPC data. 4 | 5 | Last updated: 05-26-2022 -------------------------------------------------------------------------------- /crates/forge/tests/ui.rs: -------------------------------------------------------------------------------- 1 | use foundry_test_utils::ui_runner; 2 | use std::{env, path::Path}; 3 | 4 | const FORGE_CMD: &str = env!("CARGO_BIN_EXE_forge"); 5 | const FORGE_DIR: &str = env!("CARGO_MANIFEST_DIR"); 6 | 7 | fn main() -> impl std::process::Termination { 8 | let forge_cmd = Path::new(FORGE_CMD); 9 | let forge_dir = Path::new(FORGE_DIR); 10 | let lint_testdata = forge_dir.parent().unwrap().join("lint").join("testdata"); 11 | 12 | ui_runner::run_tests("lint", forge_cmd, &lint_testdata) 13 | } 14 | -------------------------------------------------------------------------------- /crates/linking/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-linking" 3 | description = "Smart contract linking tools" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | foundry-compilers = { workspace = true, features = ["full"] } 18 | semver.workspace = true 19 | alloy-primitives = { workspace = true, features = ["rlp"] } 20 | thiserror.workspace = true 21 | -------------------------------------------------------------------------------- /crates/lint/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "forge-lint" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | # lib 18 | foundry-compilers.workspace = true 19 | foundry-config.workspace = true 20 | 21 | solar-parse.workspace = true 22 | solar-ast.workspace = true 23 | solar-interface = { workspace = true, features = ["json"] } 24 | 25 | heck.workspace = true 26 | rayon.workspace = true 27 | thiserror.workspace = true 28 | -------------------------------------------------------------------------------- /crates/lint/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 3 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 4 | 5 | pub mod linter; 6 | pub mod sol; 7 | -------------------------------------------------------------------------------- /crates/lint/src/sol/gas/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | register_lints, 3 | sol::{EarlyLintPass, SolLint}, 4 | }; 5 | 6 | mod keccak; 7 | use keccak::ASM_KECCAK256; 8 | 9 | register_lints!((AsmKeccak256, (ASM_KECCAK256))); 10 | -------------------------------------------------------------------------------- /crates/lint/src/sol/high/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | register_lints, 3 | sol::{EarlyLintPass, SolLint}, 4 | }; 5 | 6 | mod incorrect_shift; 7 | use incorrect_shift::INCORRECT_SHIFT; 8 | 9 | register_lints!((IncorrectShift, (INCORRECT_SHIFT))); 10 | -------------------------------------------------------------------------------- /crates/lint/src/sol/info/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | register_lints, 3 | sol::{EarlyLintPass, SolLint}, 4 | }; 5 | 6 | mod mixed_case; 7 | use mixed_case::{MIXED_CASE_FUNCTION, MIXED_CASE_VARIABLE}; 8 | 9 | mod pascal_case; 10 | use pascal_case::PASCAL_CASE_STRUCT; 11 | 12 | mod screaming_snake_case; 13 | use screaming_snake_case::{SCREAMING_SNAKE_CASE_CONSTANT, SCREAMING_SNAKE_CASE_IMMUTABLE}; 14 | 15 | register_lints!( 16 | (PascalCaseStruct, (PASCAL_CASE_STRUCT)), 17 | (MixedCaseVariable, (MIXED_CASE_VARIABLE)), 18 | (MixedCaseFunction, (MIXED_CASE_FUNCTION)), 19 | (ScreamingSnakeCase, (SCREAMING_SNAKE_CASE_CONSTANT, SCREAMING_SNAKE_CASE_IMMUTABLE)) 20 | ); 21 | -------------------------------------------------------------------------------- /crates/lint/src/sol/med/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | register_lints, 3 | sol::{EarlyLintPass, SolLint}, 4 | }; 5 | 6 | mod div_mul; 7 | use div_mul::DIVIDE_BEFORE_MULTIPLY; 8 | 9 | register_lints!((DivideBeforeMultiply, (DIVIDE_BEFORE_MULTIPLY))); 10 | -------------------------------------------------------------------------------- /crates/lint/testdata/Keccak256.sol: -------------------------------------------------------------------------------- 1 | contract AsmKeccak256 { 2 | 3 | // constants are optimized by the compiler 4 | bytes32 constant HASH = keccak256("hello"); 5 | bytes32 constant OTHER_HASH = keccak256(1234); 6 | 7 | constructor(uint256 a, uint256 b) { 8 | keccak256(abi.encodePacked(a, b)); //~NOTE: hash using inline assembly to save gas 9 | } 10 | 11 | function solidityHash(uint256 a, uint256 b) public view returns (bytes32) { 12 | bytes32 hash = keccak256(a); //~NOTE: hash using inline assembly to save gas 13 | return keccak256(abi.encodePacked(a, b)); //~NOTE: hash using inline assembly to save gas 14 | } 15 | 16 | function assemblyHash(uint256 a, uint256 b) public view returns (bytes32){ 17 | //optimized 18 | assembly { 19 | mstore(0x00, a) 20 | mstore(0x20, b) 21 | let hashedVal := keccak256(0x00, 0x40) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/lint/testdata/Keccak256.stderr: -------------------------------------------------------------------------------- 1 | note[asm-keccak256]: hash using inline assembly to save gas 2 | --> ROOT/testdata/Keccak256.sol:LL:CC 3 | | 4 | 8 | keccak256(abi.encodePacked(a, b)); 5 | | --------- 6 | | 7 | = help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256 8 | 9 | note[asm-keccak256]: hash using inline assembly to save gas 10 | --> ROOT/testdata/Keccak256.sol:LL:CC 11 | | 12 | 12 | bytes32 hash = keccak256(a); 13 | | --------- 14 | | 15 | = help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256 16 | 17 | note[asm-keccak256]: hash using inline assembly to save gas 18 | --> ROOT/testdata/Keccak256.sol:LL:CC 19 | | 20 | 13 | return keccak256(abi.encodePacked(a, b)); 21 | | --------- 22 | | 23 | = help: https://book.getfoundry.sh/reference/forge/forge-lint#asm-keccak256 24 | 25 | -------------------------------------------------------------------------------- /crates/lint/testdata/StructPascalCase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | contract StructPascalCaseTest { 5 | struct PascalCase { 6 | uint256 a; 7 | } 8 | 9 | struct PascalCAse { 10 | uint256 a; 11 | } 12 | 13 | struct _PascalCase { //~NOTE: structs should use PascalCase 14 | uint256 a; 15 | } 16 | 17 | struct pascalCase { //~NOTE: structs should use PascalCase 18 | uint256 a; 19 | } 20 | 21 | struct pascalcase { //~NOTE: structs should use PascalCase 22 | uint256 a; 23 | } 24 | 25 | struct pascal_case { //~NOTE: structs should use PascalCase 26 | uint256 a; 27 | } 28 | 29 | struct PASCAL_CASE { //~NOTE: structs should use PascalCase 30 | uint256 a; 31 | } 32 | 33 | struct PASCALCASE { //~NOTE: structs should use PascalCase 34 | uint256 a; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /crates/macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-macros" 3 | 4 | version.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | authors.workspace = true 8 | license.workspace = true 9 | homepage.workspace = true 10 | repository.workspace = true 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [lib] 16 | proc-macro = true 17 | # proc-macro tests aren't fully supported by cargo-nextest archives 18 | test = false 19 | doc = false 20 | 21 | [dependencies] 22 | proc-macro2.workspace = true 23 | quote.workspace = true 24 | syn.workspace = true 25 | proc-macro-error2 = "2" 26 | -------------------------------------------------------------------------------- /crates/macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-macros 2 | //! 3 | //! Internal Foundry proc-macros. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate proc_macro_error2; 10 | 11 | use proc_macro::TokenStream; 12 | use syn::{parse_macro_input, DeriveInput, Error}; 13 | 14 | mod cheatcodes; 15 | mod console_fmt; 16 | 17 | #[proc_macro_derive(ConsoleFmt)] 18 | pub fn console_fmt(input: TokenStream) -> TokenStream { 19 | let input = parse_macro_input!(input as DeriveInput); 20 | console_fmt::console_fmt(&input).into() 21 | } 22 | 23 | #[proc_macro_derive(Cheatcode, attributes(cheatcode))] 24 | #[proc_macro_error] 25 | pub fn cheatcode(input: TokenStream) -> TokenStream { 26 | let input = parse_macro_input!(input as DeriveInput); 27 | cheatcodes::derive_cheatcode(&input).unwrap_or_else(Error::into_compile_error).into() 28 | } 29 | -------------------------------------------------------------------------------- /crates/script-sequence/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "forge-script-sequence" 3 | description = "Script sequence types" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | foundry-config.workspace = true 18 | foundry-common.workspace = true 19 | foundry-compilers = { workspace = true, features = ["full"] } 20 | 21 | serde.workspace = true 22 | eyre.workspace = true 23 | serde_json.workspace = true 24 | walkdir.workspace = true 25 | 26 | revm-inspectors.workspace = true 27 | 28 | alloy-primitives.workspace = true 29 | alloy-network.workspace = true 30 | -------------------------------------------------------------------------------- /crates/script-sequence/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Script Sequence and related types. 2 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 3 | 4 | #[macro_use] 5 | extern crate foundry_common; 6 | 7 | pub mod reader; 8 | pub mod sequence; 9 | pub mod transaction; 10 | 11 | pub use reader::*; 12 | pub use sequence::*; 13 | pub use transaction::*; 14 | -------------------------------------------------------------------------------- /crates/sol-macro-gen/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "forge-sol-macro-gen" 3 | description = "Contains types and methods for generating rust bindings using sol!" 4 | publish = false 5 | 6 | version.workspace = true 7 | edition.workspace = true 8 | rust-version.workspace = true 9 | authors.workspace = true 10 | license.workspace = true 11 | homepage.workspace = true 12 | repository.workspace = true 13 | 14 | [lints] 15 | workspace = true 16 | 17 | [dependencies] 18 | alloy-sol-macro-input.workspace = true 19 | alloy-sol-macro-expander = { workspace = true, features = ["json"] } 20 | foundry-common.workspace = true 21 | 22 | proc-macro2.workspace = true 23 | quote.workspace = true 24 | syn.workspace = true 25 | prettyplease.workspace = true 26 | serde_json.workspace = true 27 | 28 | eyre.workspace = true 29 | 30 | heck.workspace = true 31 | -------------------------------------------------------------------------------- /crates/sol-macro-gen/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate contains the logic for Rust bindings generating from Solidity contracts 2 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 3 | 4 | pub mod sol_macro_gen; 5 | 6 | pub use sol_macro_gen::*; 7 | -------------------------------------------------------------------------------- /crates/test-utils/src/fd_lock.rs: -------------------------------------------------------------------------------- 1 | //! File locking utilities. 2 | 3 | use crate::util::pretty_err; 4 | use std::{ 5 | fs::{File, OpenOptions}, 6 | path::Path, 7 | }; 8 | 9 | pub use fd_lock::*; 10 | 11 | /// Creates a new lock file at the given path. 12 | pub fn new_lock(lock_path: impl AsRef) -> RwLock { 13 | fn new_lock(lock_path: &Path) -> RwLock { 14 | let lock_file = pretty_err( 15 | lock_path, 16 | OpenOptions::new().read(true).write(true).create(true).truncate(false).open(lock_path), 17 | ); 18 | RwLock::new(lock_file) 19 | } 20 | new_lock(lock_path.as_ref()) 21 | } 22 | -------------------------------------------------------------------------------- /crates/verify/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Smart contract verification. 2 | 3 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 4 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 5 | 6 | #[macro_use] 7 | extern crate foundry_common; 8 | 9 | #[macro_use] 10 | extern crate tracing; 11 | 12 | mod etherscan; 13 | 14 | pub mod provider; 15 | 16 | pub mod bytecode; 17 | pub use bytecode::VerifyBytecodeArgs; 18 | 19 | pub mod retry; 20 | pub use retry::RetryArgs; 21 | 22 | mod sourcify; 23 | 24 | pub mod verify; 25 | pub use verify::{VerifierArgs, VerifyArgs, VerifyCheckArgs}; 26 | 27 | mod types; 28 | 29 | mod utils; 30 | -------------------------------------------------------------------------------- /crates/wallets/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-wallets 2 | //! 3 | //! Utilities for working with multiple signers. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate tracing; 10 | 11 | pub mod error; 12 | pub mod multi_wallet; 13 | pub mod raw_wallet; 14 | pub mod utils; 15 | pub mod wallet; 16 | pub mod wallet_signer; 17 | 18 | pub use multi_wallet::MultiWalletOpts; 19 | pub use raw_wallet::RawWalletOpts; 20 | pub use wallet::WalletOpts; 21 | pub use wallet_signer::{PendingSigner, WalletSigner}; 22 | -------------------------------------------------------------------------------- /docs/dev/architecture.md: -------------------------------------------------------------------------------- 1 | # Architecture 2 | 3 | This document describes the high-level architecture of Foundry. 4 | 5 | ### `evm/` 6 | 7 | Foundry's EVM tooling. This is built around [`revm`](https://github.com/bluealloy/revm) and has additional 8 | implementation of: 9 | 10 | - [cheatcodes](./cheatcodes.md) a set of solidity calls dedicated to testing which can manipulate the environment in which the execution is run 11 | 12 | ### `config/` 13 | 14 | Includes all of Foundry's settings and how to get them 15 | 16 | ### `cli/` 17 | 18 | The core `forge` and `cast` cli implementation. Includes all subcommands. 19 | -------------------------------------------------------------------------------- /docs/dev/debugging.md: -------------------------------------------------------------------------------- 1 | # Debugging 2 | 3 | This is a working document intended to outline some commands contributors can use to debug various parts of Foundry. 4 | 5 | ## Logs 6 | 7 | All crates use [tracing](https://docs.rs/tracing/latest/tracing/) for logging. A console formatter is installed in each binary (`cast`, `forge`, `anvil`). 8 | 9 | By setting `RUST_LOG=` you can get a lot more info out of Forge and Cast. For example, running Forge with `RUST_LOG=forge` will emit all logs of the `cli` crate, same for Cast. 10 | 11 | The most basic valid filter is a log level, of which these are valid: 12 | 13 | - `error` 14 | - `warn` 15 | - `info` 16 | - `debug` 17 | - `trace` 18 | 19 | Filters are explained in detail in the [`env_logger` crate docs](https://docs.rs/env_logger). 20 | 21 | You can also use the `dbg!` macro from Rust's standard library. 22 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | reorder_imports = true 2 | imports_granularity = "Crate" 3 | use_small_heuristics = "Max" 4 | comment_width = 100 5 | wrap_comments = true 6 | binop_separator = "Back" 7 | trailing_comma = "Vertical" 8 | trailing_semicolon = false 9 | use_field_init_shorthand = true 10 | format_code_in_doc_comments = true 11 | doc_comment_code_block_width = 100 12 | -------------------------------------------------------------------------------- /testdata/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | .lock 5 | -------------------------------------------------------------------------------- /testdata/README.md: -------------------------------------------------------------------------------- 1 | ## Foundry Tests 2 | 3 | A test suite that tests different aspects of Foundry. 4 | 5 | ### Structure 6 | 7 | - [`core`](default/core): Tests for fundamental aspects of Foundry 8 | - [`logs`](default/logs): Tests for Foundry logging capabilities 9 | - [`cheats`](default/cheats): Tests for Foundry cheatcodes 10 | - [`fuzz`](default/fuzz): Tests for the Foundry fuzzer 11 | - [`trace`](default/trace): Tests for the Foundry tracer 12 | - [`fork`](default/fork): Tests for Foundry forking capabilities 13 | -------------------------------------------------------------------------------- /testdata/default/cheats/Addr.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract AddrTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | /// forge-config: default.allow_internal_expect_revert = true 11 | function testRevertIfPkZero() public { 12 | vm.expectRevert("vm.addr: private key cannot be 0"); 13 | vm.addr(0); 14 | } 15 | 16 | function testAddr() public { 17 | uint256 pk = 77814517325470205911140941194401928579557062014761831930645393041380819009408; 18 | address expected = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; 19 | 20 | assertEq(vm.addr(pk), expected, "expected address did not match"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/cheats/Assume.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract AssumeTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testAssume(uint8 x) public { 11 | vm.assume(x < 2 ** 7); 12 | assertTrue(x < 2 ** 7, "did not discard inputs"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/cheats/Bank.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract CoinbaseTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testCoinbase() public { 11 | vm.coinbase(0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8); 12 | assertEq(block.coinbase, 0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8, "coinbase failed"); 13 | } 14 | 15 | function testCoinbaseFuzzed(address who) public { 16 | vm.coinbase(who); 17 | assertEq(block.coinbase, who, "coinbase failed"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/Base64.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | import "../logs/console.sol"; 7 | 8 | contract Base64Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_toBase64() public { 12 | bytes memory input = hex"00112233445566778899aabbccddeeff"; 13 | string memory expected = "ABEiM0RVZneImaq7zN3u/w=="; 14 | string memory actual = vm.toBase64(input); 15 | assertEq(actual, expected); 16 | } 17 | 18 | function test_toBase64URL() public { 19 | bytes memory input = hex"00112233445566778899aabbccddeeff"; 20 | string memory expected = "ABEiM0RVZneImaq7zN3u_w=="; 21 | string memory actual = vm.toBase64URL(input); 22 | assertEq(actual, expected); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/default/cheats/BlobBaseFee.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.25; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract BlobBaseFeeTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function test_blob_base_fee() public { 11 | vm.blobBaseFee(6969); 12 | assertEq(vm.getBlobBaseFee(), 6969); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/cheats/Blobhashes.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.25; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract BlobhashesTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testSetAndGetBlobhashes() public { 11 | bytes32[] memory blobhashes = new bytes32[](2); 12 | blobhashes[0] = bytes32(0x0000000000000000000000000000000000000000000000000000000000000001); 13 | blobhashes[1] = bytes32(0x0000000000000000000000000000000000000000000000000000000000000002); 14 | vm.blobhashes(blobhashes); 15 | 16 | bytes32[] memory gotBlobhashes = vm.getBlobhashes(); 17 | assertEq(gotBlobhashes[0], blobhashes[0]); 18 | assertEq(gotBlobhashes[1], blobhashes[1]); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/default/cheats/ChainId.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ChainIdTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testChainId() public { 11 | uint256 newChainId = 99; 12 | vm.chainId(newChainId); 13 | assertEq(newChainId, block.chainid); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/default/cheats/Deal.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract DealTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testDeal(uint256 amount) public { 11 | address target = address(10); 12 | assertEq(target.balance, 0, "initial balance incorrect"); 13 | 14 | // Give half the amount 15 | vm.deal(target, amount / 2); 16 | assertEq(target.balance, amount / 2, "half balance is incorrect"); 17 | 18 | // Give the entire amount to check that deal is not additive 19 | vm.deal(target, amount); 20 | assertEq(target.balance, amount, "deal did not overwrite balance"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/cheats/Derive.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract DeriveTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testDerive() public { 11 | string memory mnemonic = "test test test test test test test test test test test junk"; 12 | 13 | uint256 privateKey = vm.deriveKey(mnemonic, 0); 14 | assertEq(privateKey, 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80); 15 | 16 | uint256 privateKeyDerivationPathChanged = vm.deriveKey(mnemonic, "m/44'/60'/0'/1/", 0); 17 | assertEq(privateKeyDerivationPathChanged, 0x6abb89895f93b02c1b9470db0fa675297f6cca832a5fc66d5dfd7661a42b37be); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/EnsNamehash.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract EnsNamehashTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testEnsNamehash() public { 11 | assertEq(vm.ensNamehash(""), 0x0000000000000000000000000000000000000000000000000000000000000000); 12 | assertEq(vm.ensNamehash("eth"), 0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae); 13 | assertEq(vm.ensNamehash("foo.eth"), 0xde9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/default/cheats/Etch.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract EtchTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testEtch() public { 11 | address target = address(7070707); 12 | bytes memory code = hex"1010"; 13 | vm.etch(target, code); 14 | assertEq(string(code), string(target.code)); 15 | } 16 | 17 | function testEtchNotAvailableOnPrecompiles() public { 18 | address target = address(1); 19 | bytes memory code = hex"1010"; 20 | vm._expectCheatcodeRevert("cannot use precompile 0x0000000000000000000000000000000000000001 as an argument"); 21 | vm.etch(target, code); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/cheats/Fee.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract FeeTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testFee() public { 11 | vm.fee(10); 12 | assertEq(block.basefee, 10, "fee failed"); 13 | } 14 | 15 | function testFeeFuzzed(uint64 fee) public { 16 | vm.fee(fee); 17 | assertEq(block.basefee, fee, "fee failed"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/GetBlockTimestamp.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract GetBlockTimestampTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testGetTimestamp() public { 11 | uint256 timestamp = vm.getBlockTimestamp(); 12 | assertEq(timestamp, 1, "timestamp should be 1"); 13 | } 14 | 15 | function testGetTimestampWithWarp() public { 16 | assertEq(vm.getBlockTimestamp(), 1, "timestamp should be 1"); 17 | vm.warp(10); 18 | assertEq(vm.getBlockTimestamp(), 10, "warp failed"); 19 | } 20 | 21 | function testGetTimestampWithWarpFuzzed(uint32 jump) public { 22 | uint256 pre = vm.getBlockTimestamp(); 23 | vm.warp(pre + jump); 24 | assertEq(vm.getBlockTimestamp(), pre + jump, "warp failed"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/cheats/GetLabel.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract GetLabelTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testGetLabel() public { 11 | // Label an address. 12 | vm.label(address(1), "Sir Address the 1st"); 13 | 14 | // Retrieve the label and check it. 15 | string memory label = vm.getLabel(address(1)); 16 | assertEq(label, "Sir Address the 1st"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/cheats/GetNonce.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Foo {} 8 | 9 | contract GetNonceTest is DSTest { 10 | Vm constant vm = Vm(HEVM_ADDRESS); 11 | 12 | function testGetNonce() public { 13 | uint64 nonce1 = vm.getNonce(address(this)); 14 | new Foo(); 15 | new Foo(); 16 | uint64 nonce2 = vm.getNonce(address(this)); 17 | assertEq(nonce1 + 2, nonce2); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/Label.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract LabelTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testLabel() public { 11 | vm.label(address(1), "Sir Address the 1st"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/default/cheats/Nonce.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Counter { 8 | uint256 public count; 9 | 10 | function increment() public { 11 | count += 1; 12 | } 13 | } 14 | 15 | contract NonceIsolatedTest is DSTest { 16 | Vm constant vm = Vm(HEVM_ADDRESS); 17 | 18 | function testIncrementNonce() public { 19 | address bob = address(14); 20 | vm.startPrank(bob); 21 | Counter counter = new Counter(); 22 | assertEq(vm.getNonce(bob), 1); 23 | counter.increment(); 24 | assertEq(vm.getNonce(bob), 2); 25 | new Counter(); 26 | assertEq(vm.getNonce(bob), 3); 27 | counter.increment(); 28 | assertEq(vm.getNonce(bob), 4); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /testdata/default/cheats/RandomAddress.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract RandomAddress is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testRandomAddress() public { 11 | vm.randomAddress(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/default/cheats/RandomBytes.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract RandomBytes is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testRandomBytes4() public { 11 | vm.randomBytes4(); 12 | } 13 | 14 | function testRandomBytes8() public { 15 | vm.randomBytes8(); 16 | } 17 | 18 | function testFillrandomBytes() public view { 19 | uint256 len = 16; 20 | vm.randomBytes(len); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/cheats/RandomUint.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract RandomUint is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testRandomUint() public { 11 | vm.randomUint(); 12 | } 13 | 14 | function testRandomUintRangeOverflow() public { 15 | vm.randomUint(0, uint256(int256(-1))); 16 | } 17 | 18 | function testRandomUintSame(uint256 val) public { 19 | uint256 rand = vm.randomUint(val, val); 20 | assertTrue(rand == val); 21 | } 22 | 23 | function testRandomUintRange(uint256 min, uint256 max) public { 24 | vm.assume(max >= min); 25 | uint256 rand = vm.randomUint(min, max); 26 | assertTrue(rand >= min, "rand >= min"); 27 | assertTrue(rand <= max, "rand <= max"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testdata/default/cheats/Remember.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract RememberTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testRememberKey() public { 11 | string memory mnemonic = "test test test test test test test test test test test junk"; 12 | 13 | uint256 privateKey = vm.deriveKey(mnemonic, 0); 14 | assertEq(privateKey, 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80); 15 | 16 | address thisAddress = vm.rememberKey(privateKey); 17 | assertEq(thisAddress, 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/SetBlockhash.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract SetBlockhash is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testSetBlockhash() public { 11 | bytes32 blockHash = 0x1234567890123456789012345678901234567890123456789012345678901234; 12 | vm.setBlockhash(block.number - 1, blockHash); 13 | bytes32 expected = blockhash(block.number - 1); 14 | assertEq(blockHash, expected); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/cheats/SignP256.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract SignTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testSignP256() public { 11 | bytes32 pk = hex"A8568B74282DCC66FF70F10B4CE5CC7B391282F5381BBB4F4D8DD96974B16E6B"; 12 | bytes32 digest = hex"54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad"; 13 | 14 | (bytes32 r, bytes32 s) = vm.signP256(uint256(pk), digest); 15 | assertEq(r, hex"7C11C3641B19E7822DB644CBF76ED0420A013928C2FD3E36D8EF983B103BDFE1"); 16 | assertEq(s, hex"317D89879868D484810D4E508A96109F8C87617B7BE9337411348D7B786F945F"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/cheats/Sort.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract SortTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testSortCheatcode() public { 11 | uint256[] memory numbers = new uint256[](3); 12 | numbers[0] = 3; 13 | numbers[1] = 1; 14 | numbers[2] = 2; 15 | 16 | uint256[] memory sortedNumbers = vm.sort(numbers); 17 | 18 | assertEq(sortedNumbers[0], 1); 19 | assertEq(sortedNumbers[1], 2); 20 | assertEq(sortedNumbers[2], 3); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/cheats/Travel.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ChainIdTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testChainId() public { 11 | vm.chainId(10); 12 | assertEq(block.chainid, 10, "chainId switch failed"); 13 | } 14 | 15 | function testChainIdFuzzed(uint64 chainId) public { 16 | vm.chainId(chainId); 17 | assertEq(block.chainid, chainId, "chainId switch failed"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/Warp.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract WarpTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testWarp() public { 11 | vm.warp(10); 12 | assertEq(block.timestamp, 10, "warp failed"); 13 | } 14 | 15 | function testWarpFuzzed(uint32 jump) public { 16 | uint256 pre = block.timestamp; 17 | vm.warp(block.timestamp + jump); 18 | assertEq(block.timestamp, pre + jump, "warp failed"); 19 | } 20 | 21 | function testWarp2() public { 22 | assertEq(block.timestamp, 1); 23 | vm.warp(100); 24 | assertEq(block.timestamp, 100); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/cheats/getBlockNumber.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract GetBlockNumberTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testGetBlockNumber() public { 11 | uint256 height = vm.getBlockNumber(); 12 | assertEq(height, uint256(block.number), "height should be equal to block.number"); 13 | } 14 | 15 | function testGetBlockNumberWithRoll() public { 16 | vm.roll(10); 17 | assertEq(vm.getBlockNumber(), 10, "could not get correct block height after roll"); 18 | } 19 | 20 | function testGetBlockNumberWithRollFuzzed(uint32 jump) public { 21 | uint256 pre = vm.getBlockNumber(); 22 | vm.roll(pre + jump); 23 | assertEq(vm.getBlockNumber(), pre + jump, "could not get correct block height after roll"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testdata/default/core/Abstract.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | contract TestFixture { 5 | function something() public pure returns (string memory) { 6 | return "something"; 7 | } 8 | } 9 | 10 | abstract contract AbstractTestBase { 11 | TestFixture fixture; 12 | 13 | function testSomething() public { 14 | fixture.something(); 15 | } 16 | } 17 | 18 | contract AbstractTest is AbstractTestBase { 19 | function setUp() public { 20 | fixture = new TestFixture(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/core/BadSigAfterInvariant.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract BadSigAfterInvariant is DSTest { 7 | function afterinvariant() public {} 8 | 9 | function testShouldPassWithWarning() public { 10 | assert(true); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/default/core/FailingTestAfterFailedSetup.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract FailingTestAfterFailedSetupTest is DSTest { 7 | function setUp() public { 8 | assertTrue(false); 9 | } 10 | 11 | function testAssertSuccess() public { 12 | assertTrue(true); 13 | } 14 | 15 | function testAssertFailure() public { 16 | assertTrue(false); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/core/LegacyAssertions.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract NoAssertionsRevertTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testMultipleAssertFailures() public { 11 | vm.assertEq(uint256(1), uint256(2)); 12 | vm.assertLt(uint256(5), uint256(4)); 13 | } 14 | } 15 | 16 | contract LegacyAssertionsTest { 17 | bool public failed; 18 | 19 | function testFlagNotSetSuccess() public {} 20 | 21 | function testFlagSetFailure() public { 22 | failed = true; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/default/core/PaymentFailure.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Payable { 8 | function pay() public payable {} 9 | } 10 | 11 | contract PaymentFailureTest is DSTest { 12 | Vm constant vm = Vm(HEVM_ADDRESS); 13 | 14 | function testCantPay() public { 15 | Payable target = new Payable(); 16 | vm.prank(address(1)); 17 | target.pay{value: 1}(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/core/Reverting.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract RevertingTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | /// forge-config: default.allow_internal_expect_revert = true 11 | function testRevert() public { 12 | vm.expectRevert("should revert here"); 13 | require(false, "should revert here"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/default/core/SetupConsistency.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract SetupConsistencyCheck is DSTest { 7 | uint256 two; 8 | uint256 four; 9 | uint256 result; 10 | 11 | function setUp() public { 12 | two = 2; 13 | four = 4; 14 | result = 0; 15 | } 16 | 17 | function testAdd() public { 18 | assertEq(result, 0); 19 | result = two + four; 20 | assertEq(result, 6); 21 | } 22 | 23 | function testMultiply() public { 24 | assertEq(result, 0); 25 | result = two * four; 26 | assertEq(result, 8); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testdata/default/fork/ForkSame_1.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ForkTest is DSTest { 8 | address constant WETH_TOKEN_ADDR = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 forkA; 11 | 12 | // this will create two _different_ forks during setup 13 | function setUp() public { 14 | forkA = vm.createFork("mainnet", 15_977_624); 15 | } 16 | 17 | function testDummy() public { 18 | uint256 balance = WETH_TOKEN_ADDR.balance; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/default/fork/ForkSame_2.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ForkTest is DSTest { 8 | address constant WETH_TOKEN_ADDR = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 forkA; 11 | 12 | // this will create two _different_ forks during setup 13 | function setUp() public { 14 | forkA = vm.createFork("mainnet", 15_977_624); 15 | } 16 | 17 | function testDummy() public { 18 | uint256 balance = WETH_TOKEN_ADDR.balance; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/default/fuzz/Fuzz.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract FuzzTest is DSTest { 8 | constructor() { 9 | emit log("constructor"); 10 | } 11 | 12 | Vm constant vm = Vm(HEVM_ADDRESS); 13 | 14 | function setUp() public { 15 | emit log("setUp"); 16 | } 17 | 18 | function testShouldFailFuzz(uint8 x) public { 19 | emit log("testFailFuzz"); 20 | require(x > 128, "should revert"); 21 | } 22 | 23 | function testSuccessfulFuzz(uint128 a, uint128 b) public { 24 | emit log("testSuccessfulFuzz"); 25 | assertEq(uint256(a) + uint256(b), uint256(a) + uint256(b)); 26 | } 27 | 28 | function testToStringFuzz(bytes32 data) public { 29 | vm.toString(data); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/fuzz/FuzzFailurePersist.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | struct TestTuple { 8 | address user; 9 | uint256 amount; 10 | } 11 | 12 | contract FuzzFailurePersistTest is DSTest { 13 | Vm vm = Vm(HEVM_ADDRESS); 14 | 15 | function test_persist_fuzzed_failure( 16 | uint256 x, 17 | int256 y, 18 | address addr, 19 | bool cond, 20 | string calldata test, 21 | TestTuple calldata tuple, 22 | address[] calldata addresses 23 | ) public { 24 | // dummy assume to trigger runs 25 | vm.assume(x > 1 && x < 1111111111111111111111111111); 26 | vm.assume(y > 1 && y < 1111111111111111111111111111); 27 | require(false); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testdata/default/fuzz/FuzzPositive.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract FuzzPositive is DSTest { 7 | function testSuccessChecker(uint256 val) public { 8 | assertTrue(true); 9 | } 10 | 11 | function testSuccessChecker2(int256 val) public { 12 | assert(val == val); 13 | } 14 | 15 | function testSuccessChecker3(uint32 val) public { 16 | assert(val + 0 == val); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantAssume.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.0; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Handler is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function doSomething(uint256 param) public { 11 | vm.assume(param == 0); 12 | } 13 | } 14 | 15 | contract InvariantAssume is DSTest { 16 | Handler handler; 17 | 18 | function setUp() public { 19 | handler = new Handler(); 20 | } 21 | 22 | function invariant_dummy() public {} 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantCustomError.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.0; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ContractWithCustomError { 8 | error InvariantCustomError(uint256, string); 9 | 10 | function revertWithInvariantCustomError() external { 11 | revert InvariantCustomError(111, "custom"); 12 | } 13 | } 14 | 15 | contract Handler is DSTest { 16 | ContractWithCustomError target; 17 | 18 | constructor() { 19 | target = new ContractWithCustomError(); 20 | } 21 | 22 | function revertTarget() external { 23 | target.revertWithInvariantCustomError(); 24 | } 25 | } 26 | 27 | contract InvariantCustomError is DSTest { 28 | Handler handler; 29 | 30 | function setUp() external { 31 | handler = new Handler(); 32 | } 33 | 34 | function invariant_decode_error() public {} 35 | } 36 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantExcludedSenders.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract InvariantSenders { 7 | function checkSender() external { 8 | require(msg.sender != 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D, "sender cannot be cheatcode address"); 9 | require(msg.sender != 0x000000000000000000636F6e736F6c652e6c6f67, "sender cannot be console address"); 10 | require(msg.sender != 0x4e59b44847b379578588920cA78FbF26c0B4956C, "sender cannot be CREATE2 deployer"); 11 | } 12 | } 13 | 14 | contract InvariantExcludedSendersTest is DSTest { 15 | InvariantSenders target; 16 | 17 | function setUp() public { 18 | target = new InvariantSenders(); 19 | } 20 | 21 | function invariant_check_sender() public view {} 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantSequenceNoReverts.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract SequenceNoReverts { 7 | uint256 public count; 8 | 9 | function work(uint256 x) public { 10 | require(x % 2 != 0); 11 | count++; 12 | } 13 | } 14 | 15 | contract SequenceNoRevertsTest is DSTest { 16 | SequenceNoReverts target; 17 | 18 | function setUp() public { 19 | target = new SequenceNoReverts(); 20 | } 21 | 22 | function invariant_no_reverts() public view { 23 | require(target.count() < 10, "condition met"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ShrinkBigSequence { 8 | uint256 cond; 9 | 10 | function work(uint256 x) public { 11 | if (x % 2 != 0 && x < 9000) { 12 | cond++; 13 | } 14 | } 15 | 16 | function checkCond() public view { 17 | require(cond < 77, "condition met"); 18 | } 19 | } 20 | 21 | contract ShrinkBigSequenceTest is DSTest { 22 | ShrinkBigSequence target; 23 | 24 | function setUp() public { 25 | target = new ShrinkBigSequence(); 26 | } 27 | 28 | function invariant_shrink_big_sequence() public view { 29 | target.checkCond(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ShrinkFailOnRevert { 8 | uint256 cond; 9 | 10 | function work(uint256 x) public { 11 | if (x % 2 != 0 && x < 9000) { 12 | cond++; 13 | } 14 | require(cond < 10, "condition met"); 15 | } 16 | } 17 | 18 | contract ShrinkFailOnRevertTest is DSTest { 19 | ShrinkFailOnRevert target; 20 | 21 | function setUp() public { 22 | target = new ShrinkFailOnRevert(); 23 | } 24 | 25 | function invariant_shrink_fail_on_revert() public view {} 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantShrinkWithAssert.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract Counter { 7 | uint256 public number; 8 | 9 | function increment() public { 10 | number++; 11 | } 12 | 13 | function decrement() public { 14 | number--; 15 | } 16 | } 17 | 18 | contract InvariantShrinkWithAssert is DSTest { 19 | Counter public counter; 20 | 21 | function setUp() public { 22 | counter = new Counter(); 23 | } 24 | 25 | function invariant_with_assert() public { 26 | assertTrue(counter.number() < 2, "wrong counter"); 27 | } 28 | 29 | function invariant_with_require() public { 30 | require(counter.number() < 2, "wrong counter"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/target/ExcludeContracts.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract Hello { 7 | bool public world = true; 8 | 9 | function change() public { 10 | world = false; 11 | } 12 | } 13 | 14 | contract ExcludeContracts is DSTest { 15 | Hello hello; 16 | 17 | function setUp() public { 18 | hello = new Hello(); 19 | new Hello(); 20 | } 21 | 22 | function excludeContracts() public returns (address[] memory) { 23 | address[] memory addrs = new address[](1); 24 | addrs[0] = address(hello); 25 | return addrs; 26 | } 27 | 28 | function invariantTrueWorld() public { 29 | require(hello.world() == true, "false world"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/target/TargetContracts.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract Hello { 7 | bool public world = true; 8 | 9 | function change() public { 10 | world = false; 11 | } 12 | } 13 | 14 | contract TargetContracts is DSTest { 15 | Hello hello1; 16 | Hello hello2; 17 | 18 | function setUp() public { 19 | hello1 = new Hello(); 20 | hello2 = new Hello(); 21 | } 22 | 23 | function targetContracts() public returns (address[] memory) { 24 | address[] memory addrs = new address[](1); 25 | addrs[0] = address(hello1); 26 | return addrs; 27 | } 28 | 29 | function invariantTrueWorld() public { 30 | require(hello2.world() == true, "false world"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/target/TargetSenders.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract Hello { 7 | bool public world = true; 8 | 9 | function change() public { 10 | require(msg.sender == address(0xdeadbeef)); 11 | world = false; 12 | } 13 | } 14 | 15 | contract TargetSenders is DSTest { 16 | Hello hello; 17 | 18 | function setUp() public { 19 | hello = new Hello(); 20 | } 21 | 22 | function targetSenders() public returns (address[] memory) { 23 | address[] memory addrs = new address[](1); 24 | addrs[0] = address(0xdeadbeef); 25 | return addrs; 26 | } 27 | 28 | function invariantTrueWorld() public { 29 | require(hello.world() == true, "false world"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/inline/FuzzInlineConf.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract FuzzInlineConf is DSTest { 7 | /** 8 | * forge-config: default.fuzz.runs = 1024 9 | * forge-config: default.fuzz.max-test-rejects = 500 10 | */ 11 | function testInlineConfFuzz(uint8 x) public { 12 | require(true, "this is not going to revert"); 13 | } 14 | } 15 | 16 | /// forge-config: default.fuzz.runs = 10 17 | contract FuzzInlineConf2 is DSTest { 18 | /// forge-config: default.fuzz.runs = 1 19 | function testInlineConfFuzz1(uint8 x) public { 20 | require(true, "this is not going to revert"); 21 | } 22 | 23 | function testInlineConfFuzz2(uint8 x) public { 24 | require(true, "this is not going to revert"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/linking/cycle/Cycle.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | library Foo { 5 | function foo() external { 6 | Bar.bar(); 7 | } 8 | 9 | function flum() external {} 10 | } 11 | 12 | library Bar { 13 | function bar() external { 14 | Foo.flum(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/linking/simple/Simple.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | // Linking scenario: contract with one library 7 | 8 | library Lib { 9 | function plus100(uint256 a) public pure returns (uint256) { 10 | return a + 100; 11 | } 12 | } 13 | 14 | contract LibraryConsumer { 15 | function consume(uint256 a) public pure returns (uint256) { 16 | return Lib.plus100(a); 17 | } 18 | } 19 | 20 | contract SimpleLibraryLinkingTest is DSTest { 21 | LibraryConsumer consumer; 22 | 23 | function setUp() public { 24 | consumer = new LibraryConsumer(); 25 | } 26 | 27 | function testCall() public { 28 | assertEq(consumer.consume(1), 101, "library call failed"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue10527.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract A { 8 | event Event1(); 9 | event Event2(); 10 | 11 | function foo() public { 12 | emit Event1(); 13 | } 14 | 15 | function bar() public { 16 | emit Event2(); 17 | } 18 | } 19 | 20 | contract Issue10527Test is DSTest { 21 | Vm constant vm = Vm(HEVM_ADDRESS); 22 | 23 | A a; 24 | 25 | function setUp() public { 26 | a = new A(); 27 | } 28 | 29 | function test_foo_Event1() public { 30 | vm.expectEmit(address(a)); 31 | emit A.Event1(); 32 | 33 | a.foo(); 34 | } 35 | 36 | function test_foo_Event2() public { 37 | vm.expectEmit({emitter: address(a), count: 0}); 38 | emit A.Event2(); 39 | 40 | a.foo(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2623.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/2623 8 | contract Issue2623Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testRollFork() public { 12 | uint256 fork = vm.createFork("mainnet", 10); 13 | vm.selectFork(fork); 14 | 15 | assertEq(block.number, 10); 16 | assertEq(block.timestamp, 1438270128); 17 | 18 | vm.rollFork(11); 19 | 20 | assertEq(block.number, 11); 21 | assertEq(block.timestamp, 1438270136); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2629.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/2629 8 | contract Issue2629Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testSelectFork() public { 12 | address coinbase = 0x0193d941b50d91BE6567c7eE1C0Fe7AF498b4137; 13 | 14 | uint256 f1 = vm.createSelectFork("mainnet", 9); 15 | vm.selectFork(f1); 16 | 17 | assertEq(block.number, 9); 18 | assertEq(coinbase.balance, 11250000000000000000); 19 | 20 | uint256 f2 = vm.createFork("mainnet", 10); 21 | vm.selectFork(f2); 22 | 23 | assertEq(block.number, 10); 24 | assertEq(coinbase.balance, 16250000000000000000); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2723.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/2723 8 | contract Issue2723Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testRollFork() public { 12 | address coinbase = 0x0193d941b50d91BE6567c7eE1C0Fe7AF498b4137; 13 | 14 | vm.createSelectFork("mainnet", 9); 15 | 16 | assertEq(block.number, 9); 17 | assertEq(coinbase.balance, 11250000000000000000); 18 | 19 | vm.rollFork(10); 20 | 21 | assertEq(block.number, 10); 22 | assertEq(coinbase.balance, 16250000000000000000); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2851.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.1; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract Backdoor { 7 | uint256 public number = 1; 8 | 9 | function backdoor(uint256 newNumber) public payable { 10 | uint256 x = newNumber - 1; 11 | if (x == 6912213124124531) { 12 | number = 0; 13 | } 14 | } 15 | } 16 | 17 | // https://github.com/foundry-rs/foundry/issues/2851 18 | contract Issue2851Test is DSTest { 19 | Backdoor back; 20 | 21 | function setUp() public { 22 | back = new Backdoor(); 23 | } 24 | 25 | function invariantNotZero() public { 26 | assertEq(back.number(), 1); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2898.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | import "../logs/console.sol"; 7 | 8 | // https://github.com/foundry-rs/foundry/issues/2898 9 | contract Issue2898Test is DSTest { 10 | address private constant BRIDGE = address(10); 11 | address private constant BENEFICIARY = address(11); 12 | Vm constant vm = Vm(HEVM_ADDRESS); 13 | 14 | function setUp() public { 15 | vm.deal(BRIDGE, 100); 16 | vm.deal(BENEFICIARY, 99); 17 | 18 | vm.setNonce(BRIDGE, 10); 19 | } 20 | 21 | function testDealBalance() public { 22 | assertEq(BRIDGE.balance, 100); 23 | assertEq(BENEFICIARY.balance, 99); 24 | } 25 | 26 | function testSetNonce() public { 27 | assertEq(vm.getNonce(BRIDGE), 10); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2984.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/2984 8 | contract Issue2984Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 fork; 11 | uint256 snapshot; 12 | 13 | function setUp() public { 14 | fork = vm.createSelectFork("avaxTestnet", 12880747); 15 | snapshot = vm.snapshotState(); 16 | } 17 | 18 | function testForkRevertSnapshot() public { 19 | vm.revertToState(snapshot); 20 | } 21 | 22 | function testForkSelectSnapshot() public { 23 | uint256 fork2 = vm.createSelectFork("avaxTestnet", 12880749); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3189.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3189 8 | contract MyContract { 9 | function foo(uint256 arg) public returns (uint256) { 10 | return arg + 2; 11 | } 12 | } 13 | 14 | contract MyContractUser is DSTest { 15 | MyContract immutable myContract; 16 | 17 | constructor() { 18 | myContract = new MyContract(); 19 | } 20 | 21 | function foo(uint256 arg) public returns (uint256 ret) { 22 | ret = myContract.foo(arg); 23 | assertEq(ret, arg + 1, "Invariant failed"); 24 | } 25 | } 26 | 27 | contract Issue3189Test is DSTest { 28 | function testFoo() public { 29 | MyContractUser user = new MyContractUser(); 30 | uint256 fooRet = user.foo(123); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3190.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | import "../logs/console.sol"; 7 | 8 | // https://github.com/foundry-rs/foundry/issues/3190 9 | contract Issue3190Test is DSTest { 10 | Vm constant vm = Vm(HEVM_ADDRESS); 11 | 12 | function setUp() public { 13 | vm.chainId(99); 14 | assertEq(99, block.chainid); 15 | } 16 | 17 | function testChainId() public { 18 | assertEq(99, block.chainid); 19 | vm.chainId(100); 20 | assertEq(100, block.chainid); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3192.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3192 8 | contract Issue3192Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 fork1; 11 | uint256 fork2; 12 | 13 | function setUp() public { 14 | fork1 = vm.createFork("mainnet", 7475589); 15 | fork2 = vm.createFork("mainnet", 12880747); 16 | vm.selectFork(fork1); 17 | } 18 | 19 | function testForkSwapSelect() public { 20 | assertEq(fork1, vm.activeFork()); 21 | vm.selectFork(fork2); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3347.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3347 8 | contract Issue3347Test is DSTest { 9 | event log2(uint256, uint256); 10 | 11 | function test() public { 12 | emit log2(1, 2); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3437.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity >=0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3437 8 | contract Issue3347Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function internalRevert() internal { 12 | revert(); 13 | } 14 | 15 | function testFailExample() public { 16 | vm.expectRevert(); 17 | internalRevert(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3596.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3596 8 | contract Issue3596Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testDealTransfer() public { 12 | address addr = vm.addr(1337); 13 | vm.startPrank(addr); 14 | vm.deal(addr, 20000001 ether); 15 | payable(address(this)).transfer(20000000 ether); 16 | 17 | Nested nested = new Nested(); 18 | nested.doStuff(); 19 | vm.stopPrank(); 20 | } 21 | } 22 | 23 | contract Nested { 24 | function doStuff() public { 25 | doRevert(); 26 | } 27 | 28 | function doRevert() public { 29 | revert("This fails"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3653.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3653 8 | contract Issue3653Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 fork; 11 | Token token; 12 | 13 | constructor() { 14 | fork = vm.createSelectFork("mainnet", 1000000); 15 | token = new Token(); 16 | vm.makePersistent(address(token)); 17 | } 18 | 19 | function testDummy() public { 20 | assertEq(block.number, 1000000); 21 | } 22 | } 23 | 24 | contract Token {} 25 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3661.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | // https://github.com/foundry-rs/foundry/issues/3661 7 | contract Issue3661Test is DSTest { 8 | address sender; 9 | 10 | function setUp() public { 11 | sender = msg.sender; 12 | } 13 | 14 | function testSameSender() public { 15 | assert(sender == msg.sender); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3674.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3674 8 | contract Issue3674Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testNonceCreateSelect() public { 12 | vm.createSelectFork("sepolia"); 13 | 14 | vm.createSelectFork("avaxTestnet"); 15 | assert(vm.getNonce(msg.sender) > 0x17); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3723.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity >=0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3723 8 | contract Issue3723Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testFailExample() public { 12 | vm.expectRevert(); 13 | revert(); 14 | 15 | vm.expectRevert(); 16 | emit log_string("Do not revert"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3753.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3753 8 | contract Issue3753Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_repro() public { 12 | bool res; 13 | assembly { 14 | res := staticcall(gas(), 4, 0, 0, 0, 0) 15 | } 16 | vm.expectRevert("require"); 17 | this.revert_require(); 18 | } 19 | 20 | function revert_require() public { 21 | revert("require"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3792.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Config { 8 | address public test = 0xcBa28b38103307Ec8dA98377ffF9816C164f9AFa; 9 | } 10 | 11 | contract TestSetup is Config, DSTest { 12 | Vm constant vm = Vm(HEVM_ADDRESS); 13 | 14 | // More context: the inheritance order causes the _failed flag 15 | // that is usually checked on snapshots to be shifted. 16 | // We now check for keccak256("failed") on the hevm address. 17 | // This test should succeed. 18 | function testSnapshotStorageShift() public { 19 | uint256 snapshotId = vm.snapshotState(); 20 | 21 | vm.prank(test); 22 | 23 | vm.revertToState(snapshotId); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue4630.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/4630 8 | contract Issue4630Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testExistingValue() public { 12 | string memory path = "fixtures/Json/Issue4630.json"; 13 | string memory json = vm.readFile(path); 14 | uint256 val = vm.parseJsonUint(json, ".local.prop1"); 15 | assertEq(val, 10); 16 | } 17 | 18 | function testMissingValue() public { 19 | string memory path = "fixtures/Json/Issue4630.json"; 20 | string memory json = vm.readFile(path); 21 | vm._expectCheatcodeRevert(); 22 | vm.parseJsonUint(json, ".localempty.prop1"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue4640.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/4640 8 | contract Issue4640Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testArbitrumBlockNumber() public { 12 | // 13 | vm.createSelectFork("arbitrum", 75219831); 14 | // L1 block number 15 | assertEq(block.number, 16939475); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue4832.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity >=0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/4832 8 | contract Issue4832Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testFailExample() public { 12 | assertEq(uint256(1), 2); 13 | 14 | vm.expectRevert(); 15 | revert(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue5808.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/5808 8 | contract Issue5808Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testReadInt() public { 12 | string memory str1 = '["ffffffff","00000010"]'; 13 | vm._expectCheatcodeRevert(); 14 | int256[] memory ints1 = vm.parseJsonIntArray(str1, ""); 15 | 16 | string memory str2 = '["0xffffffff","0x00000010"]'; 17 | int256[] memory ints2 = vm.parseJsonIntArray(str2, ""); 18 | assertEq(ints2[0], 0xffffffff); 19 | assertEq(ints2[1], 16); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue5929.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/5929 8 | contract Issue5929Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_transact_not_working() public { 12 | vm.createSelectFork("mainnet", 21134547); 13 | // https://etherscan.io/tx/0x96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143 14 | vm.transact(hex"7dcff74771babf9c23363c4228e55a27f50224d4596b1ba6608b0b45712f94ba"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue5935.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract SimpleStorage { 8 | uint256 public value; 9 | 10 | function set(uint256 _value) external { 11 | value = _value; 12 | } 13 | } 14 | 15 | contract Issue5935Test is DSTest { 16 | Vm constant vm = Vm(HEVM_ADDRESS); 17 | 18 | function testFork() public { 19 | uint256 forkId1 = vm.createFork("mainnet", 18234083); 20 | uint256 forkId2 = vm.createFork("mainnet", 18234083); 21 | vm.selectFork(forkId1); 22 | SimpleStorage myContract = new SimpleStorage(); 23 | myContract.set(42); 24 | vm.selectFork(forkId2); 25 | SimpleStorage myContract2 = new SimpleStorage(); 26 | assertEq(myContract2.value(), 0); 27 | 28 | vm.selectFork(forkId1); 29 | assertEq(myContract.value(), 42); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6070.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6070 8 | contract Issue6066Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testNonPrefixed() public { 12 | vm.setEnv("__FOUNDRY_ISSUE_6066", "abcd"); 13 | vm._expectCheatcodeRevert( 14 | "failed parsing $__FOUNDRY_ISSUE_6066 as type `uint256`: missing hex prefix (\"0x\") for hex string" 15 | ); 16 | uint256 x = vm.envUint("__FOUNDRY_ISSUE_6066"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6170.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Emitter { 8 | event Values(uint256 indexed a, uint256 indexed b); 9 | 10 | function plsEmit(uint256 a, uint256 b) external { 11 | emit Values(a, b); 12 | } 13 | } 14 | 15 | // https://github.com/foundry-rs/foundry/issues/6170 16 | contract Issue6170Test is DSTest { 17 | Vm constant vm = Vm(HEVM_ADDRESS); 18 | 19 | event Values(uint256 indexed a, uint256 b); 20 | 21 | Emitter e = new Emitter(); 22 | 23 | function test() public { 24 | vm.expectEmit(true, true, false, true); 25 | emit Values(69, 420); 26 | e.plsEmit(69, 420); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6180.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6180 8 | contract Issue6180Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_timebug() external { 12 | uint256 start = block.timestamp; 13 | uint256 count = 4; 14 | uint256 duration = 15; 15 | for (uint256 i; i < count; i++) { 16 | vm.warp(block.timestamp + duration); 17 | } 18 | 19 | uint256 end = block.timestamp; 20 | assertEq(end, start + count * duration); 21 | assertEq(end - start, count * duration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6293.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6293 8 | contract Issue6293Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | constructor() { 12 | require(address(this).balance > 0); 13 | payable(address(1)).call{value: 1}(""); 14 | } 15 | 16 | function test() public { 17 | assertGt(address(this).balance, 0); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6501.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "../logs/console.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6501 8 | contract Issue6501Test is DSTest { 9 | function test_hhLogs() public { 10 | console.log("a"); 11 | console.log(uint256(1)); 12 | console.log("b", uint256(2)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6538.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6538 8 | contract Issue6538Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_transact() public { 12 | bytes32 lastHash = 0x4b70ca8c5a0990b43df3064372d424d46efa41dfaab961754b86c5afb2df4f61; 13 | vm.createSelectFork("mainnet", lastHash); 14 | bytes32 txhash = 0x7dcff74771babf9c23363c4228e55a27f50224d4596b1ba6608b0b45712f94ba; 15 | vm.transact(txhash); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6554.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6554 8 | contract Issue6554Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testPermissions() public { 12 | vm.writeFile("./out/default/Issue6554.t.sol/cachedFile.txt", "cached data"); 13 | string memory content = vm.readFile("./out/default/Issue6554.t.sol/cachedFile.txt"); 14 | assertEq(content, "cached data"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6616.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6616 8 | contract Issue6616Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testCreateForkRollLatestBlock() public { 12 | vm.createSelectFork("mainnet"); 13 | uint256 startBlock = block.number; 14 | // this will create new forks and exit once a new latest block is found 15 | for (uint256 i; i < 10; i++) { 16 | vm.sleep(5000); 17 | vm.createSelectFork("mainnet"); 18 | if (block.number > startBlock) break; 19 | } 20 | assertGt(block.number, startBlock); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6759.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6759 8 | contract Issue6759Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testCreateMulti() public { 12 | uint256 fork1 = vm.createFork("mainnet", 10); 13 | uint256 fork2 = vm.createFork("mainnet", 10); 14 | uint256 fork3 = vm.createFork("mainnet", 10); 15 | assert(fork1 != fork2); 16 | assert(fork1 != fork3); 17 | assert(fork2 != fork3); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6966.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | // https://github.com/foundry-rs/foundry/issues/6966 7 | // See also https://github.com/RustCrypto/elliptic-curves/issues/988#issuecomment-1817681013 8 | contract Issue6966Test is DSTest { 9 | function testEcrecover() public { 10 | bytes32 h = 0x0000000000000000000000000000000000000000000000000000000000000000; 11 | uint8 v = 27; 12 | bytes32 r = bytes32(0xf87fff3202dfeae34ce9cb8151ce2e176bee02a937baac6de85c4ea03d6a6618); 13 | bytes32 s = bytes32(0xedf9ab5c7d3ec1df1c2b48600ab0a35f586e069e9a69c6cdeebc99920128d1a5); 14 | assert(ecrecover(h, v, r, s) != address(0)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue8566.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/8566 8 | contract Issue8566Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testParseJsonUint() public { 12 | string memory json = 13 | "{ \"1284\": { \"addRewardInfo\": { \"amount\": 74258.225772486694040708e18, \"rewardPerSec\": 0.03069536448928848133e20 } } }"; 14 | 15 | assertEq(74258225772486694040708, vm.parseJsonUint(json, ".1284.addRewardInfo.amount")); 16 | assertEq(3069536448928848133, vm.parseJsonUint(json, ".1284.addRewardInfo.rewardPerSec")); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/spec/ShanghaiCompat.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ShanghaiCompat is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testPush0() public { 11 | address target = address(uint160(uint256(0xc4f3))); 12 | 13 | bytes memory bytecode = hex"365f5f37365ff3"; 14 | // 36 CALLDATASIZE 15 | // 5F PUSH0 16 | // 5F PUSH0 17 | // 37 CALLDATACOPY -> copies calldata at mem[0..calldatasize] 18 | 19 | // 36 CALLDATASIZE 20 | // 5F PUSH0 21 | // F3 RETURN -> returns mem[0..calldatasize] 22 | 23 | vm.etch(target, bytecode); 24 | 25 | (bool success, bytes memory result) = target.call(bytes("hello PUSH0")); 26 | assertTrue(success); 27 | assertEq(string(result), "hello PUSH0"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testdata/default/vyper/Counter.vy: -------------------------------------------------------------------------------- 1 | from . import ICounter 2 | implements: ICounter 3 | 4 | number: public(uint256) 5 | 6 | @external 7 | def set_number(new_number: uint256): 8 | self.number = new_number 9 | 10 | @external 11 | def increment(): 12 | self.number += 1 13 | -------------------------------------------------------------------------------- /testdata/default/vyper/CounterTest.vy: -------------------------------------------------------------------------------- 1 | from . import ICounter 2 | 3 | interface Vm: 4 | def deployCode(artifact_name: String[1024], args: Bytes[1024] = b"") -> address: nonpayable 5 | 6 | vm: constant(Vm) = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D) 7 | counter: ICounter 8 | 9 | @external 10 | def setUp(): 11 | self.counter = ICounter(extcall vm.deployCode("vyper/Counter.vy")) 12 | 13 | @external 14 | def test_increment(): 15 | extcall self.counter.increment() 16 | assert staticcall self.counter.number() == 1 17 | -------------------------------------------------------------------------------- /testdata/default/vyper/ICounter.vyi: -------------------------------------------------------------------------------- 1 | @view 2 | @external 3 | def number() -> uint256: 4 | ... 5 | 6 | @external 7 | def set_number(new_number: uint256): 8 | ... 9 | 10 | @external 11 | def increment(): 12 | ... -------------------------------------------------------------------------------- /testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x044b75f554b886a065b9567891e45c79542d7357","contractCreator":"0xf87bc5535602077d340806d71f805ea9907a843d","txHash":"0x9a89d2f5528bf07661e92f3f78a3311396f11f15da19e3ec4d880be1ad1a4bec"} -------------------------------------------------------------------------------- /testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x35fb958109b70799a8f9bc2a8b1ee4cc62034193","contractCreator":"0x3e32324277e96b69750bc6f7c4ba27e122413e07","txHash":"0x41e3517f8262b55e1eb1707ba0760b603a70e89ea4a86eff56072fcc80c3d0a1"} -------------------------------------------------------------------------------- /testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x3a23f943181408eac424116af7b7790c94cb97a5","contractCreator":"0xe8dd38e673a93ccfc2e3d7053efccb5c93f49365","txHash":"0x29328ac0edf7b080320bc8ed998fcd3e866f7eec3775b0d91a86f5d02ab83c28"} -------------------------------------------------------------------------------- /testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x71356e37e0368bd10bfdbf41dc052fe5fa24cd05","contractCreator":"0xaa1d342354d755ec515f40e7d5e83cb4184bb9ee","txHash":"0x1c800c2c2d5230823602cae6896a8db1ab7d1341ca697c6c64d9f0edf11dabe2"} -------------------------------------------------------------------------------- /testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x8b3d32cf2bb4d0d16656f4c0b04fa546274f1545","contractCreator":"0x958892b4a0512b28aaac890fc938868bbd42f064","txHash":"0x79820495643caf5a1e7e96578361c9ddba0e0735cd684ada7450254f6fd58f51"} -------------------------------------------------------------------------------- /testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x9ab6b21cdf116f611110b048987e58894786c244","contractCreator":"0x603d50bad151da8becf405e51a8c4abc8ba1c95e","txHash":"0x72be611ae1ade09242d9fc9c950a73d076f6c23514564a7b9ac730400dbaf2c0"} -------------------------------------------------------------------------------- /testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/creation_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "contractAddress": "0x9d27527ada2cf29fbdab2973cfa243845a08bd3f", 3 | "contractCreator": "0x7773ae67403d2e30102a84c48cc939919c4c881c", 4 | "txHash": "0xc757719b7ae11ea651b1b23249978a3e8fca94d358610f5809a5dc19fbf850ce" 5 | } -------------------------------------------------------------------------------- /testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0xdb53f47ac61fe54f456a4eb3e09832d08dd7beec","contractCreator":"0xc7f8d87734ab2cbf70030ac8aa82abfe3e8126cb","txHash":"0x196898c69f6b1944f1011120b15c0903329d46259c8cdc0fbcad71da1fe58245"} -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_chinese_simplified.txt: -------------------------------------------------------------------------------- 1 | 谐 谐 谐 谐 谐 谐 谐 谐 谐 谐 谐 宗 -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_chinese_traditional.txt: -------------------------------------------------------------------------------- 1 | 諧 諧 諧 諧 諧 諧 諧 諧 諧 諧 諧 宗 -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_czech.txt: -------------------------------------------------------------------------------- 1 | uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina nevina -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_english.txt: -------------------------------------------------------------------------------- 1 | test test test test test test test test test test test junk -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_french.txt: -------------------------------------------------------------------------------- 1 | sonde sonde sonde sonde sonde sonde sonde sonde sonde sonde sonde hématome -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_italian.txt: -------------------------------------------------------------------------------- 1 | surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato mansarda -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_japanese.txt: -------------------------------------------------------------------------------- 1 | ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ぜんご -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_korean.txt: -------------------------------------------------------------------------------- 1 | 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 시스템 -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_portuguese.txt: -------------------------------------------------------------------------------- 1 | sobra sobra sobra sobra sobra sobra sobra sobra sobra sobra sobra guarani -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_spanish.txt: -------------------------------------------------------------------------------- 1 | tacto tacto tacto tacto tacto tacto tacto tacto tacto tacto tacto lacra -------------------------------------------------------------------------------- /testdata/fixtures/Dir/depth1: -------------------------------------------------------------------------------- 1 | Wow! 😀 -------------------------------------------------------------------------------- /testdata/fixtures/Dir/nested/depth2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/testdata/fixtures/Dir/nested/depth2 -------------------------------------------------------------------------------- /testdata/fixtures/Dir/nested/nested2/depth3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foundry-rs/foundry/b42d5121ba3f03099b1d649ab71f2100a212d3f3/testdata/fixtures/Dir/nested/nested2/depth3 -------------------------------------------------------------------------------- /testdata/fixtures/File/read.txt: -------------------------------------------------------------------------------- 1 | hello readable world 2 | this is the second line! -------------------------------------------------------------------------------- /testdata/fixtures/File/symlink: -------------------------------------------------------------------------------- 1 | read.txt -------------------------------------------------------------------------------- /testdata/fixtures/GetCode/Override.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.13; 3 | 4 | contract Override { 5 | event Payload(address sender, address target, bytes data); 6 | 7 | function emitPayload(address target, bytes calldata message) external payable returns (uint256) { 8 | emit Payload(msg.sender, target, message); 9 | return 0; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/fixtures/GetCode/UnlinkedContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | library SmolLibrary { 5 | function add(uint256 a, uint256 b) public pure returns (uint256 c) { 6 | c = a + b; 7 | } 8 | } 9 | 10 | contract UnlinkedContract { 11 | function complicated(uint256 a, uint256 b, uint256 c) public pure returns (uint256 d) { 12 | d = SmolLibrary.add(SmolLibrary.add(a, b), c); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/fixtures/GetCode/WorkingContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | contract WorkingContract { 5 | uint256 public constant secret = 42; 6 | } 7 | -------------------------------------------------------------------------------- /testdata/fixtures/Json/Issue4402.json: -------------------------------------------------------------------------------- 1 | { 2 | "tokens": ["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"], 3 | "empty": [] 4 | } -------------------------------------------------------------------------------- /testdata/fixtures/Json/Issue4630.json: -------------------------------------------------------------------------------- 1 | { 2 | "local": { 3 | "prop1": 10 4 | }, 5 | "localempty": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /testdata/fixtures/Json/test_allocs.json: -------------------------------------------------------------------------------- 1 | { 2 | "0x0000000000000000000000000000000000000420": { 3 | "balance": "0xabcd", 4 | "code": "0x604260005260206000F3", 5 | "storage": { 6 | "0x1000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000000000000000000000000000000000000000beef" 7 | } 8 | }, 9 | "0x0000000000000000000000000000000000000421": { 10 | "balance": "0x0", 11 | "storage": { 12 | "0x1000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000000000000000000000000000000000000000beef" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/fixtures/Json/whole_json.json: -------------------------------------------------------------------------------- 1 | { 2 | "str": "hai", 3 | "uintArray": [42, 43], 4 | "strArray": ["hai", "there"] 5 | } 6 | -------------------------------------------------------------------------------- /testdata/fixtures/Json/write_complex_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 123, 3 | "b": "test", 4 | "c": { 5 | "a": 123, 6 | "b": "test" 7 | } 8 | } -------------------------------------------------------------------------------- /testdata/fixtures/Json/write_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 123, 3 | "b": "0x000000000000000000000000000000000000bEEF" 4 | } -------------------------------------------------------------------------------- /testdata/fixtures/Rpc/README.md: -------------------------------------------------------------------------------- 1 | # Fixture Generation Instructions 2 | 3 | ### `eth_getLogs.json` 4 | 5 | To generate this fixture, send a POST request to a Eth Mainnet (chainId = 1) RPC 6 | 7 | ``` 8 | { 9 | "jsonrpc": "2.0", 10 | "method": "eth_getLogs", 11 | "id": "1", 12 | "params": [ 13 | { 14 | "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", 15 | "fromBlock": "0x10CEB1B", 16 | "toBlock": "0x10CEB1B", 17 | "topics": [ 18 | "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65" 19 | ] 20 | } 21 | ] 22 | } 23 | ``` 24 | 25 | Then you must change the `address` key to `emitter` because in Solidity, a struct's name cannot be `address` as that is a keyword. 26 | -------------------------------------------------------------------------------- /testdata/fixtures/Rpc/balance_params.json: -------------------------------------------------------------------------------- 1 | ["0x8D97689C9818892B700e27F316cc3E41e17fBeb9", "0x117BC09"] -------------------------------------------------------------------------------- /testdata/fixtures/SolidityGeneration/GeneratedNamedInterface.sol: -------------------------------------------------------------------------------- 1 | interface test { 2 | event Bar(address indexed x); 3 | event Foo(address x); 4 | 5 | function guess(uint8 n, address x) external payable; 6 | function isComplete() external view returns (bool example, string memory); 7 | } 8 | -------------------------------------------------------------------------------- /testdata/fixtures/SolidityGeneration/GeneratedUnnamedInterface.sol: -------------------------------------------------------------------------------- 1 | interface Interface { 2 | event Bar(address indexed x); 3 | event Foo(address x); 4 | 5 | function guess(uint8 n, address x) external payable; 6 | function isComplete() external view returns (bool example, string memory); 7 | } 8 | -------------------------------------------------------------------------------- /testdata/fixtures/Toml/Issue4402.toml: -------------------------------------------------------------------------------- 1 | tokens = ["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"] 2 | empty = [] 3 | -------------------------------------------------------------------------------- /testdata/fixtures/Toml/nested_toml_struct.toml: -------------------------------------------------------------------------------- 1 | name = "test" 2 | 3 | [[members]] 4 | a = 100 5 | arr = [ 6 | [1, -2, -5], 7 | [1000, 2000, 0] 8 | ] 9 | str = "some string" 10 | b = "0x" 11 | addr = "0x0000000000000000000000000000000000000000" 12 | fixedBytes = "0x8ae3fc6bd1b150a73ec4afe3ef136fa2f88e9c96131c883c5e4a4714811c1598" 13 | 14 | [[members]] 15 | a = 200 16 | arr = [] 17 | str = "some other string" 18 | b = "0x0000000000000000000000000000000000000000" 19 | addr = "0x167D91deaEEE3021161502873d3bcc6291081648" 20 | fixedBytes = "0xed1c7beb1f00feaaaec5636950d6edb25a8d4fedc8deb2711287b64c4d27719d" 21 | 22 | [inner] 23 | fixedBytes = "0x12345678" 24 | -------------------------------------------------------------------------------- /testdata/fixtures/Toml/whole_toml.toml: -------------------------------------------------------------------------------- 1 | str = "hai" 2 | uintArray = [42, 43] 3 | strArray = ["hai", "there"] 4 | -------------------------------------------------------------------------------- /testdata/fixtures/Toml/write_complex_test.toml: -------------------------------------------------------------------------------- 1 | a = 123 2 | b = "test" 3 | 4 | [c] 5 | a = 123 6 | b = "test" 7 | -------------------------------------------------------------------------------- /testdata/fixtures/Toml/write_test.toml: -------------------------------------------------------------------------------- 1 | a = 123 2 | b = "0x000000000000000000000000000000000000bEEF" 3 | -------------------------------------------------------------------------------- /testdata/fixtures/broadcast.sensitive.log.json: -------------------------------------------------------------------------------- 1 | { 2 | "transactions": [ 3 | { 4 | "rpc": "http://127.0.0.1:57544" 5 | }, 6 | { 7 | "rpc": "http://127.0.0.1:57544" 8 | }, 9 | { 10 | "rpc": "http://127.0.0.1:57544" 11 | }, 12 | { 13 | "rpc": "http://127.0.0.1:57544" 14 | }, 15 | { 16 | "rpc": "http://127.0.0.1:57544" 17 | }, 18 | { 19 | "rpc": "http://127.0.0.1:57544" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /testdata/forge-std-rev: -------------------------------------------------------------------------------- 1 | 77041d2ce690e692d6e03cc812b57d1ddaa4d505 -------------------------------------------------------------------------------- /testdata/multi-version/Counter.sol: -------------------------------------------------------------------------------- 1 | contract Counter { 2 | uint256 public number; 3 | 4 | function setNumber(uint256 newNumber) public { 5 | number = newNumber; 6 | } 7 | 8 | function increment() public { 9 | number++; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/multi-version/Importer.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.17; 2 | 3 | import "./Counter.sol"; 4 | 5 | // Please do not remove or change version pragma for this file. 6 | // If you need to ensure that some of the files are compiled with 7 | // solc 0.8.17, you should add imports of them to this file. 8 | -------------------------------------------------------------------------------- /testdata/paris/spec/ShanghaiCompat.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ShanghaiCompat is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testPush0() public { 11 | address target = address(uint160(uint256(0xc4f3))); 12 | 13 | bytes memory bytecode = hex"365f5f37365ff3"; 14 | // 36 CALLDATASIZE 15 | // 5F PUSH0 16 | // 5F PUSH0 17 | // 37 CALLDATACOPY -> copies calldata at mem[0..calldatasize] 18 | 19 | // 36 CALLDATASIZE 20 | // 5F PUSH0 21 | // F3 RETURN -> returns mem[0..calldatasize] 22 | 23 | vm.etch(target, bytecode); 24 | 25 | (bool success, bytes memory result) = target.call(bytes("hello PUSH0")); 26 | assertTrue(success); 27 | assertEq(string(result), "hello PUSH0"); 28 | } 29 | } 30 | --------------------------------------------------------------------------------