fix: VerifyAll fails when contract name differs from source file name#411
Open
fix: VerifyAll fails when contract name differs from source file name#411
Conversation
`_getCompiledBytecode` assumed the compiled artifact path matches
`out/{contractName}.sol/{contractName}.json`, but Foundry organizes
artifacts by source file name. When a contract name differs from its
source file (e.g. contract `ORA` in `OracleToken.sol`), verification
reverts with a file-not-found error.
Try the default path first, then fall back to searching the `out/`
directory for the correct artifact.
Made-with: Cursor
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VerifyAll.s.sol's_getCompiledBytecodeassumed compiled artifacts live atout/{contractName}.sol/{contractName}.json, but Foundry organizes artifacts by source file name, not contract name. When they differ (e.g. contractORAdefined inOracleToken.sol), the script reverts with a file-not-found error.out/directory viafindto locate the correct artifact.How to test
contract ORAinsideOracleToken.sol)yarn deploy --network sepoliayarn verify --network sepoliavm.readFile: failed to open file "...out/ORA.sol/ORA.json": No such file or directoryout/OracleToken.sol/ORA.jsonThings to look out for
internal viewtointernal(droppingview) because the fallback path usestryFfi. The caller_verifyContractis already non-view, so this is safe.findfallback excludesbuild-info/to avoid matching the wrong JSON files.Made with Cursor