async def addServiceContexted(self, ipfsop, service: dict, endpoint=None, publish=True, context='IpfsObjectEndpoint'): sid = service.get('id') assert isinstance(sid, str) didEx = didExplode(sid) assert didEx is not None if await self.searchServiceById(sid) is not None: raise IPIDServiceException( 'An IP service already exists with this ID') srvCtx = await ipfsop.ldContext(context) if srvCtx: service['serviceEndpoint'] = {'@context': srvCtx} if isinstance(endpoint, dict): service['serviceEndpoint'].update(endpoint) self._document['service'].append(service) await self.updateDocument(self.doc, publish=publish) await self.sServicesChanged.emit() return self._serviceInst(service)
def __init__(self, dagNode: dict, ipid): self._srv = dagNode self._didEx = didExplode(self.id) self._ipid = ipid self.sChanged = AsyncSignal() self.sChanged.connectTo(self.onChanged)
def data(self, column, role): if column == 0: handle = self.peerItem.ctx.spaceHandle exploded = didExplode(self.service.id) if exploded['path']: return posixIpfsPath.join(handle.human, exploded['path'].lstrip('/')) if column == 1: return str(self.service.id) return QVariant(None)
def data(self, column, role): if column == 0: handle = self.peerItem.ctx.spaceHandle exploded = didExplode(self.sObject['id']) if exploded and exploded['path']: return posixIpfsPath.join(handle.short, exploded['path'].lstrip('/')) if column == 1: return self.sObject['id'] return QVariant(None)
async def addServiceRaw(self, service: dict, publish=True): sid = service.get('id') assert isinstance(sid, str) didEx = didExplode(sid) assert didEx is not None if await self.searchServiceById(sid) is not None: raise IPIDServiceException( 'An IP service already exists with this ID') self._document['service'].append(service) await self.updateDocument(self.doc, publish=publish) await self.sServicesChanged.emit()
async def addServiceContexted(self, ipfsop, service: dict, endpoint=None, publish=True, contextInline=False, context='IpfsObjectEndpoint'): sid = service.get('id') assert isinstance(sid, str) didEx = didExplode(sid) assert didEx is not None if await self.searchServiceById(sid) is not None: raise IPIDServiceException( 'An IP service already exists with this ID') if contextInline is True: service['serviceEndpoint'] = { '@context': await ipfsop.ldContext(context) } else: service['serviceEndpoint'] = { '@context': f'ips://galacteek.ld/{context}', '@type': context } if isinstance(endpoint, dict): service['serviceEndpoint'].update(endpoint) self._document['service'].append(service) await self.updateDocument(self.doc, publish=publish) await self.sServicesChanged.emit() sInst = self._serviceInst(service) await self.servicePropagate(sInst) return sInst
def ipnsKey(self): exploded = didExplode(self.did) if exploded and exploded['method'] == 'ipid': return exploded['id']
def ipidExtract(text): # Extract the id from "did:ipid:<id>" exploded = didExplode(text) if exploded: return exploded['id']