Skip to content

Commit

Permalink
Merge branch 'develop' into fix/3141bugs-in-angular
Browse files Browse the repository at this point in the history
  • Loading branch information
Ihar committed Jan 22, 2025
2 parents 0f7fcf3 + 68c8c04 commit b076cb4
Show file tree
Hide file tree
Showing 85 changed files with 45,309 additions and 27,145 deletions.
33 changes: 32 additions & 1 deletion api-gateway/src/api/service/analytics.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -947,4 +947,35 @@ export class AnalyticsApi {
await InternalException(error, this.logger);
}
}

/**
* Get Indexer availability
*/
@Get('/checkIndexer')
@Auth(
Permissions.POLICIES_POLICY_EXECUTE,
)
@ApiOperation({
summary: 'Get Indexer Availability.',
description: 'Returns Indexer Availability (true/false).',
})
@ApiOkResponse({
description: 'Successful operation.',
type: Boolean,
})
@ApiInternalServerErrorResponse({
description: 'Internal server error.',
type: InternalServerErrorDTO
})
@HttpCode(HttpStatus.OK)
async checkIndexerAvailability(
@AuthUser() user: IAuthUser
): Promise<boolean> {
const guardians = new Guardians();
try {
return await guardians.getIndexerAvailability();
} catch (error) {
await InternalException(error, this.logger);
}
}
}
52 changes: 52 additions & 0 deletions api-gateway/src/api/service/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1719,5 +1719,57 @@ export class ContractsApi {
await InternalException(error, this.logger);
}
}

/**
* Get a list of all retire vcs from Indexer
*/
@Get('/retireIndexer')
@Auth(
Permissions.CONTRACTS_DOCUMENT_READ,
// UserRole.STANDARD_REGISTRY,
// UserRole.USER
)
@ApiOperation({
summary: 'Return a list of all retire vcs from Indexer.',
description: 'Returns all retire vcs from Indexer.',
})
@ApiQuery({
name: 'contractTopicId',
type: String,
description: 'The topic id of contract',
required: true,
example: '0.0.0000000',
})
@ApiOkResponse({
description: 'Successful operation.',
isArray: true,
headers: pageHeader,
schema: {
type: 'array',
items: {
type: 'object'
}
}
})
@ApiInternalServerErrorResponse({
description: 'Internal server error.',
type: InternalServerErrorDTO,
})
@ApiExtraModels(RetirePoolDTO, InternalServerErrorDTO)
@HttpCode(HttpStatus.OK)
async getRetireVCsFromIndexer(
@AuthUser() user: IAuthUser,
@Response() res: any,
@Query('contractTopicId') contractTopicId: string,
): Promise<any[]> {
try {
const owner = new EntityOwner(user);
const guardians = new Guardians();
const [vcs, count] = await guardians.getRetireVCsFromIndexer(owner, contractTopicId);
return res.header('X-Total-Count', count).send(vcs);
} catch (error) {
await InternalException(error, this.logger);
}
}
//#endregion
}
26 changes: 26 additions & 0 deletions api-gateway/src/helpers/guardians.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import {
IContract,
IDidObject,
IOwner,
IRetirementMessage,
IRetirePool,
IRetireRequest,
ISchema,
IToken,
ITokenInfo,
IUser,
IVC,
IVCDocument,
IVPDocument,
MessageAPI,
Expand Down Expand Up @@ -1852,6 +1854,22 @@ export class Guardians extends NatsService {
});
}

/**
* Get retire VCs from Indexer
* @param owner
* @param contractTopicId
* @returns Retire VCs from Indexer and count
*/
public async getRetireVCsFromIndexer(
owner: IOwner,
contractTopicId: string
): Promise<[IRetirementMessage[], number]> {
return await this.sendMessage(ContractAPI.GET_RETIRE_VCS_FROM_INDEXER, {
owner,
contractTopicId
});
}

//#endregion

/**
Expand Down Expand Up @@ -3204,6 +3222,14 @@ export class Guardians extends NatsService {
return await this.sendMessage(MessageAPI.PREVIEW_SCHEMA_RULE_FILE, { zip, owner });
}


/**
* Get Indexer availability
*/
public async getIndexerAvailability(): Promise<boolean> {
return await this.sendMessage(MessageAPI.GET_INDEXER_AVAILABILITY, {});
}

/**
* Create policy label
*
Expand Down
6 changes: 4 additions & 2 deletions common/src/database-modules/database-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,8 @@ export class DatabaseServer extends AbstractDatabaseServer {
wasTransferNeeded: boolean,
transferSerials: number[],
transferAmount: number,
tokenIds: string[]
tokenIds: string[],
target: string
]
> {
const mintRequests = await this.getMintRequests({
Expand Down Expand Up @@ -2100,7 +2101,7 @@ export class DatabaseServer extends AbstractDatabaseServer {
if (vpDocument.tokenId) {
tokenIds.add(vpDocument.tokenId);
}

const target = mintRequests?.[0]?.target;
for (const mintRequest of mintRequests) {
if (mintRequest.error) {
errors.push(mintRequest.error);
Expand Down Expand Up @@ -2172,6 +2173,7 @@ export class DatabaseServer extends AbstractDatabaseServer {
transferSerials,
transferAmount,
[...tokenIds],
target,
];
}

Expand Down
3 changes: 2 additions & 1 deletion common/src/interfaces/database-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,8 @@ export abstract class AbstractDatabaseServer {
wasTransferNeeded: boolean,
transferSerials: number[],
transferAmount: number,
tokenIds: string[]
tokenIds: string[],
target: string,
]
>

Expand Down
Loading

0 comments on commit b076cb4

Please sign in to comment.