diff --git a/api-gateway/src/api/service/analytics.ts b/api-gateway/src/api/service/analytics.ts index 945858d653..3320e1ee93 100644 --- a/api-gateway/src/api/service/analytics.ts +++ b/api-gateway/src/api/service/analytics.ts @@ -1,4 +1,4 @@ -import { Body, Controller, HttpCode, HttpException, HttpStatus, Post, Query } from '@nestjs/common'; +import { Body, Controller, Get, HttpCode, HttpException, HttpStatus, Post, Query } from '@nestjs/common'; import { ApiInternalServerErrorResponse, ApiBody, ApiOkResponse, ApiOperation, ApiTags, ApiExtraModels, ApiQuery } from '@nestjs/swagger'; import { EntityOwner, Permissions } from '@guardian/interfaces'; import { FilterDocumentsDTO, FilterModulesDTO, FilterPoliciesDTO, FilterSchemasDTO, FilterSearchPoliciesDTO, InternalServerErrorDTO, CompareDocumentsDTO, CompareModulesDTO, ComparePoliciesDTO, CompareSchemasDTO, SearchPoliciesDTO, FilterToolsDTO, CompareToolsDTO, FilterSearchBlocksDTO, SearchBlocksDTO, Examples } from '#middlewares'; @@ -947,4 +947,35 @@ export class AnalyticsApi { await InternalException(error, this.logger); } } + + /** + * Get Indexer availability + */ + @Get('/checkIndexer') + @Auth( + Permissions.POLICIES_POLICY_EXECUTE, + ) + @ApiOperation({ + summary: 'Get Indexer Availability.', + description: 'Returns Indexer Availability (true/false).', + }) + @ApiOkResponse({ + description: 'Successful operation.', + type: Boolean, + }) + @ApiInternalServerErrorResponse({ + description: 'Internal server error.', + type: InternalServerErrorDTO + }) + @HttpCode(HttpStatus.OK) + async checkIndexerAvailability( + @AuthUser() user: IAuthUser + ): Promise { + const guardians = new Guardians(); + try { + return await guardians.getIndexerAvailability(); + } catch (error) { + await InternalException(error, this.logger); + } + } } diff --git a/api-gateway/src/api/service/contract.ts b/api-gateway/src/api/service/contract.ts index f5824c87bf..2fad5fae62 100644 --- a/api-gateway/src/api/service/contract.ts +++ b/api-gateway/src/api/service/contract.ts @@ -1719,5 +1719,57 @@ export class ContractsApi { await InternalException(error, this.logger); } } + + /** + * Get a list of all retire vcs from Indexer + */ + @Get('/retireIndexer') + @Auth( + Permissions.CONTRACTS_DOCUMENT_READ, + // UserRole.STANDARD_REGISTRY, + // UserRole.USER + ) + @ApiOperation({ + summary: 'Return a list of all retire vcs from Indexer.', + description: 'Returns all retire vcs from Indexer.', + }) + @ApiQuery({ + name: 'contractTopicId', + type: String, + description: 'The topic id of contract', + required: true, + example: '0.0.0000000', + }) + @ApiOkResponse({ + description: 'Successful operation.', + isArray: true, + headers: pageHeader, + schema: { + type: 'array', + items: { + type: 'object' + } + } + }) + @ApiInternalServerErrorResponse({ + description: 'Internal server error.', + type: InternalServerErrorDTO, + }) + @ApiExtraModels(RetirePoolDTO, InternalServerErrorDTO) + @HttpCode(HttpStatus.OK) + async getRetireVCsFromIndexer( + @AuthUser() user: IAuthUser, + @Response() res: any, + @Query('contractTopicId') contractTopicId: string, + ): Promise { + try { + const owner = new EntityOwner(user); + const guardians = new Guardians(); + const [vcs, count] = await guardians.getRetireVCsFromIndexer(owner, contractTopicId); + return res.header('X-Total-Count', count).send(vcs); + } catch (error) { + await InternalException(error, this.logger); + } + } //#endregion } diff --git a/api-gateway/src/helpers/guardians.ts b/api-gateway/src/helpers/guardians.ts index 9d38d248e2..7eba0430bb 100644 --- a/api-gateway/src/helpers/guardians.ts +++ b/api-gateway/src/helpers/guardians.ts @@ -11,12 +11,14 @@ import { IContract, IDidObject, IOwner, + IRetirementMessage, IRetirePool, IRetireRequest, ISchema, IToken, ITokenInfo, IUser, + IVC, IVCDocument, IVPDocument, MessageAPI, @@ -1852,6 +1854,22 @@ export class Guardians extends NatsService { }); } + /** + * Get retire VCs from Indexer + * @param owner + * @param contractTopicId + * @returns Retire VCs from Indexer and count + */ + public async getRetireVCsFromIndexer( + owner: IOwner, + contractTopicId: string + ): Promise<[IRetirementMessage[], number]> { + return await this.sendMessage(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, { + owner, + contractTopicId + }); + } + //#endregion /** @@ -3204,6 +3222,14 @@ export class Guardians extends NatsService { return await this.sendMessage(MessageAPI.PREVIEW_SCHEMA_RULE_FILE, { zip, owner }); } + + /** + * Get Indexer availability + */ + public async getIndexerAvailability(): Promise { + return await this.sendMessage(MessageAPI.GET_INDEXER_AVAILABILITY, {}); + } + /** * Create policy label * diff --git a/common/src/database-modules/database-server.ts b/common/src/database-modules/database-server.ts index 116de7d023..54d78a54c1 100644 --- a/common/src/database-modules/database-server.ts +++ b/common/src/database-modules/database-server.ts @@ -2065,7 +2065,8 @@ export class DatabaseServer extends AbstractDatabaseServer { wasTransferNeeded: boolean, transferSerials: number[], transferAmount: number, - tokenIds: string[] + tokenIds: string[], + target: string ] > { const mintRequests = await this.getMintRequests({ @@ -2100,7 +2101,7 @@ export class DatabaseServer extends AbstractDatabaseServer { if (vpDocument.tokenId) { tokenIds.add(vpDocument.tokenId); } - + const target = mintRequests?.[0]?.target; for (const mintRequest of mintRequests) { if (mintRequest.error) { errors.push(mintRequest.error); @@ -2172,6 +2173,7 @@ export class DatabaseServer extends AbstractDatabaseServer { transferSerials, transferAmount, [...tokenIds], + target, ]; } diff --git a/common/src/interfaces/database-server.ts b/common/src/interfaces/database-server.ts index eb9d39f2ea..6484492865 100644 --- a/common/src/interfaces/database-server.ts +++ b/common/src/interfaces/database-server.ts @@ -1408,7 +1408,8 @@ export abstract class AbstractDatabaseServer { wasTransferNeeded: boolean, transferSerials: number[], transferAmount: number, - tokenIds: string[] + tokenIds: string[], + target: string, ] > diff --git a/frontend/src/app/modules/contract-engine/dialogs/user-retire-pools-dialog/user-retire-pools-dialog.component.ts b/frontend/src/app/modules/contract-engine/dialogs/user-retire-pools-dialog/user-retire-pools-dialog.component.ts index c3bd659a15..d5538a3b3d 100644 --- a/frontend/src/app/modules/contract-engine/dialogs/user-retire-pools-dialog/user-retire-pools-dialog.component.ts +++ b/frontend/src/app/modules/contract-engine/dialogs/user-retire-pools-dialog/user-retire-pools-dialog.component.ts @@ -53,6 +53,7 @@ export class UserRetirePoolsDialogComponent implements OnInit { loadPools() { this.loading = true; + this.contractService .getRetirePools({ pageIndex: this.pageIndex, diff --git a/frontend/src/app/modules/policy-engine/policy-engine.module.ts b/frontend/src/app/modules/policy-engine/policy-engine.module.ts index 57bd9f8251..0c063cf91f 100644 --- a/frontend/src/app/modules/policy-engine/policy-engine.module.ts +++ b/frontend/src/app/modules/policy-engine/policy-engine.module.ts @@ -1,5 +1,5 @@ import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; +import { CommonModule, DatePipe } from '@angular/common'; import { MaterialModule } from 'src/app/modules/common/material.module'; import { FormsModule } from '@angular/forms'; import { DragDropModule } from '@angular/cdk/drag-drop'; @@ -295,6 +295,7 @@ import { RequestDocumentBlockDialog } from './policy-viewer/blocks/request-docum WizardService, DialogService, PolicyProgressService, + DatePipe, { provide: CONFIGURATION_ERRORS, useValue: new Map() diff --git a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/messages-report-block/messages-report-block.component.html b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/messages-report-block/messages-report-block.component.html index 0bd6a7bad9..aa56e2dcba 100644 --- a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/messages-report-block/messages-report-block.component.html +++ b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/messages-report-block/messages-report-block.component.html @@ -1,778 +1,779 @@
- -
-
+ +
+
-
+
+
+
+ +
+
+
+
+
Please wait while your report is calculated
+
This may take a few minutes ...
+
-
-
-
-
-
-
Please wait while your report is calculated
-
This may take a few minutes ...
-
+
+
+ An unexpected error occurred.
- -
-
- An unexpected error occurred. -
-
- -
+
+
+
-
-
-
-
+
+ +
+
HASH/Message ID: - - -
-
- + + +
+
+ +
+ +
+
+
+
Selected document:
+
{{ target }}
+
+ Clear +
+
+
+ +
- -
-
-
-
Selected document:
-
{{ target }}
-
- Clear -
-
-
- -
+
+
+
+ Policy Message Catalog
-
-
-
- Policy Message Catalog +
+ +
+
+
+ + {{ getTopicHeader(topic.message) }}
-
- -
-
-
- - {{ getTopicHeader(topic.message) }} -
-
-
- {{ getTopicName(topic) }} -
-
{{ topic.topicId }}
-
-
-
-
-
+
+
+ {{ getTopicName(topic) }} +
+
{{ topic.topicId }}
+
-
-
- Policy Events -
-
-
-
-
-
-
- - -
- - Create policy -
-
-
{{ message.name }}
-
{{ message.owner }}
-
-
- -
- - Publish policy -
-
-
{{ message.name }}
-
Version: {{ message.version }}
-
-
- - -
- - Registration -
-
-
- {{ message.__role }} -
-
{{ message.did }}
-
-
- - -
- - {{ message.__status }} -
-
-
- {{ message.__schemaLabel }} -
-
{{ message.__userName }}
-
-
- - -
- - Mint token -
-
-
{{ message.__tokenName }} -
-
{{ message.__userName }}
-
-
- - -
- - Mint confirmation -
-
-
- Amount: {{ message.__amount }} {{ message.__token.symbol }} -
-
{{ message.__userName }}
-
-
- - -
- - Roles & Groups -
-
-
- Role: {{ message.role }} -
-
- Group: {{ message.group }} -
-
{{ message.__issuer }}
-
-
-
-
+
+ +
+
+
+
+ Policy Events +
+
+
+
+
+
+
+ + +
+ + Create policy +
+
+
{{ message.name }}
+
{{ message.owner }}
+
+
+ +
+ + Publish policy +
+
+
{{ message.name }}
+
Version: {{ message.version }}
+
+
+ + +
+ + Registration +
+
+
+ {{ message.__role }}
-
-
- {{ message.__timestamp }} -
+
{{ message.did }}
+
+ + + +
+ + {{ message.__status }} +
+
+
+ {{ message.__schemaLabel }}
-
+
{{ message.__userName }}
+
+
+ + +
+ + Mint token +
+
+
{{ message.__tokenName }} +
+
{{ message.__userName }}
+
+
+ + +
+ + Mint confirmation +
+
+
+ Amount: {{ message.__amount }} {{ message.__token.symbol }} +
+
{{ message.__userName }}
+
+
+ + +
+ + Roles & Groups +
+
+
+ Role: {{ message.role }} +
+
+ Group: {{ message.group }} +
+
{{ message.__issuer }}
+
+
+
-
-
- {{ selected.topicId }} - +
+
+
+ {{ message.__timestamp }} +
+
+
+
+
+
+ {{ selected.topicId }} + - {{ selected.id }} -
- -
+ {{ selected.id }} +
+ +
+
+
+ +
+ + Policy +
+ +
+ +
+
Policy name:
+
{{ selected.name }}
+
+
+
Policy description:
+
{{ selected.description }}
+
+
+
Policy creator:
+
{{ selected.owner }}
+
+ +
+ +
+
Topic ID:
+
+ {{ selected.topicId }} + +
+
+
+
Message ID:
+
+ {{ selected.id }} + +
+
+
+
Sender:
+
+ {{ selected.payer }} + +
+
+
+ + +
+ + Instance policy +
+ +
+ +
+
Policy name:
+
{{ selected.name }}
+
+
+
Policy description:
+
{{ selected.description }}
+
+
+
Policy creator:
+
{{ selected.owner }}
+
+
+
Policy version:
+
{{ selected.version }}
+
+ +
+ +
+
Topic ID:
+
+ {{ selected.topicId }} + +
+
+
+
Message ID:
+
+ {{ selected.id }} + +
+
+
+
Sender:
+
+ {{ selected.payer }} + +
+
+
+ + +
+ + User registration +
+ +
+ +
+
DID:
+
{{ selected.did }}
+
+
+
DID document:
+
+ Open document +
+
+ +
+ +
+
Topic ID:
+
+ {{ selected.topicId }} + +
+
+
+
Message ID:
+
+ {{ selected.id }} + +
+
+
+
Sender:
+
+ {{ selected.payer }} + +
+
+
+ + +
+ + Roles & Groups +
+ +
+ +
+
DID:
+
{{ selected.__user.did }}
+
+ +
+
Role:
+
{{ selected.role }}
+
+ +
+
Groups:
+
{{ selected.group }}
+
+ +
+
Document artifact:
+
+ Open document +
+
+ +
+ +
+
Topic ID:
+
+ {{ selected.topicId }} + +
+
+
+
Message ID:
+
+ {{ selected.id }} + +
+
+
+
Sender:
+
+ {{ selected.payer }} + +
+
+
+ + +
+ + Document +
+ +
+ +
+
Schema:
+
{{ selected.__schemaLabel }}
+
+
+
Document status:
+
{{ selected.__status }}
+
+
+
Document artifact:
+
+ Open document +
+
+ + +
+
+
DID:
+
{{ selected.__user.did }}
+
+
+
Group:
+
{{ selected.__user.group }}
+
+
+
Role:
+
{{ selected.__user.role }}
+
+
+ +
+
+
Topic ID:
+
+ {{ selected.topicId }} + +
+
+
+
Message ID:
+
+ {{ selected.id }} + +
+
+
+
Sender:
+
+ {{ selected.payer }} + +
+
+ + +
+
+
+
+ + {{ relationship.name }} +
-
- -
- - Policy -
- -
- -
-
Policy name:
-
{{ selected.name }}
-
-
-
Policy description:
-
{{ selected.description }}
-
-
-
Policy creator:
-
{{ selected.owner }}
-
- -
- -
-
Topic ID:
-
- {{ selected.topicId }} - -
-
-
-
Message ID:
-
- {{ selected.id }} - -
-
-
-
Sender:
-
- {{ selected.payer }} - -
-
-
- - -
- - Instance policy -
- -
- -
-
Policy name:
-
{{ selected.name }}
-
-
-
Policy description:
-
{{ selected.description }}
-
-
-
Policy creator:
-
{{ selected.owner }}
-
-
-
Policy version:
-
{{ selected.version }}
-
- -
- -
-
Topic ID:
-
- {{ selected.topicId }} - -
-
-
-
Message ID:
-
- {{ selected.id }} - -
-
-
-
Sender:
-
- {{ selected.payer }} - -
-
-
- - -
- - User registration -
- -
- -
-
DID:
-
{{ selected.did }}
-
-
-
DID document:
-
- Open document -
-
- -
- -
-
Topic ID:
-
- {{ selected.topicId }} - -
-
-
-
Message ID:
-
- {{ selected.id }} - -
-
-
-
Sender:
-
- {{ selected.payer }} - -
-
-
- - -
- - Roles & Groups -
- -
- -
-
DID:
-
{{ selected.__user.did }}
-
- -
-
Role:
-
{{ selected.role }}
-
- -
-
Groups:
-
{{ selected.group }}
-
- -
-
Document artifact:
-
- Open document -
-
- -
- -
-
Topic ID:
-
- {{ selected.topicId }} - -
-
-
-
Message ID:
-
- {{ selected.id }} - -
-
-
-
Sender:
-
- {{ selected.payer }} - -
-
-
- - -
- - Document -
- -
- -
-
Schema:
-
{{ selected.__schemaLabel }}
-
-
-
Document status:
-
{{ selected.__status }}
-
-
-
Document artifact:
-
- Open document -
-
- - -
-
-
DID:
-
{{ selected.__user.did }}
-
-
-
Group:
-
{{ selected.__user.group }}
-
-
-
Role:
-
{{ selected.__user.role }}
-
-
- -
-
-
Topic ID:
-
- {{ selected.topicId }} - -
-
-
-
Message ID:
-
- {{ selected.id }} - -
-
-
-
Sender:
-
- {{ selected.payer }} - -
-
- - -
-
-
-
- - {{ relationship.name }} -
-
-
-
-
- - -
- - Mint token -
- - -
- -
-
Token name:
-
{{ selected.__token.name }}
-
- -
-
Token ID:
-
{{ selected.__token.tokenId }}
-
- -
-
Amount:
-
{{ selected.__amount }}
-
-
- -
- -
-
Document artifact:
-
- Open document -
-
- - -
-
-
DID:
-
{{ selected.__user.did }}
-
-
-
Group:
-
{{ selected.__user.group }}
-
-
-
Role:
-
{{ selected.__user.role }}
-
-
- -
- -
-
Topic ID:
-
- {{ selected.topicId }} - -
-
-
-
Message ID:
-
- {{ selected.id }} - -
-
-
-
Sender:
-
- {{ selected.payer }} - -
-
- - -
-
-
-
- - {{ relationship.name }} -
-
-
-
-
- - -
- - Mint confirmation -
- -
- -
-
Documents:
-
- -
-
- - -
-
-
Token name:
-
{{ selected.__token.name }}
-
-
-
Token ID:
-
{{ selected.__token.tokenId }}
-
-
-
Amount:
-
{{ selected.__amount }}
-
-
- - -
-
-
DID:
-
{{ selected.__user.did }}
-
-
-
Group:
-
{{ selected.__user.group }}
-
-
-
Role:
-
{{ selected.__user.role }}
-
-
- -
-
-
Topic ID:
-
- {{ selected.topicId }} - -
-
-
-
Message ID:
-
- {{ selected.id }} - -
-
-
-
Sender:
-
- {{ selected.payer }} - -
-
- - -
-
-
-
- - {{ relationship.name }} -
-
-
-
-
- - -
- - Catalog -
- -
- -
-
Topic name:
-
{{ selected.name }}
-
-
-
Topic description:
-
{{ selected.description }}
-
-
-
Topic type:
-
- {{ getTopicHeader(selected) }} catalog -
-
-
-
Topic creator:
-
{{ selected.owner }}
-
- - -
- -
-
Policy name:
-
{{ selected.__rationale.name }}
-
-
-
Policy description:
-
{{ selected.__rationale.description }}
-
-
- - -
- -
-
Policy name:
-
{{ selected.__rationale.name }}
-
-
-
Policy description:
-
{{ selected.__rationale.description }}
-
-
-
Policy version:
-
{{ selected.__rationale.version }}
-
-
- -
- -
-
Topic ID:
-
- {{ selected.topicId }} - -
-
-
-
Message ID:
-
- {{ selected.id }} - -
-
-
-
Sender:
-
- {{ selected.payer }} - -
-
-
+
+ + + + +
+ + Mint token +
+ + +
+ +
+
Token name:
+
{{ selected.__token.name }}
+
+ +
+
Token ID:
+
{{ selected.__token.tokenId }}
+
+ +
+
Amount:
+
{{ selected.__amount }}
+
+
+ +
+ +
+
Document artifact:
+
+ Open document +
+
+ + +
+
+
DID:
+
{{ selected.__user.did }}
+
+
+
Group:
+
{{ selected.__user.group }}
+
+
+
Role:
+
{{ selected.__user.role }}
+
+
+ +
+ +
+
Topic ID:
+
+ {{ selected.topicId }} + +
+
+
+
Message ID:
+
+ {{ selected.id }} + +
+
+
+
Sender:
+
+ {{ selected.payer }} + +
+
+ + +
+
+
+
+ + {{ relationship.name }} +
+
+
+
+
+ + +
+ + Mint confirmation +
+ +
+ +
+
Documents:
+
+ +
+
+ + +
+
+
Token name:
+
{{ selected.__token.name }}
+
+
+
Token ID:
+
{{ selected.__token.tokenId }}
+
+
+
Amount:
+
{{ selected.__amount }}
+
+
+ + +
+
+
DID:
+
{{ selected.__user.did }}
+
+
+
Group:
+
{{ selected.__user.group }}
+
+
+
Role:
+
{{ selected.__user.role }}
+
+
+ +
+
+
Topic ID:
+
+ {{ selected.topicId }} + +
+
+
+
Message ID:
+
+ {{ selected.id }} + +
+
+
+
Sender:
+
+ {{ selected.payer }} + +
+
+ + +
+
+
+
+ + {{ relationship.name }} +
+
+
+
+ + +
+ + Catalog +
+ +
+ +
+
Topic name:
+
{{ selected.name }}
+
+
+
Topic description:
+
{{ selected.description }}
+
+
+
Topic type:
+
+ {{ getTopicHeader(selected) }} catalog +
+
+
+
Topic creator:
+
{{ selected.owner }}
+
+ + +
+ +
+
Policy name:
+
{{ selected.__rationale.name }}
+
+
+
Policy description:
+
{{ selected.__rationale.description }}
+
+
+ + +
+ +
+
Policy name:
+
{{ selected.__rationale.name }}
+
+
+
Policy description:
+
{{ selected.__rationale.description }}
+
+
+
Policy version:
+
{{ selected.__rationale.version }}
+
+
+ +
+ +
+
Topic ID:
+
+ {{ selected.topicId }} + +
+
+
+
Message ID:
+
+ {{ selected.id }} + +
+
+
+
Sender:
+
+ {{ selected.payer }} + +
+
+
+
diff --git a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/messages-report-block/messages-report-block.component.ts b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/messages-report-block/messages-report-block.component.ts index 8a98b43c61..a9c4754ed7 100644 --- a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/messages-report-block/messages-report-block.component.ts +++ b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/messages-report-block/messages-report-block.component.ts @@ -1,13 +1,13 @@ -import {Component, ElementRef, HostListener, Input, OnInit} from '@angular/core'; -import {UntypedFormBuilder, Validators} from '@angular/forms'; -import {DomSanitizer} from '@angular/platform-browser'; +import { HttpErrorResponse } from '@angular/common/http'; +import { Component, ElementRef, HostListener, Input, OnInit } from '@angular/core'; +import { UntypedFormBuilder, Validators } from '@angular/forms'; +import { DomSanitizer } from '@angular/platform-browser'; import moment from 'moment'; -import {DialogService} from 'primeng/dynamicdialog'; -import {VCViewerDialog} from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; -import {PolicyEngineService} from 'src/app/services/policy-engine.service'; -import {PolicyHelper} from 'src/app/services/policy-helper.service'; -import {WebSocketService} from 'src/app/services/web-socket.service'; -import {HttpErrorResponse} from '@angular/common/http'; +import { DialogService } from 'primeng/dynamicdialog'; +import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; +import { PolicyEngineService } from 'src/app/services/policy-engine.service'; +import { PolicyHelper } from 'src/app/services/policy-helper.service'; +import { WebSocketService } from 'src/app/services/web-socket.service'; /** * Dashboard Type @@ -18,11 +18,10 @@ enum DashboardType { } class LineContainer { - public readonly elementId1: string; - public readonly elementId2: string; - private container1: HTMLElement | null; private container2: HTMLElement | null; + public readonly elementId1: string; + public readonly elementId2: string; constructor( elementId1: string, @@ -72,19 +71,19 @@ class LineContainer { } class Line { + private readonly offset: number; + private _parent: HTMLElement | null; + private _container: LineContainer | null; + private readonly color1 = 'rgba(30, 130, 250, 0.8)'; + private readonly color2 = 'rgba(255, 152, 0, 0.9)'; public readonly elementId1: string; public readonly elementId2: string; - private readonly offset: number; public line: any; public anchor1: any; public anchor2: any; public leaderLine: Element | null; public leaderAnchor1: Element | null; public leaderAnchor2: Element | null; - private _parent: HTMLElement | null; - private _container: LineContainer | null; - private readonly color1 = 'rgba(30, 130, 250, 0.8)'; - private readonly color2 = 'rgba(255, 152, 0, 0.9)'; constructor( elementId1: string, @@ -185,32 +184,52 @@ class Line { * Component for display block of 'messagesReportBlock' types. */ @Component({ - selector: 'app-messages-report-block', - templateUrl: './messages-report-block.component.html', - styleUrls: ['./messages-report-block.component.scss'] -}) + selector: 'app-messages-report-block', + templateUrl: './messages-report-block.component.html', + styleUrls: ['./messages-report-block.component.scss'] + }) export class MessagesReportBlockComponent implements OnInit { + private _topics1!: any[]; + private _topics2!: any[]; + private _messages1!: any[]; + private _messages2!: any[]; + private _gridTemplateRows1!: string; + private _gridTemplateRows2!: string; + private _gridTemplateColumns1!: string; + private _gridTemplateColumns2!: string; + private lineContainer = new LineContainer( + 'leader-line-container-1', 'leader-line-container-2' + ); + private lines!: Line[] | null; @Input('id') id!: string; @Input('policyId') policyId!: string; @Input('static') static!: any; - public isActive = false; public loading: boolean = true; public socket: any; public content: string | null = null; public report!: any; public target!: any; - public dashboardType = DashboardType.Simplified; public status!: any; public schemas!: any[]; public tokens!: any[]; public roles!: any[]; - public selected: any; + public searchForm = this.fb.group({ + value: ['', Validators.required] + }); - private _topics1!: any[]; - private _topics2!: any[]; + constructor( + private element: ElementRef, + private fb: UntypedFormBuilder, + private policyEngineService: PolicyEngineService, + private wsService: WebSocketService, + private policyHelper: PolicyHelper, + private dialogService: DialogService, + private sanitizer: DomSanitizer + ) { + } public get topics(): any[] { if (this.dashboardType === DashboardType.Advanced) { @@ -220,9 +239,6 @@ export class MessagesReportBlockComponent implements OnInit { } } - private _messages1!: any[]; - private _messages2!: any[]; - public get messages(): any[] { if (this.dashboardType === DashboardType.Advanced) { return this._messages1; @@ -231,9 +247,6 @@ export class MessagesReportBlockComponent implements OnInit { } } - private _gridTemplateRows1!: string; - private _gridTemplateRows2!: string; - public get gridTemplateRows(): string { if (this.dashboardType === DashboardType.Advanced) { return this._gridTemplateRows1; @@ -242,9 +255,6 @@ export class MessagesReportBlockComponent implements OnInit { } } - private _gridTemplateColumns1!: string; - private _gridTemplateColumns2!: string; - public get gridTemplateColumns(): string { if (this.dashboardType === DashboardType.Advanced) { return this._gridTemplateColumns1; @@ -253,47 +263,6 @@ export class MessagesReportBlockComponent implements OnInit { } } - public searchForm = this.fb.group({ - value: ['', Validators.required], - }); - - private lineContainer = new LineContainer( - 'leader-line-container-1', 'leader-line-container-2' - ); - private lines!: Line[] | null; - - constructor( - private element: ElementRef, - private fb: UntypedFormBuilder, - private policyEngineService: PolicyEngineService, - private wsService: WebSocketService, - private policyHelper: PolicyHelper, - private dialogService: DialogService, - private sanitizer: DomSanitizer - ) { - } - - public ngOnInit(): void { - if (!this.static) { - this.socket = this.wsService.blockSubscribe(this.onUpdate.bind(this)); - } - this.onResize(); - this.loadData(); - } - - public ngOnDestroy(): void { - if (this.socket) { - this.socket.unsubscribe(); - } - this.removeLines(); - } - - public onUpdate(blocks: string[]): void { - if (Array.isArray(blocks) && blocks.includes(this.id)) { - this.loadData(); - } - } - private loadData() { this.loading = true; if (this.static) { @@ -705,6 +674,120 @@ export class MessagesReportBlockComponent implements OnInit { return documents; } + private getRelationship(messages: any[], id: string): any { + for (const message of messages) { + if (message.id === id) { + return message; + } + } + return null; + } + + private ifTopicMessage(message: any): boolean { + return message.type === 'Topic'; + } + + private ifPolicyMessage(message: any): boolean { + return message.type === 'Policy'; + } + + private ifInstanceMessage(message: any): boolean { + return message.type === 'Instance-Policy'; + } + + private ifDIDMessage(message: any): boolean { + return message.type === 'DID-Document'; + } + + private ifVCMessage(message: any): boolean { + return message.type === 'VC-Document' && message.__schemaName !== 'MintToken'; + } + + private ifMintMessage(message: any): boolean { + return message.type === 'VC-Document' && message.__schemaName === 'MintToken'; + } + + private ifVPMessage(message: any): boolean { + return message.type === 'VP-Document'; + } + + private ifRoleMessage(message: any): boolean { + return message.type === 'Role-Document'; + } + + private removeLines() { + if (this.lines) { + for (const item of this.lines) { + item.remove(); + } + this.lines = null; + } + } + + private renderLines(messages: any[]) { + LeaderLine.positionByWindowResize = false; + const container = this.lineContainer.render(); + if (!container) { + return; + } + this.lines = []; + for (const message of messages) { + if (message.__relationships) { + const relationships = message.__relationships.filter((r: any) => r.visible); + const offset = 90 / (relationships.length + 1); + for (let index = 0; index < relationships.length; index++) { + const relationship = relationships[index]; + const line = new Line(relationship.id, message.id, (offset * (index + 1))); + line.render(container); + this.lines.push(line); + } + } + } + for (const item of this.lines) { + item.select(this.selected && ( + this.selected.id === item.elementId1 || + this.selected.id === item.elementId2 + )); + } + } + + private update() { + const container = this.lineContainer.render(); + if (!container) { + return; + } + if (!this.lines) { + return; + } + for (const item of this.lines) { + item.select(this.selected && ( + this.selected.id === item.elementId1 || + this.selected.id === item.elementId2 + )); + } + } + + public ngOnInit(): void { + if (!this.static) { + this.socket = this.wsService.blockSubscribe(this.onUpdate.bind(this)); + } + this.onResize(); + this.loadData(); + } + + public ngOnDestroy(): void { + if (this.socket) { + this.socket.unsubscribe(); + } + this.removeLines(); + } + + public onUpdate(blocks: string[]): void { + if (Array.isArray(blocks) && blocks.includes(this.id)) { + this.loadData(); + } + } + public onSelect(message: any) { this.selected = message; this.update(); @@ -825,100 +908,6 @@ export class MessagesReportBlockComponent implements OnInit { } } - private getRelationship(messages: any[], id: string): any { - for (const message of messages) { - if (message.id === id) { - return message; - } - } - return null; - } - - - private ifTopicMessage(message: any): boolean { - return message.type === 'Topic'; - } - - private ifPolicyMessage(message: any): boolean { - return message.type === 'Policy'; - } - - private ifInstanceMessage(message: any): boolean { - return message.type === 'Instance-Policy'; - } - - private ifDIDMessage(message: any): boolean { - return message.type === 'DID-Document'; - } - - private ifVCMessage(message: any): boolean { - return message.type === 'VC-Document' && message.__schemaName !== 'MintToken'; - } - - private ifMintMessage(message: any): boolean { - return message.type === 'VC-Document' && message.__schemaName === 'MintToken'; - } - - private ifVPMessage(message: any): boolean { - return message.type === 'VP-Document'; - } - - private ifRoleMessage(message: any): boolean { - return message.type === 'Role-Document'; - } - - private removeLines() { - if (this.lines) { - for (const item of this.lines) { - item.remove(); - } - this.lines = null; - } - } - - private renderLines(messages: any[]) { - LeaderLine.positionByWindowResize = false; - const container = this.lineContainer.render(); - if (!container) { - return; - } - this.lines = []; - for (const message of messages) { - if (message.__relationships) { - const relationships = message.__relationships.filter((r: any) => r.visible); - const offset = 90 / (relationships.length + 1); - for (let index = 0; index < relationships.length; index++) { - const relationship = relationships[index]; - const line = new Line(relationship.id, message.id, (offset * (index + 1))); - line.render(container); - this.lines.push(line); - } - } - } - for (const item of this.lines) { - item.select(this.selected && ( - this.selected.id === item.elementId1 || - this.selected.id === item.elementId2 - )); - } - } - - private update() { - const container = this.lineContainer.render(); - if (!container) { - return; - } - if (!this.lines) { - return; - } - for (const item of this.lines) { - item.select(this.selected && ( - this.selected.id === item.elementId1 || - this.selected.id === item.elementId2 - )); - } - } - @HostListener('window:resize', ['$event']) onResize() { const container = this.element?.nativeElement?.children[0]; diff --git a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.html b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.html index 82ab842d18..737b057fdb 100644 --- a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.html +++ b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.html @@ -1,324 +1,324 @@
-
-
Trust Chain
-
-
-
- - -
-
-
+
+
Trust Chain
+
+
+
+ + +
+
+
-
- Can't find document with HASH: {{ this.hash }} +
+ Can't find document with HASH: {{ this.hash }} +
+ +
+
+
+
+

Verifiable Presentation

+ + + +
+
+ +
+

HASH

+

{{ item.vpDocument.hash }}

+
+
-
-
-
-
-

Verifiable Presentation

- - - -
-
- -
-

HASH

-

{{ item.vpDocument.hash }}

-
-
-
+
+
+ + +
+

HASH

+

{{ item.vcDocument.hash }}

+
+
+
-
-
- - -
-

HASH

-

{{ item.vcDocument.hash }}

-
-
-
+
+
+

Token & Issuer

+ + +
+
+
+
Token
+
+ {{ item.mintDocument.tokenId }} +
+
+
+
Receipt Name
+
+ {{ item.mintDocument.username }} +
+
+
+
Token amount
+
+ {{ item.mintDocument.amount }} / {{ item.mintDocument.expected }} minted +
+
+
+
Token transfer
+
+ {{ item.mintDocument.transferAmount }} / {{ item.mintDocument.expected }} transferred +
+
+
+
Mint date
+
+ {{ item.mintDocument.date }} +
+
+
+
-
-
-

Token & Issuer

- - +
+
+
+

Primary Impacts

+
+
+
+
+
+
+
+ +
+ {{ item.label }}
-
-
-
Token
-
- {{ item.mintDocument.tokenId }} -
-
-
-
Receipt Name
-
- {{ item.mintDocument.username }} -
-
-
-
Token amount
-
- {{ item.mintDocument.amount }} / {{ item.mintDocument.expected }} minted -
-
-
-
Token transfer
-
- {{ item.mintDocument.transferAmount }} / {{ item.mintDocument.expected }} transferred -
-
-
-
Mint date
-
- {{ item.mintDocument.date }} -
-
+ -
- -
-
-
-

Primary Impacts

-
-
-
-
-
-
-
- -
- {{ item.label }} -
-
- VC File -
-
-
+
- {{ item.description }} -
-
- {{ item.amount }} - {{ item.unit }} -
-
-
-
-
-
+ {{ item.description }} +
+
+ {{ item.amount }} + {{ item.unit }} +
-
-
-

Secondary Impacts

-
-
-
-
-
-
-
- -
- {{ item.label }} -
-
- VC File -
-
-
+

Secondary Impacts

+
+
+
+
+
+
+
+ +
+ {{ item.label }} +
+
+ VC File +
+
+
- {{ item.description }} -
-
- {{ item.amount }} - {{ item.unit }} -
-
-
-
-
-
+ {{ item.description }} +
+
+ {{ item.amount }} + {{ item.unit }} +
+
+
+
+
+
-
-
- This Carbon Offset Claim has met all the requirements as - issued in the policy secured to this token. -
-
-
-
- Verified Signature: -
-
- {{ item.vpDocument.document.document?.proof?.jws }} -
-
-
-
- Verified Signature: -
-
- {{ item.vcDocument.document.document?.proof?.jws }} -
-
-
-
+
+
+ This Carbon Offset Claim has met all the requirements as + issued in the policy secured to this token. +
+
+
+
+ Verified Signature: +
+
+ {{ item.vpDocument.document.document?.proof?.jws }} +
+
+
+
+ Verified Signature: +
+
+ {{ item.vcDocument.document.document?.proof?.jws }} +
+
+
+
-
-
-
-

Policy Overview

- - -
-
-
-
Policy Name
-
- {{ policyDocument.name }} -
-
-
-
Description
-
- {{ policyDocument.description }} -
-
-
-
Version
-
- {{ policyDocument.version }} -
-
-
-
Issuer Name
-
- {{ policyDocument.username }} -
-
-
-
+
+
+
+

Policy Overview

+ + +
+
+
+
Policy Name
+
+ {{ policyDocument.name }} +
+
+
+
Description
+
+ {{ policyDocument.description }} +
+
+
+
Version
+
+ {{ policyDocument.version }} +
+
+
Issuer Name
+
+ {{ policyDocument.username }} +
+
+
+
+
-
-
- - -
-
- -
- +
+ + +
+
+ +
+ -
-
+
-
+ + class="pi pi-sitemap item-relationships-icon" + > -
1, @@ -356,124 +356,124 @@

Policy Overview

'single-multiple-document': item.document.length === 1 }" - class="chain-item item-type-{{item.type}}" - > -
- - - - - {{ item.title }} -
-
+
+ + + + + {{ item.title }} +
+
- - Revoked with reason: "{{ document.document.comment }}" -
-
- {{ item.description }} -
-
-
- Parties: -
-
-
- {{ document.username }} -
-
-
- -
- VC File -
-
+ + Revoked with reason: "{{ document.document.comment }}" +
+
+ {{ item.description }} +
+
+
+ Parties: +
+
+
+ {{ document.username }} +
+
+
+ +
+ VC File +
+
- - {{ item.activeDocumentIndex }} in {{ item.document.length }} - -
-
-
- - -
+ + {{ item.activeDocumentIndex }} in {{ item.document.length }} + +
+
+
+
+ +
-
-
- {{ item.title }} -
-
- -
- Documents Not Found -
-
-
-
-
-
-
-
-
- - +
+
+ {{ item.title }} +
+
+ +
+ Documents Not Found +
+
+
+
-
+ +
+
+ +
+
+
+
-
+
-
+
diff --git a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.scss b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.scss index 3115f358c7..da15d88cae 100644 --- a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.scss +++ b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.scss @@ -122,14 +122,14 @@ a[disabled="true"] { height: 25px; } -.display-chain {} +.display-chain { +} .container { display: flex; } -.container>i, -.container>svg { +.container>mat-icon { font-size: 50px; flex: 0 0 80px; align-self: center; @@ -165,8 +165,8 @@ a[disabled="true"] { } .chain-item { - margin: 6px 23px; - padding: 22px 42px; + margin: 6px 8px; + padding: 16px; /* display: flex; flex-direction: column; align-content: center; @@ -175,8 +175,8 @@ a[disabled="true"] { display: inline-block; box-sizing: border-box; - width: 493px; - height: 230px; + width: 282px; + height: 190px; background: #ffffff 0% 0% no-repeat padding-box; box-shadow: 0px 3px 6px #00000029; border-radius: 8px; @@ -209,14 +209,18 @@ a[disabled="true"] { .chain-document { position: absolute; - right: 42px; - top: 23px; + right: 16px; + top: 16px; font-family: Inter; font-size: 16px; color: #0b73f8; font-weight: bold; padding: 0px 0px 0px 10px; background: #fff; + + .p-button { + padding: 6px 16px; + } } .chain-document a { @@ -236,18 +240,21 @@ a[disabled="true"] { } .chain-title { - font-family: Inter; - font-size: 18px; - color: #707070; + margin-top: 8px; display: flex; align-items: center; grid-gap: 15px; gap: 15px; font-weight: bold; + + font-family: Inter; + font-size: 12px; + font-weight: 600; + line-height: 14px; + color: #23252E; } -.chain-title i, -.chain-title svg { +.chain-title mat-icon { font-size: 30px; color: #000; position: relative; @@ -256,11 +263,16 @@ a[disabled="true"] { .chain-id { white-space: normal; - border-bottom: 1px solid rgb(112 112 112 / 64%); - margin: 0 0 25px 0; - padding: 25px 0; + border-bottom: 1px solid #E1E7EF; + margin: 0 0 16px 0; + padding: 16px 0; + font-family: Inter; - font-size: 20px; + font-size: 14px; + font-weight: 400; + line-height: 16px; + text-align: left; + /* text-transform: capitalize; */ } @@ -281,8 +293,7 @@ a[disabled="true"] { height: 170px; } -.empty-documents-description i, -.empty-documents-description svg { +.empty-documents-description mat-icon { font-size: 115px; height: 115px; width: 115px; @@ -342,8 +353,7 @@ a.go-back-link { padding-right: 28px; } -a.go-back-link i, -a.go-back-link svg { +a.go-back-link mat-icon { color: #707070; position: relative; top: -3px; @@ -355,8 +365,7 @@ a.go-back-link svg { padding: 45px; } -.header i, -.header svg { +.header mat-icon { color: #00d048; font-size: 24px; vertical-align: bottom; @@ -453,18 +462,21 @@ a.open-vp { .parties-label { font-family: Inter; - font-size: 16px; - color: #707070; - padding: 3px 0; + font-size: 12px; + font-weight: 600; + line-height: 16px; + text-align: left; + color: #23252E; } .parties-value, .nested-documents-value { font-family: Inter; - font-size: 20px; + font-size: 14px; + font-weight: 700; + line-height: 16px; + text-align: left; color: #0c77ff; - font-weight: bold; - line-height: 25px; } .parties, @@ -555,16 +567,18 @@ a.open-vp { position: absolute; right: 42px; bottom: 12px; - font-family: Inter; - font-size: 18px; color: #707070; - font-weight: bold; display: flex; align-items: center; + + font-family: Inter; + font-size: 12px; + font-weight: 500; + line-height: 14px; + color: #23252E; } -.multiple-documents-count i, -.multiple-documents-count svg { +.multiple-documents-count mat-icon { cursor: pointer; } @@ -640,8 +654,7 @@ a.open-vp { border: 1px solid var(--grey-grey-3, #E1E7EF); } -.card-item[main="true"] i, -.card-item[main="true"] svg { +.card-item[main="true"] mat-icon { color: #00a100; } @@ -660,8 +673,7 @@ a.open-vp { line-height: 14px; } -.card-icon i, -.card-icon svg { +.card-icon mat-icon { position: absolute; top: -3px; left: -3px; @@ -771,3 +783,119 @@ h3 { row-gap: 32px; column-gap: 16px } + +.item-type-RETIRE { + .chain-top-block { + padding-bottom: 14px; + margin-top: 8px; + margin-bottom: 8px; + border-bottom: 1px solid #E1E7EF; + } + + .chain-title { + margin-top: 0; + } + + &.multiple-tokens { + margin: 6px 16px 6px 8px; + width: 450px; + height: 182px; + } +} + +.retirements-container { + position: relative; + display: flex; + + .chain-item.item-type-retire-group { + border: 1px solid var(--grey-grey-6, #848FA9); + } + + .retirement-group-icon { + align-self: center; + color: var(--color-grey-4, #848FA9); + } + + .multiple-documents-count { + bottom: auto; + + .mat-icon { + color: var(--color-grey-5, #AAB7C4); + } + } +} + +.retire-block { + .chain-title { + margin-top: 0; + padding-bottom: 8px; + margin-bottom: 8px; + border-bottom: 1px solid #E1E7EF; + } +} + +.retire-multiple-card-1 { + position: absolute; + top: -4px; + right: -4px; +} + +.retire-multiple-card-2 { + position: absolute; + top: -8px; + right: -8px; +} + +.retire-multiple-tokens { + display: flex; + justify-content: space-between; +} + +.retire-info { + p { + margin-bottom: 8px; + font-family: Inter; + font-size: 12px; + font-weight: 500; + line-height: 14px; + color: #848FA9; + + span { + margin-left: 8px; + font-family: Inter; + font-size: 12px; + font-weight: 500; + line-height: 14px; + color: #000000; + } + } + + &.second-token { + p { + text-align: left; + } + } +} + +.retire-no-indexer-info { + display: flex; + padding: 8px; + gap: 8px; + border-radius: 8px; + border: 1px solid #AAB7C4; + background-color: #F9FAFC; + color: #AAB7C4; + + p { + margin: 0; + font-family: Inter; + font-size: 12px; + font-weight: 500; + line-height: 14px; + text-align: left; + text-underline-position: from-font; + text-decoration-skip-ink: none; + color: #6C7791; + white-space: break-spaces; + } +} diff --git a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.ts b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.ts index 9b7688372d..e8d5cc4b77 100644 --- a/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.ts +++ b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.ts @@ -1,22 +1,12 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {UntypedFormBuilder, Validators} from '@angular/forms'; -import { - IImpactReport, - IconType, - IPolicyReport, - IReport, - IReportItem, - ITokenReport, - IVCReport, - IVPReport, -} from '@guardian/interfaces'; -import {VCViewerDialog} from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; -import {IPFSService} from 'src/app/services/ipfs.service'; -import {PolicyEngineService} from 'src/app/services/policy-engine.service'; -import {WebSocketService} from 'src/app/services/web-socket.service'; -import {IconsArray} from './iconsArray'; -import {DialogService} from 'primeng/dynamicdialog'; -import {HttpErrorResponse} from '@angular/common/http'; +import { HttpErrorResponse } from '@angular/common/http'; +import { Component, Input, OnInit } from '@angular/core'; +import { UntypedFormBuilder, Validators } from '@angular/forms'; +import { IconType, IImpactReport, IPolicyReport, IReport, IReportItem, ITokenReport, IVCReport, IVPReport } from '@guardian/interfaces'; +import { DialogService } from 'primeng/dynamicdialog'; +import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; +import { IPFSService } from 'src/app/services/ipfs.service'; +import { PolicyEngineService } from 'src/app/services/policy-engine.service'; +import { WebSocketService } from 'src/app/services/web-socket.service'; interface IAdditionalDocument { vpDocument?: IVPReport | undefined; @@ -30,10 +20,10 @@ interface IAdditionalDocument { * Component for display block of 'ReportBlock' types. */ @Component({ - selector: 'app-report-block', - templateUrl: './report-block.component.html', - styleUrls: ['./report-block.component.scss'], -}) + selector: 'app-report-block', + templateUrl: './report-block.component.html', + styleUrls: ['./report-block.component.scss'] + }) export class ReportBlockComponent implements OnInit { @Input('id') id!: string; @Input('policyId') policyId!: string; @@ -49,8 +39,8 @@ export class ReportBlockComponent implements OnInit { documents: any; policyCreatorDocument: IReportItem | undefined; searchForm = this.fb.group({ - value: ['', Validators.required], - }); + value: ['', Validators.required] + }); constructor( private policyEngineService: PolicyEngineService, @@ -61,6 +51,22 @@ export class ReportBlockComponent implements OnInit { ) { } + private _onSuccess(data: any) { + this.setData(data); + setTimeout(() => { + this.loading = false; + }, 500); + } + + private _onError(e: HttpErrorResponse) { + console.error(e.error); + if (e.status === 503) { + this._onSuccess(null); + } else { + this.loading = false; + } + } + ngOnInit(): void { if (!this.static) { this.socket = this.wsService.blockSubscribe( @@ -97,22 +103,6 @@ export class ReportBlockComponent implements OnInit { } } - private _onSuccess(data: any) { - this.setData(data); - setTimeout(() => { - this.loading = false; - }, 500); - } - - private _onError(e: HttpErrorResponse) { - console.error(e.error); - if (e.status === 503) { - this._onSuccess(null); - } else { - this.loading = false; - } - } - setData(data: any) { if (data && data.data) { this.chainVisible = true; @@ -131,8 +121,8 @@ export class ReportBlockComponent implements OnInit { const report = data.data as IReport; this.hash = data.hash; this.searchForm.patchValue({ - value: this.hash, - }); + value: this.hash + }); this.policyDocument = report.policyDocument; this.policyCreatorDocument = report.policyCreatorDocument; this.documents = report.documents || []; @@ -156,15 +146,15 @@ export class ReportBlockComponent implements OnInit { if (this.policyDocument) { this.documents.push({ - type: this.policyDocument.type, - title: 'Policy', - description: this.policyDocument.tag, - tag: this.policyDocument.tag, - visible: true, - issuer: this.policyDocument.issuer, - username: this.policyDocument.username, - document: this.policyDocument.document, - }); + type: this.policyDocument.type, + title: 'Policy', + description: this.policyDocument.tag, + tag: this.policyDocument.tag, + visible: true, + issuer: this.policyDocument.issuer, + username: this.policyDocument.username, + document: this.policyDocument.document + }); } if (this.policyCreatorDocument) { this.documents.push(this.policyCreatorDocument); @@ -289,9 +279,9 @@ export class ReportBlockComponent implements OnInit { onScrollButtonPress(target: HTMLDivElement, amount: number = 0) { target.scrollBy({ - behavior: 'smooth', - left: amount, - }); + behavior: 'smooth', + left: amount + }); } updateFilter() { @@ -447,8 +437,8 @@ export class ReportBlockComponent implements OnInit { const indexDocument = itemDocuments.indexOf(document); const secondDocumentIndex = indexDocument - 1 < 0 - ? itemDocuments.length + (indexDocument - 1) - : indexDocument - 1; + ? itemDocuments.length + (indexDocument - 1) + : indexDocument - 1; this.onMultipleDocumentClick(itemDocuments[secondDocumentIndex], item); } } diff --git a/frontend/src/app/modules/policy-engine/policy-viewer/policy-viewer/policy-viewer.component.ts b/frontend/src/app/modules/policy-engine/policy-viewer/policy-viewer/policy-viewer.component.ts index c079aa49e1..c43cd2dca6 100644 --- a/frontend/src/app/modules/policy-engine/policy-viewer/policy-viewer/policy-viewer.component.ts +++ b/frontend/src/app/modules/policy-engine/policy-viewer/policy-viewer/policy-viewer.component.ts @@ -389,7 +389,7 @@ export class PolicyViewerComponent implements OnInit, OnDestroy { const currentStepIndex = this.policyProgressService.getCurrentStepIndex(); for (let i = (currentStepIndex - 1); i >= 0; i--) { const step = this.steps[i]; - if (!step.blockId) { + if (!step || !step.blockId) { continue; } const hasAction = this.policyProgressService.stepHasAction(step.blockId); diff --git a/frontend/src/app/services/analytics.service.ts b/frontend/src/app/services/analytics.service.ts index 8eed152cac..9f81e3ebff 100644 --- a/frontend/src/app/services/analytics.service.ts +++ b/frontend/src/app/services/analytics.service.ts @@ -74,4 +74,8 @@ export class AnalyticsService { public searchBlocks(options: any): Observable { return this.http.post(`${this.url}/search/blocks`, options); } + + public checkIndexer(): Observable { + return this.http.get(`${this.url}/checkIndexer`); + } } \ No newline at end of file diff --git a/frontend/src/app/services/contract.service.ts b/frontend/src/app/services/contract.service.ts index 4b3a0161fb..95a3992ee8 100644 --- a/frontend/src/app/services/contract.service.ts +++ b/frontend/src/app/services/contract.service.ts @@ -4,6 +4,7 @@ import { Observable } from 'rxjs'; import { API_BASE_URL } from './api'; import { ContractType, + IRetirementMessage, RetireTokenPool, RetireTokenRequest, } from '@guardian/interfaces'; @@ -15,7 +16,7 @@ import { export class ContractService { private readonly url: string = `${API_BASE_URL}/contracts`; - constructor(private http: HttpClient) {} + constructor(private http: HttpClient) { } //#region Common contract endpoints public getContracts(params: { @@ -318,5 +319,14 @@ export class ContractService { }); } + public getRetireVCsFromIndexer( + contractTopicId: string + ): Observable> { + let url = `${this.url}/retireIndexer?contractTopicId=${contractTopicId}`; + return this.http.get(url, { + observe: 'response', + }); + } + //#endregion } diff --git a/guardian-service/src/api/analytics.service.ts b/guardian-service/src/api/analytics.service.ts index dfe21feb7d..ab402dcf13 100644 --- a/guardian-service/src/api/analytics.service.ts +++ b/guardian-service/src/api/analytics.service.ts @@ -731,6 +731,20 @@ export async function analyticsAPI(logger: PinoLogger): Promise { return new MessageError(error); } }); + + ApiResponse(MessageAPI.GET_INDEXER_AVAILABILITY, + async () => { + try { + const result = await new Workers().addNonRetryableTask({ + type: WorkerTaskType.ANALYTICS_GET_INDEXER_AVAILABILITY, + data: {} + }, 2); + + return new MessageResponse(result); + } catch (error) { + return new MessageResponse(false); + } + }); } @Module({ diff --git a/guardian-service/src/api/contract.service.ts b/guardian-service/src/api/contract.service.ts index 2ac2bde1e8..83e56fae66 100644 --- a/guardian-service/src/api/contract.service.ts +++ b/guardian-service/src/api/contract.service.ts @@ -3408,4 +3408,34 @@ export async function contractAPI( return new MessageError(error); } }); + + ApiResponse(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, async (msg: { + owner: IOwner, + contractTopicId: string + }) => { + try { + if (!msg) { + return new MessageError('Invalid get contract parameters'); + } + + const { owner, contractTopicId } = msg; + + if (!owner.creator) { + throw new Error('Owner is required'); + } + + const messages = await new Workers().addNonRetryableTask({ + type: WorkerTaskType.ANALYTICS_GET_RETIRE_DOCUMENTS, + data: { + payload: { options: { topicId: contractTopicId } } + } + }, 2); + + return new MessageResponse([messages, messages.length]); + } catch (error) { + await logger.error(error, ['GUARDIAN_SERVICE']); + return new MessageError(error); + } + }); + } diff --git a/guardian-service/system-schemas/system-schemas.json b/guardian-service/system-schemas/system-schemas.json index 20ce7d0751..a5ea4fcf98 100644 --- a/guardian-service/system-schemas/system-schemas.json +++ b/guardian-service/system-schemas/system-schemas.json @@ -163,8 +163,8 @@ }, "contractId": { "$comment": "{\"term\": \"user\", \"@id\": \"https://www.schema.org/text\"}", - "title": "user", - "description": "user", + "title": "contract", + "description": "contract", "type": "string", "readOnly": false }, diff --git a/indexer-api-gateway/src/api/services/analytics.ts b/indexer-api-gateway/src/api/services/analytics.ts index cb8dce1c45..8416fa79df 100644 --- a/indexer-api-gateway/src/api/services/analytics.ts +++ b/indexer-api-gateway/src/api/services/analytics.ts @@ -1,4 +1,4 @@ -import { Controller, HttpCode, HttpStatus, Body, Post } from '@nestjs/common'; +import { Controller, HttpCode, HttpStatus, Body, Post, Get } from '@nestjs/common'; import { ApiBody, ApiInternalServerErrorResponse, @@ -7,12 +7,14 @@ import { ApiTags, ApiUnprocessableEntityResponse, } from '@nestjs/swagger'; -import { IndexerMessageAPI } from '@indexer/common'; +import { IndexerMessageAPI, Message } from '@indexer/common'; import { ApiClient } from '../api-client.js'; import { InternalServerErrorDTO, + RawMessageDTO, SearchPolicyParamsDTO, SearchPolicyResultDTO, + MessageDTO, } from '#dto'; @Controller('analytics') @@ -45,4 +47,50 @@ export class AnalyticsApi extends ApiClient { body ); } + + @ApiOperation({ + summary: 'Search contract retirements', + description: 'Returns contract retirements result', + }) + @ApiBody({ + description: 'Search policy parameters', + type: RawMessageDTO, + }) + @ApiOkResponse({ + description: 'Search policy result', + type: [MessageDTO], + }) + @ApiInternalServerErrorResponse({ + description: 'Internal server error', + type: InternalServerErrorDTO, + }) + @ApiUnprocessableEntityResponse({ + description: 'Unprocessable entity', + }) + @Post('/search/retire') + @HttpCode(HttpStatus.OK) + async getRetireDocuments(@Body() body: RawMessageDTO) { + return await this.send( + IndexerMessageAPI.GET_RETIRE_DOCUMENTS, + body + ); + } + + @Get('/checkAvailability') + @ApiOperation({ + summary: 'Get indexer availability', + description: 'Returns indexer availability', + }) + @ApiOkResponse({ + description: 'Indexer availability result', + type: Boolean, + }) + @ApiInternalServerErrorResponse({ + description: 'Internal server error', + type: InternalServerErrorDTO, + }) + @HttpCode(HttpStatus.OK) + async getIndexerAvailability(): Promise { + return await this.send(IndexerMessageAPI.GET_INDEXER_AVAILABILITY, {}); + } } diff --git a/indexer-api-gateway/src/dto/index.ts b/indexer-api-gateway/src/dto/index.ts index 267738e5c3..478aaa1723 100644 --- a/indexer-api-gateway/src/dto/index.ts +++ b/indexer-api-gateway/src/dto/index.ts @@ -11,3 +11,4 @@ export * from './relationships.dto.js'; export * from './schema-tree.dto.js'; export * from './internal-server-error.dto.js'; export * from './search-policy.dto.js'; +export * from './message.dto.js'; diff --git a/indexer-api-gateway/src/dto/message.dto.ts b/indexer-api-gateway/src/dto/message.dto.ts index a12b351009..616c427223 100644 --- a/indexer-api-gateway/src/dto/message.dto.ts +++ b/indexer-api-gateway/src/dto/message.dto.ts @@ -87,4 +87,9 @@ export class MessageDTO implements Message { example: ['0.0.4481265'], }) tokens: string[]; + @ApiProperty({ + description: 'SequenceNumber', + example: 0, + }) + sequenceNumber?: number; } diff --git a/indexer-common/src/entity/message.ts b/indexer-common/src/entity/message.ts index 5e9ef605dc..7c00bc2d7e 100644 --- a/indexer-common/src/entity/message.ts +++ b/indexer-common/src/entity/message.ts @@ -1,14 +1,6 @@ -import { - Entity, - Property, - PrimaryKey, - SerializedPrimaryKey, - Unique, - Index, - Enum, -} from '@mikro-orm/core'; -import { ObjectId } from '@mikro-orm/mongodb'; import { Message as IMessage, MessageAction, MessageType } from '@indexer/interfaces'; +import { Entity, Enum, Index, PrimaryKey, Property, SerializedPrimaryKey, Unique } from '@mikro-orm/core'; +import { ObjectId } from '@mikro-orm/mongodb'; @Entity() @Unique({ name: 'consensus_timestamp', properties: ['consensusTimestamp'] }) @@ -34,9 +26,6 @@ export class Message implements IMessage { @Property() consensusTimestamp: string; - @Property() - sequenceNumber: number; - @Property() owner: string; @@ -102,6 +91,9 @@ export class Message implements IMessage { @Property({ nullable: true }) tokens: string[]; + @Property({ nullable: true }) + sequenceNumber?: number; + @Property({ nullable: true }) loaded: boolean; } diff --git a/indexer-common/src/messages/message-api.ts b/indexer-common/src/messages/message-api.ts index 3e94de677d..5ea6e26803 100644 --- a/indexer-common/src/messages/message-api.ts +++ b/indexer-common/src/messages/message-api.ts @@ -80,5 +80,8 @@ export enum IndexerMessageAPI { GET_ANALYTICS_SEARCH_POLICY = 'INDEXER_API_GET_ANALYTICS_SEARCH_POLICY', // #endregion - UPDATE_FILES = 'INDEXER_API_UPDATE_FILES' + UPDATE_FILES = 'INDEXER_API_UPDATE_FILES', + + GET_INDEXER_AVAILABILITY = "INDEXER_API_GET_INDEXER_AVAILABILITY", + GET_RETIRE_DOCUMENTS = "INDEXER_API_GET_RETIRE_DOCUMENTS" } diff --git a/indexer-interfaces/src/interfaces/message.interface.ts b/indexer-interfaces/src/interfaces/message.interface.ts index 12fe00cbba..59b7220db1 100644 --- a/indexer-interfaces/src/interfaces/message.interface.ts +++ b/indexer-interfaces/src/interfaces/message.interface.ts @@ -77,4 +77,8 @@ export interface Message { * Tokens */ tokens: string[]; + /** + * Sequence number + */ + sequenceNumber?: number; } diff --git a/indexer-service/src/api/analytics.service.ts b/indexer-service/src/api/analytics.service.ts index fc2ca20985..222086e27c 100644 --- a/indexer-service/src/api/analytics.service.ts +++ b/indexer-service/src/api/analytics.service.ts @@ -6,10 +6,11 @@ import { MessageError, DataBaseHelper, Message, - AnyResponse + AnyResponse, + MessageCache } from '@indexer/common'; import escapeStringRegexp from 'escape-string-regexp'; -import { MessageAction, MessageType, SearchPolicyParams, SearchPolicyResult } from '@indexer/interfaces'; +import { MessageAction, MessageType, RawMessage, SearchPolicyParams, SearchPolicyResult, VCDetails } from '@indexer/interfaces'; import { HashComparator } from '../analytics/index.js'; function createRegex(text: string) { @@ -126,4 +127,55 @@ export class AnalyticsService { return new MessageError(error); } } + + @MessagePattern(IndexerMessageAPI.GET_RETIRE_DOCUMENTS) + async getRetireDocuments( + @Payload() + msg: RawMessage + ): Promise> { + try { + const { topicId } = msg; + const em = DataBaseHelper.getEntityManager(); + const [messages, count] = (await em.findAndCount( + Message, + { + topicId, + action: MessageAction.CreateVC, + } as any + )) as any; + + const [messagesCache] = (await em.findAndCount( + MessageCache, + { + topicId, + } as any + )) as any; + + for (const message of messages) { + let VCdocuments: VCDetails[] = []; + for (const fileName of message.files) { + try { + const file = await DataBaseHelper.loadFile(fileName); + VCdocuments.push(JSON.parse(file) as VCDetails); + } catch (error) { + } + } + message.documents = VCdocuments; + + var messageCache = messagesCache.find((cache: MessageCache) => cache.consensusTimestamp == message.consensusTimestamp); + if (messageCache) { + message.sequenceNumber = messageCache.sequenceNumber; + } + } + + return new MessageResponse(messages); + } catch (error) { + return new MessageError(error); + } + } + + @MessagePattern(IndexerMessageAPI.GET_INDEXER_AVAILABILITY) + async checkAvailability(): Promise> { + return new MessageResponse(true); + } } diff --git a/interfaces/src/interface/index.ts b/interfaces/src/interface/index.ts index 9f2a24d943..63a3c24457 100644 --- a/interfaces/src/interface/index.ts +++ b/interfaces/src/interface/index.ts @@ -43,4 +43,5 @@ export * from './sign-options.interface.js' export * from './owner.interface.js' export * from './statistic.interface.js' export * from './schema-rules.interface.js' -export * from './policy-label.interface.js' \ No newline at end of file +export * from './retirement-message.interface.js' +export * from './policy-label.interface.js' diff --git a/interfaces/src/interface/retirement-message.interface.ts b/interfaces/src/interface/retirement-message.interface.ts new file mode 100644 index 0000000000..ce2f8fac0b --- /dev/null +++ b/interfaces/src/interface/retirement-message.interface.ts @@ -0,0 +1,73 @@ +/** + * Contract + */ +export class IRetirementMessage { + /** + * Identifier + */ + id: string; + /** + * Topic identifier + */ + topicId: string; + /** + * Message identifier + */ + consensusTimestamp: string; + /** + * Owner + */ + owner: string; + /** + * UUID + */ + uuid: string; + /** + * Status + */ + status: string; + /** + * Status reason + */ + statusReason: string; + /** + * Lang + */ + lang: string; + /** + * Response type + */ + responseType: string; + /** + * Status message + */ + statusMessage: string; + /** + * Options + */ + options: any; + /** + * Analytics + */ + analytics?: any; + /** + * Files + */ + files: string[]; + /** + * Documents + */ + documents: any[]; + /** + * Topics + */ + topics: string[]; + /** + * Tokens + */ + tokens: string[]; + /** + * Sequence number + */ + sequenceNumber: string; +} diff --git a/interfaces/src/type/messages/contract-api.type.ts b/interfaces/src/type/messages/contract-api.type.ts index 0bc2e0b677..b3383aabcb 100644 --- a/interfaces/src/type/messages/contract-api.type.ts +++ b/interfaces/src/type/messages/contract-api.type.ts @@ -48,7 +48,8 @@ export enum ContractAPI { APPROVE_RETIRE = 'APPROVE_RETIRE', ADD_RETIRE_ADMIN = 'ADD_RETIRE_ADMIN', REMOVE_RETIRE_ADMIN = 'REMOVE_RETIRE_ADMIN', - GET_RETIRE_VCS = 'GET_RETIRE_VCS' + GET_RETIRE_VCS = 'GET_RETIRE_VCS', + GET_RETIRE_VCS_FROM_INDEXER = 'GET_RETIRE_VCS_FROM_INDEXER' //#endregion } diff --git a/interfaces/src/type/messages/message-api.type.ts b/interfaces/src/type/messages/message-api.type.ts index b335cacd9d..b74c0f9b74 100644 --- a/interfaces/src/type/messages/message-api.type.ts +++ b/interfaces/src/type/messages/message-api.type.ts @@ -244,6 +244,7 @@ export enum MessageAPI { IMPORT_SCHEMA_RULE_FILE = 'IMPORT_SCHEMA_RULE_FILE', EXPORT_SCHEMA_RULE_FILE = 'EXPORT_SCHEMA_RULE_FILE', PREVIEW_SCHEMA_RULE_FILE = 'PREVIEW_SCHEMA_RULE_FILE', + GET_INDEXER_AVAILABILITY = 'GET_INDEXER_AVAILABILITY', CREATE_POLICY_LABEL = 'CREATE_POLICY_LABEL', GET_POLICY_LABELS = 'GET_POLICY_LABELS', GET_POLICY_LABEL = 'GET_POLICY_LABEL', diff --git a/interfaces/src/type/messages/workers.type.ts b/interfaces/src/type/messages/workers.type.ts index 7c5d149884..68f623c540 100644 --- a/interfaces/src/type/messages/workers.type.ts +++ b/interfaces/src/type/messages/workers.type.ts @@ -37,7 +37,9 @@ export enum WorkerTaskType { GET_TOKEN_INFO = 'get-token-info', GET_CONTRACT_EVENTS = 'get-contract-events', GET_TRANSACTIONS = 'get-transaction', - ANALYTICS_SEARCH_POLICIES= 'analytics-search-policies', + ANALYTICS_SEARCH_POLICIES = 'analytics-search-policies', + ANALYTICS_GET_INDEXER_AVAILABILITY = "analytics-get-indexer-availability", + ANALYTICS_GET_RETIRE_DOCUMENTS = 'analytics-get-retire-documents' } /** diff --git a/policy-service/src/policy-engine/blocks/report-block.ts b/policy-service/src/policy-engine/blocks/report-block.ts index 0fc8a0ee13..dcdd0af08b 100644 --- a/policy-service/src/policy-engine/blocks/report-block.ts +++ b/policy-service/src/policy-engine/blocks/report-block.ts @@ -426,7 +426,7 @@ export class ReportBlock { const vp: any = await ref.databaseServer.getVpDocument({ hash, policyId: ref.policyId }); if (vp) { - [vp.serials, vp.amount, vp.error, vp.wasTransferNeeded, vp.transferSerials, vp.transferAmount, vp.tokenIds] = await ref.databaseServer.getVPMintInformation(vp); + [vp.serials, vp.amount, vp.error, vp.wasTransferNeeded, vp.transferSerials, vp.transferAmount, vp.tokenIds, vp.target] = await ref.databaseServer.getVPMintInformation(vp); report = await this.addReportByVP(report, variables, vp, true); } else { const vc = await ref.databaseServer.getVcDocument({ hash, policyId: ref.policyId }) diff --git a/swagger-indexer.yaml b/swagger-indexer.yaml index b16bffc87b..1c49089b1f 100644 --- a/swagger-indexer.yaml +++ b/swagger-indexer.yaml @@ -2341,8 +2341,59 @@ paths: application/json: schema: $ref: '#/components/schemas/InternalServerErrorDTO' - tags: + tags: &ref_2 - analytics + /analytics/search/retire: + post: + operationId: AnalyticsApi_getRetireDocuments + summary: Search contract retirements + description: Returns contract retirements result + parameters: [] + requestBody: + required: true + description: Search policy parameters + content: + application/json: + schema: + $ref: '#/components/schemas/RawMessageDTO' + responses: + '200': + description: Search policy result + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/MessageDTO' + '422': + description: Unprocessable entity + '500': + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/InternalServerErrorDTO' + tags: *ref_2 + /analytics/checkAvailability: + get: + operationId: AnalyticsApi_getIndexerAvailability + summary: Get indexer availability + description: Returns indexer availability + parameters: [] + responses: + '200': + description: Indexer availability result + content: + application/json: + schema: + type: boolean + '500': + description: Internal server error + content: + application/json: + schema: + $ref: '#/components/schemas/InternalServerErrorDTO' + tags: *ref_2 info: title: Guardian description: >- @@ -2493,25 +2544,29 @@ components: description: Status message files: description: Files - example: &ref_2 + example: &ref_3 - QmYtKEVfpbDwn7XLHjnjap224ESi3vLiYpkbWoabnxs6cX type: array items: type: string topics: description: Topics - example: &ref_3 + example: &ref_4 - 0.0.4481265 type: array items: type: string tokens: description: Tokens - example: &ref_4 + example: &ref_5 - 0.0.4481265 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -2598,6 +2653,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -2808,22 +2864,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -2910,6 +2970,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -2958,22 +3019,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -3068,6 +3133,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -3286,22 +3352,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -3388,6 +3458,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -3531,22 +3602,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -3633,6 +3708,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -3756,22 +3832,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -3858,6 +3938,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -3974,22 +4055,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -4074,6 +4159,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -4162,22 +4248,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -4277,6 +4367,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -4553,22 +4644,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -4663,6 +4758,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -4762,22 +4858,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -4864,6 +4964,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -4982,22 +5083,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -5084,6 +5189,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -5219,22 +5325,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -5321,6 +5431,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -5422,22 +5533,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -5524,6 +5639,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -5639,22 +5755,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -5739,6 +5859,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -5812,22 +5933,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -5914,6 +6039,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -5962,22 +6088,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -6072,6 +6202,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -6146,22 +6277,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 required: - id - topicId @@ -6176,6 +6311,7 @@ components: - files - topics - tokens + - sequenceNumber RelationshipDTO: type: object properties: @@ -6352,22 +6488,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -6462,6 +6602,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -6720,22 +6861,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -6822,6 +6967,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -7021,22 +7167,26 @@ components: description: Status message files: description: Files - example: *ref_2 + example: *ref_3 type: array items: type: string topics: description: Topics - example: *ref_3 + example: *ref_4 type: array items: type: string tokens: description: Tokens - example: *ref_4 + example: *ref_5 type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -7123,6 +7273,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options diff --git a/swagger.yaml b/swagger.yaml index 12a53a9be2..1f73fdb192 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -822,6 +822,32 @@ paths: tags: *ref_1 security: - bearer: [] + /analytics/checkIndexer: + get: + operationId: AnalyticsApi_checkIndexerAvailability + summary: Get Indexer Availability. + description: Returns Indexer Availability (true/false). + parameters: [] + responses: + '200': + description: Successful operation. + content: + application/json: + schema: + type: boolean + '401': + description: Unauthorized. + '403': + description: Forbidden. + '500': + description: Internal server error. + content: + application/json: + schema: + $ref: '#/components/schemas/InternalServerErrorDTO' + tags: *ref_1 + security: + - bearer: [] /artifacts: get: operationId: ArtifactApi_getArtifactsV2 @@ -2391,6 +2417,46 @@ paths: tags: *ref_3 security: - bearer: [] + /contracts/retireIndexer: + get: + operationId: ContractsApi_getRetireVCsFromIndexer + summary: Return a list of all retire vcs from Indexer. + description: Returns all retire vcs from Indexer. + parameters: + - name: contractTopicId + required: true + in: query + description: The topic id of contract + example: 0.0.0000000 + schema: + type: string + responses: + '200': + description: Successful operation. + headers: + X-Total-Count: + schema: + type: integer + description: Total items in the collection. + content: + application/json: + schema: + type: array + items: + type: object + '401': + description: Unauthorized. + '403': + description: Forbidden. + '500': + description: Internal server error. + content: + application/json: + schema: + $ref: '#/components/schemas/InternalServerErrorDTO' + tags: *ref_3 + security: + - bearer: [] /demo/registered-users: get: operationId: DemoApi_registeredUsers diff --git a/worker-service/src/api/worker.ts b/worker-service/src/api/worker.ts index bfe9c4a0fa..5230f3f76c 100644 --- a/worker-service/src/api/worker.ts +++ b/worker-service/src/api/worker.ts @@ -327,6 +327,42 @@ export class Worker extends NatsService { break; } + case WorkerTaskType.ANALYTICS_GET_RETIRE_DOCUMENTS: { + const { options } = task.data.payload; + try { + const response = await axios.post( + `${this.analyticsService}/analytics/search/retire`, + options, + { responseType: 'json' } + ); + result.data = response.data; + + } catch (error) { + if (error.code === 'ECONNREFUSED') { + result.error = 'Indexer service is not available'; + } else { + result.error = error.message; + } + } + break; + } + + case WorkerTaskType.ANALYTICS_GET_INDEXER_AVAILABILITY: { + try { + const response = await axios.get( + `${this.analyticsService}/analytics/checkAvailability` + ); + result.data = response.data; + } catch (error) { + if (error.code === 'ECONNREFUSED') { + result.error = 'Indexer service is not available'; + } else { + result.error = error.message; + } + } + break; + } + case WorkerTaskType.HTTP_REQUEST: { const { method, url, headers, body } = task.data.payload; const response = await axios({