Skip to content

Commit

Permalink
add verbosity when pinning assets
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Nov 22, 2019
1 parent c7f3f4a commit c96c728
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion brownie/_cli/ethpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _release(project_path, registry_address, sender):
with project_path.joinpath("ethpm-config.yaml").open() as fp:
project_config = yaml.safe_load(fp)
print("Generating manifest and pinning assets to IPFS...")
manifest, uri = ethpm.create_manifest(project_path, project_config, True)
manifest, uri = ethpm.create_manifest(project_path, project_config, True, False)
if CONFIG["brownie_folder"].joinpath(f"data/accounts/{sender}.json").exists():
account = accounts.load(sender)
else:
Expand Down
14 changes: 11 additions & 3 deletions brownie/project/ethpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from brownie.exceptions import InvalidManifest
from brownie.network.web3 import web3
from brownie.typing import AccountsType, TransactionReceiptType
from brownie.utils import color

from . import compiler

Expand Down Expand Up @@ -372,7 +373,7 @@ def remove_package(project_path: Path, package_name: str, delete_files: bool) ->


def create_manifest(
project_path: Path, package_config: Dict, pin_assets: bool = False
project_path: Path, package_config: Dict, pin_assets: bool = False, silent: bool = True
) -> Tuple[Dict, str]:

"""
Expand All @@ -389,6 +390,9 @@ def create_manifest(

package_config = _remove_empty_fields(package_config)

if pin_assets:
ipfs_backend = InfuraIPFSBackend()

manifest = {
"manifest_version": "2",
"package_name": package_config["package_name"],
Expand Down Expand Up @@ -419,7 +423,9 @@ def create_manifest(
if path.relative_to(project_path).as_posix() in packages_json["sources"]:
continue
if pin_assets:
uri = InfuraIPFSBackend().pin_assets(path)[0]["Hash"]
if not silent:
print(f'Pinning "{color("bright magenta")}{path.name}{color}"...')
uri = ipfs_backend.pin_assets(path)[0]["Hash"]
else:
with path.open("rb") as fp:
uri = generate_file_hash(fp.read())
Expand Down Expand Up @@ -491,10 +497,12 @@ def create_manifest(

uri = None
if pin_assets:
if not silent:
print("Pinning manifest...")
temp_path = Path(tempfile.gettempdir()).joinpath("manifest.json")
with temp_path.open("w") as fp:
json.dump(manifest, fp, sort_keys=True, separators=(",", ":"))
uri = InfuraIPFSBackend().pin_assets(temp_path)[0]["Hash"]
uri = ipfs_backend.pin_assets(temp_path)[0]["Hash"]

return manifest, uri

Expand Down

0 comments on commit c96c728

Please sign in to comment.