def resolve_manifest_uri(uri: URI, ipfs: BaseIPFSBackend) -> ResolvedManifestURI: github_backend = GithubOverHTTPSBackend() if github_backend.can_resolve_uri(uri): raw_manifest = github_backend.fetch_uri_contents(uri) resolved_content_hash = parse.urlparse(uri).path.split("/")[-1] elif ipfs.can_resolve_uri(uri): raw_manifest = ipfs.fetch_uri_contents(uri) resolved_content_hash = extract_ipfs_path_from_uri(uri) else: raise UriNotSupportedError( f"{uri} is not supported. Currently ethPM CLI only supports " "IPFS and Github blob manifest uris.") return ResolvedManifestURI(raw_manifest, resolved_content_hash)
def test_github_over_https_backend_fetch_uri_contents(uri, owned_contract, w3): # these tests may occassionally fail CI as a result of their network requests backend = GithubOverHTTPSBackend() assert backend.base_uri == GITHUB_API_AUTHORITY # integration with Package.from_uri owned_package = Package.from_uri(uri, w3) assert owned_package.name == "owned"