Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid removing dependencies from the build #1564

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Handle version bytecode for Vyper `>=0.3.4` ([#1578](https://github.com/eth-brownie/brownie/pull/1578))
- Handle Vyper `>=0.3.4` coverage data generation breaking project compilation ([#1586](https://github.com/eth-brownie/brownie/pull/1586))

### Fixed
- Handle null value of `to` field in transaction receipt so that contract deploying with Anvil works properly ([#1573](https://github.com/eth-brownie/brownie/pull/1573))
- Avoid removing dependencies from the build ([#1564](https://github.com/eth-brownie/brownie/pull/1564))

## [1.19.0](https://github.com/eth-brownie/brownie/tree/v1.19.0) - 2022-05-29
### Added
Expand Down
14 changes: 13 additions & 1 deletion brownie/project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,19 @@ def load(self, raise_if_loaded: bool = True) -> None:
self._build = Build(self._sources)

contract_list = self._sources.get_contract_list()
potential_dependencies = []
for path in list(self._build_path.glob("contracts/*.json")):
try:
with path.open() as fp:
build_json = json.load(fp)
except json.JSONDecodeError:
build_json = {}
if not set(BUILD_KEYS).issubset(build_json) or path.stem not in contract_list:
if not set(BUILD_KEYS).issubset(build_json):
path.unlink()
continue
if path.stem not in contract_list:
potential_dependencies.append((path, build_json))
continue
if isinstance(build_json["allSourcePaths"], list):
# this handles the format change in v1.7.0, it can be removed in a future release
path.unlink()
Expand All @@ -222,6 +226,14 @@ def load(self, raise_if_loaded: bool = True) -> None:
continue
self._build._add_contract(build_json)

for path, build_json in potential_dependencies:
dependents = self._build.get_dependents(path.stem)
is_dependency = len(set(dependents) & set(contract_list)) > 0
if is_dependency:
self._build._add_contract(build_json)
else:
path.unlink()

interface_hashes = {}
interface_list = self._sources.get_interface_list()
for path in list(self._build_path.glob("interfaces/*.json")):
Expand Down