Ejemplo n.º 1
0
 def _get_organization_metadata_from_registry(self, org_id):
     rez = self._get_organization_registration(org_id)
     metadata_hash = bytesuri_to_hash(rez["orgMetadataURI"])
     metadata = get_from_ipfs_and_checkhash(self._get_ipfs_client(),
                                            metadata_hash)
     metadata = metadata.decode("utf-8")
     return OrganizationMetadata.from_json(json.loads(metadata))
Ejemplo n.º 2
0
 def _get_service_metadata_from_registry(self):
     rez = self._get_service_registration()
     metadata_hash = bytesuri_to_hash(rez["metadataURI"])
     metadata = get_from_ipfs_and_checkhash(self._get_ipfs_client(),
                                            metadata_hash)
     metadata = metadata.decode("utf-8")
     metadata = mpe_service_metadata_from_json(metadata)
     return metadata
Ejemplo n.º 3
0
    def fetch_org_metadata(self, org_id):
        (found, id, metadata_uri, owner, members, service_ids) = self.registry_contract.functions.getOrganizationById(
            bytes(org_id, "utf-8")).call()
        if found is not True:
            raise Exception('Organization with org ID "{}" not found '.format(org_id))

        metadata_hash = bytesuri_to_hash(metadata_uri)
        metadata_json = get_from_ipfs_and_checkhash(self._ipfs_client, metadata_hash)
        org_metadata = json.loads(metadata_json)
        return org_metadata
Ejemplo n.º 4
0
    def fetch_service_metadata(self, org_id, service_id):
        (found, registration_id, metadata_uri) = self.registry_contract.functions.getServiceRegistrationById(
            bytes(org_id, "utf-8"), bytes(service_id, "utf-8")).call()

        if found is not True:
            raise Exception('No service "{}" found in organization "{}"'.format(service_id, org_id))

        metadata_hash = bytesuri_to_hash(metadata_uri)
        metadata_json = get_from_ipfs_and_checkhash(self._ipfs_client, metadata_hash)
        metadata = mpe_service_metadata_from_json(metadata_json)
        return metadata