Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions guardian-service/src/api/helpers/profile-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export async function createSystemSchemas({
return null;
} catch (error) {
logger.error(error, ['GUARDIAN_SERVICE'], logId);
return null;
throw error;
}
}

Expand Down Expand Up @@ -465,8 +465,7 @@ export async function createUserProfile({
await dataBaseServer.update(DidDocumentCollection, null, didRow);
} catch (error) {
logger.error(error, ['GUARDIAN_SERVICE'], logId);
// didRow.status = DidDocumentStatus.FAILED;
// await new DataBaseHelper(DidDocumentCollection).update(didRow);
throw error;
}
notifier.completeStep(STEP_PUBLISH_DID);
// ------------------------
Expand Down Expand Up @@ -499,11 +498,13 @@ export async function createUserProfile({
notifier.startStep(STEP_PUBLISH_VC);
logger.info('Create VC Document', ['GUARDIAN_SERVICE'], logId);

if (!schemaObject) {
throw new Error(`System schema for entity "${entity}" not found.`);
}

let credentialSubject: any = { ...vcDocument };
credentialSubject.id = userDID;
if (schemaObject) {
credentialSubject = SchemaHelper.updateObjectContext(schemaObject, credentialSubject);
}
credentialSubject = SchemaHelper.updateObjectContext(schemaObject, credentialSubject);

const vcObject = await vcHelper.createVerifiableCredential(credentialSubject, currentDidDocument, null, null);
const vcMessage = new VCMessage(MessageAction.CreateVC);
Expand Down
8 changes: 2 additions & 6 deletions queue-service/src/queue-service/queue-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,14 @@ export class QueueService extends NatsService {
} else {
task.isError = true;
task.errorReason = data.error;
if (!task.interception) {
await this.completeTaskInQueue(data.id, data.data, data.error);
}
await this.completeTaskInQueue(data.id, data.data, data.error);
}
} else {
task.attempt = 0;
task.isError = true;
task.errorReason = data.error;

if (!task.interception) {
await this.completeTaskInQueue(data.id, data.data, data.error);
}
await this.completeTaskInQueue(data.id, data.data, data.error);
}

await dataBaseServer.save(TaskEntity, task);
Expand Down
12 changes: 12 additions & 0 deletions worker-service/src/api/ipfs-client-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ export class IpfsClientClass {
}
}

/**
* Guard against an uninitialized client.
* @private
*/
private assertClientReady(): void {
if (!this.client) {
throw new Error(`IPFS client not initialized (provider="${this.IPFS_PROVIDER}"); check IPFS_PROVIDER and credentials.`);
}
}

/**
* Create ipfs client
* @private
Expand Down Expand Up @@ -121,6 +131,7 @@ export class IpfsClientClass {
* @param beforeCallback
*/
public async addFile(file: Buffer): Promise<string> {
this.assertClientReady();
let cid: string;
switch (this.IPFS_PROVIDER) {
case IpfsProvider.WEB3STORAGE: {
Expand Down Expand Up @@ -152,6 +163,7 @@ export class IpfsClientClass {
* @param cid
*/
public async deleteCid(cid: string): Promise<boolean> {
this.assertClientReady();
switch (this.IPFS_PROVIDER) {
case IpfsProvider.LOCAL: {
await this.client.pin.rm(cid);
Expand Down
Loading