Skip to content

Commit

Permalink
Merge pull request #1564 from danhper/avoid-removing-dependencies
Browse files Browse the repository at this point in the history
Avoid removing dependencies from the build
  • Loading branch information
iamdefinitelyahuman authored Aug 7, 2022
2 parents c24a8a9 + bba0272 commit f63180e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit f63180e

Please sign in to comment.