Skip to content

Commit

Permalink
Fix preview policy from ipfs (#454)
Browse files Browse the repository at this point in the history
Co-authored-by: Stepan Kiryakov <stepan.kiryakov@envisionblockchain.com>
  • Loading branch information
Stepan-Kirjakov and Stepan-Kirjakov authored Feb 15, 2022
1 parent 0c2b118 commit 4959e67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
11 changes: 4 additions & 7 deletions ui-service/src/policy-engine/import-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ importExportAPI.get('/:policyId/export/file', async (req: AuthenticatedRequest,
res.setHeader('Content-disposition', `attachment; filename=${policy.name}`);
res.setHeader('Content-type', 'application/zip');
arcStream.pipe(res);
} catch(e) {
res.status(500).send({code: 500, message: e.message});
} catch (e) {
res.status(500).send({ code: 500, message: e.message });
}
});

Expand Down Expand Up @@ -101,12 +101,9 @@ importExportAPI.post('/import/message/preview', async (req: AuthenticatedRequest
if (!zip) {
throw new Error('file in body is empty');
}

const guardians = new Guardians();

const policyToImport = await PolicyImportExportHelper.parseZipFile(zip);
const schemasIds = findAllEntities(policyToImport.policy.config, 'schema');
// const schemas = await guardians.getSchemaPreview(schemasIds);
// res.status(200).json({ ...policyToImport, schemas });
res.status(200).json(policyToImport);
} catch (error) {
res.status(500).json({ code: 500, message: error.message });
}
Expand Down
12 changes: 9 additions & 3 deletions vc-modules/src/helpers/hedera-mirror-node.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ import axios from "axios";
import { HederaHelper, ISubmitModelMessage } from "..";
import { IPolicySubmitMessage } from "../interfaces/policy-submit-message.interface";
import { ISchemaSubmitMessage } from "../interfaces/schema-submit-message.interface";
import { timeout } from "./utils";

/**
* Hedera mirror node helper
*/
export class HederaMirrorNodeHelper {
public static MAX_TIMEOUT: number = 60000;

/**
* Return message by timestamp (messageId)
* @param {string} timeStamp Message identifier
*
* @returns {any} - Message
*/
@timeout(HederaMirrorNodeHelper.MAX_TIMEOUT)
public static async getTopicMessage(timeStamp: string): Promise<{
timeStamp: string,
topicId: string,
Expand All @@ -31,6 +35,7 @@ export class HederaMirrorNodeHelper {
* @param timeStamp Message identifier
* @returns Message
*/
@timeout(HederaMirrorNodeHelper.MAX_TIMEOUT)
public static async getSchemaTopicMessage(timeStamp: string): Promise<{
timeStamp: string,
topicId: string,
Expand Down Expand Up @@ -66,6 +71,7 @@ export class HederaMirrorNodeHelper {
* @param timeStamp Message identifier
* @returns Message
*/
@timeout(HederaMirrorNodeHelper.MAX_TIMEOUT)
public static async getPolicyTopicMessage(timeStamp: string): Promise<{
timeStamp: string,
topicId: string,
Expand Down Expand Up @@ -116,7 +122,7 @@ export class HederaMirrorNodeHelper {
* @param message Message
* @returns Validation flag
*/
private static validateBasicMessageFields (message: ISubmitModelMessage): boolean {
private static validateBasicMessageFields(message: ISubmitModelMessage): boolean {
if (!message.name) {
return false;
}
Expand All @@ -142,7 +148,7 @@ export class HederaMirrorNodeHelper {
* @param message Policy submit message
* @returns Validation flag
*/
private static validatePolicyMessageFields (message : IPolicySubmitMessage): boolean {
private static validatePolicyMessageFields(message: IPolicySubmitMessage): boolean {
if (!this.validateBasicMessageFields(message)) {
return false;
}
Expand Down Expand Up @@ -172,7 +178,7 @@ export class HederaMirrorNodeHelper {
* @param message Schema submit message
* @returns Validation flag
*/
private static validateSchemaMessageFields (message : ISchemaSubmitMessage): boolean {
private static validateSchemaMessageFields(message: ISchemaSubmitMessage): boolean {
if (!this.validateBasicMessageFields(message)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion vc-modules/src/helpers/hedera-vc-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class VCHelper {
*
* @returns {boolean} - is verified
*/
public async verifyVC(vcDocument: HcsVcDocument<VcSubject> | any) {
public async verifyVC(vcDocument: HcsVcDocument<VcSubject> | any): Promise<boolean> {
let vc: any;
if (vcDocument && typeof vcDocument.toJsonTree === 'function') {
vc = vcDocument.toJsonTree();
Expand Down

0 comments on commit 4959e67

Please sign in to comment.