def release_package(self, package_name: str, version: str, manifest_uri: str) -> bytes: """ Returns the release id generated by releasing a package on the current registry. Requires ``web3.PM`` to have a registry set. Requires ``web3.eth.defaultAccount`` to be the registry owner. * Parameters: * ``package_name``: Must be a valid package name, matching the given manifest. * ``version``: Must be a valid package version, matching the given manifest. * ``manifest_uri``: Must be a valid content-addressed URI. Currently, only IPFS and Github content-addressed URIs are supported. """ validate_is_supported_manifest_uri(manifest_uri) raw_manifest = to_text(resolve_uri_contents(manifest_uri)) validate_raw_manifest_format(raw_manifest) manifest = json.loads(raw_manifest) validate_manifest_against_schema(manifest) if package_name != manifest["package_name"]: raise ManifestValidationError( f"Provided package name: {package_name} does not match the package name " f"found in the manifest: {manifest['package_name']}.") if version != manifest["version"]: raise ManifestValidationError( f"Provided package version: {version} does not match the package version " f"found in the manifest: {manifest['version']}.") self._validate_set_registry() return self.registry._release(package_name, version, manifest_uri)
def validate_is_supported_manifest_uri(uri): if not is_supported_content_addressed_uri(uri): raise ManifestValidationError( f"URI: {uri} is not a valid content-addressed URI. " "Currently only IPFS and Github content-addressed URIs are supported." )