Add legacy Crypto identifier to linter#2238
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR adds support for the legacy Crypto identifier in the Cadence linter by enabling proper resolution of Crypto contract imports. The implementation follows the same pattern used for other standard library imports like Test and BlockchainHelpers.
- Adds handling for
stdlib.CryptoContractLocationin the import resolver - Includes test coverage for Crypto contract imports across different contexts
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/cadence/linter.go | Adds case handling for CryptoContractLocation to parse and check the Crypto contract when imported |
| internal/cadence/lint_test.go | Adds test case and test file to verify Crypto import resolution works correctly |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Build contract name -> address mapping per network | ||
| for _, network := range *networks { | ||
| checkerAddr, err := l.state.ContractAddress(checkerContract, network) | ||
| if err != nil || checkerAddr == nil { | ||
| continue | ||
| contractNameToAddress := make(map[string]flowGo.Address) | ||
|
|
||
| // Add aliases first | ||
| contracts := l.state.Contracts() | ||
| if contracts != nil { | ||
| for _, contract := range *contracts { | ||
| if alias := contract.Aliases.ByNetwork(network.Name); alias != nil { | ||
| contractNameToAddress[contract.Name] = alias.Address | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
This only resolved deployment contract addresses, but did not properly resolve dependencies. Noticed when testing against sample repo.
Closes #2242
Description
For contributor use:
masterbranchFiles changedin the Github PR explorer