From 206ee02fb8531b697a3b17191975985396319ab8 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Fri, 22 Nov 2024 14:14:44 +0100 Subject: [PATCH 01/28] WIP: Add token retirement info in trustchain. --- .../report-block/report-block.component.html | 29 ++++++++++++ .../report-block/report-block.component.scss | 33 +++++++++++++ .../report-block/report-block.component.ts | 47 +++++++++++++++++-- 3 files changed, 105 insertions(+), 4 deletions(-) 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 125a5e7ad5..b75d00ebf2 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 @@ -446,6 +446,35 @@

Policy Overview

+
+ +
+
+
+ Token Retirements: {{retirementDocuments.length}} +
+
+
+

Retirement

+ VC File +

ContractID:{{ item.document.credentialSubject[0].contractId }}

+

UserID: {{ item.document.credentialSubject[0].user }}

+
+

TokenID: {{ token.tokenId }}

+

{{ token.serials ? token.serials.join(',') : token.count }}

+
+
+
+
+
+
+
{ + this.retirementDocuments = (policiesResponse.body || []) + .filter((item: any) => item.type == 'RETIRE' + && item.document.credentialSubject.some((subject: any) => + subject.tokens.some((token: any) => + token.tokenId === this.mintTokenId + && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) + )))); + + this.loading = false; + }, + (e) => { + this.loading = false; + } + ); + } + // ... + loadData() { this.loading = true; if (this.static) { @@ -150,6 +179,16 @@ export class ReportBlockComponent implements OnInit { this.policyCreatorDocument = report.policyCreatorDocument; this.documents = report.documents || []; + + + // Testing + this.mintTokenId = report.mintDocument?.tokenId || ''; + this.mintTokenSerials = (report.vpDocument?.document as any).serials.map((serialItem: any) => serialItem.serial); // Fix + this.loadRetireData(); + // ... + + + const mainDocument = this.createAdditionalDocument(report); if (mainDocument) { this.mainDocuments = [mainDocument]; @@ -249,7 +288,7 @@ export class ReportBlockComponent implements OnInit { type: 'VC', } }); - dialogRef.onClose.subscribe(async (result) => {}); + dialogRef.onClose.subscribe(async (result) => { }); } openVPDocument(item: any) { @@ -268,7 +307,7 @@ export class ReportBlockComponent implements OnInit { type: 'VP', } }); - dialogRef.onClose.subscribe(async (result) => {}); + dialogRef.onClose.subscribe(async (result) => { }); } openJsonDocument(item: ITokenReport) { @@ -284,7 +323,7 @@ export class ReportBlockComponent implements OnInit { type: 'JSON', } }); - dialogRef.onClose.subscribe(async (result) => {}); + dialogRef.onClose.subscribe(async (result) => { }); } mapData(data: any[]) { From b349d6b3063c98fc58786a9d28a3e5e6cd60945c Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Thu, 5 Dec 2024 14:33:28 +0100 Subject: [PATCH 02/28] Add receiving token info. --- guardian-service/src/api/contract.service.ts | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/guardian-service/src/api/contract.service.ts b/guardian-service/src/api/contract.service.ts index 2ac2bde1e8..6ec502f893 100644 --- a/guardian-service/src/api/contract.service.ts +++ b/guardian-service/src/api/contract.service.ts @@ -2606,6 +2606,37 @@ export async function contractAPI( ); } + const workers = new Workers(); + const tokenInfo = await workers.addRetryableTask( + { + type: WorkerTaskType.GET_TOKEN_INFO, + data: { tokenId: '0.0.5148481' }, + }, + 10 + ); + + + const mintTransactions = await new Workers().addRetryableTask( + { + type: WorkerTaskType.GET_TRANSACTIONS, + data: { + accountId: '0.0.5148419', // test user account id + transactiontype: 'TOKENMINT', + timestamp: '2024-11-19T22:02:43.698Z', + filter: { + memo_base64: btoa('0.0.5148482'), + }, + limit: 5, + }, + }, + 1, + 10 + ); + + console.log(tokenInfo); + console.log(mintTransactions); + + return new MessageResponse( await dataBaseServer.findAndCount(RetirePool, filters, otherOptions) ); From 40731c60602f9b8ceb6817e0afb44d9d9477061a Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Wed, 11 Dec 2024 18:09:54 +0100 Subject: [PATCH 03/28] WIP 2243 --- frontend/package-lock.json | 7 +- .../retire-pools-dialog.component.ts | 5 + .../user-retire-pools-dialog.component.ts | 2 + .../report-block/report-block.component.html | 155 ++++++++++++++++++ frontend/src/app/services/contract.service.ts | 4 + guardian-service/src/api/contract.service.ts | 53 +++--- .../src/api/services/analytics.ts | 30 ++++ indexer-common/src/messages/message-api.ts | 4 +- indexer-service/src/api/analytics.service.ts | 49 +++++- indexer-service/src/api/search.service.ts | 39 ++++- .../src/services/message-service.ts | 3 + interfaces/src/type/messages/workers.type.ts | 1 + worker-service/src/api/worker.ts | 20 +++ 13 files changed, 335 insertions(+), 37 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index bc705165de..8c514c9d04 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "guardian", - "version": "2.27.1", + "version": "3.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "guardian", - "version": "2.27.1", + "version": "3.0.0", "license": "Apache-2.0", "dependencies": { "@angular-material-components/datetime-picker": "^16.0.0", @@ -72,7 +72,8 @@ } }, "../interfaces": { - "version": "2.27.1", + "name": "@guardian/interfaces", + "version": "3.0.0", "license": "Apache-2.0", "dependencies": { "gulp": "^4.0.2", diff --git a/frontend/src/app/modules/contract-engine/dialogs/retire-pools-dialog/retire-pools-dialog.component.ts b/frontend/src/app/modules/contract-engine/dialogs/retire-pools-dialog/retire-pools-dialog.component.ts index bfbd5a71ef..2a0c929ba6 100644 --- a/frontend/src/app/modules/contract-engine/dialogs/retire-pools-dialog/retire-pools-dialog.component.ts +++ b/frontend/src/app/modules/contract-engine/dialogs/retire-pools-dialog/retire-pools-dialog.component.ts @@ -39,6 +39,7 @@ export class RetirePoolsDialogComponent implements OnInit { loadPools() { this.loading = true; + this.contractService .getRetirePools({ contractId: this.contract.contractId, @@ -69,6 +70,10 @@ export class RetirePoolsDialogComponent implements OnInit { }, () => (this.loading = false) ); + + // this.contractService.getIndexerData('0.0.5148441').subscribe((data: any) =>{ + // console.log(data); + // }); } onPage(event: any) { 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 d73c15c1f2..f2256d7303 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 @@ -52,6 +52,8 @@ export class UserRetirePoolsDialogComponent implements OnInit { loadPools() { this.loading = true; + console.log(123); + this.contractService .getRetirePools({ pageIndex: this.pageIndex, 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 b75d00ebf2..ed69f17382 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 @@ -310,6 +310,8 @@

Policy Overview

*ngFor="let document of item.document" style="display: inline-block;" > +

{{document.index}}

+

{{item.document.length}}

0"> + +
+ +
+
+ + account_tree + +
+
+ + {{ item.icon }} + + + {{ item.title }} +
+
+ warning + Revoked with reason: "{{document.document.comment}}" +
+
+ {{ item.description }} +
+
+
+ Parties: +
+
+
+ {{ document.username }} +
+
+
+ +
+ VC File +
+
+ chevron_left + + {{ item.activeDocumentIndex }} in {{ item.document.length }} + + chevron_right +
+
+
+
+ +
+
+
+ {{ item.title }} +
+
+ search +
+ Documents Not Found +
+
+
+
+
+
+
+
diff --git a/frontend/src/app/services/contract.service.ts b/frontend/src/app/services/contract.service.ts index 4b3a0161fb..08240aaa00 100644 --- a/frontend/src/app/services/contract.service.ts +++ b/frontend/src/app/services/contract.service.ts @@ -224,6 +224,10 @@ export class ContractService { }); } + public getIndexerData(contractId: string,) { + + } + public clearRetireRequests(contractId: string) { return this.http.delete( `${this.url}/retire/${contractId}/requests` diff --git a/guardian-service/src/api/contract.service.ts b/guardian-service/src/api/contract.service.ts index 6ec502f893..e7d6abcb0f 100644 --- a/guardian-service/src/api/contract.service.ts +++ b/guardian-service/src/api/contract.service.ts @@ -1161,7 +1161,7 @@ async function saveRetireVC( userHederaAccountId: string, tokens: (RetireTokenRequest & { decimals: number })[] ) { - const contract = await dataBaseServer.findOne(Contract, { + const contract = await dataBaseServer.findOne(Contract, { // Get retirement and save or maybe create new one contractId, owner: owner.creator, }); @@ -2606,36 +2606,33 @@ export async function contractAPI( ); } - const workers = new Workers(); - const tokenInfo = await workers.addRetryableTask( - { - type: WorkerTaskType.GET_TOKEN_INFO, - data: { tokenId: '0.0.5148481' }, - }, - 10 - ); + + + console.log("____________retirements"); + const retirements = await new Workers().addNonRetryableTask({ + type: WorkerTaskType.ANALYTICS_GET_RETIRE_DOCUMENTS, + data: { + payload: { options: { topicId: '0.0.5148441' } } + } + }, 2); + console.log(JSON.stringify(retirements, null, 4)); - const mintTransactions = await new Workers().addRetryableTask( - { - type: WorkerTaskType.GET_TRANSACTIONS, - data: { - accountId: '0.0.5148419', // test user account id - transactiontype: 'TOKENMINT', - timestamp: '2024-11-19T22:02:43.698Z', - filter: { - memo_base64: btoa('0.0.5148482'), - }, - limit: 5, - }, - }, - 1, - 10 - ); - console.log(tokenInfo); - console.log(mintTransactions); + const filtersOld: any = { + owner: owner.owner, + type: SchemaEntity.RETIRE_TOKEN, + }; + if (user.role === UserRole.USER) { + filters['document.credentialSubject.user'] = + user.hederaAccountId; + } + + const oldRetirements = await dataBaseServer.findAndCount(VcDocument, filtersOld) // find old Retirement VCs + + console.log(JSON.stringify(oldRetirements, null, 4)); + return new MessageResponse( await dataBaseServer.findAndCount(RetirePool, filters, otherOptions) @@ -3432,7 +3429,7 @@ export async function contractAPI( } return new MessageResponse( - await dataBaseServer.findAndCount(VcDocument, filters, otherOptions) + await dataBaseServer.findAndCount(VcDocument, filters, otherOptions) // find Retirement VCs ); } catch (error) { await logger.error(error, ['GUARDIAN_SERVICE']); diff --git a/indexer-api-gateway/src/api/services/analytics.ts b/indexer-api-gateway/src/api/services/analytics.ts index cb8dce1c45..420e839c40 100644 --- a/indexer-api-gateway/src/api/services/analytics.ts +++ b/indexer-api-gateway/src/api/services/analytics.ts @@ -11,8 +11,10 @@ import { IndexerMessageAPI } from '@indexer/common'; import { ApiClient } from '../api-client.js'; import { InternalServerErrorDTO, + RawMessageDTO, SearchPolicyParamsDTO, SearchPolicyResultDTO, + VCDetailsDTO, } from '#dto'; @Controller('analytics') @@ -45,4 +47,32 @@ 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: [VCDetailsDTO], + }) + @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 + ); + } } diff --git a/indexer-common/src/messages/message-api.ts b/indexer-common/src/messages/message-api.ts index 39ec90bae7..8e5ae20d17 100644 --- a/indexer-common/src/messages/message-api.ts +++ b/indexer-common/src/messages/message-api.ts @@ -72,5 +72,7 @@ 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_RETIRE_DOCUMENTS = "INDEXER_API_GET_RETIRE_DOCUMENTS" } diff --git a/indexer-service/src/api/analytics.service.ts b/indexer-service/src/api/analytics.service.ts index 8d9fe2e7a9..5a102e49cd 100644 --- a/indexer-service/src/api/analytics.service.ts +++ b/indexer-service/src/api/analytics.service.ts @@ -9,7 +9,7 @@ import { AnyResponse } 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'; @Controller() @@ -122,4 +122,51 @@ 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 retirements = []; + + const [messages, count] = (await em.findAndCount( + Message, + { + topicId, + action: MessageAction.CreateVC, + } as any + )) as any; + + console.log(messages); + console.log(count); + + let VCdocuments: VCDetails[] = []; + for (const result of messages) { + console.log(result.files); + + for (const fileName of result.files) { + try { + const file = await DataBaseHelper.loadFile(fileName); + VCdocuments.push(JSON.parse(file) as VCDetails); + } catch (error) { + VCdocuments.push(null); + } + } + } + console.log(VCdocuments); + console.log(topicId); + console.log("YEEEE!!!"); + + const results = []; + + return new MessageResponse(VCdocuments); + } catch (error) { + return new MessageError(error); + } + } } diff --git a/indexer-service/src/api/search.service.ts b/indexer-service/src/api/search.service.ts index 45d1d97ed6..a22ec3459c 100644 --- a/indexer-service/src/api/search.service.ts +++ b/indexer-service/src/api/search.service.ts @@ -9,6 +9,7 @@ import { } from '@indexer/common'; import { parsePageParams } from '../utils/parse-page-params.js'; import { Page, SearchItem } from '@indexer/interfaces'; +import { loadFiles } from 'helpers/load-files.js'; @Controller() export class SearchService { @@ -23,17 +24,47 @@ export class SearchService { } const options = parsePageParams(msg); const { search } = msg; + const em = DataBaseHelper.getEntityManager(); + // const [results, count] = (await em.findAndCount( + // Message, + // { + // $text: { + // $search: search, + // }, + // } as any, + // options + // )) as any as [SearchItem[], number]; + + const retirements = []; + const [results, count] = (await em.findAndCount( Message, { - $text: { - $search: search, - }, + "topicId": "0.0.5148441", // memo from contract or topicId + "action": "create-vc-document" } as any, options - )) as any as [SearchItem[], number]; + )) as any; + + let VCdocuments = []; + for (const result of results) { + console.log(result.files); + + for (const fileName of result.files) { + try { + const file = await DataBaseHelper.loadFile(fileName); + VCdocuments.push(file); + } catch (error) { + VCdocuments.push(null); + } + } + } + + console.log(VCdocuments); + + const result = { items: results, diff --git a/indexer-worker-service/src/services/message-service.ts b/indexer-worker-service/src/services/message-service.ts index 9ae47bd6ca..8610e81c7d 100644 --- a/indexer-worker-service/src/services/message-service.ts +++ b/indexer-worker-service/src/services/message-service.ts @@ -50,6 +50,9 @@ export class MessageService { $or: [ { status: 'LOADING', lastUpdate: { $lt: delay } }, { status: 'COMPRESSED' } + ], + $and: [ + { topicId: "0.0.5148441" } ] }, { diff --git a/interfaces/src/type/messages/workers.type.ts b/interfaces/src/type/messages/workers.type.ts index 7c5d149884..84d721b731 100644 --- a/interfaces/src/type/messages/workers.type.ts +++ b/interfaces/src/type/messages/workers.type.ts @@ -38,6 +38,7 @@ export enum WorkerTaskType { GET_CONTRACT_EVENTS = 'get-contract-events', GET_TRANSACTIONS = 'get-transaction', ANALYTICS_SEARCH_POLICIES= 'analytics-search-policies', + ANALYTICS_GET_RETIRE_DOCUMENTS= 'analytics-get-retire-documents', } /** diff --git a/worker-service/src/api/worker.ts b/worker-service/src/api/worker.ts index bfe9c4a0fa..9def9025ac 100644 --- a/worker-service/src/api/worker.ts +++ b/worker-service/src/api/worker.ts @@ -327,6 +327,26 @@ 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.HTTP_REQUEST: { const { method, url, headers, body } = task.data.payload; const response = await axios({ From 7f3da4d6ad86fb5001160c3e1fdf9b010d0a9a80 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Thu, 12 Dec 2024 18:55:42 +0100 Subject: [PATCH 04/28] WIP: 2 2243 --- api-gateway/src/api/service/contract.ts | 59 +++++++ api-gateway/src/helpers/guardians.ts | 19 +++ .../report-block/report-block.component.ts | 5 + frontend/src/app/services/contract.service.ts | 13 ++ guardian-service/src/api/contract.service.ts | 156 ++++++++++++++---- .../src/type/messages/contract-api.type.ts | 3 +- 6 files changed, 225 insertions(+), 30 deletions(-) diff --git a/api-gateway/src/api/service/contract.ts b/api-gateway/src/api/service/contract.ts index f5824c87bf..91ad7f23df 100644 --- a/api-gateway/src/api/service/contract.ts +++ b/api-gateway/src/api/service/contract.ts @@ -1719,5 +1719,64 @@ 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: 'pageIndex', + type: Number, + description: 'The number of pages to skip before starting to collect the result set', + required: false, + example: 0, + }) + @ApiQuery({ + name: 'pageSize', + type: Number, + description: 'The numbers of items to return', + example: 20, + }) + @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('pageIndex') pageIndex?: number, + @Query('pageSize') pageSize?: number, + ): Promise { + try { + const owner = new EntityOwner(user); + const guardians = new Guardians(); + const [vcs, count] = await guardians.getRetireVCsFromIndexer(owner, pageIndex, pageSize); + 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 f9e074354d..175e79c32d 100644 --- a/api-gateway/src/helpers/guardians.ts +++ b/api-gateway/src/helpers/guardians.ts @@ -1846,6 +1846,25 @@ export class Guardians extends NatsService { }); } + /** + * Get retire VCs from Indexer + * @param owner + * @param pageIndex + * @param pageSize + * @returns Retire VCs from Indexer and count + */ + public async getRetireVCsFromIndexer( + owner: IOwner, + pageIndex?: any, + pageSize?: any + ): Promise<[IVCDocument, number]> { + return await this.sendMessage(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, { + owner, + pageIndex, + pageSize, + }); + } + //#endregion /** 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 e84bf852ce..746b8fa2f3 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 @@ -121,6 +121,11 @@ export class ReportBlockComponent implements OnInit { this.loading = false; } ); + + this.contractService.getRetireVCsFromIndexer().subscribe((indexerData) => { + console.log(indexerData); + + }) } // ... diff --git a/frontend/src/app/services/contract.service.ts b/frontend/src/app/services/contract.service.ts index 08240aaa00..bec30eb147 100644 --- a/frontend/src/app/services/contract.service.ts +++ b/frontend/src/app/services/contract.service.ts @@ -322,5 +322,18 @@ export class ContractService { }); } + public getRetireVCsFromIndexer( + pageIndex?: number, + pageSize?: number + ) { + let url = `${this.url}/retireIndexer`; + if (pageIndex && pageSize) { + url += `?pageIndex=${pageIndex}&pageSize=${pageSize}` + } + return this.http.get(url, { + observe: 'response', + }); + } + //#endregion } diff --git a/guardian-service/src/api/contract.service.ts b/guardian-service/src/api/contract.service.ts index e7d6abcb0f..f3614ad0b3 100644 --- a/guardian-service/src/api/contract.service.ts +++ b/guardian-service/src/api/contract.service.ts @@ -2606,34 +2606,6 @@ export async function contractAPI( ); } - - - - console.log("____________retirements"); - const retirements = await new Workers().addNonRetryableTask({ - type: WorkerTaskType.ANALYTICS_GET_RETIRE_DOCUMENTS, - data: { - payload: { options: { topicId: '0.0.5148441' } } - } - }, 2); - console.log(JSON.stringify(retirements, null, 4)); - - - const filtersOld: any = { - owner: owner.owner, - type: SchemaEntity.RETIRE_TOKEN, - }; - if (user.role === UserRole.USER) { - filters['document.credentialSubject.user'] = - user.hederaAccountId; - } - - const oldRetirements = await dataBaseServer.findAndCount(VcDocument, filtersOld) // find old Retirement VCs - - - console.log(JSON.stringify(oldRetirements, null, 4)); - - return new MessageResponse( await dataBaseServer.findAndCount(RetirePool, filters, otherOptions) ); @@ -2986,7 +2958,7 @@ export async function contractAPI( } }); - ApiResponse(ContractAPI.RETIRE, async (msg: { + ApiResponse(ContractAPI.RETIRE, async (msg: { // Tokens Retire here owner: IOwner, poolId: string, tokens: RetireTokenRequest[] @@ -3436,4 +3408,130 @@ export async function contractAPI( return new MessageError(error); } }); + + ApiResponse(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, async (msg: { + owner: IOwner, + pageIndex?: any, + pageSize?: any + }) => { + try { + if (!msg) { + return new MessageError('Invalid get contract parameters'); + } + + const { pageIndex, pageSize, owner } = msg; + + if (!owner.creator) { + throw new Error('Owner is required'); + } + + const otherOptions: any = {}; + const _pageSize = parseInt(pageSize, 10); + const _pageIndex = parseInt(pageIndex, 10); + if (Number.isInteger(_pageSize) && Number.isInteger(_pageIndex)) { + otherOptions.orderBy = { createDate: 'DESC' }; + otherOptions.limit = Math.min(100, _pageSize); + otherOptions.offset = _pageIndex * _pageSize; + } else { + otherOptions.orderBy = { createDate: 'DESC' }; + otherOptions.limit = 100; + } + + const users = new Users(); + const user = await users.getUserById(owner.creator); + + const filters: any = { + owner: owner.owner, + type: SchemaEntity.RETIRE_TOKEN, + }; + if (user.role === UserRole.USER) { + filters['document.credentialSubject.user'] = + user.hederaAccountId; + } + + + + + + + + + + + console.log("____________retirements"); + const retirements = await new Workers().addNonRetryableTask({ + type: WorkerTaskType.ANALYTICS_GET_RETIRE_DOCUMENTS, + data: { + payload: { options: { topicId: '0.0.5148441' } } + } + }, 2); + console.log(JSON.stringify(retirements, null, 4)); + + + + const filtersOld: any = { + owner: owner.owner, + type: SchemaEntity.RETIRE_TOKEN, + }; + if (user.role === UserRole.USER) { + filters['document.credentialSubject.user'] = + user.hederaAccountId; + } + + const oldRetirements = await dataBaseServer.findAndCount(VcDocument, filtersOld) // find old Retirement VCs + + + console.log(JSON.stringify(oldRetirements, null, 4)); + + retirements.forEach(retirement => { + oldRetirements.forEach(oldRetirement => { + + }); + + console.log(retirement); + + }); + + const vcMessage = new VCMessage(MessageAction.CreateVC); + console.log(vcMessage.hash); + + // vcMessage.setDocument(vcObject); + + // await dataBaseServer.save(VcDocumentCollection, { + // hash: vcMessage.hash, + // owner: owner.creator, + // document: vcMessage.document, + // type: schemaObject?.entity, + // documentFields: ['credentialSubject.0.user'], + // }); + + // await saveRetireVC( + // // contractRepository, + // dataBaseServer, + // pool.contractId, + // srUser, + // sr.hederaAccountId, + // srKey, + // root.hederaAccountId, + // tokens.map((token) => { + // const newToken: any = { + // ...token, + // }; + // const poolToken = pool.tokens.find( + // // tslint:disable-next-line:no-shadowed-variable + // (poolToken) => (poolToken.token = token.token) + // ); + // newToken.decimals = poolToken.decimals; + // return newToken; + // }) + // ); + + + return new MessageResponse(retirements); + } catch (error) { + await logger.error(error, ['GUARDIAN_SERVICE']); + return new MessageError(error); + } + }); + } 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 } From 70b73df4faac154f58726a5044c022675813874b Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Thu, 12 Dec 2024 22:34:36 +0100 Subject: [PATCH 05/28] WIP 3: 2243 --- api-gateway/src/api/service/contract.ts | 10 +- api-gateway/src/helpers/guardians.ts | 5 +- .../report-block/report-block.component.ts | 38 +++++- frontend/src/app/services/contract.service.ts | 3 +- guardian-service/src/api/contract.service.ts | 123 +++++++++--------- 5 files changed, 108 insertions(+), 71 deletions(-) diff --git a/api-gateway/src/api/service/contract.ts b/api-gateway/src/api/service/contract.ts index 91ad7f23df..828b5aaab1 100644 --- a/api-gateway/src/api/service/contract.ts +++ b/api-gateway/src/api/service/contract.ts @@ -1733,6 +1733,13 @@ export class ContractsApi { 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', + }) @ApiQuery({ name: 'pageIndex', type: Number, @@ -1766,13 +1773,14 @@ export class ContractsApi { async getRetireVCsFromIndexer( @AuthUser() user: IAuthUser, @Response() res: any, + @Query('contractTopicId') contractTopicId: string, @Query('pageIndex') pageIndex?: number, @Query('pageSize') pageSize?: number, ): Promise { try { const owner = new EntityOwner(user); const guardians = new Guardians(); - const [vcs, count] = await guardians.getRetireVCsFromIndexer(owner, pageIndex, pageSize); + const [vcs, count] = await guardians.getRetireVCsFromIndexer(owner, contractTopicId, pageIndex, pageSize); return res.header('X-Total-Count', count).send(vcs); } catch (error) { await InternalException(error, this.logger); diff --git a/api-gateway/src/helpers/guardians.ts b/api-gateway/src/helpers/guardians.ts index 175e79c32d..45709e4f26 100644 --- a/api-gateway/src/helpers/guardians.ts +++ b/api-gateway/src/helpers/guardians.ts @@ -17,6 +17,7 @@ import { IToken, ITokenInfo, IUser, + IVC, IVCDocument, IVPDocument, MessageAPI, @@ -1855,11 +1856,13 @@ export class Guardians extends NatsService { */ public async getRetireVCsFromIndexer( owner: IOwner, + contractTopicId: string, pageIndex?: any, pageSize?: any - ): Promise<[IVCDocument, number]> { + ): Promise<[IVC[], number]> { return await this.sendMessage(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, { owner, + contractTopicId, pageIndex, pageSize, }); 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 746b8fa2f3..a5c7e24e0b 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 @@ -12,6 +12,7 @@ import { ITokenReport, IVCReport, IVPReport, + ContractType, } from '@guardian/interfaces'; import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; import { IPFSService } from 'src/app/services/ipfs.service'; @@ -122,10 +123,39 @@ export class ReportBlockComponent implements OnInit { } ); - this.contractService.getRetireVCsFromIndexer().subscribe((indexerData) => { - console.log(indexerData); - - }) + const retirementsFromIndexer: any[] = []; + + this.contractService + .getContracts({ + type: ContractType.RETIRE + }) + .subscribe( + (policiesResponse) => { + const contracts = policiesResponse.body || []; + const tokenContractTopicIds: string[] = []; + + if (contracts && contracts.length > 0) { + contracts.forEach(contract => { + if (contract.wipeTokenIds && contract.wipeTokenIds.length > 0 && + contract.wipeTokenIds.some((tokenId: string) => tokenId == this.mintTokenId)) { + tokenContractTopicIds.push(contract.topicId); + } + }); + } + + if (tokenContractTopicIds.length > 0) { + tokenContractTopicIds.forEach(id => { + this.contractService.getRetireVCsFromIndexer(id).subscribe((indexerData) => { + console.log(id); + console.log(indexerData); + }) + }) + } + }, + (e) => { + this.loading = false; + } + ); } // ... diff --git a/frontend/src/app/services/contract.service.ts b/frontend/src/app/services/contract.service.ts index bec30eb147..d112f47ac3 100644 --- a/frontend/src/app/services/contract.service.ts +++ b/frontend/src/app/services/contract.service.ts @@ -323,10 +323,11 @@ export class ContractService { } public getRetireVCsFromIndexer( + contractTopicId: string, pageIndex?: number, pageSize?: number ) { - let url = `${this.url}/retireIndexer`; + let url = `${this.url}/retireIndexer?contractTopicId=${contractTopicId}`; if (pageIndex && pageSize) { url += `?pageIndex=${pageIndex}&pageSize=${pageSize}` } diff --git a/guardian-service/src/api/contract.service.ts b/guardian-service/src/api/contract.service.ts index f3614ad0b3..688d938e20 100644 --- a/guardian-service/src/api/contract.service.ts +++ b/guardian-service/src/api/contract.service.ts @@ -3411,6 +3411,7 @@ export async function contractAPI( ApiResponse(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, async (msg: { owner: IOwner, + contractTopicId: string, pageIndex?: any, pageSize?: any }) => { @@ -3419,7 +3420,7 @@ export async function contractAPI( return new MessageError('Invalid get contract parameters'); } - const { pageIndex, pageSize, owner } = msg; + const { owner, contractTopicId, pageIndex, pageSize } = msg; if (!owner.creator) { throw new Error('Owner is required'); @@ -3456,78 +3457,72 @@ export async function contractAPI( - - - console.log("____________retirements"); + // Get Retirements from Indexer const retirements = await new Workers().addNonRetryableTask({ type: WorkerTaskType.ANALYTICS_GET_RETIRE_DOCUMENTS, data: { - payload: { options: { topicId: '0.0.5148441' } } + payload: { options: { topicId: contractTopicId } } } }, 2); - console.log(JSON.stringify(retirements, null, 4)); - - - - const filtersOld: any = { - owner: owner.owner, - type: SchemaEntity.RETIRE_TOKEN, - }; - if (user.role === UserRole.USER) { - filters['document.credentialSubject.user'] = - user.hederaAccountId; - } - - const oldRetirements = await dataBaseServer.findAndCount(VcDocument, filtersOld) // find old Retirement VCs - - console.log(JSON.stringify(oldRetirements, null, 4)); - - retirements.forEach(retirement => { - oldRetirements.forEach(oldRetirement => { + // Save to Guardian DB + // const filtersOld: any = { + // owner: owner.owner, + // type: SchemaEntity.RETIRE_TOKEN, + // }; + // if (user.role === UserRole.USER) { + // filters['document.credentialSubject.user'] = + // user.hederaAccountId; + // } + + // const oldRetirements = await dataBaseServer.findAndCount(VcDocument, filtersOld) // find old Retirement VCs + // console.log(JSON.stringify(oldRetirements, null, 4)); + + // retirements.forEach(retirement => { + // oldRetirements.forEach(oldRetirement => { + + // }); + + // console.log(retirement); - }); + // }); - console.log(retirement); + // const vcMessage = new VCMessage(MessageAction.CreateVC); + // console.log(vcMessage.hash); - }); - - const vcMessage = new VCMessage(MessageAction.CreateVC); - console.log(vcMessage.hash); - - // vcMessage.setDocument(vcObject); - - // await dataBaseServer.save(VcDocumentCollection, { - // hash: vcMessage.hash, - // owner: owner.creator, - // document: vcMessage.document, - // type: schemaObject?.entity, - // documentFields: ['credentialSubject.0.user'], - // }); - - // await saveRetireVC( - // // contractRepository, - // dataBaseServer, - // pool.contractId, - // srUser, - // sr.hederaAccountId, - // srKey, - // root.hederaAccountId, - // tokens.map((token) => { - // const newToken: any = { - // ...token, - // }; - // const poolToken = pool.tokens.find( - // // tslint:disable-next-line:no-shadowed-variable - // (poolToken) => (poolToken.token = token.token) - // ); - // newToken.decimals = poolToken.decimals; - // return newToken; - // }) - // ); - - - return new MessageResponse(retirements); + // vcMessage.setDocument(vcObject); + + // await dataBaseServer.save(VcDocumentCollection, { + // hash: vcMessage.hash, + // owner: owner.creator, + // document: vcMessage.document, + // type: schemaObject?.entity, + // documentFields: ['credentialSubject.0.user'], + // }); + + // await saveRetireVC( + // // contractRepository, + // dataBaseServer, + // pool.contractId, + // srUser, + // sr.hederaAccountId, + // srKey, + // root.hederaAccountId, + // tokens.map((token) => { + // const newToken: any = { + // ...token, + // }; + // const poolToken = pool.tokens.find( + // // tslint:disable-next-line:no-shadowed-variable + // (poolToken) => (poolToken.token = token.token) + // ); + // newToken.decimals = poolToken.decimals; + // return newToken; + // }) + // ); + // ... + + return new MessageResponse([retirements, retirements.length]); } catch (error) { await logger.error(error, ['GUARDIAN_SERVICE']); return new MessageError(error); From 55fc2ff824a0ea26960ef29f79ab04f178eae4aa Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Mon, 16 Dec 2024 18:48:21 +0100 Subject: [PATCH 06/28] WIP: Add check indexer availability status. Change trust chain component. Add api, services. Add styles. --- api-gateway/src/api/service/analytics.ts | 33 +- api-gateway/src/helpers/guardians.ts | 1 + .../report-block/report-block.component.html | 437 +++++------------- .../report-block/report-block.component.scss | 150 +++++- .../report-block/report-block.component.ts | 89 ++-- .../src/app/services/analytics.service.ts | 4 + guardian-service/src/api/analytics.service.ts | 19 + .../src/api/services/analytics.ts | 22 +- indexer-common/src/messages/message-api.ts | 1 + indexer-service/src/api/analytics.service.ts | 10 +- .../src/type/messages/message-api.type.ts | 1 + interfaces/src/type/messages/workers.type.ts | 3 +- worker-service/src/api/worker.ts | 16 + 13 files changed, 410 insertions(+), 376 deletions(-) diff --git a/api-gateway/src/api/service/analytics.ts b/api-gateway/src/api/service/analytics.ts index 945858d653..86da057316 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.ANALYTIC_POLICY_READ, + ) + @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/helpers/guardians.ts b/api-gateway/src/helpers/guardians.ts index 45709e4f26..02dfc018df 100644 --- a/api-gateway/src/helpers/guardians.ts +++ b/api-gateway/src/helpers/guardians.ts @@ -18,6 +18,7 @@ import { ITokenInfo, IUser, IVC, + IVC, IVCDocument, IVPDocument, MessageAPI, 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 ed69f17382..f0bf6c12e6 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,26 +1,11 @@
Trust Chain
-
+ HASH/ID - - @@ -31,23 +16,18 @@
-
+

Verifiable Presentation

check_circle - +
+ pButton>

HASH

{{ item.vpDocument.hash }}

@@ -58,11 +38,9 @@

Verifiable Presentation

- + pButton> +

HASH

{{ item.vcDocument.hash }}

@@ -70,17 +48,12 @@

Verifiable Presentation

-
+

Token & Issuer

- +
@@ -91,11 +64,8 @@

Token & Issuer

Receipt Name
-
+
{{ item.mintDocument.username }}
@@ -120,11 +90,8 @@

Token & Issuer

-
+

Primary Impacts

@@ -132,11 +99,7 @@

Primary Impacts

-
+
workspace_premium @@ -145,13 +108,10 @@

Primary Impacts

VC File + *ngIf="item.document" class="open-vc">VC File
-
Primary Impacts
-
+ ">

Secondary Impacts

-
+
workspace_premium @@ -192,7 +150,8 @@

Secondary Impacts

{{ item.label }}
1" - class="vp-section" - > +
This Carbon Offset Claim has met all the requirements as issued in the policy secured to this token. @@ -249,9 +205,8 @@

Secondary Impacts

Policy Overview

- +
@@ -274,11 +229,8 @@

Policy Overview

Issuer Name
-
+
{{ policyDocument.username }}
@@ -288,30 +240,19 @@

Policy Overview

-
-
+
- -
-

{{document.index}}

-

{{item.document.length}}

+
-
+ account_tree -
1, @@ -349,40 +286,25 @@

{{item.document.length}}

document.index === null), 'single-multiple-document': item.document.length === 1 - }" - class="chain-item item-type-{{item.type}}" - > + }" class="chain-item item-type-{{item.type}}">
- + {{ item.icon }} - + {{ item.title }}
-
+ " class="revoke-container"> warning Revoked with reason: "{{document.document.comment}}"
{{ item.description }}
-
+
Parties:
@@ -394,45 +316,37 @@

{{item.document.length}}

-
- VC File +
+
-
1 - " - class="multiple-documents-count" - > - chevron_left + " class="multiple-documents-count"> + chevron_left {{ item.activeDocumentIndex }} in {{ item.document.length }} - chevron_right + chevron_right
-
+ " style="display: inline-block;">
{{ item.title }} @@ -448,195 +362,80 @@

{{item.document.length}}

- - - -
- -
-
- - account_tree - -
-
- - {{ item.icon }} - - - {{ item.title }} -
-
- warning - Revoked with reason: "{{document.document.comment}}" -
-
- {{ item.description }} -
-
-
- Parties: -
-
-
- {{ document.username }} -
-
-
- -
- VC File -
-
- chevron_left - {{ item.activeDocumentIndex }} in {{ item.document.length }} + - chevron_right +
+
+ +
+
+
+
+ Token(s) Retirement: {{ retirementDocuments.length }} +
+
+

Token ID {{ mintTokenId }}

+

ContractID {{ + currentRetirementDocument.document.credentialSubject[0].contractId + }}

+

UserID {{ + currentRetirementDocument.document.credentialSubject[0].user + }}

+
+
+ +

+ No data from the indexer. Connect it and click Refresh for full + details. +

+
- -
-
+ + + +
+
+
- {{ item.title }} + {{ currentRetirementDocument.createDate | date : 'YYYY-MM-dd, hh:mm:ss' }}
-
- search -
- Documents Not Found -
+
+
-
- -
- - -
- -
-
-
- Token Retirements: {{retirementDocuments.length}} -
-
-
-

Retirement

- VC File -

ContractID:{{ item.document.credentialSubject[0].contractId }}

-

UserID: {{ item.document.credentialSubject[0].user }}

-
-

TokenID: {{ token.tokenId }}

-

{{ token.serials ? token.serials.join(',') : token.count }}

+
+

Instance ID {{ '?' }}

+

Token {{ '?' }}

+

Transaction {{ '?' }} +

+
+ +
+ chevron_left + + {{ (currentRetirementIndex + 1) }} of {{ retirementDocuments.length }} + + chevron_right
-
- -
+
+
-
- +
@@ -652,4 +451,4 @@

{{item.document.length}}

-
+
\ No newline at end of file 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 31461fa9eb..ad37290d3e 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 @@ -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,14 +240,18 @@ 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 mat-icon { @@ -255,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; */ } @@ -449,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, @@ -551,12 +567,15 @@ 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 mat-icon { @@ -770,8 +789,16 @@ h3 { .item-type-RETIRE { - width: auto; - /* background: #fff1e8; */ + .chain-top-block { + padding-bottom: 14px; + margin-top: 8px; + margin-bottom: 8px; + border-bottom: 1px solid #E1E7EF; + } + + .chain-title { + margin-top: 0; + } } .retirement-container { @@ -796,4 +823,79 @@ h3 { border-radius: 4px; border: 1px solid var(--grey-grey-3, #E1E7EF); background: var(--grey-white, #FFF); +} + + +.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-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; + } + } +} + +.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; + } } \ No newline at end of file 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 a5c7e24e0b..4389c5dcdd 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 @@ -13,6 +13,7 @@ import { IVCReport, IVPReport, ContractType, + ContractType, } from '@guardian/interfaces'; import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; import { IPFSService } from 'src/app/services/ipfs.service'; @@ -67,6 +68,7 @@ export class ReportBlockComponent implements OnInit { sanitizer: DomSanitizer, private ipfs: IPFSService, private contractService: ContractService, + private analyticsService: AnalyticsService ) { for (let i = 0; i < IconsArray.length; i++) { const element = IconsArray[i]; @@ -102,6 +104,9 @@ export class ReportBlockComponent implements OnInit { mintTokenId: string; mintTokenSerials: string[] = []; retirementDocuments: any = []; + indexerAvailable: boolean = false; + currentRetirementDocument: any; + currentRetirementIndex: number = 0; private loadRetireData() { this.loading = true; this.contractService @@ -116,6 +121,11 @@ export class ReportBlockComponent implements OnInit { && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) )))); + this.currentRetirementIndex = 0; + this.currentRetirementDocument = this.retirementDocuments.length > (this.currentRetirementIndex + 1) ? this.retirementDocuments[this.currentRetirementIndex] : null; + + console.log(this.retirementDocuments); + this.loading = false; }, (e) => { @@ -125,38 +135,59 @@ export class ReportBlockComponent implements OnInit { const retirementsFromIndexer: any[] = []; - this.contractService - .getContracts({ - type: ContractType.RETIRE - }) - .subscribe( - (policiesResponse) => { - const contracts = policiesResponse.body || []; - const tokenContractTopicIds: string[] = []; - - if (contracts && contracts.length > 0) { - contracts.forEach(contract => { - if (contract.wipeTokenIds && contract.wipeTokenIds.length > 0 && - contract.wipeTokenIds.some((tokenId: string) => tokenId == this.mintTokenId)) { - tokenContractTopicIds.push(contract.topicId); + this.analyticsService.checkIndexer().subscribe(indexerAvailable => { + this.indexerAvailable = indexerAvailable; + if (indexerAvailable) { + + this.contractService + .getContracts({ + type: ContractType.RETIRE + }) + .subscribe( + (policiesResponse) => { + const contracts = policiesResponse.body || []; + const tokenContractTopicIds: string[] = []; + + if (contracts && contracts.length > 0) { + contracts.forEach(contract => { + if (contract.wipeTokenIds && contract.wipeTokenIds.length > 0 && + contract.wipeTokenIds.some((tokenId: string) => tokenId == this.mintTokenId)) { + tokenContractTopicIds.push(contract.topicId); + } + }); } - }); - } - if (tokenContractTopicIds.length > 0) { - tokenContractTopicIds.forEach(id => { - this.contractService.getRetireVCsFromIndexer(id).subscribe((indexerData) => { - console.log(id); - console.log(indexerData); - }) - }) - } - }, - (e) => { - this.loading = false; - } - ); + if (tokenContractTopicIds.length > 0) { + tokenContractTopicIds.forEach(id => { + this.contractService.getRetireVCsFromIndexer(id).subscribe((indexerData) => { + console.log(id); + console.log(indexerData); + }) + }) + } + }, + (e) => { + this.loading = false; + } + ); + } + }) } + + onNextRetirementClick(event: any) { + event.stopPropagation(); + + this.currentRetirementIndex = this.retirementDocuments.length > (this.currentRetirementIndex + 1) ? this.currentRetirementIndex + 1 : 0; + this.currentRetirementDocument = this.retirementDocuments[this.currentRetirementIndex]; + } + + onPrevRetirementClick(event: any) { + event.stopPropagation(); + + this.currentRetirementIndex = (this.currentRetirementIndex - 1) >= 0 ? (this.currentRetirementIndex - 1) : (this.retirementDocuments.length - 1); + this.currentRetirementDocument = this.retirementDocuments[this.currentRetirementIndex]; + } + // ... loadData() { diff --git a/frontend/src/app/services/analytics.service.ts b/frontend/src/app/services/analytics.service.ts index 8eed152cac..d37921242a 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/guardian-service/src/api/analytics.service.ts b/guardian-service/src/api/analytics.service.ts index 199f93f816..398dec4cca 100644 --- a/guardian-service/src/api/analytics.service.ts +++ b/guardian-service/src/api/analytics.service.ts @@ -721,6 +721,25 @@ export async function analyticsAPI(logger: PinoLogger): Promise { return new MessageError(error); } }); + + ApiResponse(MessageAPI.GET_INDEXER_AVAILABILITY, + async () => { + console.log(123); + try { + const result = await new Workers().addNonRetryableTask({ + type: WorkerTaskType.ANALYTICS_GET_INDEXER_AVAILABILITY, + data: {} + }, 2); + + console.log(result); + + + return new MessageResponse(result); + } catch (error) { + console.log(321); + return new MessageResponse(false); + } + }); } @Module({ diff --git a/indexer-api-gateway/src/api/services/analytics.ts b/indexer-api-gateway/src/api/services/analytics.ts index 420e839c40..5b98f4777a 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, @@ -12,9 +12,11 @@ import { ApiClient } from '../api-client.js'; import { InternalServerErrorDTO, RawMessageDTO, + RawMessageDTO, SearchPolicyParamsDTO, SearchPolicyResultDTO, VCDetailsDTO, + VCDetailsDTO, } from '#dto'; @Controller('analytics') @@ -75,4 +77,22 @@ export class AnalyticsApi extends ApiClient { 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-common/src/messages/message-api.ts b/indexer-common/src/messages/message-api.ts index 8e5ae20d17..c0ae57bde6 100644 --- a/indexer-common/src/messages/message-api.ts +++ b/indexer-common/src/messages/message-api.ts @@ -74,5 +74,6 @@ export enum IndexerMessageAPI { 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-service/src/api/analytics.service.ts b/indexer-service/src/api/analytics.service.ts index 5a102e49cd..c7d666ea44 100644 --- a/indexer-service/src/api/analytics.service.ts +++ b/indexer-service/src/api/analytics.service.ts @@ -10,6 +10,7 @@ import { } from '@indexer/common'; import escapeStringRegexp from 'escape-string-regexp'; import { MessageAction, MessageType, RawMessage, SearchPolicyParams, SearchPolicyResult, VCDetails } from '@indexer/interfaces'; +import { MessageAction, MessageType, RawMessage, SearchPolicyParams, SearchPolicyResult, VCDetails } from '@indexer/interfaces'; import { HashComparator } from '../analytics/index.js'; @Controller() @@ -160,7 +161,6 @@ export class AnalyticsService { } console.log(VCdocuments); console.log(topicId); - console.log("YEEEE!!!"); const results = []; @@ -169,4 +169,12 @@ export class AnalyticsService { return new MessageError(error); } } + + /** + * Get Indexer availability + */ + @MessagePattern(IndexerMessageAPI.GET_INDEXER_AVAILABILITY) + async checkAvailability(): Promise> { + return new MessageResponse(true); + } } diff --git a/interfaces/src/type/messages/message-api.type.ts b/interfaces/src/type/messages/message-api.type.ts index 105b6c8f14..30058c9848 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', } /** diff --git a/interfaces/src/type/messages/workers.type.ts b/interfaces/src/type/messages/workers.type.ts index 84d721b731..f1831c3055 100644 --- a/interfaces/src/type/messages/workers.type.ts +++ b/interfaces/src/type/messages/workers.type.ts @@ -38,7 +38,8 @@ export enum WorkerTaskType { GET_CONTRACT_EVENTS = 'get-contract-events', GET_TRANSACTIONS = 'get-transaction', ANALYTICS_SEARCH_POLICIES= 'analytics-search-policies', - ANALYTICS_GET_RETIRE_DOCUMENTS= 'analytics-get-retire-documents', + ANALYTICS_GET_INDEXER_AVAILABILITY = "analytics-get-indexer-availability", + ANALYTICS_GET_RETIRE_DOCUMENTS= 'analytics-get-retire-documents' } /** diff --git a/worker-service/src/api/worker.ts b/worker-service/src/api/worker.ts index 9def9025ac..5230f3f76c 100644 --- a/worker-service/src/api/worker.ts +++ b/worker-service/src/api/worker.ts @@ -347,6 +347,22 @@ export class Worker extends NatsService { 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({ From e03af02c57e78065d48a28c8a114d9c6d12115ba Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Mon, 16 Dec 2024 19:04:46 +0100 Subject: [PATCH 07/28] WIP: Merge stash fix. --- api-gateway/src/helpers/guardians.ts | 9 ++++++++- .../blocks/report-block/report-block.component.ts | 2 +- frontend/src/app/services/analytics.service.ts | 2 +- indexer-service/src/api/analytics.service.ts | 1 - 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/api-gateway/src/helpers/guardians.ts b/api-gateway/src/helpers/guardians.ts index 02dfc018df..1d61d3336e 100644 --- a/api-gateway/src/helpers/guardians.ts +++ b/api-gateway/src/helpers/guardians.ts @@ -18,7 +18,6 @@ import { ITokenInfo, IUser, IVC, - IVC, IVCDocument, IVPDocument, MessageAPI, @@ -3220,4 +3219,12 @@ export class Guardians extends NatsService { public async previewSchemaRule(zip: any, owner: IOwner) { 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, {}); + } } 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 4389c5dcdd..772f7e87d9 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 @@ -13,7 +13,6 @@ import { IVCReport, IVPReport, ContractType, - ContractType, } from '@guardian/interfaces'; import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; import { IPFSService } from 'src/app/services/ipfs.service'; @@ -23,6 +22,7 @@ import { IconsArray } from './iconsArray'; import { DialogService } from 'primeng/dynamicdialog'; import { HttpErrorResponse } from '@angular/common/http'; import { ContractService } from 'src/app/services/contract.service'; +import { AnalyticsService } from 'src/app/services/analytics.service'; interface IAdditionalDocument { vpDocument?: IVPReport | undefined; diff --git a/frontend/src/app/services/analytics.service.ts b/frontend/src/app/services/analytics.service.ts index d37921242a..9f81e3ebff 100644 --- a/frontend/src/app/services/analytics.service.ts +++ b/frontend/src/app/services/analytics.service.ts @@ -75,7 +75,7 @@ export class AnalyticsService { return this.http.post(`${this.url}/search/blocks`, options); } - public checkIndexer(): Observable { + public checkIndexer(): Observable { return this.http.get(`${this.url}/checkIndexer`); } } \ No newline at end of file diff --git a/indexer-service/src/api/analytics.service.ts b/indexer-service/src/api/analytics.service.ts index c7d666ea44..4b1f73e4d2 100644 --- a/indexer-service/src/api/analytics.service.ts +++ b/indexer-service/src/api/analytics.service.ts @@ -10,7 +10,6 @@ import { } from '@indexer/common'; import escapeStringRegexp from 'escape-string-regexp'; import { MessageAction, MessageType, RawMessage, SearchPolicyParams, SearchPolicyResult, VCDetails } from '@indexer/interfaces'; -import { MessageAction, MessageType, RawMessage, SearchPolicyParams, SearchPolicyResult, VCDetails } from '@indexer/interfaces'; import { HashComparator } from '../analytics/index.js'; @Controller() From bdc01ca35463ff525f0e3505432ae014963b15d2 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Mon, 16 Dec 2024 22:00:53 +0100 Subject: [PATCH 08/28] WIP: Map retirements. --- api-gateway/src/api/service/analytics.ts | 2 +- .../report-block/report-block.component.html | 4 +- .../report-block/report-block.component.ts | 113 +++++++++--------- guardian-service/src/api/analytics.service.ts | 4 - .../src/api/services/analytics.ts | 2 - indexer-worker-service/configs/.env.worker | 4 +- .../configs/.env.worker.develop | 4 +- .../configs/.env.worker.template | 4 +- 8 files changed, 68 insertions(+), 69 deletions(-) diff --git a/api-gateway/src/api/service/analytics.ts b/api-gateway/src/api/service/analytics.ts index 86da057316..3320e1ee93 100644 --- a/api-gateway/src/api/service/analytics.ts +++ b/api-gateway/src/api/service/analytics.ts @@ -953,7 +953,7 @@ export class AnalyticsApi { */ @Get('/checkIndexer') @Auth( - Permissions.ANALYTIC_POLICY_READ, + Permissions.POLICIES_POLICY_EXECUTE, ) @ApiOperation({ summary: 'Get Indexer Availability.', 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 f0bf6c12e6..2e32610997 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 @@ -377,10 +377,10 @@

Policy Overview

Token ID {{ mintTokenId }}

ContractID {{ - currentRetirementDocument.document.credentialSubject[0].contractId + currentRetirementDocument.contractId }}

UserID {{ - currentRetirementDocument.document.credentialSubject[0].user + currentRetirementDocument.user }}

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 772f7e87d9..e99a00536d 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 @@ -20,9 +20,10 @@ 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, HttpResponse } from '@angular/common/http'; import { ContractService } from 'src/app/services/contract.service'; import { AnalyticsService } from 'src/app/services/analytics.service'; +import { forkJoin, Observable } from 'rxjs'; interface IAdditionalDocument { vpDocument?: IVPReport | undefined; @@ -109,69 +110,73 @@ export class ReportBlockComponent implements OnInit { currentRetirementIndex: number = 0; private loadRetireData() { this.loading = true; - this.contractService - .getRetireVCs() - .subscribe( - (policiesResponse) => { - this.retirementDocuments = (policiesResponse.body || []) - .filter((item: any) => item.type == 'RETIRE' - && item.document.credentialSubject.some((subject: any) => - subject.tokens.some((token: any) => - token.tokenId === this.mintTokenId - && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) - )))); - - this.currentRetirementIndex = 0; - this.currentRetirementDocument = this.retirementDocuments.length > (this.currentRetirementIndex + 1) ? this.retirementDocuments[this.currentRetirementIndex] : null; - - console.log(this.retirementDocuments); - - this.loading = false; - }, - (e) => { - this.loading = false; - } - ); const retirementsFromIndexer: any[] = []; - this.analyticsService.checkIndexer().subscribe(indexerAvailable => { - this.indexerAvailable = indexerAvailable; - if (indexerAvailable) { - - this.contractService - .getContracts({ - type: ContractType.RETIRE - }) - .subscribe( - (policiesResponse) => { - const contracts = policiesResponse.body || []; - const tokenContractTopicIds: string[] = []; - - if (contracts && contracts.length > 0) { - contracts.forEach(contract => { - if (contract.wipeTokenIds && contract.wipeTokenIds.length > 0 && - contract.wipeTokenIds.some((tokenId: string) => tokenId == this.mintTokenId)) { - tokenContractTopicIds.push(contract.topicId); - } - }); + this.contractService + .getContracts({ + type: ContractType.RETIRE + }) + .subscribe( + (policiesResponse) => { + const contracts = policiesResponse.body || []; + const tokenContractTopicIds: string[] = []; + + if (contracts && contracts.length > 0) { + contracts.forEach(contract => { + if (contract.wipeTokenIds && contract.wipeTokenIds.length > 0 && + contract.wipeTokenIds.some((tokenId: string) => tokenId == this.mintTokenId)) { + tokenContractTopicIds.push(contract.topicId); } + }); + } + this.analyticsService.checkIndexer().subscribe(indexerAvailable => { + this.indexerAvailable = indexerAvailable; + if (indexerAvailable) { if (tokenContractTopicIds.length > 0) { + const indexerCalls: Observable>[] = []; tokenContractTopicIds.forEach(id => { - this.contractService.getRetireVCsFromIndexer(id).subscribe((indexerData) => { - console.log(id); - console.log(indexerData); - }) + indexerCalls.push(this.contractService.getRetireVCsFromIndexer(id)) + }) + + forkJoin([this.contractService.getRetireVCs(), ...indexerCalls]).subscribe((results: any) => { + const retires = results.map((item: any) => item.body) + console.log(retires); + this.retirementDocuments = retires[0]; }) } - }, - (e) => { - this.loading = false; + } else { + this.contractService + .getRetireVCs() + .subscribe( + (policiesResponse) => { + this.retirementDocuments = (policiesResponse.body || []) + .filter((item: any) => item.type == 'RETIRE' + && item.document.credentialSubject.some((subject: any) => + subject.tokens.some((token: any) => + token.tokenId === this.mintTokenId + && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) + )))).map((vc: any) => vc.document); + + this.currentRetirementIndex = 0; + this.currentRetirementDocument = this.retirementDocuments.length > (this.currentRetirementIndex + 1) ? this.retirementDocuments[this.currentRetirementIndex] : null; + + console.log(this.retirementDocuments); + + this.loading = false; + }, + (e) => { + this.loading = false; + } + ); } - ); - } - }) + }) + }, + (e) => { + this.loading = false; + } + ); } onNextRetirementClick(event: any) { diff --git a/guardian-service/src/api/analytics.service.ts b/guardian-service/src/api/analytics.service.ts index 398dec4cca..59b5d2d8d6 100644 --- a/guardian-service/src/api/analytics.service.ts +++ b/guardian-service/src/api/analytics.service.ts @@ -724,16 +724,12 @@ export async function analyticsAPI(logger: PinoLogger): Promise { ApiResponse(MessageAPI.GET_INDEXER_AVAILABILITY, async () => { - console.log(123); try { const result = await new Workers().addNonRetryableTask({ type: WorkerTaskType.ANALYTICS_GET_INDEXER_AVAILABILITY, data: {} }, 2); - console.log(result); - - return new MessageResponse(result); } catch (error) { console.log(321); diff --git a/indexer-api-gateway/src/api/services/analytics.ts b/indexer-api-gateway/src/api/services/analytics.ts index 5b98f4777a..ad63967030 100644 --- a/indexer-api-gateway/src/api/services/analytics.ts +++ b/indexer-api-gateway/src/api/services/analytics.ts @@ -12,11 +12,9 @@ import { ApiClient } from '../api-client.js'; import { InternalServerErrorDTO, RawMessageDTO, - RawMessageDTO, SearchPolicyParamsDTO, SearchPolicyResultDTO, VCDetailsDTO, - VCDetailsDTO, } from '#dto'; @Controller('analytics') diff --git a/indexer-worker-service/configs/.env.worker b/indexer-worker-service/configs/.env.worker index 7883f908b7..8d12583fd9 100644 --- a/indexer-worker-service/configs/.env.worker +++ b/indexer-worker-service/configs/.env.worker @@ -18,7 +18,7 @@ CYCLE_TIME="3600000" TOPIC_READ_DELAY="1000" TOPIC_READ_TIMEOUT="60000" TOPIC_JOB_REFRESH_TIME="60000" -TOPIC_JOB_COUNT="5" +TOPIC_JOB_COUNT="30" TOKEN_READ_DELAY="1000" TOKEN_READ_TIMEOUT="60000" TOKEN_JOB_REFRESH_TIME="60000" @@ -26,5 +26,5 @@ TOKEN_JOB_COUNT="2" MESSAGE_READ_DELAY="1000" MESSAGE_READ_TIMEOUT="60000" MESSAGE_JOB_REFRESH_TIME="60000" -MESSAGE_JOB_COUNT="5" +MESSAGE_JOB_COUNT="30" IPFS_GATEWAY="http://127.0.0.1:8080/ipfs/${cid}" diff --git a/indexer-worker-service/configs/.env.worker.develop b/indexer-worker-service/configs/.env.worker.develop index ed0126179f..08c9942b17 100644 --- a/indexer-worker-service/configs/.env.worker.develop +++ b/indexer-worker-service/configs/.env.worker.develop @@ -18,7 +18,7 @@ CYCLE_TIME="3600000" TOPIC_READ_DELAY="1000" TOPIC_READ_TIMEOUT="60000" TOPIC_JOB_REFRESH_TIME="60000" -TOPIC_JOB_COUNT="5" +TOPIC_JOB_COUNT="30" TOKEN_READ_DELAY="1000" TOKEN_READ_TIMEOUT="60000" TOKEN_JOB_REFRESH_TIME="60000" @@ -26,5 +26,5 @@ TOKEN_JOB_COUNT="2" MESSAGE_READ_DELAY="1000" MESSAGE_READ_TIMEOUT="60000" MESSAGE_JOB_REFRESH_TIME="60000" -MESSAGE_JOB_COUNT="5" +MESSAGE_JOB_COUNT="30" IPFS_GATEWAY="http://127.0.0.1:8080/ipfs/${cid}" \ No newline at end of file diff --git a/indexer-worker-service/configs/.env.worker.template b/indexer-worker-service/configs/.env.worker.template index 4616c23784..508cb9fd82 100644 --- a/indexer-worker-service/configs/.env.worker.template +++ b/indexer-worker-service/configs/.env.worker.template @@ -18,7 +18,7 @@ CYCLE_TIME="3600000" TOPIC_READ_DELAY="1000" TOPIC_READ_TIMEOUT="60000" TOPIC_JOB_REFRESH_TIME="60000" -TOPIC_JOB_COUNT="5" +TOPIC_JOB_COUNT="30" TOKEN_READ_DELAY="1000" TOKEN_READ_TIMEOUT="60000" TOKEN_JOB_REFRESH_TIME="60000" @@ -26,4 +26,4 @@ TOKEN_JOB_COUNT="2" MESSAGE_READ_DELAY="1000" MESSAGE_READ_TIMEOUT="60000" MESSAGE_JOB_REFRESH_TIME="60000" -MESSAGE_JOB_COUNT="5" \ No newline at end of file +MESSAGE_JOB_COUNT="30" \ No newline at end of file From e0f3c0023edad4ffeb29605f0d3a8cb6c331e24d Mon Sep 17 00:00:00 2001 From: envision-ci-agent Date: Mon, 16 Dec 2024 21:03:42 +0000 Subject: [PATCH 09/28] [skip ci] Add swagger.yaml --- swagger-analytics.yaml | 2 +- swagger-indexer.yaml | 163 +++++++++++++++++++++++++++-------------- swagger.yaml | 84 ++++++++++++++++++++- 3 files changed, 191 insertions(+), 58 deletions(-) diff --git a/swagger-analytics.yaml b/swagger-analytics.yaml index a3c2ecb53a..0bafe2aceb 100644 --- a/swagger-analytics.yaml +++ b/swagger-analytics.yaml @@ -208,7 +208,7 @@ info: the heart of the Guardian solution is a sophisticated Policy Workflow Engine (PWE) that enables applications to offer a requirements-based tokenization implementation. - version: 2.27.1 + version: 3.0.0 contact: name: API developer url: https://envisionblockchain.com diff --git a/swagger-indexer.yaml b/swagger-indexer.yaml index 04a6e2775e..418ae059a7 100644 --- a/swagger-indexer.yaml +++ b/swagger-indexer.yaml @@ -1865,8 +1865,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/VCDetailsDTO' + '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: >- @@ -1875,7 +1926,7 @@ info: the heart of the Guardian solution is a sophisticated Policy Workflow Engine (PWE) that enables applications to offer a requirements-based tokenization implementation. - version: 2.27.1 + version: 3.0.0 contact: name: API developer url: https://envisionblockchain.com @@ -2017,21 +2068,21 @@ 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: @@ -2320,19 +2371,19 @@ 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 @@ -2458,19 +2509,19 @@ 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 @@ -2774,19 +2825,19 @@ 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 @@ -3007,19 +3058,19 @@ 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 @@ -3220,19 +3271,19 @@ 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 @@ -3426,19 +3477,19 @@ 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 @@ -3602,19 +3653,19 @@ 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 @@ -3957,19 +4008,19 @@ 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 @@ -4153,19 +4204,19 @@ 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 @@ -4291,19 +4342,19 @@ 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 @@ -4463,19 +4514,19 @@ 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 @@ -4653,19 +4704,19 @@ 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 @@ -4817,19 +4868,19 @@ 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 @@ -5039,19 +5090,19 @@ 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 @@ -5177,19 +5228,19 @@ 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 @@ -5528,19 +5579,19 @@ 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 @@ -5817,19 +5868,19 @@ 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 diff --git a/swagger.yaml b/swagger.yaml index eb910980a2..64a3df79dd 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,62 @@ 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 + - name: pageIndex + required: false + in: query + description: >- + The number of pages to skip before starting to collect the result + set + example: 0 + schema: + type: number + - name: pageSize + required: true + in: query + description: The numbers of items to return + example: 20 + schema: + type: number + 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 @@ -13142,7 +13224,7 @@ info: the heart of the Guardian solution is a sophisticated Policy Workflow Engine (PWE) that enables applications to offer a requirements-based tokenization implementation. - version: 2.27.1 + version: 3.0.0 contact: name: API developer url: https://envisionblockchain.com From 79c68e32085127c358cf0078c71f44a7c625bb23 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Tue, 17 Dec 2024 16:06:55 +0100 Subject: [PATCH 10/28] Remove debug code of WIP commits. --- .../retire-pools-dialog.component.ts | 5 --- .../user-retire-pools-dialog.component.ts | 1 - frontend/src/app/services/contract.service.ts | 4 -- guardian-service/src/api/analytics.service.ts | 1 - guardian-service/src/api/contract.service.ts | 13 ++----- indexer-service/src/api/analytics.service.ts | 15 ------- indexer-service/src/api/search.service.ts | 39 ++----------------- indexer-worker-service/configs/.env.worker | 4 +- .../configs/.env.worker.develop | 4 +- .../configs/.env.worker.template | 4 +- .../src/services/message-service.ts | 3 -- 11 files changed, 13 insertions(+), 80 deletions(-) diff --git a/frontend/src/app/modules/contract-engine/dialogs/retire-pools-dialog/retire-pools-dialog.component.ts b/frontend/src/app/modules/contract-engine/dialogs/retire-pools-dialog/retire-pools-dialog.component.ts index 2a0c929ba6..bfbd5a71ef 100644 --- a/frontend/src/app/modules/contract-engine/dialogs/retire-pools-dialog/retire-pools-dialog.component.ts +++ b/frontend/src/app/modules/contract-engine/dialogs/retire-pools-dialog/retire-pools-dialog.component.ts @@ -39,7 +39,6 @@ export class RetirePoolsDialogComponent implements OnInit { loadPools() { this.loading = true; - this.contractService .getRetirePools({ contractId: this.contract.contractId, @@ -70,10 +69,6 @@ export class RetirePoolsDialogComponent implements OnInit { }, () => (this.loading = false) ); - - // this.contractService.getIndexerData('0.0.5148441').subscribe((data: any) =>{ - // console.log(data); - // }); } onPage(event: any) { 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 f2256d7303..b723b25efb 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 @@ -52,7 +52,6 @@ export class UserRetirePoolsDialogComponent implements OnInit { loadPools() { this.loading = true; - console.log(123); this.contractService .getRetirePools({ diff --git a/frontend/src/app/services/contract.service.ts b/frontend/src/app/services/contract.service.ts index d112f47ac3..aa657d185a 100644 --- a/frontend/src/app/services/contract.service.ts +++ b/frontend/src/app/services/contract.service.ts @@ -224,10 +224,6 @@ export class ContractService { }); } - public getIndexerData(contractId: string,) { - - } - public clearRetireRequests(contractId: string) { return this.http.delete( `${this.url}/retire/${contractId}/requests` diff --git a/guardian-service/src/api/analytics.service.ts b/guardian-service/src/api/analytics.service.ts index 59b5d2d8d6..4b0a76975c 100644 --- a/guardian-service/src/api/analytics.service.ts +++ b/guardian-service/src/api/analytics.service.ts @@ -732,7 +732,6 @@ export async function analyticsAPI(logger: PinoLogger): Promise { return new MessageResponse(result); } catch (error) { - console.log(321); return new MessageResponse(false); } }); diff --git a/guardian-service/src/api/contract.service.ts b/guardian-service/src/api/contract.service.ts index 688d938e20..ad8dcba307 100644 --- a/guardian-service/src/api/contract.service.ts +++ b/guardian-service/src/api/contract.service.ts @@ -1161,7 +1161,7 @@ async function saveRetireVC( userHederaAccountId: string, tokens: (RetireTokenRequest & { decimals: number })[] ) { - const contract = await dataBaseServer.findOne(Contract, { // Get retirement and save or maybe create new one + const contract = await dataBaseServer.findOne(Contract, { contractId, owner: owner.creator, }); @@ -2958,7 +2958,7 @@ export async function contractAPI( } }); - ApiResponse(ContractAPI.RETIRE, async (msg: { // Tokens Retire here + ApiResponse(ContractAPI.RETIRE, async (msg: { owner: IOwner, poolId: string, tokens: RetireTokenRequest[] @@ -3401,7 +3401,7 @@ export async function contractAPI( } return new MessageResponse( - await dataBaseServer.findAndCount(VcDocument, filters, otherOptions) // find Retirement VCs + await dataBaseServer.findAndCount(VcDocument, filters, otherOptions) ); } catch (error) { await logger.error(error, ['GUARDIAN_SERVICE']); @@ -3450,13 +3450,6 @@ export async function contractAPI( user.hederaAccountId; } - - - - - - - // Get Retirements from Indexer const retirements = await new Workers().addNonRetryableTask({ type: WorkerTaskType.ANALYTICS_GET_RETIRE_DOCUMENTS, diff --git a/indexer-service/src/api/analytics.service.ts b/indexer-service/src/api/analytics.service.ts index 4b1f73e4d2..404889a8e6 100644 --- a/indexer-service/src/api/analytics.service.ts +++ b/indexer-service/src/api/analytics.service.ts @@ -131,9 +131,6 @@ export class AnalyticsService { try { const { topicId } = msg; const em = DataBaseHelper.getEntityManager(); - - const retirements = []; - const [messages, count] = (await em.findAndCount( Message, { @@ -141,14 +138,9 @@ export class AnalyticsService { action: MessageAction.CreateVC, } as any )) as any; - - console.log(messages); - console.log(count); let VCdocuments: VCDetails[] = []; for (const result of messages) { - console.log(result.files); - for (const fileName of result.files) { try { const file = await DataBaseHelper.loadFile(fileName); @@ -158,10 +150,6 @@ export class AnalyticsService { } } } - console.log(VCdocuments); - console.log(topicId); - - const results = []; return new MessageResponse(VCdocuments); } catch (error) { @@ -169,9 +157,6 @@ export class AnalyticsService { } } - /** - * Get Indexer availability - */ @MessagePattern(IndexerMessageAPI.GET_INDEXER_AVAILABILITY) async checkAvailability(): Promise> { return new MessageResponse(true); diff --git a/indexer-service/src/api/search.service.ts b/indexer-service/src/api/search.service.ts index a22ec3459c..45d1d97ed6 100644 --- a/indexer-service/src/api/search.service.ts +++ b/indexer-service/src/api/search.service.ts @@ -9,7 +9,6 @@ import { } from '@indexer/common'; import { parsePageParams } from '../utils/parse-page-params.js'; import { Page, SearchItem } from '@indexer/interfaces'; -import { loadFiles } from 'helpers/load-files.js'; @Controller() export class SearchService { @@ -24,47 +23,17 @@ export class SearchService { } const options = parsePageParams(msg); const { search } = msg; - const em = DataBaseHelper.getEntityManager(); - // const [results, count] = (await em.findAndCount( - // Message, - // { - // $text: { - // $search: search, - // }, - // } as any, - // options - // )) as any as [SearchItem[], number]; - - const retirements = []; - const [results, count] = (await em.findAndCount( Message, { - "topicId": "0.0.5148441", // memo from contract or topicId - "action": "create-vc-document" + $text: { + $search: search, + }, } as any, options - )) as any; - - let VCdocuments = []; - for (const result of results) { - console.log(result.files); - - for (const fileName of result.files) { - try { - const file = await DataBaseHelper.loadFile(fileName); - VCdocuments.push(file); - } catch (error) { - VCdocuments.push(null); - } - } - } - - console.log(VCdocuments); - - + )) as any as [SearchItem[], number]; const result = { items: results, diff --git a/indexer-worker-service/configs/.env.worker b/indexer-worker-service/configs/.env.worker index 8d12583fd9..7883f908b7 100644 --- a/indexer-worker-service/configs/.env.worker +++ b/indexer-worker-service/configs/.env.worker @@ -18,7 +18,7 @@ CYCLE_TIME="3600000" TOPIC_READ_DELAY="1000" TOPIC_READ_TIMEOUT="60000" TOPIC_JOB_REFRESH_TIME="60000" -TOPIC_JOB_COUNT="30" +TOPIC_JOB_COUNT="5" TOKEN_READ_DELAY="1000" TOKEN_READ_TIMEOUT="60000" TOKEN_JOB_REFRESH_TIME="60000" @@ -26,5 +26,5 @@ TOKEN_JOB_COUNT="2" MESSAGE_READ_DELAY="1000" MESSAGE_READ_TIMEOUT="60000" MESSAGE_JOB_REFRESH_TIME="60000" -MESSAGE_JOB_COUNT="30" +MESSAGE_JOB_COUNT="5" IPFS_GATEWAY="http://127.0.0.1:8080/ipfs/${cid}" diff --git a/indexer-worker-service/configs/.env.worker.develop b/indexer-worker-service/configs/.env.worker.develop index 08c9942b17..ed0126179f 100644 --- a/indexer-worker-service/configs/.env.worker.develop +++ b/indexer-worker-service/configs/.env.worker.develop @@ -18,7 +18,7 @@ CYCLE_TIME="3600000" TOPIC_READ_DELAY="1000" TOPIC_READ_TIMEOUT="60000" TOPIC_JOB_REFRESH_TIME="60000" -TOPIC_JOB_COUNT="30" +TOPIC_JOB_COUNT="5" TOKEN_READ_DELAY="1000" TOKEN_READ_TIMEOUT="60000" TOKEN_JOB_REFRESH_TIME="60000" @@ -26,5 +26,5 @@ TOKEN_JOB_COUNT="2" MESSAGE_READ_DELAY="1000" MESSAGE_READ_TIMEOUT="60000" MESSAGE_JOB_REFRESH_TIME="60000" -MESSAGE_JOB_COUNT="30" +MESSAGE_JOB_COUNT="5" IPFS_GATEWAY="http://127.0.0.1:8080/ipfs/${cid}" \ No newline at end of file diff --git a/indexer-worker-service/configs/.env.worker.template b/indexer-worker-service/configs/.env.worker.template index 508cb9fd82..4616c23784 100644 --- a/indexer-worker-service/configs/.env.worker.template +++ b/indexer-worker-service/configs/.env.worker.template @@ -18,7 +18,7 @@ CYCLE_TIME="3600000" TOPIC_READ_DELAY="1000" TOPIC_READ_TIMEOUT="60000" TOPIC_JOB_REFRESH_TIME="60000" -TOPIC_JOB_COUNT="30" +TOPIC_JOB_COUNT="5" TOKEN_READ_DELAY="1000" TOKEN_READ_TIMEOUT="60000" TOKEN_JOB_REFRESH_TIME="60000" @@ -26,4 +26,4 @@ TOKEN_JOB_COUNT="2" MESSAGE_READ_DELAY="1000" MESSAGE_READ_TIMEOUT="60000" MESSAGE_JOB_REFRESH_TIME="60000" -MESSAGE_JOB_COUNT="30" \ No newline at end of file +MESSAGE_JOB_COUNT="5" \ No newline at end of file diff --git a/indexer-worker-service/src/services/message-service.ts b/indexer-worker-service/src/services/message-service.ts index 8610e81c7d..9ae47bd6ca 100644 --- a/indexer-worker-service/src/services/message-service.ts +++ b/indexer-worker-service/src/services/message-service.ts @@ -50,9 +50,6 @@ export class MessageService { $or: [ { status: 'LOADING', lastUpdate: { $lt: delay } }, { status: 'COMPRESSED' } - ], - $and: [ - { topicId: "0.0.5148441" } ] }, { From 495c400cdb5bfc0825b58f7f0ad06250f8c14329 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Wed, 18 Dec 2024 14:58:21 +0100 Subject: [PATCH 11/28] Improve trust chain component. Add interfaces. Add receiving transaction timestamp. --- api-gateway/src/helpers/guardians.ts | 3 +- .../report-block/report-block.component.html | 164 +++++++++++------- .../report-block/report-block.component.scss | 29 ++++ .../report-block/report-block.component.ts | 105 +++++++++-- .../policy-viewer/policy-viewer.component.ts | 2 +- frontend/src/app/services/contract.service.ts | 3 +- guardian-service/src/api/contract.service.ts | 4 +- .../src/api/services/analytics.ts | 6 +- indexer-api-gateway/src/dto/index.ts | 1 + indexer-service/src/api/analytics.service.ts | 12 +- interfaces/src/interface/index.ts | 3 +- .../interface/retirement-message.interface.ts | 69 ++++++++ 12 files changed, 310 insertions(+), 91 deletions(-) create mode 100644 interfaces/src/interface/retirement-message.interface.ts diff --git a/api-gateway/src/helpers/guardians.ts b/api-gateway/src/helpers/guardians.ts index 1d61d3336e..b344b2fa5c 100644 --- a/api-gateway/src/helpers/guardians.ts +++ b/api-gateway/src/helpers/guardians.ts @@ -11,6 +11,7 @@ import { IContract, IDidObject, IOwner, + IRetirementMessage, IRetirePool, IRetireRequest, ISchema, @@ -1859,7 +1860,7 @@ export class Guardians extends NatsService { contractTopicId: string, pageIndex?: any, pageSize?: any - ): Promise<[IVC[], number]> { + ): Promise<[IRetirementMessage[], number]> { return await this.sendMessage(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, { owner, contractTopicId, 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 2e32610997..5f9c1cfb3b 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 @@ -363,75 +363,119 @@

Policy Overview

- - -
-
- -
-
-
-
- Token(s) Retirement: {{ retirementDocuments.length }} + + +
+
+ +
+
+
+
+ Token(s) Retirement: {{ group.documents.length }} +
+
+

Token ID {{ mintTokenId }}

+

ContractID {{ + group.contractId + }}

+
+
+ +

+ No data from the indexer. Connect it and click Refresh for full + details. +

+
-
-

Token ID {{ mintTokenId }}

-

ContractID {{ - currentRetirementDocument.contractId - }}

-

UserID {{ - currentRetirementDocument.user - }}

+
+
+ + + + + + +
+
+
+
+
+
+ {{ getRetirementGroupVC(group).issuanceDate | date : 'YYYY-MM-dd, hh:mm:ss' }} +
+
+ +
-
- -

- No data from the indexer. Connect it and click Refresh for full - details. -

+
+
+

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].serials.join(', ') }}

+

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].tokenId }}

+

Transaction {{ getRetirementGroupVC(group).timestamp || '-'}}

+

UserID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

+
+
+

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].serials.join(', ') }}

+

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].tokenId }}

+
+
+ +
+ chevron_left + + {{ (group.selectedItemIndex + 1) }} of {{ group.documents.length }} + + chevron_right
-
-
- - - -
-
-
-
- {{ currentRetirementDocument.createDate | date : 'YYYY-MM-dd, hh:mm:ss' }} -
-
- + + +
+
+
+
+ {{ getRetirementGroupVC(group).issuanceDate | date : 'YYYY-MM-dd, hh:mm:ss' }} +
+
+ +
+
+
+

Instance ID {{ '?' }}

+

Token {{ getRetirementGroupVC(group).tokenId }}

+

Transaction {{ getRetirementGroupVC(group).timestamp }}

+

UserID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

+
+ +
+ chevron_left + + {{ (group.selectedItemIndex + 1) }} of {{ group.documents.length }} + + chevron_right +
-
-

Instance ID {{ '?' }}

-

Token {{ '?' }}

-

Transaction {{ '?' }} -

-
- -
- chevron_left - - {{ (currentRetirementIndex + 1) }} of {{ retirementDocuments.length }} - - chevron_right -
-
+
-
+
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 451bbe40eb..ff4b18f265 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 @@ -799,6 +799,12 @@ h3 { .chain-title { margin-top: 0; } + + &.multiple-tokens { + margin: 6px 16px 6px 8px; + width: 450px; + height: 182px; + } } .retirement-container { @@ -857,6 +863,23 @@ h3 { } } +.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; @@ -875,6 +898,12 @@ h3 { color: #000000; } } + + &.second-token { + p { + text-align: left; + } + } } .retire-no-indexer-info { 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 e99a00536d..ede873738c 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 @@ -13,6 +13,8 @@ import { IVCReport, IVPReport, ContractType, + IRetirementMessage, + IVC, } from '@guardian/interfaces'; import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; import { IPFSService } from 'src/app/services/ipfs.service'; @@ -104,15 +106,11 @@ export class ReportBlockComponent implements OnInit { // Testing mintTokenId: string; mintTokenSerials: string[] = []; - retirementDocuments: any = []; + groupedByContractRetirements: any = []; indexerAvailable: boolean = false; - currentRetirementDocument: any; - currentRetirementIndex: number = 0; private loadRetireData() { this.loading = true; - const retirementsFromIndexer: any[] = []; - this.contractService .getContracts({ type: ContractType.RETIRE @@ -134,6 +132,7 @@ export class ReportBlockComponent implements OnInit { this.analyticsService.checkIndexer().subscribe(indexerAvailable => { this.indexerAvailable = indexerAvailable; if (indexerAvailable) { + this.loading = true; if (tokenContractTopicIds.length > 0) { const indexerCalls: Observable>[] = []; tokenContractTopicIds.forEach(id => { @@ -141,9 +140,51 @@ export class ReportBlockComponent implements OnInit { }) forkJoin([this.contractService.getRetireVCs(), ...indexerCalls]).subscribe((results: any) => { + this.loading = false; const retires = results.map((item: any) => item.body) - console.log(retires); - this.retirementDocuments = retires[0]; + + const [retiresDb, ...retiresIndexer] = retires; + const retiresDbMapped = retiresDb + .filter((item: any) => item.type == 'RETIRE') + .map((item: any) => item.document); + + console.log(retiresIndexer); + + const combinedRetirements = [...retiresDbMapped]; + retiresIndexer.forEach((retirements: IRetirementMessage[]) => { + retirements.forEach((item: IRetirementMessage) => { + const existInGuardianDocument = retiresDbMapped.find((retire: IVC) => retire.id === item.documents[0].id); + console.log(existInGuardianDocument); + if (!existInGuardianDocument) { + item.documents[0].timestamp = item.consensusTimestamp; + item.documents[0].owner = item.owner; + combinedRetirements.push(item.documents[0]); + } + else { + existInGuardianDocument.timestamp = item.consensusTimestamp; + existInGuardianDocument.owner = item.owner; + } + }); + }); + + const tokenRetirementDocuments = combinedRetirements + .filter((item: any) => item.credentialSubject.some((subject: any) => + subject.tokens.some((token: any) => + token.tokenId === this.mintTokenId + && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) + )))); + + console.log(tokenRetirementDocuments); + + this.groupedByContractRetirements = Array.from( + new Map(tokenRetirementDocuments + .map((item: any) => [item.credentialSubject[0].contractId, []]) + )).map(([contractId, documents]) => ({ + contractId, + selectedItemIndex: 0, + documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) + })) + console.log(this.groupedByContractRetirements); }) } } else { @@ -151,7 +192,7 @@ export class ReportBlockComponent implements OnInit { .getRetireVCs() .subscribe( (policiesResponse) => { - this.retirementDocuments = (policiesResponse.body || []) + const tokenRetirementDocuments = (policiesResponse.body || []) .filter((item: any) => item.type == 'RETIRE' && item.document.credentialSubject.some((subject: any) => subject.tokens.some((token: any) => @@ -159,10 +200,17 @@ export class ReportBlockComponent implements OnInit { && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) )))).map((vc: any) => vc.document); - this.currentRetirementIndex = 0; - this.currentRetirementDocument = this.retirementDocuments.length > (this.currentRetirementIndex + 1) ? this.retirementDocuments[this.currentRetirementIndex] : null; + console.log(tokenRetirementDocuments); - console.log(this.retirementDocuments); + this.groupedByContractRetirements = Array.from( + new Map(tokenRetirementDocuments + .map((item: any) => [item.credentialSubject[0].contractId, []]) + )).map(([contractId, documents]) => ({ + contractId, + selectedItemIndex: 0, + documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) + })) + console.log(this.groupedByContractRetirements); this.loading = false; }, @@ -179,18 +227,20 @@ export class ReportBlockComponent implements OnInit { ); } - onNextRetirementClick(event: any) { + getRetirementGroupVC(group: any): any { + return group.documents[group.selectedItemIndex]; + } + + onNextRetirementClick(event: any, group: any) { event.stopPropagation(); - this.currentRetirementIndex = this.retirementDocuments.length > (this.currentRetirementIndex + 1) ? this.currentRetirementIndex + 1 : 0; - this.currentRetirementDocument = this.retirementDocuments[this.currentRetirementIndex]; + group.selectedItemIndex = group.documents.length > (group.selectedItemIndex + 1) ? group.selectedItemIndex + 1 : 0; } - onPrevRetirementClick(event: any) { + onPrevRetirementClick(event: any, group: any) { event.stopPropagation(); - this.currentRetirementIndex = (this.currentRetirementIndex - 1) >= 0 ? (this.currentRetirementIndex - 1) : (this.retirementDocuments.length - 1); - this.currentRetirementDocument = this.retirementDocuments[this.currentRetirementIndex]; + group.selectedItemIndex = (group.selectedItemIndex - 1) >= 0 ? (group.selectedItemIndex - 1) : (group.documents.length - 1); } // ... @@ -397,6 +447,27 @@ export class ReportBlockComponent implements OnInit { dialogRef.onClose.subscribe(async (result) => { }); } + openRetireVCDocument( + item: any, + document?: any + ) { + const title = `Retire Document`; + const dialogRef = this.dialogService.open(VCViewerDialog, { + showHeader: false, + width: '1000px', + styleClass: 'guardian-dialog', + data: { + id: item.id, + row: item, + viewDocument: true, + document: item, + title: title, + type: 'VC', + } + }); + dialogRef.onClose.subscribe(async (result) => { }); + } + mapData(data: any[]) { const chain: any[] = data; return chain; 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/contract.service.ts b/frontend/src/app/services/contract.service.ts index aa657d185a..0f85024ee8 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'; @@ -322,7 +323,7 @@ export class ContractService { contractTopicId: string, pageIndex?: number, pageSize?: number - ) { + ): Observable> { let url = `${this.url}/retireIndexer?contractTopicId=${contractTopicId}`; if (pageIndex && pageSize) { url += `?pageIndex=${pageIndex}&pageSize=${pageSize}` diff --git a/guardian-service/src/api/contract.service.ts b/guardian-service/src/api/contract.service.ts index ad8dcba307..afc470fe03 100644 --- a/guardian-service/src/api/contract.service.ts +++ b/guardian-service/src/api/contract.service.ts @@ -3451,7 +3451,7 @@ export async function contractAPI( } // Get Retirements from Indexer - const retirements = await new Workers().addNonRetryableTask({ + const messages = await new Workers().addNonRetryableTask({ type: WorkerTaskType.ANALYTICS_GET_RETIRE_DOCUMENTS, data: { payload: { options: { topicId: contractTopicId } } @@ -3515,7 +3515,7 @@ export async function contractAPI( // ); // ... - return new MessageResponse([retirements, retirements.length]); + return new MessageResponse([messages, messages.length]); } catch (error) { await logger.error(error, ['GUARDIAN_SERVICE']); return new MessageError(error); diff --git a/indexer-api-gateway/src/api/services/analytics.ts b/indexer-api-gateway/src/api/services/analytics.ts index ad63967030..8416fa79df 100644 --- a/indexer-api-gateway/src/api/services/analytics.ts +++ b/indexer-api-gateway/src/api/services/analytics.ts @@ -7,14 +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, - VCDetailsDTO, + MessageDTO, } from '#dto'; @Controller('analytics') @@ -58,7 +58,7 @@ export class AnalyticsApi extends ApiClient { }) @ApiOkResponse({ description: 'Search policy result', - type: [VCDetailsDTO], + type: [MessageDTO], }) @ApiInternalServerErrorResponse({ description: 'Internal server error', 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-service/src/api/analytics.service.ts b/indexer-service/src/api/analytics.service.ts index 404889a8e6..2eec4c4dfa 100644 --- a/indexer-service/src/api/analytics.service.ts +++ b/indexer-service/src/api/analytics.service.ts @@ -127,7 +127,7 @@ export class AnalyticsService { async getRetireDocuments( @Payload() msg: RawMessage - ): Promise> { + ): Promise> { try { const { topicId } = msg; const em = DataBaseHelper.getEntityManager(); @@ -139,9 +139,9 @@ export class AnalyticsService { } as any )) as any; - let VCdocuments: VCDetails[] = []; - for (const result of messages) { - for (const fileName of result.files) { + 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); @@ -149,9 +149,11 @@ export class AnalyticsService { VCdocuments.push(null); } } + + message.documents = VCdocuments; } - return new MessageResponse(VCdocuments); + return new MessageResponse(messages); } catch (error) { return new MessageError(error); } diff --git a/interfaces/src/interface/index.ts b/interfaces/src/interface/index.ts index d158738003..0de6f98623 100644 --- a/interfaces/src/interface/index.ts +++ b/interfaces/src/interface/index.ts @@ -42,4 +42,5 @@ export * from './policy-tool-metadata.interface.js'; export * from './sign-options.interface.js' export * from './owner.interface.js' export * from './statistic.interface.js' -export * from './schema-rules.interface.js' \ No newline at end of file +export * from './schema-rules.interface.js' +export * from './retirement-message.interface.js' \ No newline at end of file diff --git a/interfaces/src/interface/retirement-message.interface.ts b/interfaces/src/interface/retirement-message.interface.ts new file mode 100644 index 0000000000..74c781bf88 --- /dev/null +++ b/interfaces/src/interface/retirement-message.interface.ts @@ -0,0 +1,69 @@ +/** + * 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[]; +} From 9b21e876e1726ba460347b99702d03bb2a67249a Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Wed, 18 Dec 2024 22:40:53 +0100 Subject: [PATCH 12/28] Improve new trust chain. Improve trust chain. --- .../policy-engine/policy-engine.module.ts | 3 +- .../messages-report-block.component.html | 84 +++++++++++++ .../messages-report-block.component.ts | 111 +++++++++++++++++- .../report-block/report-block.component.html | 15 ++- .../report-block/report-block.component.ts | 105 ++++++++--------- 5 files changed, 252 insertions(+), 66 deletions(-) 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 a38a05f6ca..ce94ab53f1 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 @@ -184,6 +184,21 @@
{{message.__issuer}}
+ + +
+ receipt + Retirement +
+
+
+ Contract ID: {{message.documents[0].credentialSubject[0].contractId}} +
+
+ User ID: {{message.documents[0].credentialSubject[0].user}} +
+
+
@@ -730,6 +745,75 @@
+ + +
+ receipt + Retirement message +
+ +
+ +
+
Document artifact:
+
+ Open document +
+
+ +
+
+
Contract ID:
+
{{selected.documents[0].credentialSubject[0].contractId}}
+
+
+
User ID:
+
{{selected.documents[0].credentialSubject[0].user}}
+
+
+
+
+
Token ID:
+
{{token.tokenId}}
+
+
+
Instance ID:
+
{{token.serials.join(', ')}}
+
+
+
Amount:
+
{{token.count}}
+
+
+
Transaction:
+
{{selected.consensusTimestamp}}
+
+
+ +
+ +
+
Topic ID:
+
+ {{selected.topicId}} +
+
+
+
Message ID:
+
+ {{selected.consensusTimestamp}} +
+
+
+
Owner:
+
+ {{selected.owner}} +
+
+
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 b7b6fa89d3..deaf45b45f 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 @@ -9,7 +9,12 @@ import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialo 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 { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { ContractType, IRetirementMessage, IVC } from '@guardian/interfaces'; +import { Observable, forkJoin } from 'rxjs'; +import { ContractService } from 'src/app/services/contract.service'; +import { AnalyticsService } from 'src/app/services/analytics.service'; +import { DatePipe } from '@angular/common'; /** * Dashboard Type @@ -268,7 +273,10 @@ export class MessagesReportBlockComponent implements OnInit { private dialog: MatDialog, private dialogService: DialogService, private iconRegistry: MatIconRegistry, - private sanitizer: DomSanitizer + private sanitizer: DomSanitizer, + private contractService: ContractService, + private analyticsService: AnalyticsService, + private datePipe: DatePipe ) { iconRegistry.addSvgIconLiteral('token', sanitizer.bypassSecurityTrustHtml(` @@ -365,6 +373,11 @@ export class MessagesReportBlockComponent implements OnInit { }, 100); } + mintTokenId: string; + mintTokenSerials: string[] = []; + groupedByContractRetirements: any = []; + indexerAvailable: boolean = false; + retirementMessages: any[] = []; private createSmallReport() { for (const topic of this._topics1) { if (topic.message?.messageType === 'INSTANCE_POLICY_TOPIC') { @@ -381,6 +394,98 @@ export class MessagesReportBlockComponent implements OnInit { this._messages2.push(message); } } + + this._messages2.forEach(message => { + if (message.__ifMintMessage) { + this.mintTokenId = message.__tokenId; + + // this.mintTokenSerials = (report.vpDocument?.document as any).serials.map((serialItem: any) => serialItem.serial); // Fix + } + }); + + + this.contractService + .getContracts({ + type: ContractType.RETIRE + }) + .subscribe( + (policiesResponse) => { + const contracts = policiesResponse.body || []; + const tokenContractTopicIds: string[] = []; + + if (contracts && contracts.length > 0) { + contracts.forEach(contract => { + if (contract.wipeTokenIds && contract.wipeTokenIds.length > 0 && + contract.wipeTokenIds.some((tokenId: string) => tokenId == this.mintTokenId)) { + tokenContractTopicIds.push(contract.topicId); + } + }); + } + + this.analyticsService.checkIndexer().subscribe(indexerAvailable => { + this.indexerAvailable = indexerAvailable; + if (indexerAvailable && tokenContractTopicIds.length > 0) { + const indexerCalls: Observable>[] = []; + tokenContractTopicIds.forEach(id => { + indexerCalls.push(this.contractService.getRetireVCsFromIndexer(id)) + }) + + this.loading = true; + forkJoin(indexerCalls).subscribe((results: any) => { + this.loading = false; + const retires = results.map((item: any) => item.body) + + const tokenRetires = retires.map((retirements: IRetirementMessage[]) => { + const ret = retirements.filter((item: IRetirementMessage) => item.documents[0].credentialSubject.some((subject: any) => + subject.tokens.some((token: any) => + token.tokenId === this.mintTokenId + && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) + )))); + return ret + }); + + const allRetireMessages: any = []; + retires.forEach((retirements: IRetirementMessage[]) => { + retirements.forEach((item: IRetirementMessage) => { + if (item.documents[0].credentialSubject[0].tokens.some((token: any) => token.tokenId === this.mintTokenId)) { + item.id == item.consensusTimestamp; + allRetireMessages.push(item); + } + }); + }); + + console.log(this.mintTokenSerials); + + this.groupedByContractRetirements = Array.from( + new Map(allRetireMessages + .map((item: any) => [item.documents[0].credentialSubject[0].contractId, []]) + )).map(([contractId, documents]) => ({ + contractId, + selectedItemIndex: 0, + __ifRetireMessage: true, + documents: allRetireMessages.filter((item: any) => item.documents[0].credentialSubject[0].contractId === contractId) + })) + + allRetireMessages.forEach((element: any) => { + element.__ifRetireMessage = true; + element.__timestamp = this.datePipe.transform(new Date(element.documents[0].issuanceDate), 'yyyy-MM-dd, mm:hh:ss'); + this._messages2.push(element); + this._topics2[0].messages.push(element); + console.log(this._messages2); + }); + + this.retirementMessages = [...allRetireMessages]; + + this._gridTemplateColumns2 = 'repeat(' + (gridSize + this.retirementMessages.length) + ', 230px)'; + }) + } + }) + }, + (e) => { + this.loading = false; + } + ); + let gridSize = 0; this._messages2.sort((a, b) => a.__order > b.__order ? 1 : -1); for (let index = 0; index < this._messages2.length; index++) { @@ -802,7 +907,7 @@ export class MessagesReportBlockComponent implements OnInit { styleClass: 'guardian-dialog', data: { row: null, - document: message.document, + document: message.document || message.documents[0], title: 'VC Document', type: 'VC', viewDocument: true, 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 5f9c1cfb3b..a4d899a7d1 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 @@ -414,13 +414,15 @@

Policy Overview

-

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].serials.join(', ') }}

+

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].serials.join(', ') }}

+

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].count }}

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].tokenId }}

Transaction {{ getRetirementGroupVC(group).timestamp || '-'}}

-

UserID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

+

User ID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

-

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].serials.join(', ') }}

+

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].serials.join(', ') }}

+

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].count }}

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].tokenId }}

@@ -454,10 +456,11 @@

Policy Overview

-

Instance ID {{ '?' }}

-

Token {{ getRetirementGroupVC(group).tokenId }}

+

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].serials.join(', ') }}

+

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].count }}

+

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].tokenId }}

Transaction {{ getRetirementGroupVC(group).timestamp }}

-

UserID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

+

User ID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

Date: Thu, 19 Dec 2024 23:15:15 +0100 Subject: [PATCH 15/28] Add sequence number for retirement message for hedera explorer. --- .../messages-report-block.component.html | 10 ++--- .../messages-report-block.component.ts | 3 -- .../report-block/report-block.component.ts | 38 +++++++++---------- indexer-api-gateway/src/dto/message.dto.ts | 5 +++ indexer-common/src/entity/message.ts | 3 ++ .../src/interfaces/message.interface.ts | 4 ++ indexer-service/src/api/analytics.service.ts | 21 +++++++--- 7 files changed, 52 insertions(+), 32 deletions(-) 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 ce94ab53f1..449e365cf2 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 @@ -770,6 +770,10 @@
User ID:
{{selected.documents[0].credentialSubject[0].user}}
+
+
Transaction:
+
{{selected.consensusTimestamp}}
+
@@ -784,10 +788,6 @@
Amount:
{{token.count}}
-
-
Transaction:
-
{{selected.consensusTimestamp}}
-
@@ -803,7 +803,7 @@
Message ID:
{{selected.consensusTimestamp}} + [subParams]="selected.sequenceNumber">{{selected.consensusTimestamp}}
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 deaf45b45f..f57835e4c9 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 @@ -454,8 +454,6 @@ export class MessagesReportBlockComponent implements OnInit { }); }); - console.log(this.mintTokenSerials); - this.groupedByContractRetirements = Array.from( new Map(allRetireMessages .map((item: any) => [item.documents[0].credentialSubject[0].contractId, []]) @@ -471,7 +469,6 @@ export class MessagesReportBlockComponent implements OnInit { element.__timestamp = this.datePipe.transform(new Date(element.documents[0].issuanceDate), 'yyyy-MM-dd, mm:hh:ss'); this._messages2.push(element); this._topics2[0].messages.push(element); - console.log(this._messages2); }); this.retirementMessages = [...allRetireMessages]; 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 6acb14465e..58655b32c9 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 @@ -104,6 +104,7 @@ export class ReportBlockComponent implements OnInit { } // Testing + vpDocument: any; mintTokenId: string; mintTokenSerials: string[] = []; groupedByContractRetirements: any = []; @@ -146,7 +147,7 @@ export class ReportBlockComponent implements OnInit { const retiresDbMapped = retiresDb .filter((item: any) => item.type == 'RETIRE') .map((item: any) => item.document); - + const combinedRetirements = [...retiresDbMapped]; retiresIndexer.forEach((retirements: IRetirementMessage[]) => { retirements.forEach((item: IRetirementMessage) => { @@ -164,8 +165,9 @@ export class ReportBlockComponent implements OnInit { }); const tokenRetirementDocuments = combinedRetirements - .filter((item: any) => item.credentialSubject.some((subject: any) => - subject.tokens.some((token: any) => + .filter((item: any) => item.credentialSubject.some((subject: any) => + subject.user === this.vpDocument.document.target + && subject.tokens.some((token: any) => token.tokenId === this.mintTokenId && this.mintTokenSerials.length <= 0 || token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) )))); @@ -173,11 +175,11 @@ export class ReportBlockComponent implements OnInit { this.groupedByContractRetirements = Array.from( new Map(tokenRetirementDocuments .map((item: any) => [item.credentialSubject[0].contractId, []]) - )).map(([contractId, documents]) => ({ - contractId, - selectedItemIndex: 0, - documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) - })) + )).map(([contractId, documents]) => ({ + contractId, + selectedItemIndex: 0, + documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) + })) }) } else { this.contractService @@ -187,22 +189,20 @@ export class ReportBlockComponent implements OnInit { const tokenRetirementDocuments = (policiesResponse.body || []) .filter((item: any) => item.type == 'RETIRE' && item.document.credentialSubject.some((subject: any) => - subject.tokens.some((token: any) => + subject.user === this.vpDocument.document.target + && subject.tokens.some((token: any) => token.tokenId === this.mintTokenId && this.mintTokenSerials.length <= 0 || token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) )))).map((vc: any) => vc.document); - console.log(tokenRetirementDocuments); - this.groupedByContractRetirements = Array.from( new Map(tokenRetirementDocuments .map((item: any) => [item.credentialSubject[0].contractId, []]) - )).map(([contractId, documents]) => ({ - contractId, - selectedItemIndex: 0, - documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) - })) - console.log(this.groupedByContractRetirements); + )).map(([contractId, documents]) => ({ + contractId, + selectedItemIndex: 0, + documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) + })) this.loading = false; }, @@ -293,11 +293,11 @@ export class ReportBlockComponent implements OnInit { this.documents = report.documents || []; - console.log(report.vpDocument); - + // Testing this.mintTokenId = report.mintDocument?.tokenId || ''; this.mintTokenSerials = (report.vpDocument?.document as any).serials.map((serialItem: any) => serialItem.serial); // Fix + this.vpDocument = report.vpDocument; this.loadRetireData(); // ... 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 27a834b1ad..15494b922f 100644 --- a/indexer-common/src/entity/message.ts +++ b/indexer-common/src/entity/message.ts @@ -90,4 +90,7 @@ export class Message implements IMessage { @Property({ nullable: true }) tokens: string[]; + + @Property({ nullable: true }) + sequenceNumber?: number; } diff --git a/indexer-interfaces/src/interfaces/message.interface.ts b/indexer-interfaces/src/interfaces/message.interface.ts index da9aadbfc7..b09aa1fa9c 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 2eec4c4dfa..1c127adb8d 100644 --- a/indexer-service/src/api/analytics.service.ts +++ b/indexer-service/src/api/analytics.service.ts @@ -6,7 +6,8 @@ import { MessageError, DataBaseHelper, Message, - AnyResponse + AnyResponse, + MessageCache } from '@indexer/common'; import escapeStringRegexp from 'escape-string-regexp'; import { MessageAction, MessageType, RawMessage, SearchPolicyParams, SearchPolicyResult, VCDetails } from '@indexer/interfaces'; @@ -138,7 +139,14 @@ export class AnalyticsService { 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) { @@ -146,13 +154,16 @@ export class AnalyticsService { const file = await DataBaseHelper.loadFile(fileName); VCdocuments.push(JSON.parse(file) as VCDetails); } catch (error) { - VCdocuments.push(null); } } - 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); From 939a2048009574e8f6cf364d32e3077e64608ed4 Mon Sep 17 00:00:00 2001 From: envision-ci-agent Date: Thu, 19 Dec 2024 22:19:36 +0000 Subject: [PATCH 16/28] [skip ci] Add swagger.yaml --- swagger-indexer.yaml | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/swagger-indexer.yaml b/swagger-indexer.yaml index f14b129704..94412afa63 100644 --- a/swagger-indexer.yaml +++ b/swagger-indexer.yaml @@ -2087,6 +2087,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -2161,6 +2165,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -2387,6 +2392,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -2461,6 +2470,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -2525,6 +2535,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -2607,6 +2621,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -2841,6 +2856,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -2915,6 +2934,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -3074,6 +3094,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -3148,6 +3172,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -3287,6 +3312,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -3361,6 +3390,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -3493,6 +3523,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -3565,6 +3599,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -3669,6 +3704,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -3756,6 +3795,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -4024,6 +4064,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -4098,6 +4142,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -4220,6 +4265,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -4294,6 +4343,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -4358,6 +4408,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -4440,6 +4494,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -4530,6 +4585,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 required: - id - topicId @@ -4544,6 +4603,7 @@ components: - files - topics - tokens + - sequenceNumber RelationshipDTO: type: object properties: @@ -4720,6 +4780,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -4792,6 +4856,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -4884,6 +4949,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -4966,6 +5035,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -5106,6 +5176,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -5180,6 +5254,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -5244,6 +5319,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -5326,6 +5405,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -5595,6 +5675,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -5669,6 +5753,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options @@ -5884,6 +5969,10 @@ components: type: array items: type: string + sequenceNumber: + type: number + description: SequenceNumber + example: 0 type: type: string description: Type @@ -5958,6 +6047,7 @@ components: - files - topics - tokens + - sequenceNumber - type - action - options From 1d44a6775d4795f9f1f2567614ddb7418dd88ad7 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Fri, 20 Dec 2024 00:13:16 +0100 Subject: [PATCH 17/28] Add retirements and message order for advanced view. --- .../messages-report-block.component.ts | 118 +++++++++++------- 1 file changed, 74 insertions(+), 44 deletions(-) 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 f57835e4c9..4bb0520c56 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 @@ -364,6 +364,7 @@ export class MessagesReportBlockComponent implements OnInit { if (this.report) { this.createReport(this.report); this.createSmallReport(); + this.loadRetirementMessages(); } } this.removeLines(); @@ -373,37 +374,16 @@ export class MessagesReportBlockComponent implements OnInit { }, 100); } + + gridSize: number = 0; + mintTokenId: string; mintTokenSerials: string[] = []; groupedByContractRetirements: any = []; indexerAvailable: boolean = false; retirementMessages: any[] = []; - private createSmallReport() { - for (const topic of this._topics1) { - if (topic.message?.messageType === 'INSTANCE_POLICY_TOPIC') { - const t = { ...topic }; - t.__parent = null; - t.__offset = 20; - t.__order = this._topics2.length + 1; - t.messages = this.getAllMessages(topic, []); - this._topics2.push(t); - } - } - for (const topic of this._topics2) { - for (const message of topic.messages) { - this._messages2.push(message); - } - } - - this._messages2.forEach(message => { - if (message.__ifMintMessage) { - this.mintTokenId = message.__tokenId; - - // this.mintTokenSerials = (report.vpDocument?.document as any).serials.map((serialItem: any) => serialItem.serial); // Fix - } - }); - + private loadRetirementMessages() { this.contractService .getContracts({ type: ContractType.RETIRE @@ -435,14 +415,14 @@ export class MessagesReportBlockComponent implements OnInit { this.loading = false; const retires = results.map((item: any) => item.body) - const tokenRetires = retires.map((retirements: IRetirementMessage[]) => { - const ret = retirements.filter((item: IRetirementMessage) => item.documents[0].credentialSubject.some((subject: any) => - subject.tokens.some((token: any) => - token.tokenId === this.mintTokenId - && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) - )))); - return ret - }); + // const tokenRetires = retires.map((retirements: IRetirementMessage[]) => { + // const ret = retirements.filter((item: IRetirementMessage) => item.documents[0].credentialSubject.some((subject: any) => + // subject.tokens.some((token: any) => + // token.tokenId === this.mintTokenId + // && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) + // )))); + // return ret + // }); const allRetireMessages: any = []; retires.forEach((retirements: IRetirementMessage[]) => { @@ -464,16 +444,38 @@ export class MessagesReportBlockComponent implements OnInit { documents: allRetireMessages.filter((item: any) => item.documents[0].credentialSubject[0].contractId === contractId) })) + let lastOrderMessageTopic1 = this._topics1?.[this._topics1.length - 1]?.messages.reduce((acc: number, item: any) => item.__order > acc ? item.__order : acc, 0) + 1; allRetireMessages.forEach((element: any) => { - element.__ifRetireMessage = true; - element.__timestamp = this.datePipe.transform(new Date(element.documents[0].issuanceDate), 'yyyy-MM-dd, mm:hh:ss'); - this._messages2.push(element); - this._topics2[0].messages.push(element); + var newElement = {...element, __order: lastOrderMessageTopic1} + newElement.__ifRetireMessage = true; + newElement.__timestamp = this.datePipe.transform(new Date(newElement.documents[0].issuanceDate), 'yyyy-MM-dd, mm:hh:ss'); + + this._messages1.push(newElement); + this._topics1[this._topics1.length - 1].messages.push(newElement); + + lastOrderMessageTopic1++; }); + + let lastOrderMessageTopic2 = this._topics2?.[0]?.messages.reduce((acc: number, item: any) => item.__order > acc ? item.__order : acc, 0) + 1; + allRetireMessages.forEach((element: any) => { + var newElement = {...element, __order: lastOrderMessageTopic2} + newElement.__ifRetireMessage = true; + newElement.__timestamp = this.datePipe.transform(new Date(newElement.documents[0].issuanceDate), 'yyyy-MM-dd, mm:hh:ss'); + + this._messages2.push(newElement); + this._topics2[0].messages.push(newElement); + + lastOrderMessageTopic2++; + }); + + console.log(this._topics1); + console.log(this._topics2); + this.retirementMessages = [...allRetireMessages]; - this._gridTemplateColumns2 = 'repeat(' + (gridSize + this.retirementMessages.length) + ', 230px)'; + this._gridTemplateColumns1 = 'repeat(' + (this.gridSize + this.retirementMessages.length + 1) + ', 230px)'; + this._gridTemplateColumns2 = 'repeat(' + (this.gridSize + this.retirementMessages.length) + ', 230px)'; }) } }) @@ -482,15 +484,43 @@ export class MessagesReportBlockComponent implements OnInit { this.loading = false; } ); + } + + + + private createSmallReport() { + for (const topic of this._topics1) { + if (topic.message?.messageType === 'INSTANCE_POLICY_TOPIC') { + const t = { ...topic }; + t.__parent = null; + t.__offset = 20; + t.__order = this._topics2.length + 1; + t.messages = this.getAllMessages(topic, []); + this._topics2.push(t); + } + } + for (const topic of this._topics2) { + for (const message of topic.messages) { + this._messages2.push(message); + } + } + + this._messages2.forEach(message => { + if (message.__ifMintMessage) { + this.mintTokenId = message.__tokenId; + + // this.mintTokenSerials = (report.vpDocument?.document as any).serials.map((serialItem: any) => serialItem.serial); // Fix + } + }); - let gridSize = 0; + this.gridSize = 0; this._messages2.sort((a, b) => a.__order > b.__order ? 1 : -1); for (let index = 0; index < this._messages2.length; index++) { const message = this._messages2[index]; message.__order = index + 1; - gridSize = Math.max(gridSize, message.__order); + this.gridSize = Math.max(this.gridSize, message.__order); } - this._gridTemplateColumns2 = 'repeat(' + gridSize + ', 230px)'; + this._gridTemplateColumns2 = 'repeat(' + this.gridSize + ', 230px)'; this._gridTemplateRows2 = 'repeat(' + this._topics2.length + ', 100px) 30px'; } @@ -536,7 +566,7 @@ export class MessagesReportBlockComponent implements OnInit { } private parseMessages() { - let gridSize = 0; + this.gridSize = 0; for (const topic of this._topics1) { if (topic.message) { this.parseMessage(topic, topic.message); @@ -544,7 +574,7 @@ export class MessagesReportBlockComponent implements OnInit { for (const message of topic.messages) { this.parseMessage(topic, message); this._messages1.push(message); - gridSize = Math.max(gridSize, message.__order); + this.gridSize = Math.max(this.gridSize, message.__order); } if (topic.__parent) { topic.__start = 100 * topic.__parent.__order; @@ -567,7 +597,7 @@ export class MessagesReportBlockComponent implements OnInit { topic.message.__rationale = topic.__rationale; } } - this._gridTemplateColumns1 = 'repeat(' + gridSize + ', 230px)'; + this._gridTemplateColumns1 = 'repeat(' + this.gridSize + ', 230px)'; this._gridTemplateRows1 = 'repeat(' + this._topics1.length + ', 100px) 30px'; } From d3665700abf62a9d541e162d7f7f4609fa8a795f Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Fri, 20 Dec 2024 15:00:50 +0100 Subject: [PATCH 18/28] Fix single token retirement display. --- .../blocks/report-block/report-block.component.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 a4d899a7d1..675dd9a59f 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 @@ -395,7 +395,7 @@

Policy Overview

- +
@@ -421,8 +421,8 @@

Policy Overview

User ID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

-

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].serials.join(', ') }}

-

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].count }}

+

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].serials.join(', ') }}

+

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].count }}

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].tokenId }}

From e6712bebc307c5e44762e3cefeed3d275bd6edf3 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Fri, 20 Dec 2024 17:11:10 +0100 Subject: [PATCH 19/28] Add hedera explorer to old trust chain retirement message. --- .../messages-report-block.component.html | 4 ++-- .../report-block/report-block.component.html | 14 ++++++++++---- .../blocks/report-block/report-block.component.ts | 4 ++++ .../src/interface/retirement-message.interface.ts | 4 ++++ 4 files changed, 20 insertions(+), 6 deletions(-) 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 449e365cf2..69030597ae 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 @@ -770,7 +770,7 @@
User ID:
{{selected.documents[0].credentialSubject[0].user}}
-
+
Transaction:
{{selected.consensusTimestamp}}
@@ -810,7 +810,7 @@
Owner:
{{selected.owner}} + [params]="selected.owner">{{selected.owner}}
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 675dd9a59f..4cbfa6d1bd 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 @@ -414,16 +414,22 @@

Policy Overview

+

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].tokenId }}

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].serials.join(', ') }}

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].count }}

-

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].tokenId }}

-

Transaction {{ getRetirementGroupVC(group).timestamp || '-'}}

+ +

Transaction + {{getRetirementGroupVC(group).timestamp}} +

+

Transaction -

+

User ID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

+

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].tokenId }}

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].serials.join(', ') }}

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].count }}

-

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].tokenId }}

@@ -456,9 +462,9 @@

Policy Overview

+

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].tokenId }}

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].serials.join(', ') }}

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].count }}

-

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].tokenId }}

Transaction {{ getRetirementGroupVC(group).timestamp }}

User ID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

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 58655b32c9..aa02d337b2 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 @@ -153,12 +153,16 @@ export class ReportBlockComponent implements OnInit { retirements.forEach((item: IRetirementMessage) => { const existInGuardianDocument = retiresDbMapped.find((retire: IVC) => retire.id === item.documents[0].id); if (!existInGuardianDocument) { + item.documents[0].topicId = item.topicId; item.documents[0].timestamp = item.consensusTimestamp; + item.documents[0].sequenceNumber = item.sequenceNumber; item.documents[0].owner = item.owner; combinedRetirements.push(item.documents[0]); } else { + existInGuardianDocument.topicId = item.topicId; existInGuardianDocument.timestamp = item.consensusTimestamp; + existInGuardianDocument.sequenceNumber = item.sequenceNumber; existInGuardianDocument.owner = item.owner; } }); diff --git a/interfaces/src/interface/retirement-message.interface.ts b/interfaces/src/interface/retirement-message.interface.ts index 74c781bf88..ce2f8fac0b 100644 --- a/interfaces/src/interface/retirement-message.interface.ts +++ b/interfaces/src/interface/retirement-message.interface.ts @@ -66,4 +66,8 @@ export class IRetirementMessage { * Tokens */ tokens: string[]; + /** + * Sequence number + */ + sequenceNumber: string; } From 9232211e695ec24e4fa06939b9e49589529814f0 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Fri, 20 Dec 2024 18:01:50 +0100 Subject: [PATCH 20/28] Add retirement messages ordering in new trust chain. --- .../messages-report-block.component.ts | 49 ++++++++----------- .../report-block/report-block.component.ts | 8 +-- 2 files changed, 21 insertions(+), 36 deletions(-) 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 4bb0520c56..3ba55a54c4 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 @@ -424,54 +424,47 @@ export class MessagesReportBlockComponent implements OnInit { // return ret // }); - const allRetireMessages: any = []; - retires.forEach((retirements: IRetirementMessage[]) => { - retirements.forEach((item: IRetirementMessage) => { + // this.groupedByContractRetirements = Array.from( + // new Map(allRetireMessages + // .map((item: any) => [item.documents[0].credentialSubject[0].contractId, []]) + // )).map(([contractId, documents]) => ({ + // contractId, + // selectedItemIndex: 0, + // __ifRetireMessage: true, + // documents: allRetireMessages.filter((item: any) => item.documents[0].credentialSubject[0].contractId === contractId) + // })) + + let allRetireMessages: any = []; + retires.forEach((retirements: any[]) => { + retirements.forEach((item: any) => { if (item.documents[0].credentialSubject[0].tokens.some((token: any) => token.tokenId === this.mintTokenId)) { - item.id == item.consensusTimestamp; + item.id = item.consensusTimestamp; + item.__ifRetireMessage = true; + item.__timestamp = this.datePipe.transform(new Date(item.documents[0].issuanceDate), 'yyyy-MM-dd, hh:mm:ss'); allRetireMessages.push(item); } }); }); - - this.groupedByContractRetirements = Array.from( - new Map(allRetireMessages - .map((item: any) => [item.documents[0].credentialSubject[0].contractId, []]) - )).map(([contractId, documents]) => ({ - contractId, - selectedItemIndex: 0, - __ifRetireMessage: true, - documents: allRetireMessages.filter((item: any) => item.documents[0].credentialSubject[0].contractId === contractId) - })) - + + allRetireMessages.sort((a: any, b: any) => new Date(a.documents[0].issuanceDate).getTime() - new Date(b.documents[0].issuanceDate).getTime()); + + // For different topics different ordering let lastOrderMessageTopic1 = this._topics1?.[this._topics1.length - 1]?.messages.reduce((acc: number, item: any) => item.__order > acc ? item.__order : acc, 0) + 1; allRetireMessages.forEach((element: any) => { var newElement = {...element, __order: lastOrderMessageTopic1} - newElement.__ifRetireMessage = true; - newElement.__timestamp = this.datePipe.transform(new Date(newElement.documents[0].issuanceDate), 'yyyy-MM-dd, mm:hh:ss'); - this._messages1.push(newElement); this._topics1[this._topics1.length - 1].messages.push(newElement); lastOrderMessageTopic1++; }); - - let lastOrderMessageTopic2 = this._topics2?.[0]?.messages.reduce((acc: number, item: any) => item.__order > acc ? item.__order : acc, 0) + 1; allRetireMessages.forEach((element: any) => { var newElement = {...element, __order: lastOrderMessageTopic2} - newElement.__ifRetireMessage = true; - newElement.__timestamp = this.datePipe.transform(new Date(newElement.documents[0].issuanceDate), 'yyyy-MM-dd, mm:hh:ss'); - this._messages2.push(newElement); this._topics2[0].messages.push(newElement); - lastOrderMessageTopic2++; }); - console.log(this._topics1); - console.log(this._topics2); - this.retirementMessages = [...allRetireMessages]; this._gridTemplateColumns1 = 'repeat(' + (this.gridSize + this.retirementMessages.length + 1) + ', 230px)'; @@ -508,8 +501,6 @@ export class MessagesReportBlockComponent implements OnInit { this._messages2.forEach(message => { if (message.__ifMintMessage) { this.mintTokenId = message.__tokenId; - - // this.mintTokenSerials = (report.vpDocument?.document as any).serials.map((serialItem: any) => serialItem.serial); // Fix } }); 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 aa02d337b2..941014b8bb 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 @@ -296,16 +296,10 @@ export class ReportBlockComponent implements OnInit { this.policyCreatorDocument = report.policyCreatorDocument; this.documents = report.documents || []; - - - // Testing this.mintTokenId = report.mintDocument?.tokenId || ''; - this.mintTokenSerials = (report.vpDocument?.document as any).serials.map((serialItem: any) => serialItem.serial); // Fix + this.mintTokenSerials = (report.vpDocument?.document as any).serials.map((serialItem: any) => serialItem.serial); this.vpDocument = report.vpDocument; this.loadRetireData(); - // ... - - const mainDocument = this.createAdditionalDocument(report); if (mainDocument) { From fc420ad8a6a01a7fd18ce7ba99dea3ee13291e17 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Sat, 21 Dec 2024 03:09:28 +0100 Subject: [PATCH 21/28] Simplify logic and improve readability. --- api-gateway/src/api/service/contract.ts | 17 +- api-gateway/src/helpers/guardians.ts | 11 +- .../messages-report-block.component.ts | 51 ++---- .../report-block/report-block.component.html | 159 +++++++++--------- .../report-block/report-block.component.scss | 29 ---- .../report-block/report-block.component.ts | 22 ++- frontend/src/app/services/contract.service.ts | 9 +- guardian-service/src/api/contract.service.ts | 88 +--------- interfaces/src/type/messages/workers.type.ts | 4 +- 9 files changed, 116 insertions(+), 274 deletions(-) diff --git a/api-gateway/src/api/service/contract.ts b/api-gateway/src/api/service/contract.ts index 828b5aaab1..2fad5fae62 100644 --- a/api-gateway/src/api/service/contract.ts +++ b/api-gateway/src/api/service/contract.ts @@ -1740,19 +1740,6 @@ export class ContractsApi { required: true, example: '0.0.0000000', }) - @ApiQuery({ - name: 'pageIndex', - type: Number, - description: 'The number of pages to skip before starting to collect the result set', - required: false, - example: 0, - }) - @ApiQuery({ - name: 'pageSize', - type: Number, - description: 'The numbers of items to return', - example: 20, - }) @ApiOkResponse({ description: 'Successful operation.', isArray: true, @@ -1774,13 +1761,11 @@ export class ContractsApi { @AuthUser() user: IAuthUser, @Response() res: any, @Query('contractTopicId') contractTopicId: string, - @Query('pageIndex') pageIndex?: number, - @Query('pageSize') pageSize?: number, ): Promise { try { const owner = new EntityOwner(user); const guardians = new Guardians(); - const [vcs, count] = await guardians.getRetireVCsFromIndexer(owner, contractTopicId, pageIndex, pageSize); + const [vcs, count] = await guardians.getRetireVCsFromIndexer(owner, contractTopicId); return res.header('X-Total-Count', count).send(vcs); } catch (error) { await InternalException(error, this.logger); diff --git a/api-gateway/src/helpers/guardians.ts b/api-gateway/src/helpers/guardians.ts index b344b2fa5c..0e8508011f 100644 --- a/api-gateway/src/helpers/guardians.ts +++ b/api-gateway/src/helpers/guardians.ts @@ -1851,21 +1851,16 @@ export class Guardians extends NatsService { /** * Get retire VCs from Indexer * @param owner - * @param pageIndex - * @param pageSize + * @param contractTopicId * @returns Retire VCs from Indexer and count */ public async getRetireVCsFromIndexer( owner: IOwner, - contractTopicId: string, - pageIndex?: any, - pageSize?: any + contractTopicId: string ): Promise<[IRetirementMessage[], number]> { return await this.sendMessage(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, { owner, - contractTopicId, - pageIndex, - pageSize, + contractTopicId }); } 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 3ba55a54c4..cf07f7a590 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 @@ -264,6 +264,14 @@ export class MessagesReportBlockComponent implements OnInit { ); private lines!: Line[] | null; + gridSize: number = 0; + + mintTokenId: string; + mintTokenSerials: string[] = []; + groupedByContractRetirements: any = []; + indexerAvailable: boolean = false; + retirementMessages: any[] = []; + constructor( private element: ElementRef, private fb: UntypedFormBuilder, @@ -374,16 +382,13 @@ export class MessagesReportBlockComponent implements OnInit { }, 100); } - - gridSize: number = 0; - - mintTokenId: string; - mintTokenSerials: string[] = []; - groupedByContractRetirements: any = []; - indexerAvailable: boolean = false; - retirementMessages: any[] = []; - private loadRetirementMessages() { + this._messages2.forEach(message => { + if (message.__ifMintMessage) { + this.mintTokenId = message.__tokenId; + } + }); + this.contractService .getContracts({ type: ContractType.RETIRE @@ -415,25 +420,6 @@ export class MessagesReportBlockComponent implements OnInit { this.loading = false; const retires = results.map((item: any) => item.body) - // const tokenRetires = retires.map((retirements: IRetirementMessage[]) => { - // const ret = retirements.filter((item: IRetirementMessage) => item.documents[0].credentialSubject.some((subject: any) => - // subject.tokens.some((token: any) => - // token.tokenId === this.mintTokenId - // && token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) - // )))); - // return ret - // }); - - // this.groupedByContractRetirements = Array.from( - // new Map(allRetireMessages - // .map((item: any) => [item.documents[0].credentialSubject[0].contractId, []]) - // )).map(([contractId, documents]) => ({ - // contractId, - // selectedItemIndex: 0, - // __ifRetireMessage: true, - // documents: allRetireMessages.filter((item: any) => item.documents[0].credentialSubject[0].contractId === contractId) - // })) - let allRetireMessages: any = []; retires.forEach((retirements: any[]) => { retirements.forEach((item: any) => { @@ -465,6 +451,7 @@ export class MessagesReportBlockComponent implements OnInit { lastOrderMessageTopic2++; }); + // Todo: Need filtration by serials and token user this.retirementMessages = [...allRetireMessages]; this._gridTemplateColumns1 = 'repeat(' + (this.gridSize + this.retirementMessages.length + 1) + ', 230px)'; @@ -498,12 +485,6 @@ export class MessagesReportBlockComponent implements OnInit { } } - this._messages2.forEach(message => { - if (message.__ifMintMessage) { - this.mintTokenId = message.__tokenId; - } - }); - this.gridSize = 0; this._messages2.sort((a, b) => a.__order > b.__order ? 1 : -1); for (let index = 0; index < this._messages2.length; index++) { @@ -925,7 +906,7 @@ export class MessagesReportBlockComponent implements OnInit { styleClass: 'guardian-dialog', data: { row: null, - document: message.document || message.documents[0], + document: message.document || message.documents?.[0], title: 'VC Document', type: 'VC', viewDocument: true, 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 4cbfa6d1bd..ee11404055 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 @@ -394,94 +394,95 @@

Policy Overview

- - -
-
-
-
-
-
- {{ getRetirementGroupVC(group).issuanceDate | date : 'YYYY-MM-dd, hh:mm:ss' }} + + +
+
+
+
+
+
+ {{ selectedVC.issuanceDate | date : 'YYYY-MM-dd, hh:mm:ss' }} +
+
+ +
-
- +
+
+

Token {{ selectedVC.credentialSubject[0]?.tokens[0].tokenId }}

+

Instance ID {{ selectedVC.credentialSubject[0]?.tokens[0].serials.join(', ') }}

+

Amount {{ selectedVC.credentialSubject[0]?.tokens[0].count }}

+ +

Transaction + {{selectedVC.timestamp}} +

+

Transaction -

+ +

User ID {{ selectedVC.credentialSubject[0]?.user }}

+
+
+

Token {{ selectedVC.credentialSubject[0]?.tokens[1].tokenId }}

+

Instance ID {{ selectedVC.credentialSubject[0]?.tokens[1].serials.join(', ') }}

+

Amount {{ selectedVC.credentialSubject[0]?.tokens[1].count }}

+
-
-
-
-

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].tokenId }}

-

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].serials.join(', ') }}

-

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].count }}

- -

Transaction - {{getRetirementGroupVC(group).timestamp}} -

-

Transaction -

- -

User ID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

+ +
+ chevron_left + + {{ (group.selectedItemIndex + 1) }} of {{ group.documents.length }} + + chevron_right
-
-

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].tokenId }}

-

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].serials.join(', ') }}

-

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[1].count }}

-
-
- -
- chevron_left - - {{ (group.selectedItemIndex + 1) }} of {{ group.documents.length }} - - chevron_right
-
- - -
-
-
-
- {{ getRetirementGroupVC(group).issuanceDate | date : 'YYYY-MM-dd, hh:mm:ss' }} + + +
+
+
+
+ {{ selectedVC.issuanceDate | date : 'YYYY-MM-dd, hh:mm:ss' }} +
+
+ +
-
- +
+

Token {{ selectedVC.credentialSubject[0]?.tokens[0].tokenId }}

+

Instance ID {{ selectedVC.credentialSubject[0]?.tokens[0].serials.join(', ') }}

+

Amount {{ selectedVC.credentialSubject[0]?.tokens[0].count }}

+

Transaction {{ selectedVC.timestamp }}

+

User ID {{ selectedVC.credentialSubject[0]?.user }}

+
+ +
+ chevron_left + + {{ (group.selectedItemIndex + 1) }} of {{ group.documents.length }} + + chevron_right
-
-
-

Token {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].tokenId }}

-

Instance ID {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].serials.join(', ') }}

-

Amount {{ getRetirementGroupVC(group).credentialSubject[0]?.tokens[0].count }}

-

Transaction {{ getRetirementGroupVC(group).timestamp }}

-

User ID {{ getRetirementGroupVC(group).credentialSubject[0]?.user }}

-
- -
- chevron_left - - {{ (group.selectedItemIndex + 1) }} of {{ group.documents.length }} - - chevron_right
-
-
+ +
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 ff4b18f265..d58fa479b4 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 @@ -784,10 +784,6 @@ h3 { column-gap: 16px } - - - - .item-type-RETIRE { .chain-top-block { padding-bottom: 14px; @@ -807,31 +803,6 @@ h3 { } } -.retirement-container { - padding: 24px; - border-radius: 8px; - border: 1px solid var(--grey-grey-3, #E1E7EF); - background: var(--grey-white, #FFF); -} - -.retirement-items-wrapper { - display: flex; - gap: 16px; -} - -.retirement-item { - display: grid; - grid-template-columns: repeat(2, 1fr); - column-gap: 8px; - max-width: 320px; - margin-top: 16px; - padding: 8px; - border-radius: 4px; - border: 1px solid var(--grey-grey-3, #E1E7EF); - background: var(--grey-white, #FFF); -} - - .retirements-container { position: relative; display: flex; 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 941014b8bb..7afbde9b35 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 @@ -61,6 +61,12 @@ export class ReportBlockComponent implements OnInit { value: ['', Validators.required], }); + vpDocument: any; + mintTokenId: string; + mintTokenSerials: string[] = []; + groupedByContractRetirements: any = []; + indexerAvailable: boolean = false; + constructor( private policyEngineService: PolicyEngineService, private wsService: WebSocketService, @@ -103,13 +109,7 @@ export class ReportBlockComponent implements OnInit { } } - // Testing - vpDocument: any; - mintTokenId: string; - mintTokenSerials: string[] = []; - groupedByContractRetirements: any = []; - indexerAvailable: boolean = false; - private loadRetireData() { + loadRetireData() { this.loading = true; this.contractService @@ -179,7 +179,7 @@ export class ReportBlockComponent implements OnInit { this.groupedByContractRetirements = Array.from( new Map(tokenRetirementDocuments .map((item: any) => [item.credentialSubject[0].contractId, []]) - )).map(([contractId, documents]) => ({ + )).map(([contractId]) => ({ contractId, selectedItemIndex: 0, documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) @@ -202,7 +202,7 @@ export class ReportBlockComponent implements OnInit { this.groupedByContractRetirements = Array.from( new Map(tokenRetirementDocuments .map((item: any) => [item.credentialSubject[0].contractId, []]) - )).map(([contractId, documents]) => ({ + )).map(([contractId]) => ({ contractId, selectedItemIndex: 0, documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) @@ -223,7 +223,7 @@ export class ReportBlockComponent implements OnInit { ); } - getRetirementGroupVC(group: any): any { + getSelectedRetirementVC(group: any): any { return group.documents[group.selectedItemIndex]; } @@ -239,8 +239,6 @@ export class ReportBlockComponent implements OnInit { group.selectedItemIndex = (group.selectedItemIndex - 1) >= 0 ? (group.selectedItemIndex - 1) : (group.documents.length - 1); } - // ... - loadData() { this.loading = true; if (this.static) { diff --git a/frontend/src/app/services/contract.service.ts b/frontend/src/app/services/contract.service.ts index 0f85024ee8..95a3992ee8 100644 --- a/frontend/src/app/services/contract.service.ts +++ b/frontend/src/app/services/contract.service.ts @@ -16,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: { @@ -320,14 +320,9 @@ export class ContractService { } public getRetireVCsFromIndexer( - contractTopicId: string, - pageIndex?: number, - pageSize?: number + contractTopicId: string ): Observable> { let url = `${this.url}/retireIndexer?contractTopicId=${contractTopicId}`; - if (pageIndex && pageSize) { - url += `?pageIndex=${pageIndex}&pageSize=${pageSize}` - } return this.http.get(url, { observe: 'response', }); diff --git a/guardian-service/src/api/contract.service.ts b/guardian-service/src/api/contract.service.ts index afc470fe03..83e56fae66 100644 --- a/guardian-service/src/api/contract.service.ts +++ b/guardian-service/src/api/contract.service.ts @@ -3411,109 +3411,25 @@ export async function contractAPI( ApiResponse(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, async (msg: { owner: IOwner, - contractTopicId: string, - pageIndex?: any, - pageSize?: any + contractTopicId: string }) => { try { if (!msg) { return new MessageError('Invalid get contract parameters'); } - const { owner, contractTopicId, pageIndex, pageSize } = msg; + const { owner, contractTopicId } = msg; if (!owner.creator) { throw new Error('Owner is required'); } - const otherOptions: any = {}; - const _pageSize = parseInt(pageSize, 10); - const _pageIndex = parseInt(pageIndex, 10); - if (Number.isInteger(_pageSize) && Number.isInteger(_pageIndex)) { - otherOptions.orderBy = { createDate: 'DESC' }; - otherOptions.limit = Math.min(100, _pageSize); - otherOptions.offset = _pageIndex * _pageSize; - } else { - otherOptions.orderBy = { createDate: 'DESC' }; - otherOptions.limit = 100; - } - - const users = new Users(); - const user = await users.getUserById(owner.creator); - - const filters: any = { - owner: owner.owner, - type: SchemaEntity.RETIRE_TOKEN, - }; - if (user.role === UserRole.USER) { - filters['document.credentialSubject.user'] = - user.hederaAccountId; - } - - // Get Retirements from Indexer const messages = await new Workers().addNonRetryableTask({ type: WorkerTaskType.ANALYTICS_GET_RETIRE_DOCUMENTS, data: { payload: { options: { topicId: contractTopicId } } } }, 2); - - // Save to Guardian DB - // const filtersOld: any = { - // owner: owner.owner, - // type: SchemaEntity.RETIRE_TOKEN, - // }; - // if (user.role === UserRole.USER) { - // filters['document.credentialSubject.user'] = - // user.hederaAccountId; - // } - - // const oldRetirements = await dataBaseServer.findAndCount(VcDocument, filtersOld) // find old Retirement VCs - // console.log(JSON.stringify(oldRetirements, null, 4)); - - // retirements.forEach(retirement => { - // oldRetirements.forEach(oldRetirement => { - - // }); - - // console.log(retirement); - - // }); - - // const vcMessage = new VCMessage(MessageAction.CreateVC); - // console.log(vcMessage.hash); - - // vcMessage.setDocument(vcObject); - - // await dataBaseServer.save(VcDocumentCollection, { - // hash: vcMessage.hash, - // owner: owner.creator, - // document: vcMessage.document, - // type: schemaObject?.entity, - // documentFields: ['credentialSubject.0.user'], - // }); - - // await saveRetireVC( - // // contractRepository, - // dataBaseServer, - // pool.contractId, - // srUser, - // sr.hederaAccountId, - // srKey, - // root.hederaAccountId, - // tokens.map((token) => { - // const newToken: any = { - // ...token, - // }; - // const poolToken = pool.tokens.find( - // // tslint:disable-next-line:no-shadowed-variable - // (poolToken) => (poolToken.token = token.token) - // ); - // newToken.decimals = poolToken.decimals; - // return newToken; - // }) - // ); - // ... return new MessageResponse([messages, messages.length]); } catch (error) { diff --git a/interfaces/src/type/messages/workers.type.ts b/interfaces/src/type/messages/workers.type.ts index f1831c3055..68f623c540 100644 --- a/interfaces/src/type/messages/workers.type.ts +++ b/interfaces/src/type/messages/workers.type.ts @@ -37,9 +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' + ANALYTICS_GET_RETIRE_DOCUMENTS = 'analytics-get-retire-documents' } /** From c27ddb6dc4890dcc8c43f870d93d76c620a44c48 Mon Sep 17 00:00:00 2001 From: envision-ci-agent Date: Sat, 21 Dec 2024 02:12:28 +0000 Subject: [PATCH 22/28] [skip ci] Add swagger.yaml --- swagger.yaml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 92e2a1cc9b..f28e90f1fa 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -2430,22 +2430,6 @@ paths: example: 0.0.0000000 schema: type: string - - name: pageIndex - required: false - in: query - description: >- - The number of pages to skip before starting to collect the result - set - example: 0 - schema: - type: number - - name: pageSize - required: true - in: query - description: The numbers of items to return - example: 20 - schema: - type: number responses: '200': description: Successful operation. From 570169502b3c03df9828722a76e52e548bb5af35 Mon Sep 17 00:00:00 2001 From: Dariy Miseldzhani Date: Sat, 21 Dec 2024 04:01:20 +0100 Subject: [PATCH 23/28] Simplify logic and improve readability. Signed-off-by: Dariy Miseldzhani --- .../policy-viewer/blocks/report-block/report-block.component.ts | 2 -- 1 file changed, 2 deletions(-) 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 7afbde9b35..6e9ae51c5d 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 @@ -229,13 +229,11 @@ export class ReportBlockComponent implements OnInit { onNextRetirementClick(event: any, group: any) { event.stopPropagation(); - group.selectedItemIndex = group.documents.length > (group.selectedItemIndex + 1) ? group.selectedItemIndex + 1 : 0; } onPrevRetirementClick(event: any, group: any) { event.stopPropagation(); - group.selectedItemIndex = (group.selectedItemIndex - 1) >= 0 ? (group.selectedItemIndex - 1) : (group.documents.length - 1); } From efd306e4ea226a9f2c7fd643fc719a23454b39d2 Mon Sep 17 00:00:00 2001 From: simvalery Date: Fri, 17 Jan 2025 15:45:20 +0400 Subject: [PATCH 24/28] fix build Signed-off-by: simvalery Signed-off-by: simvalery --- indexer-common/src/entity/message.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/indexer-common/src/entity/message.ts b/indexer-common/src/entity/message.ts index c4371720a7..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; From 7b34566f705b73ba297f27ddd39bbd38dead1da9 Mon Sep 17 00:00:00 2001 From: envision-ci-agent Date: Fri, 17 Jan 2025 11:48:23 +0000 Subject: [PATCH 25/28] [skip ci] Add swagger.yaml --- swagger-indexer.yaml | 273 +++++++++++++++++++++++++++++++++---------- 1 file changed, 212 insertions(+), 61 deletions(-) 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 From a3f2cbf13c734b493a063b1bca2e706e40d1362c Mon Sep 17 00:00:00 2001 From: simvalery Date: Fri, 17 Jan 2025 15:56:52 +0400 Subject: [PATCH 26/28] fix build Signed-off-by: simvalery Signed-off-by: simvalery --- .../messages-report-block.component.ts | 360 +++++++++--------- .../report-block/report-block.component.ts | 148 ++++--- 2 files changed, 243 insertions(+), 265 deletions(-) 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 cf07f7a590..11c6716515 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,20 +1,20 @@ +import { DatePipe } from '@angular/common'; +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { Component, ElementRef, HostListener, Input, OnInit } from '@angular/core'; import { UntypedFormBuilder, Validators } from '@angular/forms'; -import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; import { MatIconRegistry } from '@angular/material/icon'; +import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; import { DomSanitizer } from '@angular/platform-browser'; +import { ContractType } from '@guardian/interfaces'; import * as moment from 'moment'; import { DialogService } from 'primeng/dynamicdialog'; +import { forkJoin, Observable } from 'rxjs'; import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; +import { AnalyticsService } from 'src/app/services/analytics.service'; +import { ContractService } from 'src/app/services/contract.service'; 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, HttpResponse } from '@angular/common/http'; -import { ContractType, IRetirementMessage, IVC } from '@guardian/interfaces'; -import { Observable, forkJoin } from 'rxjs'; -import { ContractService } from 'src/app/services/contract.service'; -import { AnalyticsService } from 'src/app/services/analytics.service'; -import { DatePipe } from '@angular/common'; /** * Dashboard Type @@ -25,11 +25,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, @@ -79,19 +78,20 @@ 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, elementId2: string, @@ -191,81 +191,42 @@ 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; - - private _topics1!: any[]; - private _topics2!: any[]; - public get topics(): any[] { - if (this.dashboardType === DashboardType.Advanced) { - return this._topics1; - } else { - return this._topics2; - } - } - - private _messages1!: any[]; - private _messages2!: any[]; - public get messages(): any[] { - if (this.dashboardType === DashboardType.Advanced) { - return this._messages1; - } else { - return this._messages2; - } - } - - private _gridTemplateRows1!: string; - private _gridTemplateRows2!: string; - public get gridTemplateRows(): string { - if (this.dashboardType === DashboardType.Advanced) { - return this._gridTemplateRows1; - } else { - return this._gridTemplateRows2; - } - } - - private _gridTemplateColumns1!: string; - private _gridTemplateColumns2!: string; - public get gridTemplateColumns(): string { - if (this.dashboardType === DashboardType.Advanced) { - return this._gridTemplateColumns1; - } else { - return this._gridTemplateColumns2; - } - } - public searchForm = this.fb.group({ - value: ['', Validators.required], - }); - - private lineContainer = new LineContainer( - 'leader-line-container-1', 'leader-line-container-2' - ); - private lines!: Line[] | null; - + value: ['', Validators.required] + }); gridSize: number = 0; - mintTokenId: string; mintTokenSerials: string[] = []; groupedByContractRetirements: any = []; @@ -293,24 +254,35 @@ export class MessagesReportBlockComponent implements OnInit { `)); } - public ngOnInit(): void { - if (!this.static) { - this.socket = this.wsService.blockSubscribe(this.onUpdate.bind(this)); + public get topics(): any[] { + if (this.dashboardType === DashboardType.Advanced) { + return this._topics1; + } else { + return this._topics2; } - this.onResize(); - this.loadData(); } - public ngOnDestroy(): void { - if (this.socket) { - this.socket.unsubscribe(); + public get messages(): any[] { + if (this.dashboardType === DashboardType.Advanced) { + return this._messages1; + } else { + return this._messages2; } - this.removeLines(); } - public onUpdate(blocks: string[]): void { - if (Array.isArray(blocks) && blocks.includes(this.id)) { - this.loadData(); + public get gridTemplateRows(): string { + if (this.dashboardType === DashboardType.Advanced) { + return this._gridTemplateRows1; + } else { + return this._gridTemplateRows2; + } + } + + public get gridTemplateColumns(): string { + if (this.dashboardType === DashboardType.Advanced) { + return this._gridTemplateColumns1; + } else { + return this._gridTemplateColumns2; } } @@ -388,11 +360,11 @@ export class MessagesReportBlockComponent implements OnInit { this.mintTokenId = message.__tokenId; } }); - + this.contractService .getContracts({ - type: ContractType.RETIRE - }) + type: ContractType.RETIRE + }) .subscribe( (policiesResponse) => { const contracts = policiesResponse.body || []; @@ -431,9 +403,9 @@ export class MessagesReportBlockComponent implements OnInit { } }); }); - + allRetireMessages.sort((a: any, b: any) => new Date(a.documents[0].issuanceDate).getTime() - new Date(b.documents[0].issuanceDate).getTime()); - + // For different topics different ordering let lastOrderMessageTopic1 = this._topics1?.[this._topics1.length - 1]?.messages.reduce((acc: number, item: any) => item.__order > acc ? item.__order : acc, 0) + 1; allRetireMessages.forEach((element: any) => { @@ -466,8 +438,6 @@ export class MessagesReportBlockComponent implements OnInit { ); } - - private createSmallReport() { for (const topic of this._topics1) { if (topic.message?.messageType === 'INSTANCE_POLICY_TOPIC') { @@ -806,6 +776,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(); @@ -917,100 +1001,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.ts b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.ts index 6e9ae51c5d..bf6737cd00 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,31 +1,19 @@ +import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { Component, Input, OnInit } from '@angular/core'; import { UntypedFormBuilder, Validators } from '@angular/forms'; -import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; import { MatIconRegistry } from '@angular/material/icon'; +import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; import { DomSanitizer } from '@angular/platform-browser'; -import { - IImpactReport, - IconType, - IPolicyReport, - IReport, - IReportItem, - ITokenReport, - IVCReport, - IVPReport, - ContractType, - IRetirementMessage, - IVC, -} from '@guardian/interfaces'; +import { ContractType, IconType, IImpactReport, IPolicyReport, IReport, IReportItem, IRetirementMessage, ITokenReport, IVC, IVCReport, IVPReport } from '@guardian/interfaces'; +import { DialogService } from 'primeng/dynamicdialog'; +import { forkJoin, Observable } from 'rxjs'; import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; +import { AnalyticsService } from 'src/app/services/analytics.service'; +import { ContractService } from 'src/app/services/contract.service'; 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, HttpResponse } from '@angular/common/http'; -import { ContractService } from 'src/app/services/contract.service'; -import { AnalyticsService } from 'src/app/services/analytics.service'; -import { forkJoin, Observable } from 'rxjs'; interface IAdditionalDocument { vpDocument?: IVPReport | undefined; @@ -39,10 +27,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; @@ -58,8 +46,8 @@ export class ReportBlockComponent implements OnInit { documents: any; policyCreatorDocument: IReportItem | undefined; searchForm = this.fb.group({ - value: ['', Validators.required], - }); + value: ['', Validators.required] + }); vpDocument: any; mintTokenId: string; @@ -88,6 +76,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( @@ -114,8 +118,8 @@ export class ReportBlockComponent implements OnInit { this.contractService .getContracts({ - type: ContractType.RETIRE - }) + type: ContractType.RETIRE + }) .subscribe( (policiesResponse) => { const contracts = policiesResponse.body || []; @@ -170,20 +174,20 @@ export class ReportBlockComponent implements OnInit { const tokenRetirementDocuments = combinedRetirements .filter((item: any) => item.credentialSubject.some((subject: any) => - subject.user === this.vpDocument.document.target - && subject.tokens.some((token: any) => - token.tokenId === this.mintTokenId - && this.mintTokenSerials.length <= 0 || token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) - )))); + subject.user === this.vpDocument.document.target + && subject.tokens.some((token: any) => + token.tokenId === this.mintTokenId + && this.mintTokenSerials.length <= 0 || token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) + )))); this.groupedByContractRetirements = Array.from( new Map(tokenRetirementDocuments - .map((item: any) => [item.credentialSubject[0].contractId, []]) + .map((item: any) => [item.credentialSubject[0].contractId, []]) )).map(([contractId]) => ({ - contractId, - selectedItemIndex: 0, - documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) - })) + contractId, + selectedItemIndex: 0, + documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) + })) }) } else { this.contractService @@ -192,21 +196,21 @@ export class ReportBlockComponent implements OnInit { (policiesResponse) => { const tokenRetirementDocuments = (policiesResponse.body || []) .filter((item: any) => item.type == 'RETIRE' - && item.document.credentialSubject.some((subject: any) => - subject.user === this.vpDocument.document.target - && subject.tokens.some((token: any) => - token.tokenId === this.mintTokenId - && this.mintTokenSerials.length <= 0 || token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) - )))).map((vc: any) => vc.document); + && item.document.credentialSubject.some((subject: any) => + subject.user === this.vpDocument.document.target + && subject.tokens.some((token: any) => + token.tokenId === this.mintTokenId + && this.mintTokenSerials.length <= 0 || token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) + )))).map((vc: any) => vc.document); this.groupedByContractRetirements = Array.from( new Map(tokenRetirementDocuments - .map((item: any) => [item.credentialSubject[0].contractId, []]) + .map((item: any) => [item.credentialSubject[0].contractId, []]) )).map(([contractId]) => ({ - contractId, - selectedItemIndex: 0, - documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) - })) + contractId, + selectedItemIndex: 0, + documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) + })) this.loading = false; }, @@ -252,22 +256,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; @@ -286,8 +274,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 || []; @@ -316,15 +304,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); @@ -467,9 +455,9 @@ export class ReportBlockComponent implements OnInit { onScrollButtonPress(target: HTMLDivElement, amount: number = 0) { target.scrollBy({ - behavior: 'smooth', - left: amount, - }); + behavior: 'smooth', + left: amount + }); } updateFilter() { @@ -625,8 +613,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); } } From 5340a5477a882949e0aafa5976f0ed2ff5b0e287 Mon Sep 17 00:00:00 2001 From: simvalery Date: Fri, 17 Jan 2025 16:12:48 +0400 Subject: [PATCH 27/28] fix build Signed-off-by: simvalery Signed-off-by: simvalery --- .../messages-report-block.component.ts | 185 +++++------------ .../report-block/report-block.component.ts | 194 +----------------- 2 files changed, 55 insertions(+), 324 deletions(-) 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 11c6716515..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,17 +1,10 @@ -import { DatePipe } from '@angular/common'; -import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { HttpErrorResponse } from '@angular/common/http'; import { Component, ElementRef, HostListener, Input, OnInit } from '@angular/core'; import { UntypedFormBuilder, Validators } from '@angular/forms'; -import { MatIconRegistry } from '@angular/material/icon'; -import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; import { DomSanitizer } from '@angular/platform-browser'; -import { ContractType } from '@guardian/interfaces'; -import * as moment from 'moment'; +import moment from 'moment'; import { DialogService } from 'primeng/dynamicdialog'; -import { forkJoin, Observable } from 'rxjs'; import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; -import { AnalyticsService } from 'src/app/services/analytics.service'; -import { ContractService } from 'src/app/services/contract.service'; 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'; @@ -226,12 +219,6 @@ export class MessagesReportBlockComponent implements OnInit { public searchForm = this.fb.group({ value: ['', Validators.required] }); - gridSize: number = 0; - mintTokenId: string; - mintTokenSerials: string[] = []; - groupedByContractRetirements: any = []; - indexerAvailable: boolean = false; - retirementMessages: any[] = []; constructor( private element: ElementRef, @@ -239,19 +226,9 @@ export class MessagesReportBlockComponent implements OnInit { private policyEngineService: PolicyEngineService, private wsService: WebSocketService, private policyHelper: PolicyHelper, - private dialog: MatDialog, private dialogService: DialogService, - private iconRegistry: MatIconRegistry, - private sanitizer: DomSanitizer, - private contractService: ContractService, - private analyticsService: AnalyticsService, - private datePipe: DatePipe + private sanitizer: DomSanitizer ) { - iconRegistry.addSvgIconLiteral('token', sanitizer.bypassSecurityTrustHtml(` - - - - `)); } public get topics(): any[] { @@ -344,7 +321,6 @@ export class MessagesReportBlockComponent implements OnInit { if (this.report) { this.createReport(this.report); this.createSmallReport(); - this.loadRetirementMessages(); } } this.removeLines(); @@ -354,94 +330,10 @@ export class MessagesReportBlockComponent implements OnInit { }, 100); } - private loadRetirementMessages() { - this._messages2.forEach(message => { - if (message.__ifMintMessage) { - this.mintTokenId = message.__tokenId; - } - }); - - this.contractService - .getContracts({ - type: ContractType.RETIRE - }) - .subscribe( - (policiesResponse) => { - const contracts = policiesResponse.body || []; - const tokenContractTopicIds: string[] = []; - - if (contracts && contracts.length > 0) { - contracts.forEach(contract => { - if (contract.wipeTokenIds && contract.wipeTokenIds.length > 0 && - contract.wipeTokenIds.some((tokenId: string) => tokenId == this.mintTokenId)) { - tokenContractTopicIds.push(contract.topicId); - } - }); - } - - this.analyticsService.checkIndexer().subscribe(indexerAvailable => { - this.indexerAvailable = indexerAvailable; - if (indexerAvailable && tokenContractTopicIds.length > 0) { - const indexerCalls: Observable>[] = []; - tokenContractTopicIds.forEach(id => { - indexerCalls.push(this.contractService.getRetireVCsFromIndexer(id)) - }) - - this.loading = true; - forkJoin(indexerCalls).subscribe((results: any) => { - this.loading = false; - const retires = results.map((item: any) => item.body) - - let allRetireMessages: any = []; - retires.forEach((retirements: any[]) => { - retirements.forEach((item: any) => { - if (item.documents[0].credentialSubject[0].tokens.some((token: any) => token.tokenId === this.mintTokenId)) { - item.id = item.consensusTimestamp; - item.__ifRetireMessage = true; - item.__timestamp = this.datePipe.transform(new Date(item.documents[0].issuanceDate), 'yyyy-MM-dd, hh:mm:ss'); - allRetireMessages.push(item); - } - }); - }); - - allRetireMessages.sort((a: any, b: any) => new Date(a.documents[0].issuanceDate).getTime() - new Date(b.documents[0].issuanceDate).getTime()); - - // For different topics different ordering - let lastOrderMessageTopic1 = this._topics1?.[this._topics1.length - 1]?.messages.reduce((acc: number, item: any) => item.__order > acc ? item.__order : acc, 0) + 1; - allRetireMessages.forEach((element: any) => { - var newElement = {...element, __order: lastOrderMessageTopic1} - this._messages1.push(newElement); - this._topics1[this._topics1.length - 1].messages.push(newElement); - - lastOrderMessageTopic1++; - }); - let lastOrderMessageTopic2 = this._topics2?.[0]?.messages.reduce((acc: number, item: any) => item.__order > acc ? item.__order : acc, 0) + 1; - allRetireMessages.forEach((element: any) => { - var newElement = {...element, __order: lastOrderMessageTopic2} - this._messages2.push(newElement); - this._topics2[0].messages.push(newElement); - lastOrderMessageTopic2++; - }); - - // Todo: Need filtration by serials and token user - this.retirementMessages = [...allRetireMessages]; - - this._gridTemplateColumns1 = 'repeat(' + (this.gridSize + this.retirementMessages.length + 1) + ', 230px)'; - this._gridTemplateColumns2 = 'repeat(' + (this.gridSize + this.retirementMessages.length) + ', 230px)'; - }) - } - }) - }, - (e) => { - this.loading = false; - } - ); - } - private createSmallReport() { for (const topic of this._topics1) { if (topic.message?.messageType === 'INSTANCE_POLICY_TOPIC') { - const t = { ...topic }; + const t = {...topic}; t.__parent = null; t.__offset = 20; t.__order = this._topics2.length + 1; @@ -454,22 +346,21 @@ export class MessagesReportBlockComponent implements OnInit { this._messages2.push(message); } } - - this.gridSize = 0; + let gridSize = 0; this._messages2.sort((a, b) => a.__order > b.__order ? 1 : -1); for (let index = 0; index < this._messages2.length; index++) { const message = this._messages2[index]; message.__order = index + 1; - this.gridSize = Math.max(this.gridSize, message.__order); + gridSize = Math.max(gridSize, message.__order); } - this._gridTemplateColumns2 = 'repeat(' + this.gridSize + ', 230px)'; + this._gridTemplateColumns2 = 'repeat(' + gridSize + ', 230px)'; this._gridTemplateRows2 = 'repeat(' + this._topics2.length + ', 100px) 30px'; } private getAllMessages(topic: any, messages: any[]): any[] { if (topic.messages) { for (const message of topic.messages) { - messages.push({ ...message }); + messages.push({...message}); } } if (topic.children) { @@ -508,7 +399,7 @@ export class MessagesReportBlockComponent implements OnInit { } private parseMessages() { - this.gridSize = 0; + let gridSize = 0; for (const topic of this._topics1) { if (topic.message) { this.parseMessage(topic, topic.message); @@ -516,7 +407,7 @@ export class MessagesReportBlockComponent implements OnInit { for (const message of topic.messages) { this.parseMessage(topic, message); this._messages1.push(message); - this.gridSize = Math.max(this.gridSize, message.__order); + gridSize = Math.max(gridSize, message.__order); } if (topic.__parent) { topic.__start = 100 * topic.__parent.__order; @@ -539,7 +430,7 @@ export class MessagesReportBlockComponent implements OnInit { topic.message.__rationale = topic.__rationale; } } - this._gridTemplateColumns1 = 'repeat(' + this.gridSize + ', 230px)'; + this._gridTemplateColumns1 = 'repeat(' + gridSize + ', 230px)'; this._gridTemplateRows1 = 'repeat(' + this._topics1.length + ', 100px) 30px'; } @@ -685,13 +576,20 @@ export class MessagesReportBlockComponent implements OnInit { private getStatusLabel(message: any) { switch (message.documentStatus) { - case 'NEW': return 'Create document'; - case 'ISSUE': return 'Create document'; - case 'REVOKE': return 'Revoke document'; - case 'SUSPEND': return 'Suspend document'; - case 'RESUME': return 'Resume document'; - case 'FAILED': return 'Failed'; - default: return message.documentStatus || 'Create document'; + case 'NEW': + return 'Create document'; + case 'ISSUE': + return 'Create document'; + case 'REVOKE': + return 'Revoke document'; + case 'SUSPEND': + return 'Suspend document'; + case 'RESUME': + return 'Resume document'; + case 'FAILED': + return 'Failed'; + default: + return message.documentStatus || 'Create document'; } } @@ -761,7 +659,7 @@ export class MessagesReportBlockComponent implements OnInit { const documents: any[] = []; if (message.document && message.document.verifiableCredential) { for (const vc of message.document.verifiableCredential) { - const item: any = { document: vc }; + const item: any = {document: vc}; item.__schema = this.searchSchema(item); item.__issuer = this.getIssuer(item); if (item.__schema) { @@ -907,11 +805,14 @@ export class MessagesReportBlockComponent implements OnInit { public getTopicHeader(message: any): string { if (message) { switch (message.messageType) { - case 'USER_TOPIC': return 'Standard Registry'; - case 'POLICY_TOPIC': return 'Policy'; + case 'USER_TOPIC': + return 'Standard Registry'; + case 'POLICY_TOPIC': + return 'Policy'; case 'INSTANCE_POLICY_TOPIC': return this.dashboardType === DashboardType.Advanced ? 'Policy instance' : message.name; - case 'DYNAMIC_TOPIC': return 'User defined'; + case 'DYNAMIC_TOPIC': + return 'User defined'; } } return 'Global'; @@ -920,10 +821,14 @@ export class MessagesReportBlockComponent implements OnInit { public getTopicName(topic: any): string { if (topic.message) { switch (topic.message.messageType) { - case 'USER_TOPIC': return ''; - case 'POLICY_TOPIC': return topic.message.name; - case 'INSTANCE_POLICY_TOPIC': return 'Version: ' + (topic.__rationale?.version || 'N/A'); - case 'DYNAMIC_TOPIC': return topic.message.name; + case 'USER_TOPIC': + return ''; + case 'POLICY_TOPIC': + return topic.message.name; + case 'INSTANCE_POLICY_TOPIC': + return 'Version: ' + (topic.__rationale?.version || 'N/A'); + case 'DYNAMIC_TOPIC': + return topic.message.name; } } return ''; @@ -946,7 +851,7 @@ export class MessagesReportBlockComponent implements OnInit { this.loading = true; let filterValue = this.searchForm.value.value || ''; filterValue = filterValue.trim(); - this.policyEngineService.setBlockData(this.id, this.policyId, { filterValue }).subscribe(() => { + this.policyEngineService.setBlockData(this.id, this.policyId, {filterValue}).subscribe(() => { this.loadData(); }, (e) => { console.error(e.error); @@ -981,7 +886,8 @@ export class MessagesReportBlockComponent implements OnInit { viewDocument: false } }); - dialogRef.onClose.subscribe(async (result) => { }); + dialogRef.onClose.subscribe(async (result) => { + }); } else { const dialogRef = this.dialogService.open(VCViewerDialog, { @@ -990,14 +896,15 @@ export class MessagesReportBlockComponent implements OnInit { styleClass: 'guardian-dialog', data: { row: null, - document: message.document || message.documents?.[0], + document: message.document, title: 'VC Document', type: 'VC', viewDocument: true, schema: message.__schema, } }); - dialogRef.onClose.subscribe(async (result) => { }); + dialogRef.onClose.subscribe(async (result) => { + }); } } 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 bf6737cd00..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,19 +1,12 @@ -import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { HttpErrorResponse } from '@angular/common/http'; import { Component, Input, OnInit } from '@angular/core'; import { UntypedFormBuilder, Validators } from '@angular/forms'; -import { MatIconRegistry } from '@angular/material/icon'; -import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'; -import { DomSanitizer } from '@angular/platform-browser'; -import { ContractType, IconType, IImpactReport, IPolicyReport, IReport, IReportItem, IRetirementMessage, ITokenReport, IVC, IVCReport, IVPReport } from '@guardian/interfaces'; +import { IconType, IImpactReport, IPolicyReport, IReport, IReportItem, ITokenReport, IVCReport, IVPReport } from '@guardian/interfaces'; import { DialogService } from 'primeng/dynamicdialog'; -import { forkJoin, Observable } from 'rxjs'; import { VCViewerDialog } from 'src/app/modules/schema-engine/vc-dialog/vc-dialog.component'; -import { AnalyticsService } from 'src/app/services/analytics.service'; -import { ContractService } from 'src/app/services/contract.service'; 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'; interface IAdditionalDocument { vpDocument?: IVPReport | undefined; @@ -49,31 +42,13 @@ export class ReportBlockComponent implements OnInit { value: ['', Validators.required] }); - vpDocument: any; - mintTokenId: string; - mintTokenSerials: string[] = []; - groupedByContractRetirements: any = []; - indexerAvailable: boolean = false; - constructor( private policyEngineService: PolicyEngineService, private wsService: WebSocketService, private fb: UntypedFormBuilder, - public dialog: MatDialog, private dialogService: DialogService, - iconRegistry: MatIconRegistry, - sanitizer: DomSanitizer, - private ipfs: IPFSService, - private contractService: ContractService, - private analyticsService: AnalyticsService + private ipfs: IPFSService ) { - for (let i = 0; i < IconsArray.length; i++) { - const element = IconsArray[i]; - iconRegistry.addSvgIconLiteral( - element.name, - sanitizer.bypassSecurityTrustHtml(element.icon) - ); - } } private _onSuccess(data: any) { @@ -113,134 +88,6 @@ export class ReportBlockComponent implements OnInit { } } - loadRetireData() { - this.loading = true; - - this.contractService - .getContracts({ - type: ContractType.RETIRE - }) - .subscribe( - (policiesResponse) => { - const contracts = policiesResponse.body || []; - const tokenContractTopicIds: string[] = []; - - if (contracts && contracts.length > 0) { - contracts.forEach(contract => { - if (contract.wipeTokenIds && contract.wipeTokenIds.length > 0 && - contract.wipeTokenIds.some((tokenId: string) => tokenId == this.mintTokenId)) { - tokenContractTopicIds.push(contract.topicId); - } - }); - } - - this.analyticsService.checkIndexer().subscribe(indexerAvailable => { - this.indexerAvailable = indexerAvailable; - if (indexerAvailable && tokenContractTopicIds.length > 0) { - const indexerCalls: Observable>[] = []; - tokenContractTopicIds.forEach(id => { - indexerCalls.push(this.contractService.getRetireVCsFromIndexer(id)) - }) - - this.loading = true; - forkJoin([this.contractService.getRetireVCs(), ...indexerCalls]).subscribe((results: any) => { - this.loading = false; - const retires = results.map((item: any) => item.body) - - const [retiresDb, ...retiresIndexer] = retires; - const retiresDbMapped = retiresDb - .filter((item: any) => item.type == 'RETIRE') - .map((item: any) => item.document); - - const combinedRetirements = [...retiresDbMapped]; - retiresIndexer.forEach((retirements: IRetirementMessage[]) => { - retirements.forEach((item: IRetirementMessage) => { - const existInGuardianDocument = retiresDbMapped.find((retire: IVC) => retire.id === item.documents[0].id); - if (!existInGuardianDocument) { - item.documents[0].topicId = item.topicId; - item.documents[0].timestamp = item.consensusTimestamp; - item.documents[0].sequenceNumber = item.sequenceNumber; - item.documents[0].owner = item.owner; - combinedRetirements.push(item.documents[0]); - } - else { - existInGuardianDocument.topicId = item.topicId; - existInGuardianDocument.timestamp = item.consensusTimestamp; - existInGuardianDocument.sequenceNumber = item.sequenceNumber; - existInGuardianDocument.owner = item.owner; - } - }); - }); - - const tokenRetirementDocuments = combinedRetirements - .filter((item: any) => item.credentialSubject.some((subject: any) => - subject.user === this.vpDocument.document.target - && subject.tokens.some((token: any) => - token.tokenId === this.mintTokenId - && this.mintTokenSerials.length <= 0 || token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) - )))); - - this.groupedByContractRetirements = Array.from( - new Map(tokenRetirementDocuments - .map((item: any) => [item.credentialSubject[0].contractId, []]) - )).map(([contractId]) => ({ - contractId, - selectedItemIndex: 0, - documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) - })) - }) - } else { - this.contractService - .getRetireVCs() - .subscribe( - (policiesResponse) => { - const tokenRetirementDocuments = (policiesResponse.body || []) - .filter((item: any) => item.type == 'RETIRE' - && item.document.credentialSubject.some((subject: any) => - subject.user === this.vpDocument.document.target - && subject.tokens.some((token: any) => - token.tokenId === this.mintTokenId - && this.mintTokenSerials.length <= 0 || token.serials.some((serial: string) => this.mintTokenSerials.includes(serial) - )))).map((vc: any) => vc.document); - - this.groupedByContractRetirements = Array.from( - new Map(tokenRetirementDocuments - .map((item: any) => [item.credentialSubject[0].contractId, []]) - )).map(([contractId]) => ({ - contractId, - selectedItemIndex: 0, - documents: tokenRetirementDocuments.filter((item: any) => item.credentialSubject[0].contractId === contractId) - })) - - this.loading = false; - }, - (e) => { - this.loading = false; - } - ); - } - }) - }, - (e) => { - this.loading = false; - } - ); - } - - getSelectedRetirementVC(group: any): any { - return group.documents[group.selectedItemIndex]; - } - - onNextRetirementClick(event: any, group: any) { - event.stopPropagation(); - group.selectedItemIndex = group.documents.length > (group.selectedItemIndex + 1) ? group.selectedItemIndex + 1 : 0; - } - - onPrevRetirementClick(event: any, group: any) { - event.stopPropagation(); - group.selectedItemIndex = (group.selectedItemIndex - 1) >= 0 ? (group.selectedItemIndex - 1) : (group.documents.length - 1); - } - loadData() { this.loading = true; if (this.static) { @@ -280,11 +127,6 @@ export class ReportBlockComponent implements OnInit { this.policyCreatorDocument = report.policyCreatorDocument; this.documents = report.documents || []; - this.mintTokenId = report.mintDocument?.tokenId || ''; - this.mintTokenSerials = (report.vpDocument?.document as any).serials.map((serialItem: any) => serialItem.serial); - this.vpDocument = report.vpDocument; - this.loadRetireData(); - const mainDocument = this.createAdditionalDocument(report); if (mainDocument) { this.mainDocuments = [mainDocument]; @@ -384,7 +226,8 @@ export class ReportBlockComponent implements OnInit { type: 'VC', } }); - dialogRef.onClose.subscribe(async (result) => { }); + dialogRef.onClose.subscribe(async (result) => { + }); } openVPDocument(item: any) { @@ -403,7 +246,8 @@ export class ReportBlockComponent implements OnInit { type: 'VP', } }); - dialogRef.onClose.subscribe(async (result) => { }); + dialogRef.onClose.subscribe(async (result) => { + }); } openJsonDocument(item: ITokenReport) { @@ -419,28 +263,8 @@ export class ReportBlockComponent implements OnInit { type: 'JSON', } }); - dialogRef.onClose.subscribe(async (result) => { }); - } - - openRetireVCDocument( - item: any, - document?: any - ) { - const title = `Retire Document`; - const dialogRef = this.dialogService.open(VCViewerDialog, { - showHeader: false, - width: '1000px', - styleClass: 'guardian-dialog', - data: { - id: item.id, - row: item, - viewDocument: true, - document: item, - title: title, - type: 'VC', - } + dialogRef.onClose.subscribe(async (result) => { }); - dialogRef.onClose.subscribe(async (result) => { }); } mapData(data: any[]) { @@ -480,7 +304,7 @@ export class ReportBlockComponent implements OnInit { onBackClick() { this.loading = true; this.policyEngineService - .setBlockData(this.id, this.policyId, { filterValue: null }) + .setBlockData(this.id, this.policyId, {filterValue: null}) .subscribe( () => { this.loadData(); From f3e0bc79110822df2e50c27bf43b06ba3f335b59 Mon Sep 17 00:00:00 2001 From: simvalery Date: Fri, 17 Jan 2025 16:19:20 +0400 Subject: [PATCH 28/28] fix build Signed-off-by: simvalery Signed-off-by: simvalery --- .../messages-report-block.component.html | 1587 ++++++++--------- .../report-block/report-block.component.html | 833 +++++---- 2 files changed, 1154 insertions(+), 1266 deletions(-) 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 6e7695935f..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,862 +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 }}
-
-
- - -
- receipt - Retirement -
-
-
- Contract ID: {{message.documents[0].credentialSubject[0].contractId}} -
-
- User ID: {{message.documents[0].credentialSubject[0].user}} -
-
-
-
-
+
+ +
+
+
+
+ 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 }} - -
-
-
- - -
- receipt - Retirement message -
- -
- -
-
Document artifact:
-
- Open document -
-
- -
-
-
Contract ID:
-
{{selected.documents[0].credentialSubject[0].contractId}}
-
-
-
User ID:
-
{{selected.documents[0].credentialSubject[0].user}}
-
-
-
Transaction:
-
{{selected.consensusTimestamp}}
-
-
-
-
-
Token ID:
-
{{token.tokenId}}
-
-
-
Instance ID:
-
{{token.serials.join(', ')}}
-
-
-
Amount:
-
{{token.count}}
-
-
- -
- -
-
Topic ID:
-
- {{selected.topicId}} -
-
-
-
Message ID:
-
- {{selected.consensusTimestamp}} -
-
-
-
Owner:
-
- {{selected.owner}} -
-
-
+
+ + + + +
+ + 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/report-block/report-block.component.html b/frontend/src/app/modules/policy-engine/policy-viewer/blocks/report-block/report-block.component.html index b7058b59ac..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,259 +1,324 @@
-
-
Trust Chain
-
- - HASH/ID - - - -
+
+
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

- check_circle - - -
-
- -
-

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

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

Secondary Impacts

-
-
-
-
-
-
-
- workspace_premium -
- {{ 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 }} +
+
+
+
+
-
-
- - -
-
- -
- +
+ + +
+
+ +
+ -
-
+
-
+ - account_tree - -
+ +
-
- - {{ item.icon }} - - - {{ item.title }} -
-
+
+ + + + + {{ item.title }} +
+
- warning - Revoked with reason: "{{document.document.comment}}" -
-
- {{ item.description }} -
-
-
- Parties: -
-
-
- {{ document.username }} -
-
-
- -
- -
-
+ + Revoked with reason: "{{ document.document.comment }}" +
+
+ {{ item.description }} +
+
+
+ Parties: +
+
+
+ {{ document.username }} +
+
+
+ +
+ VC File +
+
- chevron_left - - {{ item.activeDocumentIndex }} in {{ item.document.length }} - - chevron_right -
-
-
- - -
+ + {{ item.activeDocumentIndex }} in {{ item.document.length }} + +
+
+
+
+ +
-
-
- {{ item.title }} -
-
- search -
- Documents Not Found -
-
-
-
-
-
-
- - - -
-
- -
-
-
-
- Token(s) Retirement: {{ group.documents.length }} -
-
-

Token ID {{ mintTokenId }}

-

ContractID {{ - group.contractId - }}

-
-
- -

- No data from the indexer. Connect it and click Refresh for full - details. -

-
-
-
-
-
- - - - - -
-
-
-
-
-
- {{ selectedVC.issuanceDate | date : 'YYYY-MM-dd, hh:mm:ss' }} -
-
- -
-
-
-
-

Token {{ selectedVC.credentialSubject[0]?.tokens[0].tokenId }}

-

Instance ID {{ selectedVC.credentialSubject[0]?.tokens[0].serials.join(', ') }}

-

Amount {{ selectedVC.credentialSubject[0]?.tokens[0].count }}

- -

Transaction - {{selectedVC.timestamp}} -

-

Transaction -

- -

User ID {{ selectedVC.credentialSubject[0]?.user }}

-
-
-

Token {{ selectedVC.credentialSubject[0]?.tokens[1].tokenId }}

-

Instance ID {{ selectedVC.credentialSubject[0]?.tokens[1].serials.join(', ') }}

-

Amount {{ selectedVC.credentialSubject[0]?.tokens[1].count }}

-
-
- -
- chevron_left - - {{ (group.selectedItemIndex + 1) }} of {{ group.documents.length }} - - chevron_right -
-
-
-
- -
-
-
-
- {{ selectedVC.issuanceDate | date : 'YYYY-MM-dd, hh:mm:ss' }} -
-
- -
-
-
-

Token {{ selectedVC.credentialSubject[0]?.tokens[0].tokenId }}

-

Instance ID {{ selectedVC.credentialSubject[0]?.tokens[0].serials.join(', ') }}

-

Amount {{ selectedVC.credentialSubject[0]?.tokens[0].count }}

-

Transaction {{ selectedVC.timestamp }}

-

User ID {{ selectedVC.credentialSubject[0]?.user }}

-
- -
- chevron_left - - {{ (group.selectedItemIndex + 1) }} of {{ group.documents.length }} - - chevron_right -
-
-
-
-
-
-
-
-
-
-
- - + " + style="display: inline-block;" + > +
+
+ {{ item.title }} +
+
+ +
+ Documents Not Found +
+
+
+
-
+
+
+
+ +
+
+
+
-
+
-
+