From d6ef1dffc542603b7e202f5fdd0740e6e7fe1fa2 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Mon, 13 Jun 2022 13:23:22 -0700 Subject: [PATCH 01/19] feat: adding packagemeta to config and project manager --- src/ape/managers/config.py | 4 ++++ src/ape/managers/project/manager.py | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/ape/managers/config.py b/src/ape/managers/config.py index 17e21036b0..ee544e6925 100644 --- a/src/ape/managers/config.py +++ b/src/ape/managers/config.py @@ -13,6 +13,7 @@ if TYPE_CHECKING: from .project import ProjectManager +from ethpm_types import PackageMeta CONFIG_FILE_NAME = "ape-config.yaml" DEFAULT_TRANSACTION_ACCEPTANCE_TIMEOUT = 120 @@ -86,6 +87,9 @@ class ConfigManager(BaseInterfaceModel): version: str = "" """The project's version.""" + meta: PackageMeta = PackageMeta + """The project's meta package""" + contracts_folder: Path = None # type: ignore """ The path to the project's ``contracts/`` directory diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 152531e930..39647bcc48 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -2,7 +2,7 @@ from pathlib import Path from typing import Dict, List, Optional, Type, Union -from ethpm_types import Compiler, ContractType, PackageManifest +from ethpm_types import Compiler, ContractType, PackageManifest, PackageMeta from ape.api import DependencyAPI, ProjectAPI from ape.contracts import ContractContainer, ContractNamespace @@ -447,16 +447,18 @@ def _get_contract(self, name: str) -> Optional[ContractContainer]: return None - # @property - # def meta(self) -> PackageMeta: - # return PackageMeta(**self.config_manager.get_config("ethpm").serialize()) + @property + def meta(self) -> PackageMeta: + return PackageMeta(**self.config_manager.get_config("ethpm").serialize()) + + def publish_manifest(self): + manifest = self.manifest.dict() + if not manifest["name"]: + raise ProjectError("Need name to release manifest") + if not manifest["version"]: + raise ProjectError("Need version to release manifest") + breakpoint() - # def publish_manifest(self): - # manifest = self.manifest.dict() - # if not manifest["name"]: - # raise ProjectError("Need name to release manifest") - # if not manifest["version"]: - # raise ProjectError("Need version to release manifest") # TODO: Clean up manifest and minify it # TODO: Publish sources to IPFS and replace with CIDs # TODO: Publish to IPFS From 06de7726e7d318c96f551f64a3f019b438bd6ae1 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:08:28 -0700 Subject: [PATCH 02/19] docs: rework meta docstring Co-authored-by: Juliya Smith --- src/ape/managers/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ape/managers/config.py b/src/ape/managers/config.py index ee544e6925..d3b22acaa6 100644 --- a/src/ape/managers/config.py +++ b/src/ape/managers/config.py @@ -88,7 +88,7 @@ class ConfigManager(BaseInterfaceModel): """The project's version.""" meta: PackageMeta = PackageMeta - """The project's meta package""" + """Metadata about the project.""" contracts_folder: Path = None # type: ignore """ From 67ccc3a11db191c3a9eaf94acf94b25e3a561b5b Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:10:38 -0700 Subject: [PATCH 03/19] refactor: adds error for incorrect configuration of metadata Co-authored-by: Juliya Smith --- src/ape/managers/project/manager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 39647bcc48..25a60d9fc3 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -449,7 +449,11 @@ def _get_contract(self, name: str) -> Optional[ContractContainer]: @property def meta(self) -> PackageMeta: - return PackageMeta(**self.config_manager.get_config("ethpm").serialize()) + meta = self.config_manager.get_config("meta") + try: + return PackageMeta(**meta.serialize()) + except Exception as e: + raise ConfigError(f"Incorrect configuration of package metadata:\n{meta}") from e def publish_manifest(self): manifest = self.manifest.dict() From 93be7329e10384a4fcf44bf6948c427d24226581 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:11:17 -0700 Subject: [PATCH 04/19] fix: breakpoint Co-authored-by: Juliya Smith --- src/ape/managers/project/manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 25a60d9fc3..55615f9ee2 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -461,7 +461,6 @@ def publish_manifest(self): raise ProjectError("Need name to release manifest") if not manifest["version"]: raise ProjectError("Need version to release manifest") - breakpoint() # TODO: Clean up manifest and minify it # TODO: Publish sources to IPFS and replace with CIDs From cd76db4de6049c70b92f807b73fc3c5df1892ae3 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:12:10 -0700 Subject: [PATCH 05/19] fix: PackageMeta must be called Co-authored-by: Juliya Smith --- src/ape/managers/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ape/managers/config.py b/src/ape/managers/config.py index d3b22acaa6..3e7c316dbc 100644 --- a/src/ape/managers/config.py +++ b/src/ape/managers/config.py @@ -87,7 +87,7 @@ class ConfigManager(BaseInterfaceModel): version: str = "" """The project's version.""" - meta: PackageMeta = PackageMeta + meta: PackageMeta = PackageMeta() """Metadata about the project.""" contracts_folder: Path = None # type: ignore From 2c9526a1db6b2b978020b1adc4f73a2928d5652a Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:14:30 -0700 Subject: [PATCH 06/19] docs: removed unnecessary TODO --- src/ape/managers/project/manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 55615f9ee2..745becd18c 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -462,6 +462,5 @@ def publish_manifest(self): if not manifest["version"]: raise ProjectError("Need version to release manifest") - # TODO: Clean up manifest and minify it # TODO: Publish sources to IPFS and replace with CIDs # TODO: Publish to IPFS From 9e6539cb39bea350156a8c32ef2bc1e4026e4e51 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:21:37 -0700 Subject: [PATCH 07/19] fix: import configerror from ape.exceptions --- src/ape/managers/project/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 745becd18c..3787b0ecad 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -6,7 +6,7 @@ from ape.api import DependencyAPI, ProjectAPI from ape.contracts import ContractContainer, ContractNamespace -from ape.exceptions import ProjectError +from ape.exceptions import ProjectError, ConfigError from ape.managers.base import BaseManager from ape.managers.project.types import ApeProject, BrownieProject From 099d610cf73b8854c709a6d197292643d7e3b3d2 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:32:16 -0700 Subject: [PATCH 08/19] refactor: commented out publish_manifest method --- src/ape/managers/project/manager.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 3787b0ecad..909f8a914f 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -455,12 +455,12 @@ def meta(self) -> PackageMeta: except Exception as e: raise ConfigError(f"Incorrect configuration of package metadata:\n{meta}") from e - def publish_manifest(self): - manifest = self.manifest.dict() - if not manifest["name"]: - raise ProjectError("Need name to release manifest") - if not manifest["version"]: - raise ProjectError("Need version to release manifest") + # def publish_manifest(self): + # manifest = self.manifest.dict() + # if not manifest["name"]: + # raise ProjectError("Need name to release manifest") + # if not manifest["version"]: + # raise ProjectError("Need version to release manifest") # TODO: Publish sources to IPFS and replace with CIDs # TODO: Publish to IPFS From 3e47528badbab8c3601714bd9bf31b55a8c11bc0 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:33:27 -0700 Subject: [PATCH 09/19] style: linting --- src/ape/managers/project/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 909f8a914f..eeb20109fb 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -6,7 +6,7 @@ from ape.api import DependencyAPI, ProjectAPI from ape.contracts import ContractContainer, ContractNamespace -from ape.exceptions import ProjectError, ConfigError +from ape.exceptions import ConfigError, ProjectError from ape.managers.base import BaseManager from ape.managers.project.types import ApeProject, BrownieProject From e892b367e0a8a711fa5a5f0e23d603044e96e4f8 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Tue, 14 Jun 2022 10:03:53 -0700 Subject: [PATCH 10/19] docs: added docstring for packagemeta method --- src/ape/managers/project/manager.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index eeb20109fb..887984565b 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -449,6 +449,10 @@ def _get_contract(self, name: str) -> Optional[ContractContainer]: @property def meta(self) -> PackageMeta: + """ + Populate package manifest with metadata as per EIP + https://eips.ethereum.org/EIPS/eip-2678#the-package-meta-object + """ meta = self.config_manager.get_config("meta") try: return PackageMeta(**meta.serialize()) From ed41979d862e01fedcbc6a7f8bef897d278ff236 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Tue, 14 Jun 2022 11:55:16 -0700 Subject: [PATCH 11/19] fix: add meta to plugin config manager --- src/ape/managers/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ape/managers/config.py b/src/ape/managers/config.py index 3e7c316dbc..8f64be6a94 100644 --- a/src/ape/managers/config.py +++ b/src/ape/managers/config.py @@ -135,6 +135,7 @@ def _plugin_configs(self) -> Dict[str, PluginConfig]: self.name = cache.get("name", "") self.version = cache.get("version", "") self.default_ecosystem = cache.get("default_ecosystem", "ethereum") + self.meta = cache.get("meta", "") self.dependencies = cache.get("dependencies", []) self.deployments = cache.get("deployments", {}) self.contracts_folder = cache.get("contracts_folder", self.PROJECT_FOLDER / "contracts") @@ -151,6 +152,7 @@ def _plugin_configs(self) -> Dict[str, PluginConfig]: user_config = load_config(config_file) if config_file.exists() else {} self.name = configs["name"] = user_config.pop("name", "") self.version = configs["version"] = user_config.pop("version", "") + self.meta = configs["meta"] = user_config.pop("meta", "") self.default_ecosystem = configs["default_ecosystem"] = user_config.pop( "default_ecosystem", "ethereum" ) From 0b68bf1c4a476f49588eb7f0dc7be5d52e24dbcb Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:22:26 -0700 Subject: [PATCH 12/19] fix: project now has meta --- src/ape/managers/config.py | 7 +++++-- src/ape/managers/project/manager.py | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ape/managers/config.py b/src/ape/managers/config.py index 8f64be6a94..069fe5d22f 100644 --- a/src/ape/managers/config.py +++ b/src/ape/managers/config.py @@ -135,7 +135,7 @@ def _plugin_configs(self) -> Dict[str, PluginConfig]: self.name = cache.get("name", "") self.version = cache.get("version", "") self.default_ecosystem = cache.get("default_ecosystem", "ethereum") - self.meta = cache.get("meta", "") + self.meta = PackageMeta.parse_obj(cache.get("meta", {})) self.dependencies = cache.get("dependencies", []) self.deployments = cache.get("deployments", {}) self.contracts_folder = cache.get("contracts_folder", self.PROJECT_FOLDER / "contracts") @@ -152,7 +152,10 @@ def _plugin_configs(self) -> Dict[str, PluginConfig]: user_config = load_config(config_file) if config_file.exists() else {} self.name = configs["name"] = user_config.pop("name", "") self.version = configs["version"] = user_config.pop("version", "") - self.meta = configs["meta"] = user_config.pop("meta", "") + meta_dict = user_config.pop("meta", {}) + meta_obj = PackageMeta.parse_obj(meta_dict) + configs["meta"] = meta_dict + self.meta = meta_obj self.default_ecosystem = configs["default_ecosystem"] = user_config.pop( "default_ecosystem", "ethereum" ) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 887984565b..749b4f6a77 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -448,14 +448,13 @@ def _get_contract(self, name: str) -> Optional[ContractContainer]: return None @property - def meta(self) -> PackageMeta: + def meta(self) -> PackageMeta: #type: ignore """ Populate package manifest with metadata as per EIP https://eips.ethereum.org/EIPS/eip-2678#the-package-meta-object """ - meta = self.config_manager.get_config("meta") try: - return PackageMeta(**meta.serialize()) + return self.config_manager.meta except Exception as e: raise ConfigError(f"Incorrect configuration of package metadata:\n{meta}") from e From 218fe1cce9051ac682099354a1746312704824ae Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:38:13 -0700 Subject: [PATCH 13/19] style: linting --- src/ape/managers/project/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 749b4f6a77..fb133739b0 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -448,7 +448,7 @@ def _get_contract(self, name: str) -> Optional[ContractContainer]: return None @property - def meta(self) -> PackageMeta: #type: ignore + def meta(self) -> PackageMeta: # type: ignore """ Populate package manifest with metadata as per EIP https://eips.ethereum.org/EIPS/eip-2678#the-package-meta-object From 6a06e2380ea2f60b6bcaf07a490428b0fb46544e Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:48:46 -0700 Subject: [PATCH 14/19] docs: type ignore and docstring for meta --- src/ape/managers/project/manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index fb133739b0..8090333207 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -448,13 +448,14 @@ def _get_contract(self, name: str) -> Optional[ContractContainer]: return None @property - def meta(self) -> PackageMeta: # type: ignore + def meta(self) -> PackageMeta: """ - Populate package manifest with metadata as per EIP + Metadata about the active project as per EIP https://eips.ethereum.org/EIPS/eip-2678#the-package-meta-object + Use when publishing your package manifest. """ try: - return self.config_manager.meta + return self.config_manager.meta # type: ignore except Exception as e: raise ConfigError(f"Incorrect configuration of package metadata:\n{meta}") from e From d8537b230ca4474484b77f3afb193a89f7314eb5 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:49:26 -0700 Subject: [PATCH 15/19] style: linting --- src/ape/managers/project/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 8090333207..4f4f96a755 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -450,7 +450,7 @@ def _get_contract(self, name: str) -> Optional[ContractContainer]: @property def meta(self) -> PackageMeta: """ - Metadata about the active project as per EIP + Metadata about the active project as per EIP https://eips.ethereum.org/EIPS/eip-2678#the-package-meta-object Use when publishing your package manifest. """ From 230b1b501ec196e81f94eebe3d3fcfec0735105a Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:53:53 -0700 Subject: [PATCH 16/19] test: added test for meta --- tests/functional/test_project.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/functional/test_project.py b/tests/functional/test_project.py index e984f3d6fe..ee65a9b693 100644 --- a/tests/functional/test_project.py +++ b/tests/functional/test_project.py @@ -3,6 +3,7 @@ from typing import Dict import pytest +from ethpm_types import PackageMeta from ethpm_types.manifest import PackageManifest @@ -45,6 +46,12 @@ def test_extract_manifest(dependency_config, project_manager): assert type(manifest) == PackageManifest +def test_meta(dependency_config, project_manager): + # NOTE: Only setting dependency_config to ensure existence of project. + meta = project_manager.meta + assert type(meta) == PackageMeta + + def test_dependency_with_longer_contracts_folder( dependency_config, config, mocker, project_manager ): From 863083d16d61485c33e9ab5a3ece67153766b994 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Tue, 14 Jun 2022 16:20:36 -0700 Subject: [PATCH 17/19] test: test meta with temp_config fixture --- tests/functional/test_project.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/functional/test_project.py b/tests/functional/test_project.py index ee65a9b693..d2cc3c0f26 100644 --- a/tests/functional/test_project.py +++ b/tests/functional/test_project.py @@ -46,10 +46,10 @@ def test_extract_manifest(dependency_config, project_manager): assert type(manifest) == PackageManifest -def test_meta(dependency_config, project_manager): - # NOTE: Only setting dependency_config to ensure existence of project. - meta = project_manager.meta - assert type(meta) == PackageMeta +def test_meta(temp_config, project_manager): + meta_config = {"meta": {"authors": ["Test Testerson"]}} + with temp_config(meta_config): + assert project_manager.meta.authors == ["Test Testerson"] def test_dependency_with_longer_contracts_folder( From f97e1d230a849fe23bac6ae1e65737f0e7d93507 Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Tue, 14 Jun 2022 16:28:26 -0700 Subject: [PATCH 18/19] test: filled out extra meta fields in test temp_config --- tests/functional/test_project.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/functional/test_project.py b/tests/functional/test_project.py index d2cc3c0f26..b43b66969d 100644 --- a/tests/functional/test_project.py +++ b/tests/functional/test_project.py @@ -3,7 +3,6 @@ from typing import Dict import pytest -from ethpm_types import PackageMeta from ethpm_types.manifest import PackageManifest @@ -47,9 +46,21 @@ def test_extract_manifest(dependency_config, project_manager): def test_meta(temp_config, project_manager): - meta_config = {"meta": {"authors": ["Test Testerson"]}} + meta_config = { + "meta": { + "authors": ["Test Testerson"], + "license": "MIT", + "description": "test", + "keywords": ["testing"], + "links": {"apeworx.io": "https://apeworx.io"}, + } + } with temp_config(meta_config): assert project_manager.meta.authors == ["Test Testerson"] + assert project_manager.meta.license == "MIT" + assert project_manager.meta.description == "test" + assert project_manager.meta.keywords == ["testing"] + assert "https://apeworx.io" in project_manager.meta.links["apeworx.io"] def test_dependency_with_longer_contracts_folder( From 552ce431355f3d2f9382fd01ba394d833820460a Mon Sep 17 00:00:00 2001 From: Doggo <27985126+sabotagebeats@users.noreply.github.com> Date: Wed, 15 Jun 2022 15:45:30 -0700 Subject: [PATCH 19/19] fix: removed exception for meta --- src/ape/managers/project/manager.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index 4f4f96a755..bb6f9e1723 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -6,7 +6,7 @@ from ape.api import DependencyAPI, ProjectAPI from ape.contracts import ContractContainer, ContractNamespace -from ape.exceptions import ConfigError, ProjectError +from ape.exceptions import ProjectError from ape.managers.base import BaseManager from ape.managers.project.types import ApeProject, BrownieProject @@ -454,10 +454,7 @@ def meta(self) -> PackageMeta: https://eips.ethereum.org/EIPS/eip-2678#the-package-meta-object Use when publishing your package manifest. """ - try: - return self.config_manager.meta # type: ignore - except Exception as e: - raise ConfigError(f"Incorrect configuration of package metadata:\n{meta}") from e + return self.config_manager.meta # type: ignore # def publish_manifest(self): # manifest = self.manifest.dict()