Skip to content

Commit

Permalink
Created new iRec policy version (#662)
Browse files Browse the repository at this point in the history
* Created new iRec policy version

* Added ability to add SourceAddons to EventBlock

* Fixed status labels

* Fixed error copying empty fields in CalculateBlock

Co-authored-by: artembuslaev <[email protected]>
Co-authored-by: Stepan Kiryakov <[email protected]>
Co-authored-by: prernaadev01 <[email protected]>
  • Loading branch information
4 people authored Apr 1, 2022
1 parent f4986bf commit 1872812
Show file tree
Hide file tree
Showing 33 changed files with 78 additions and 41 deletions.
Binary file added Demo Artifacts/iRec Policy 2.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion Demo Artifacts/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ We are keeping them in the repo as they may be relevant in future releases.
- **Root Authority**: A standard registry, or a Root Authority in our scenario, is an organization that establishes science-based standards for measuring, reporting, and verifying (MRV) ecological benefit claims and issues value in the form of credit for claims that meet the standard set. A standard registry also authorizes validation and verification bodies (VVBs) to collect and process claims based on the established standard. The creation of scientific-based standards for MRV is a rigorous discipline that requires independence from commercial influence in the pursuit of accurate accounting of benefit or emissions claims. A standard registry organization can also maintain a central registry of credits they have issued that can be sold directly via the registry itself or established as reference value on networks, exchanges, or marketplaces.
- **Auditor**: This is a 3rd part who will need to view/audit the entire chain of events; from the establishment of the science-based standards through creation of the credit.

For complete flow documentation, please refer to https://github.com/hashgraph/guardian/blob/main/docs/getting-started/demo-usage-guide.md
For complete flow documentation, please refer to https://docs.hedera.com/guardian/demo-guide/demo-usage-guide
2 changes: 1 addition & 1 deletion api-docs/api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.0
info:
title: "Guardian"
description: "The Guardian is a modular open-source solution that includes best-in-class identity management and decentralized ledger technology (DLT) libraries. At the heart of the Guardian solution is a sophisticated Policy Workflow Engine (PWE) that enables applications to offer a requirements-based tokenization implementation."
version: "1.0.0"
version: "1.2.1"
contact:
name: "API developer"
url: "https://envisionblockchain.com"
Expand Down
2 changes: 1 addition & 1 deletion api-docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api-docs",
"version": "1.0.2",
"version": "1.2.1",
"description": "Swagger Documentation",
"main": "dist/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion api-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
"start": "node dist/index.js",
"test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/ui-service.xml"
},
"version": "1.0.5"
"version": "1.2.1"
}
2 changes: 1 addition & 1 deletion api-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api-tests",
"version": "1.0.2",
"version": "1.2.1",
"description": "API Tests",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion auth-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
"start": "node dist/index.js",
"test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/ui-service.xml"
},
"version": "1.0.5"
"version": "1.2.1"
}
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
"test": "ng test",
"watch": "ng build --watch --configuration development --output-path ../www-data"
},
"version": "1.0.5"
"version": "1.2.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<div class="field">
<div class="field-name">Description</div>
<div class="field-value">{{"test"}}</div>
<div class="field-value">{{policy.description}}</div>
</div>

<div class="field">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, EventEmitter, Input, OnInit, Output, SimpleChanges } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { IconType, Schema, Token } from 'interfaces';
import { Schema, Token } from 'interfaces';
import { IconPreviewDialog } from 'src/app/components/icon-preview-dialog/icon-preview-dialog.component';
import { API_IPFS_GATEWAY_URL } from 'src/app/services/api';
import { IPFSService } from 'src/app/services/ipfs.service';
Expand Down Expand Up @@ -57,7 +57,7 @@ export class ReportItemConfigComponent implements OnInit {
this.block.filters = this.block.filters || [];
this.block.variables = this.block.variables || [];
this.block.visible = block.visible !== false;
this.block.iconType = block.iconType || IconType.COMMON
this.block.iconType = block.iconType;
}

onHide(item: any, prop: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ a[disabled="true"]{
margin: 0 0 25px 0;
padding: 25px 0;
font-size: 20px;
text-transform: capitalize;
/* text-transform: capitalize; */
}

.chain-id span {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<div class="vp-field-value">{{mintDocument.tokenId}}</div>
</div>
<div class="vp-field">
<div class="vp-field-label">Issuer: Name</div>
<div class="vp-field-label">Receipt Name</div>
<div class="vp-field-value" [title]="mintDocument.issuer">{{mintDocument.username}}</div>
</div>
<div class="vp-field">
Expand Down Expand Up @@ -80,7 +80,7 @@
<div class="vp-field-value">{{policyDocument.version}}</div>
</div>
<div class="vp-field">
<div class="vp-field-label">Issuer: Name</div>
<div class="vp-field-label">Issuer Name</div>
<div class="vp-field-value" [title]="policyDocument.issuer">{{policyDocument.username}}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MatDialog } from '@angular/material/dialog';
import { MatIconRegistry } from '@angular/material/icon';
import { DomSanitizer } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import { IconType, IPolicyReport, IReport, IReportItem, ITokenReport, IVC, IVCReport, IVPReport, Schema, SchemaHelper } from 'interfaces';
import { IPolicyReport, IReport, IReportItem, ITokenReport, IVC, IVCReport, IVPReport, Schema, SchemaHelper } from 'interfaces';
import { VCViewerDialog } from 'src/app/schema-engine/vc-dialog/vc-dialog.component';
import { AuditService } from 'src/app/services/audit.service';
import { AuthService } from 'src/app/services/auth.service';
Expand Down Expand Up @@ -152,8 +152,6 @@ export class ReportBlockComponent implements OnInit {
if (this.policyDocument) {
this.documents.push({
type: this.policyDocument.type,
icon: 'format_list_bulleted',
iconType: IconType.COMMON,
title: 'Policy',
description: this.policyDocument.tag,
tag: this.policyDocument.tag,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ChangeDetectorRef, Component, Input, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { IUser } from 'interfaces';
import { PolicyEngineService } from 'src/app/services/policy-engine.service';
import { PolicyHelper } from 'src/app/services/policy-helper.service';
import { ProfileService } from 'src/app/services/profile.service';

/**
* Component for display block of 'requestVcDocument' types.
Expand Down Expand Up @@ -39,9 +41,11 @@ export class RequestDocumentBlockComponent implements OnInit {
needPreset: any;
presetFields: any;
buttonClass: any;
user!: IUser;

constructor(
private policyEngineService: PolicyEngineService,
private profile: ProfileService,
private policyHelper: PolicyHelper,
private fb: FormBuilder,
private dialog: MatDialog,
Expand All @@ -54,7 +58,11 @@ export class RequestDocumentBlockComponent implements OnInit {
if (!this.static) {
this.socket = this.policyEngineService.subscribe(this.onUpdate.bind(this));
}
this.loadData();
this.profile.getProfile()
.subscribe((user: IUser) => {
this.user = user;
this.loadData();
});
(window as any).__requestLast = this;
(window as any).__request = (window as any).__request || {};
(window as any).__request[this.id] = this;
Expand Down Expand Up @@ -119,6 +127,15 @@ export class RequestDocumentBlockComponent implements OnInit {
}
for (let i = 0; i < presetFields.length; i++) {
const f = presetFields[i];
if (f.value === 'username') {
json[f.name] = this.user.username;
continue;
}
if (f.value === 'hederaAccountId') {
json[f.name] = this.user.hederaAccountId;
continue;
}

json[f.name] = cs[f.value];
}
return json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<th mat-header-cell *matHeaderCellDef> Status </th>
<td mat-cell *matCellDef="let element">
<span *ngIf="element.status =='DRAFT'" class="status-draft">Draft</span>
<span *ngIf="element.status =='PUBLISH'" class="status-publish">Publish</span>
<span *ngIf="element.status =='PUBLISH'" class="status-publish">Published</span>
<span *ngIf="element.status =='INVALID'" class="status-invalid">Invalid</span>
</td>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class SchemaFormViewComponent implements OnInit {
value = this.values[item.name];
}

item.value = value;
item.value = value || "";
}
if (!field.isArray && field.isRef) {
item.fields = field.fields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum PlaceholderByFieldType {
Email = "[email protected]",
Number = "123",
URL = "example.com",
String = "example string",
String = "Please enter text here",
IPFS = 'ipfs.io/ipfs/example-hash'
}

Expand Down
2 changes: 1 addition & 1 deletion guardian-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@
"start": "node dist/index.js",
"test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/guardian-service.xml"
},
"version": "1.0.5"
"version": "1.2.1"
}
4 changes: 3 additions & 1 deletion guardian-service/src/policy-engine/blocks/calculate-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export class CalculateContainerBlock {
if (ref.options.outputFields) {
for (let i = 0; i < ref.options.outputFields.length; i++) {
const field = ref.options.outputFields[i];
newJson[field.name] = scope[field.value];
if(scope[field.value]) {
newJson[field.name] = scope[field.value];
}
}
}
newJson.id = json.id;
Expand Down
4 changes: 1 addition & 3 deletions guardian-service/src/policy-engine/blocks/report-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getVCField } from '@helpers/utils';
import { Report } from '@policy-engine/helpers/decorators';
import { PolicyComponentsUtils } from '../policy-components-utils';
import { IPolicyReportBlock } from '@policy-engine/policy-engine.interface';
import { IconType, IPolicyReport, IReport, IReportItem, ITokenReport, IVCReport, IVPReport, SchemaEntity } from 'interfaces';
import { IPolicyReport, IReport, IReportItem, ITokenReport, IVCReport, IVPReport, SchemaEntity } from 'interfaces';
import { BlockActionError } from '@policy-engine/errors';
import { Users } from "@helpers/users";

Expand Down Expand Up @@ -192,8 +192,6 @@ export class ReportBlock {
if (policyCreator) {
const policyCreatorDocument: IReportItem = {
type: 'VC',
icon: 'account_circle',
iconType: IconType.COMMON,
title: 'RootAuthority',
description: 'Account Creation',
visible: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { findOptions, getVCIssuer } from "@helpers/utils";
import { ReportItem } from "@policy-engine/helpers/decorators";
import { PolicyComponentsUtils } from '../policy-components-utils';
import { IPolicyReportItemBlock } from "@policy-engine/policy-engine.interface";
import { IconType, IReportItem } from "interfaces";
import { IReportItem } from "interfaces";
import { BlockActionError } from '@policy-engine/errors';

/**
Expand All @@ -28,7 +28,7 @@ export class ReportItemBlock {
const title = ref.options.title;
const description = ref.options.description;
const visible = ref.options.visible;
const iconType = ref.options.iconType || IconType.COMMON;
const iconType = ref.options.iconType;
const item: IReportItem = {
type: 'VC',
icon: icon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IAuthUser } from '@auth/auth.interface';
import { EventBlock } from '../helpers/decorators/event-block';
import { PolicyValidationResultsContainer } from '@policy-engine/policy-validation-results-container';
import { StateField } from '@policy-engine/helpers/decorators';
import { IPolicyRequestBlock } from '@policy-engine/policy-engine.interface';

@EventBlock({
blockType: 'requestVcDocumentBlock',
Expand Down Expand Up @@ -62,7 +63,7 @@ export class RequestVcDocumentBlock {

async getData(user: IAuthUser): Promise<any> {
const options = PolicyComponentsUtils.GetBlockUniqueOptionsObject(this);
const ref = PolicyComponentsUtils.GetBlockRef(this);
const ref = PolicyComponentsUtils.GetBlockRef<IPolicyRequestBlock>(this);

if (!this.schema) {
const schema = await this.guardians.getSchemaByIRI(ref.options.schema);
Expand All @@ -71,6 +72,9 @@ export class RequestVcDocumentBlock {
if (!this.schema) {
throw new BlockActionError('Waiting for schema', ref.blockType, ref.uuid);
}

const sources = await ref.getSources(user);

return {
id: ref.uuid,
blockType: ref.blockType,
Expand All @@ -79,7 +83,8 @@ export class RequestVcDocumentBlock {
presetFields: options.presetFields,
uiMetaData: options.uiMetaData || {},
hideFields: options.hideFields || [],
active: this.getActive(user)
active: this.getActive(user),
data: sources && sources.length && sources[0] || null,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ export function EventBlock(options: Partial<PolicyBlockDecoratorOptions>) {
return {};
}

protected async getSources(...args): Promise<any[]> {
let data = [];
for (let child of this.children) {
if (child.blockClassName === 'SourceAddon') {
data = data.concat(await child.getFromSource(...args))
}
}
return data;
}
}
}
}
10 changes: 9 additions & 1 deletion guardian-service/src/policy-engine/policy-engine.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,12 @@ export interface IPolicyReportItemBlock extends IPolicyBlock {
getItems(): IPolicyReportItemBlock[];
}

export type AnyBlockType = IPolicyBlock | IPolicyInterfaceBlock | IPolicyContainerBlock | IPolicySourceBlock | IPolicyAddonBlock | IPolicyCalculateBlock | IPolicyCalculateAddon;
export interface IPolicyRequestBlock extends IPolicyBlock {
getData(user: IAuthUser): Promise<any>;

setData(user: IAuthUser, _data: any): Promise<any>;

getSources(user: IAuthUser): Promise<any[]>
}

export type AnyBlockType = IPolicyBlock | IPolicyInterfaceBlock | IPolicyContainerBlock | IPolicySourceBlock | IPolicyAddonBlock | IPolicyCalculateBlock | IPolicyCalculateAddon | IPolicyRequestBlock;
2 changes: 1 addition & 1 deletion interfaces/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"lint": "tslint --project .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.5"
"version": "1.2.1"
}
4 changes: 2 additions & 2 deletions interfaces/src/interface/chain-item.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface IPolicyReport {

export interface IReportItem {
type: string;
icon: string;
icon?: string;
title: string;
description: string;
tag: string;
Expand All @@ -63,7 +63,7 @@ export interface IReportItem {
document: IVCDocument;
documents?: IReportItem[];
visible: boolean,
iconType: IconType
iconType?: IconType
}

export interface IReport {
Expand Down
4 changes: 2 additions & 2 deletions interfaces/src/type/icon.type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum IconType {
COMMON = 'COMMON',
CUSTOM = 'CUSTOM'
COMMON = 'common',
CUSTOM = 'custom'
}
2 changes: 1 addition & 1 deletion ipfs-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
"start": "node dist/index.js",
"test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/ipfs-client.xml"
},
"version": "1.0.5"
"version": "1.2.1"
}
2 changes: 1 addition & 1 deletion logger-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
"lint": "tslint --project .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.5"
"version": "1.2.1"
}
2 changes: 1 addition & 1 deletion logger-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
"lint": "tslint --project .",
"start": "node dist/index.js"
},
"version": "1.0.5"
"version": "1.2.1"
}
2 changes: 1 addition & 1 deletion message-broker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"nodemon": "^2.0.7",
"typescript": "^4.5.5"
},
"version": "1.0.5"
"version": "1.2.1"
}
2 changes: 1 addition & 1 deletion mrv-sender/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
"start": "node dist/index.js",
"debug": "nodemon dist/index.js"
},
"version": "1.0.5"
"version": "1.2.1"
}
2 changes: 1 addition & 1 deletion vc-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
"test:network": "mocha tests/network-tests/**/*.test.js",
"test:stability": "mocha tests/stability.test.js"
},
"version": "1.0.5"
"version": "1.2.1"
}

0 comments on commit 1872812

Please sign in to comment.