Esempio n. 1
0
    def __init__(self, args: Namespace) -> None:
        # Setup IPFS backend
        if "local_ipfs" in args and args.local_ipfs:
            self.ipfs_backend = get_ipfs_backend(args.local_ipfs)
        else:
            self.ipfs_backend = get_ipfs_backend()

        # Setup _ethpm_packages dir
        if "ethpm_dir" in args and args.ethpm_dir:
            self.ethpm_dir = args.ethpm_dir
        elif ETHPM_DIR_ENV_VAR in os.environ:
            self.ethpm_dir = Path(os.environ[ETHPM_DIR_ENV_VAR])
        else:
            self.ethpm_dir = Path.cwd() / ETHPM_PACKAGES_DIR
            if not self.ethpm_dir.is_dir():
                self.ethpm_dir.mkdir()
        validate_ethpm_dir(self.ethpm_dir)

        # Setup w3
        if "chain_id" in args and args.chain_id:
            chain_id = args.chain_id
        else:
            chain_id = 1

        if "keyfile_path" in args and args.keyfile_path:
            import_keyfile(args.keyfile_path)

        if "keyfile_password" in args and args.keyfile_password:
            self.private_key = get_authorized_private_key(
                args.keyfile_password)
        self.w3 = setup_w3(chain_id, self.private_key)

        # Setup xdg ethpm dir
        self.xdg_ethpmcli_root = get_xdg_ethpmcli_root()
        setup_xdg_ethpm_dir(self.xdg_ethpmcli_root, self.w3)

        # Setup projects dir
        if "project_dir" in args and args.project_dir:
            validate_project_directory(args.project_dir)
            self.project_dir = args.project_dir
        else:
            self.project_dir = None

        if "manifest_path" in args and args.manifest_path:
            if not args.manifest_path.is_file():
                raise ConfigurationError(
                    f"Provided manifest path: {args.manifest_path} is not a file."
                )
            self.manifest_path = args.manifest_path
        else:
            self.manifest_path = None
Esempio n. 2
0
def build_pinned_sources(
        contract_types: Iterable[str], solc_output: Dict[str, Any],
        contracts_dir: Path) -> Iterable[Callable[..., Manifest]]:
    ipfs_backend = get_ipfs_backend()
    return (b.pin_source(ctype, solc_output, ipfs_backend, contracts_dir)
            for ctype in contract_types)
Esempio n. 3
0
def ipfs_backend():
    return get_ipfs_backend()