From ade6238022ee61c8ae32455d49144fa972b4f58f Mon Sep 17 00:00:00 2001 From: Shashank Kulkarni <44693969+KulkarniShashank@users.noreply.github.com> Date: Tue, 17 Oct 2023 19:08:36 +0530 Subject: [PATCH] refactor: Implemented auto flag handling within the ecosystem and introduced validation. (#158) * Added the auto submit flag for automatic submit the transaction Signed-off-by: KulkarniShashank * Removed unnecessary params Signed-off-by: KulkarniShashank * Error handling in the schema endorsement Signed-off-by: KulkarniShashank * feat: Schema and credDef auto sign and submit transaction Signed-off-by: KulkarniShashank * Solved issue when schema sign Signed-off-by: KulkarniShashank * Added the validation for the cedDef create and write Signed-off-by: KulkarniShashank * feat: auto endorsement flag handle and refactor schema and cred-def Signed-off-by: KulkarniShashank * Solved conflicts in endorsement service Signed-off-by: KulkarniShashank * Change the API URL for auto sign and submit flag Signed-off-by: KulkarniShashank * Modify the error messages in ecosystem Signed-off-by: KulkarniShashank --------- Signed-off-by: KulkarniShashank --- .../src/ecosystem/ecosystem.service.ts | 4 +- apps/ecosystem/src/ecosystem.controller.ts | 65 +------------------ apps/ecosystem/src/ecosystem.repository.ts | 2 +- apps/ecosystem/src/ecosystem.service.ts | 3 +- libs/common/src/response-messages/index.ts | 4 +- 5 files changed, 9 insertions(+), 69 deletions(-) diff --git a/apps/api-gateway/src/ecosystem/ecosystem.service.ts b/apps/api-gateway/src/ecosystem/ecosystem.service.ts index 2354cfebd..0aba0342b 100644 --- a/apps/api-gateway/src/ecosystem/ecosystem.service.ts +++ b/apps/api-gateway/src/ecosystem/ecosystem.service.ts @@ -62,8 +62,8 @@ export class EcosystemService extends BaseService { * @param userId * @returns */ - async createInvitation(bulkInvitationDto: BulkEcosystemInvitationDto, userId: string, userEmail: string): Promise { - const payload = { bulkInvitationDto, userId, userEmail }; + async createInvitation(bulkInvitationDto: BulkEcosystemInvitationDto, userId: string): Promise { + const payload = { bulkInvitationDto, userId }; return this.sendNats(this.serviceProxy, 'send-ecosystem-invitation', payload); } diff --git a/apps/ecosystem/src/ecosystem.controller.ts b/apps/ecosystem/src/ecosystem.controller.ts index 196b74e6c..9c3b287a5 100644 --- a/apps/ecosystem/src/ecosystem.controller.ts +++ b/apps/ecosystem/src/ecosystem.controller.ts @@ -93,9 +93,9 @@ export class EcosystemController { */ @MessagePattern({ cmd: 'send-ecosystem-invitation' }) async createInvitation( - payload: { bulkInvitationDto: BulkSendInvitationDto; userId: string, userEmail: string } + @Body() payload: { bulkInvitationDto: BulkSendInvitationDto; userId: string } ): Promise { - return this.ecosystemService.createInvitation(payload.bulkInvitationDto, payload.userId, payload.userEmail); + return this.ecosystemService.createInvitation(payload.bulkInvitationDto, payload.userId); } /** @@ -211,67 +211,6 @@ export class EcosystemController { }): 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 62332457e..54b481ce0 100644 --- a/apps/ecosystem/src/ecosystem.repository.ts +++ b/apps/ecosystem/src/ecosystem.repository.ts @@ -196,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); diff --git a/apps/ecosystem/src/ecosystem.service.ts b/apps/ecosystem/src/ecosystem.service.ts index 546e0ee53..6318fd209 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 } }; diff --git a/libs/common/src/response-messages/index.ts b/libs/common/src/response-messages/index.ts index 236c8bc7d..a4a4b5f7f 100644 --- a/libs/common/src/response-messages/index.ts +++ b/libs/common/src/response-messages/index.ts @@ -233,8 +233,8 @@ 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.' } },