diff --git a/apps/agent-service/src/agent-service.service.ts b/apps/agent-service/src/agent-service.service.ts index 0d3f67403..557960456 100644 --- a/apps/agent-service/src/agent-service.service.ts +++ b/apps/agent-service/src/agent-service.service.ts @@ -229,7 +229,7 @@ export class AgentServiceService { socket.emit('agent-spinup-process-initiated', { clientId: agentSpinupDto.clientSocketId }); } - await this._agentSpinup(walletProvisionPayload, agentSpinupDto, orgApiKey, orgData, user, socket); + await this._agentSpinup(walletProvisionPayload, agentSpinupDto, orgApiKey, orgData, user, socket, agentSpinupDto.ledgerId); const agentStatusResponse = { agentSpinupStatus: 1 }; @@ -251,7 +251,7 @@ export class AgentServiceService { } } - async _agentSpinup(walletProvisionPayload: IWalletProvision, agentSpinupDto: IAgentSpinupDto, orgApiKey: string, orgData: organisation, user: IUserRequestInterface, socket): Promise { + async _agentSpinup(walletProvisionPayload: IWalletProvision, agentSpinupDto: IAgentSpinupDto, orgApiKey: string, orgData: organisation, user: IUserRequestInterface, socket, ledgerId: number[]): Promise { try { const agentSpinUpResponse = new Promise(async (resolve, _reject) => { @@ -288,7 +288,8 @@ export class AgentServiceService { agentsTypeId: AgentType.AFJ, orgId: orgData.id, walletName: agentSpinupDto.walletName, - clientSocketId: agentSpinupDto.clientSocketId + clientSocketId: agentSpinupDto.clientSocketId, + ledgerId }; if (agentEndPoint && agentSpinupDto.clientSocketId) { @@ -358,7 +359,8 @@ export class AgentServiceService { orgId: payload.orgId, agentEndPoint: payload.agentEndPoint, agentId: payload.agentId, - orgAgentTypeId: OrgAgentType.DEDICATED + orgAgentTypeId: OrgAgentType.DEDICATED, + ledgerId: payload.ledgerId }; @@ -543,7 +545,8 @@ export class AgentServiceService { agentEndPoint: platformAdminSpinnedUp.org_agents[0].agentEndPoint, orgAgentTypeId: OrgAgentType.SHARED, tenantId: tenantDetails.tenantRecord.id, - walletName: label + walletName: label, + ledgerId: payload.ledgerId }; if (payload.clientSocketId) { diff --git a/apps/agent-service/src/interface/agent-service.interface.ts b/apps/agent-service/src/interface/agent-service.interface.ts index d6a7d4b99..3386889bb 100644 --- a/apps/agent-service/src/interface/agent-service.interface.ts +++ b/apps/agent-service/src/interface/agent-service.interface.ts @@ -137,6 +137,7 @@ export interface IStoreOrgAgentDetails { agentId?: number; orgAgentTypeId?: OrgAgentType; tenantId?: string; + ledgerId?: number[]; } diff --git a/apps/agent-service/src/repositories/agent-service.repository.ts b/apps/agent-service/src/repositories/agent-service.repository.ts index 15d333e92..90d050471 100644 --- a/apps/agent-service/src/repositories/agent-service.repository.ts +++ b/apps/agent-service/src/repositories/agent-service.repository.ts @@ -88,7 +88,7 @@ export class AgentServiceRepository { agentId: storeOrgAgentDetails.agentId ? storeOrgAgentDetails.agentId : null, orgAgentTypeId: storeOrgAgentDetails.orgAgentTypeId ? storeOrgAgentDetails.orgAgentTypeId : null, tenantId: storeOrgAgentDetails.tenantId ? storeOrgAgentDetails.tenantId : null, - ledgerId: 1 + ledgerId: storeOrgAgentDetails.ledgerId[0] } }); } catch (error) { diff --git a/apps/api-gateway/src/ecosystem/ecosystem.controller.ts b/apps/api-gateway/src/ecosystem/ecosystem.controller.ts index e4b9c241e..272b9a143 100644 --- a/apps/api-gateway/src/ecosystem/ecosystem.controller.ts +++ b/apps/api-gateway/src/ecosystem/ecosystem.controller.ts @@ -95,7 +95,6 @@ export class EcosystemController { @Roles(OrgRoles.OWNER, OrgRoles.ADMIN) @EcosystemsRoles(EcosystemRoles.ECOSYSTEM_OWNER, EcosystemRoles.ECOSYSTEM_LEAD, EcosystemRoles.ECOSYSTEM_MEMBER) @ApiBearerAuth() - async getEcosystemDashboardDetails(@Param('ecosystemId') ecosystemId: string, @Param('orgId') orgId: string, @Res() res: Response): Promise { const getEcosystemDetails = await this.ecosystemService.getEcosystemDashboardDetails(ecosystemId, orgId); @@ -189,49 +188,9 @@ export class EcosystemController { } -/** - * - * @param orgId - * @param res - * @returns Ecosystem members list - */ - @Get('/:ecosystemId/:orgId/members') - // @Roles(OrgRoles.OWNER, OrgRoles.ADMIN) - // @EcosystemsRoles(EcosystemRoles.ECOSYSTEM_OWNER, EcosystemRoles.ECOSYSTEM_LEAD, EcosystemRoles.ECOSYSTEM_MEMBER) - @ApiBearerAuth() - @UseGuards(AuthGuard('jwt')) - @ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto }) - @ApiOperation({ summary: 'Get ecosystem members list', description: 'Get ecosystem members list.' }) - @ApiQuery({ - name: 'pageNumber', - type: Number, - required: false - }) - @ApiQuery({ - name: 'pageSize', - type: Number, - required: false - }) - @ApiQuery({ - name: 'search', - type: String, - required: false - }) - async getEcosystemMembers( - @Param('ecosystemId') ecosystemId: string, - @Param('orgId') orgId: string, - @Query() getEcosystemMembers: GetAllEcosystemMembersDto, - @Res() res: Response): Promise { - const members = await this.ecosystemService.getEcosystemMembers(ecosystemId, getEcosystemMembers); - const finalResponse: IResponseType = { - statusCode: HttpStatus.OK, - message: ResponseMessages.ecosystem.success.fetchMembers, - data: members?.response - }; - - return res.status(HttpStatus.OK).json(finalResponse); - } - + return res.status(HttpStatus.OK).json(finalResponse); + } + /** * * @param createOrgDto @@ -297,7 +256,7 @@ export class EcosystemController { @ApiBearerAuth() @EcosystemsRoles(EcosystemRoles.ECOSYSTEM_LEAD) @Roles(OrgRoles.OWNER, OrgRoles.ADMIN) - async SignEndorsementRequests(@Param('endorsementId') endorsementId: string, @Param('ecosystemId') ecosystemId: string, @Param('orgId') orgId: number, @Res() res: Response): Promise { + async SignEndorsementRequests(@Param('endorsementId') endorsementId: string, @Param('ecosystemId') ecosystemId: string, @Param('orgId') orgId: number, @Res() res: Response): Promise { await this.ecosystemService.signTransaction(endorsementId, ecosystemId); const finalResponse: IResponseType = { statusCode: HttpStatus.CREATED, @@ -356,10 +315,44 @@ export class EcosystemController { } - @Get('/:ecosystemId/invitations') - @ApiOperation({ summary: 'Get all sent invitations', description: 'Get all sent invitations' }) - @ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto }) - @UseGuards(AuthGuard('jwt')) + /** + * + * @param res + * @returns + */ + @Put('transaction/endorsement/auto') + @ApiOperation({ + summary: 'Auto sign and submit transactions', + description: 'Auto sign and submit transactions' + }) + @UseGuards(AuthGuard('jwt'), EcosystemRolesGuard, OrgRolesGuard) + @ApiBearerAuth() + @EcosystemsRoles(EcosystemRoles.ECOSYSTEM_LEAD) + @Roles(OrgRoles.OWNER, OrgRoles.ADMIN) + async autoSignAndSubmitTransaction( + @Res() res: Response + ): Promise { + await this.ecosystemService.autoSignAndSubmitTransaction(); + const finalResponse: IResponseType = { + statusCode: HttpStatus.OK, + message: ResponseMessages.ecosystem.success.AutoEndorsementTransaction + }; + return res.status(HttpStatus.OK).json(finalResponse); + } + + /** + * + * @param acceptRejectEcosystemInvitation + * @param reqUser + * @param res + * @returns Ecosystem invitation status + */ + @Put('/:orgId/invitations/:invitationId') + @ApiOperation({ + summary: 'Accept or reject ecosystem invitation', + description: 'Accept or Reject ecosystem invitations' + }) + @UseGuards(AuthGuard('jwt'), OrgRolesGuard) @ApiBearerAuth() @ApiQuery({ name: 'pageNumber', diff --git a/apps/api-gateway/src/ecosystem/ecosystem.service.ts b/apps/api-gateway/src/ecosystem/ecosystem.service.ts index 9b267ca71..0aba0342b 100644 --- a/apps/api-gateway/src/ecosystem/ecosystem.service.ts +++ b/apps/api-gateway/src/ecosystem/ecosystem.service.ts @@ -44,7 +44,7 @@ export class EcosystemService extends BaseService { const payload = { orgId }; return this.sendNats(this.serviceProxy, 'get-all-ecosystem', payload); } - + /** * * @@ -63,8 +63,8 @@ export class EcosystemService extends BaseService { * @returns */ async createInvitation(bulkInvitationDto: BulkEcosystemInvitationDto, userId: string): Promise { - const payload = { bulkInvitationDto, userId }; - return this.sendNats(this.serviceProxy, 'send-ecosystem-invitation', payload); + const payload = { bulkInvitationDto, userId }; + return this.sendNats(this.serviceProxy, 'send-ecosystem-invitation', payload); } async getInvitationsByEcosystemId( @@ -76,8 +76,8 @@ export class EcosystemService extends BaseService { const payload = { ecosystemId, pageNumber, pageSize, search, userId }; return this.sendNats(this.serviceProxy, 'get-sent-invitations-ecosystemId', payload); } - -/** + + /** * * @returns Ecosystem members */ @@ -88,6 +88,89 @@ export class EcosystemService extends BaseService { const { pageNumber, pageSize, search } = getEcosystemMembers; const payload = { ecosystemId, pageNumber, pageSize, search}; return this.sendNats(this.serviceProxy, 'fetch-ecosystem-members', payload); - } + } + + /** + * + * @returns Ecosystem Invitations details + */ + async getEcosystemInvitations( + getAllInvitationsDto: GetAllSentEcosystemInvitationsDto, + userEmail: string, + status: string + ): Promise<{ response: object }> { + const { pageNumber, pageSize, search } = getAllInvitationsDto; + const payload = { userEmail, status, pageNumber, pageSize, search }; + return this.sendNats(this.serviceProxy, 'get-ecosystem-invitations', payload); + } + + + async deleteEcosystemInvitations( + invitationId: string + ): Promise { + const payload = { invitationId }; + return this.sendNats(this.serviceProxy, 'delete-ecosystem-invitations', payload); + } + async acceptRejectEcosystemInvitaion( + acceptRejectInvitation: AcceptRejectEcosystemInvitationDto, + userEmail: string + ): Promise<{ response: string }> { + const payload = { acceptRejectInvitation, userEmail }; + return this.sendNats(this.serviceProxy, 'accept-reject-ecosystem-invitations', payload); + } + + + async fetchEcosystemOrg( + ecosystemId: string, + orgId: string + ): Promise<{ response: object }> { + const payload = { ecosystemId, orgId }; + return this.sendNats(this.serviceProxy, 'fetch-ecosystem-org-data', payload); + } + + async getEndorsementTranasactions( + ecosystemId: string, + orgId: string, + getAllEndorsements: GetAllEndorsementsDto + ): Promise<{ response: object }> { + const { pageNumber, pageSize, search, type } = getAllEndorsements; + const payload = { ecosystemId, orgId, pageNumber, pageSize, search, type }; + return this.sendNats(this.serviceProxy, 'get-endorsement-transactions', payload); + } + + + async schemaEndorsementRequest(requestSchemaPayload: RequestSchemaDto, orgId: number, ecosystemId: string): Promise { + const payload = { requestSchemaPayload, orgId, ecosystemId }; + return this.sendNats(this.serviceProxy, 'schema-endorsement-request', payload); + } + + async credDefEndorsementRequest(requestCredDefPayload: RequestCredDefDto, orgId: number, ecosystemId: string): Promise { + const payload = { requestCredDefPayload, orgId, ecosystemId }; + return this.sendNats(this.serviceProxy, 'credDef-endorsement-request', payload); + } + + async signTransaction(endorsementId: string, ecosystemId: string): Promise { + const payload = { endorsementId, ecosystemId }; + return this.sendNats(this.serviceProxy, 'sign-endorsement-transaction', payload); + } + + async submitTransaction(endorsementId: string, ecosystemId: string): Promise { + const payload = { endorsementId, ecosystemId }; + return this.sendNats(this.serviceProxy, 'sumbit-endorsement-transaction', payload); + } + + async autoSignAndSubmitTransaction(): Promise<{ response: object }> { + const payload = {}; + return this.sendNats(this.serviceProxy, 'auto-endorsement-transaction', payload); + } + + async declineEndorsementRequestByLead( + ecosystemId: string, + endorsementId: string, + orgId: string + ): Promise<{ response: object }> { + const payload = { ecosystemId, endorsementId, orgId }; + return this.sendNats(this.serviceProxy, 'decline-endorsement-transaction', payload); + } } diff --git a/apps/ecosystem/src/ecosystem.controller.ts b/apps/ecosystem/src/ecosystem.controller.ts index bdfc6ea8c..3b3d5b42f 100644 --- a/apps/ecosystem/src/ecosystem.controller.ts +++ b/apps/ecosystem/src/ecosystem.controller.ts @@ -8,7 +8,7 @@ import { RequestSchemaEndorsement } from '../interfaces/ecosystem.interfaces'; @Controller() export class EcosystemController { - constructor(private readonly ecosystemService: EcosystemService) {} + constructor(private readonly ecosystemService: EcosystemService) { } private readonly logger = new Logger('EcosystemController'); /** @@ -27,7 +27,7 @@ export class EcosystemController { * @param payload updation Details * @returns Get updated ecosystem details */ - @MessagePattern({ cmd: 'edit-ecosystem' }) + @MessagePattern({ cmd: 'edit-ecosystem' }) async editEcosystem(@Body() payload: { editEcosystemDto, ecosystemId }): Promise { return this.ecosystemService.editEcosystem(payload.editEcosystemDto, payload.ecosystemId); } @@ -39,11 +39,38 @@ export class EcosystemController { */ @MessagePattern({ cmd: 'get-all-ecosystem' }) async getAllEcosystems( - @Body() payload: {orgId: string} + @Body() payload: { orgId: string } ): Promise { return this.ecosystemService.getAllEcosystem(payload); } + /** + * Description: get ecosystems dashboard details + * @returns Get ecosystem dashboard details + */ + @MessagePattern({ cmd: 'get-ecosystem-dashboard-details' }) + async getEcosystemDashboardDetails( + payload: { ecosystemId: string; orgId: string }): Promise { + return this.ecosystemService.getEcosystemDashboardDetails(payload.ecosystemId); + } + + + /** + * Description: get ecosystem invitations + * @returns Get sent invitation details + */ + @MessagePattern({ cmd: 'get-ecosystem-invitations' }) + async getEcosystemInvitations( + @Body() payload: { userEmail: string, status: string; pageNumber: number; pageSize: number; search: string } + ): Promise { + return this.ecosystemService.getEcosystemInvitations( + payload.userEmail, + payload.status, + payload.pageNumber, + payload.pageSize, + payload.search + ); + } /** * @@ -67,7 +94,7 @@ export class EcosystemController { @MessagePattern({ cmd: 'send-ecosystem-invitation' }) async createInvitation( @Body() payload: { bulkInvitationDto: BulkSendInvitationDto; userId: string } - ): Promise { + ): Promise { return this.ecosystemService.createInvitation(payload.bulkInvitationDto, payload.userId); } @@ -96,89 +123,98 @@ export class EcosystemController { @MessagePattern({ cmd: 'get-endorsement-transactions' }) async getEndorsementTransactions( @Body() payload: GetEndorsementsPayload - ): Promise { + ): Promise { return this.ecosystemService.getEndorsementTransactions( payload ); - } + } @MessagePattern({ cmd: 'delete-ecosystem-invitations' }) async deleteInvitation( - @Body() payload: {invitationId: string} - ): Promise { + @Body() payload: { invitationId: string } + ): Promise { return this.ecosystemService.deleteEcosystemInvitations( payload.invitationId - ); - } + ); + } @MessagePattern({ cmd: 'fetch-ecosystem-org-data' }) async fetchEcosystemOrg( - @Body() payload: { ecosystemId: string, orgId: string} + @Body() payload: { ecosystemId: string, orgId: string } ): Promise { - return this.ecosystemService.fetchEcosystemOrg( - payload - ); + return this.ecosystemService.fetchEcosystemOrg( + payload + ); + } + + /** + * + * @param payload + * @returns Schema endorsement request + */ + @MessagePattern({ cmd: 'schema-endorsement-request' }) + async schemaEndorsementRequest( + @Body() payload: { requestSchemaPayload: RequestSchemaEndorsement; orgId: number, ecosystemId: string } + ): Promise { + return this.ecosystemService.requestSchemaEndorsement(payload.requestSchemaPayload, payload.orgId, payload.ecosystemId); + } + + /** + * + * @param payload + * @returns Schema endorsement request + */ + @MessagePattern({ cmd: 'credDef-endorsement-request' }) + async credDefEndorsementRequest( + @Body() payload: { requestCredDefPayload: RequestCredDeffEndorsement; orgId: number; ecosystemId: string } + ): Promise { + return this.ecosystemService.requestCredDeffEndorsement(payload.requestCredDefPayload, payload.orgId, payload.ecosystemId); + } + + /** + * + * @param payload + * @returns sign endorsement request + */ + @MessagePattern({ cmd: 'sign-endorsement-transaction' }) + async signTransaction( + @Body() payload: { endorsementId: string, ecosystemId: string } + ): Promise { + return this.ecosystemService.signTransaction(payload.endorsementId, payload.ecosystemId); + } + + /** + * + * @param payload + * @returns submit endorsement request + */ + @MessagePattern({ cmd: 'sumbit-endorsement-transaction' }) + async submitTransaction( + @Body() payload: { endorsementId: string, ecosystemId: string } + ): Promise { + return this.ecosystemService.submitTransaction(payload.endorsementId, payload.ecosystemId); + } + + /** + * + * @param payload + * @returns auto sign and submit endorsement request + */ + @MessagePattern({ cmd: 'auto-endorsement-transaction' }) + async autoSignAndSubmitTransaction(): Promise { + return this.ecosystemService.autoSignAndSubmitTransaction(); + } + + /** + * + * @param payload + * @returns Declien Endorsement Transaction status + */ + @MessagePattern({ cmd: 'decline-endorsement-transaction' }) + async declineEndorsementRequestByLead(payload: { + ecosystemId: string, endorsementId: string + }): Promise { + return this.ecosystemService.declineEndorsementRequestByLead(payload.ecosystemId, payload.endorsementId); } - - /** - * - * @param payload - * @returns Schema endorsement request - */ - @MessagePattern({ cmd: 'schema-endorsement-request' }) - async schemaEndorsementRequest( - @Body() payload: { requestSchemaPayload: RequestSchemaEndorsement; orgId: number, ecosystemId: string } - ): Promise { - return this.ecosystemService.requestSchemaEndorsement(payload.requestSchemaPayload, payload.orgId, payload.ecosystemId); - } - - /** - * - * @param payload - * @returns Schema endorsement request - */ - @MessagePattern({ cmd: 'credDef-endorsement-request' }) - async credDefEndorsementRequest( - @Body() payload: { requestCredDefPayload: RequestCredDeffEndorsement; orgId: number; ecosystemId:string} - ): Promise { - return this.ecosystemService.requestCredDeffEndorsement(payload.requestCredDefPayload, payload.orgId, payload.ecosystemId); - } - - /** - * - * @param payload - * @returns sign endorsement request - */ - @MessagePattern({ cmd: 'sign-endorsement-transaction' }) - async signTransaction( - @Body() payload: { endorsementId: string, ecosystemId:string } - ): Promise { - return this.ecosystemService.signTransaction(payload.endorsementId, payload.ecosystemId); - } - - /** - * - * @param payload - * @returns submit endorsement request - */ - @MessagePattern({ cmd: 'sumbit-endorsement-transaction' }) - async submitTransaction( - @Body() payload: { endorsementId: string, ecosystemId:string } - ): Promise { - return this.ecosystemService.submitTransaction(payload.endorsementId, payload.ecosystemId); - } - - - /** - * - * @param payload - * @returns Declien Endorsement Transaction status - */ - @MessagePattern({ cmd: 'decline-endorsement-transaction' }) - async declineEndorsementRequestByLead(payload: { - ecosystemId:string, endorsementId:string - }): Promise { - return this.ecosystemService.declineEndorsementRequestByLead(payload.ecosystemId, payload.endorsementId); - } } diff --git a/apps/ecosystem/src/ecosystem.repository.ts b/apps/ecosystem/src/ecosystem.repository.ts index 593b33633..21d151f70 100644 --- a/apps/ecosystem/src/ecosystem.repository.ts +++ b/apps/ecosystem/src/ecosystem.repository.ts @@ -7,6 +7,7 @@ import { updateEcosystemOrgsDto } from '../dtos/update-ecosystemOrgs.dto'; import { SaveSchema, SchemaTransactionResponse, saveCredDef } from '../interfaces/ecosystem.interfaces'; import { ResponseMessages } from '@credebl/common/response-messages'; import { NotFoundException } from '@nestjs/common'; +import { CommonConstants } from '@credebl/common/common.constant'; // eslint-disable-next-line camelcase @Injectable() @@ -195,7 +196,7 @@ export class EcosystemRepository { * @returns Get specific organization details from ecosystem */ // eslint-disable-next-line camelcase - async checkEcosystemOrgs(orgId:string): Promise { + async checkEcosystemOrgs(orgId: string): Promise { try { if (!orgId) { throw new BadRequestException(ResponseMessages.ecosystem.error.invalidOrgId); @@ -215,14 +216,16 @@ export class EcosystemRepository { * * @returns Get ecosystem dashboard card count */ - - async getEcosystemDashboardDetails(ecosystemId: string): Promise<{membersCount: number; endorsementsCount: number}> { + // eslint-disable-next-line camelcase + async getEcosystemDashboardDetails(ecosystemId: string): Promise<{ membersCount: number; endorsementsCount: number; ecosystemConfigData: ecosystem_config[] }> { try { const membersCount = await this.getEcosystemMembersCount(ecosystemId); const endorsementsCount = await this.getEcosystemEndorsementsCount(ecosystemId); + const ecosystemConfigData = await this.getEcosystemConfig(); return { membersCount, - endorsementsCount + endorsementsCount, + ecosystemConfigData }; } catch (error) { this.logger.error(`error: ${JSON.stringify(error)}`); @@ -230,6 +233,16 @@ export class EcosystemRepository { } } + // eslint-disable-next-line camelcase + async getEcosystemConfig(): Promise { + try { + const getEcosystemConfigDetails = await this.prisma.ecosystem_config.findMany(); + return getEcosystemConfigDetails; + } catch (error) { + this.logger.error(`error: ${JSON.stringify(error)}`); + throw error; + } + } async getEcosystemMembersCount(ecosystemId: string): Promise { try { @@ -874,4 +887,41 @@ export class EcosystemRepository { throw error; } } + + async updateAutoSignAndSubmitTransaction(): Promise<{ + id: string; + key: string; + value: string; + createDateTime: Date; + createdBy: string; + lastChangedDateTime: Date; + lastChangedBy: string; + deletedAt: Date; + }> { + try { + + const { id, value } = await this.prisma.ecosystem_config.findFirst({ + where: { + key: `${CommonConstants.ECOSYSTEM_AUTO_ENDOSEMENT}` + } + }); + + const updatedValue = 'false' === value ? 'true' : 'false'; + + const updateEcosystemConfig = await this.prisma.ecosystem_config.update({ + where: { + id + }, + data: { + value: updatedValue + } + }); + + return updateEcosystemConfig; + + } catch (error) { + this.logger.error(`Error in update auto sign and submit flag: ${error.message}`); + throw error; + } + } } diff --git a/apps/ecosystem/src/ecosystem.service.ts b/apps/ecosystem/src/ecosystem.service.ts index a2bde60dc..b04717898 100644 --- a/apps/ecosystem/src/ecosystem.service.ts +++ b/apps/ecosystem/src/ecosystem.service.ts @@ -106,7 +106,8 @@ export class EcosystemService { endorsementsCount: endorseMemberCount.endorsementsCount, ecosystemLead:{ role: ecosystemDetails['ecosystemRole']['name'], - orgName: ecosystemDetails['orgName'] + orgName: ecosystemDetails['orgName'], + config: endorseMemberCount.ecosystemConfigData } }; @@ -562,7 +563,7 @@ export class EcosystemService { if (updateSignedTransaction && 'true' === ecosystemConfigDetails.value) { - const submitTxn = await this.submitTransaction(endorsementId, ecosystemId); + const submitTxn = await this.submitTransaction(endorsementId, ecosystemId, ecosystemLeadAgentDetails.agentEndPoint); if (!submitTxn) { await this.ecosystemRepository.updateTransactionStatus(endorsementId, endorsementTransactionStatus.REQUESTED); throw new InternalServerErrorException(ResponseMessages.ecosystem.error.sumbitTransaction); @@ -729,7 +730,7 @@ export class EcosystemService { return this.ecosystemRepository.updateTransactionStatus(endorsementId, endorsementTransactionStatus.SUBMITED); } - async submitTransaction(endorsementId, ecosystemId): Promise { + async submitTransaction(endorsementId, ecosystemId, ecosystemLeadAgentEndPoint?): Promise { try { const endorsementTransactionPayload = await this.ecosystemRepository.getEndorsementTransactionById(endorsementId, endorsementTransactionStatus.SIGNED); @@ -744,7 +745,9 @@ export class EcosystemService { const ecosystemMemberDetails = await this.getEcosystemMemberDetails(endorsementTransactionPayload); const ecosystemLeadAgentDetails = await this.getEcosystemLeadAgentDetails(ecosystemId); const platformConfig = await this.getPlatformConfig(); - const url = await this.getAgentUrl(ecosystemMemberDetails?.orgAgentTypeId, ecosystemMemberDetails.agentEndPoint, endorsementTransactionType.SUBMIT, ecosystemMemberDetails?.tenantId); + + const agentEndPoint = ecosystemLeadAgentEndPoint ? ecosystemLeadAgentEndPoint : ecosystemMemberDetails.agentEndPoint; + const url = await this.getAgentUrl(ecosystemMemberDetails?.orgAgentTypeId, agentEndPoint, endorsementTransactionType.SUBMIT, ecosystemMemberDetails?.tenantId); const payload = await this.submitTransactionPayload(endorsementTransactionPayload, ecosystemMemberDetails, ecosystemLeadAgentDetails); const submitTransactionRequest = await this._submitTransaction(payload, url, platformConfig.sgApiKey); @@ -927,6 +930,19 @@ export class EcosystemService { } } + /** + * @returns EndorsementTransaction Status message + */ + + async autoSignAndSubmitTransaction(): Promise { + try { + + return await this.ecosystemRepository.updateAutoSignAndSubmitTransaction(); + } catch (error) { + this.logger.error(`error in decline endorsement request: ${error}`); + throw new InternalServerErrorException(error); + } + } /** * diff --git a/libs/common/src/response-messages/index.ts b/libs/common/src/response-messages/index.ts index 3c158de24..e713dc8cc 100644 --- a/libs/common/src/response-messages/index.ts +++ b/libs/common/src/response-messages/index.ts @@ -188,7 +188,19 @@ export const ResponseMessages = { update: 'Ecosystem updated successfully', delete: 'Ecosystem invitations deleted successfully', fetch: 'Ecosystem fetched successfully', - getInvitation: 'Ecosystem invitations fetched successfully' + getEcosystemDashboard: 'Ecosystem dashboard details fetched successfully', + getInvitation: 'Ecosystem invitations fetched successfully', + createInvitation: 'Ecosystem invitations sent successfully', + schemaRequest: 'Schema transaction request created successfully', + credDefRequest: 'credential-definition transaction request created successfully', + sign: 'Transaction request signed successfully', + submit: 'Transaction request submitted successfully', + invitationReject: 'Ecosystem invitation rejected', + invitationAccept: 'Ecosystem invitation accepted successfully', + fetchEndorsors: 'Endorser transactions fetched successfully', + DeclineEndorsementTransaction: 'Decline endorsement request successfully', + AutoEndorsementTransaction: 'The flag for transactions has been successfully set', + fetchMembers: 'Ecosystem members fetched successfully' }, error: { notCreated: 'Error while creating ecosystem', @@ -220,10 +232,9 @@ export const ResponseMessages = { invalidTransaction: 'Transaction does not exist', transactionSubmitted: 'Transaction already submitted', invalidAgentUrl: 'Invalid agent url', - EndorsementTransactionNotFoundException:'Endorsement transaction with status requested not found', - OrgOrEcosystemNotFoundExceptionForEndorsementTransaction:'Cannot update endorsement transaction status as OrgId and EcosystemId is not present in ecosystemOrg', + EndorsementTransactionNotFoundException: 'Endorsement transaction with status requested not found', + OrgOrEcosystemNotFoundExceptionForEndorsementTransaction: 'The endorsement transaction status cant be updated', ecosystemOrgAlready: 'Organization is already part of the ecosystem. Please ensure that the organization is not duplicated.' } - } }; \ No newline at end of file