Skip to content

Commit

Permalink
refactor: Implemented auto flag handling within the ecosystem and int…
Browse files Browse the repository at this point in the history
…roduced validation. (#158)

* Added the auto submit flag for automatic submit the transaction

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Removed unnecessary params

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Error handling in the schema endorsement

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* feat: Schema and credDef auto sign and submit transaction

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Solved issue when schema sign

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added the validation for the cedDef create and write

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* feat: auto endorsement flag handle and refactor schema and cred-def

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Solved conflicts in endorsement service

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Change the API URL for auto sign and submit flag

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Modify the error messages in ecosystem

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

---------

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
  • Loading branch information
KulkarniShashank authored and KulkarniShashank committed Sep 11, 2024
1 parent cd5f786 commit 2d37b90
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 69 deletions.
4 changes: 2 additions & 2 deletions apps/api-gateway/src/ecosystem/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export class EcosystemService extends BaseService {
* @param userId
* @returns
*/
async createInvitation(bulkInvitationDto: BulkEcosystemInvitationDto, userId: string, userEmail: string): Promise<object> {
const payload = { bulkInvitationDto, userId, userEmail };
async createInvitation(bulkInvitationDto: BulkEcosystemInvitationDto, userId: string): Promise<object> {
const payload = { bulkInvitationDto, userId };
return this.sendNats(this.serviceProxy, 'send-ecosystem-invitation', payload);
}

Expand Down
65 changes: 2 additions & 63 deletions apps/ecosystem/src/ecosystem.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
return this.ecosystemService.createInvitation(payload.bulkInvitationDto, payload.userId, payload.userEmail);
return this.ecosystemService.createInvitation(payload.bulkInvitationDto, payload.userId);
}

/**
Expand Down Expand Up @@ -211,67 +211,6 @@ export class EcosystemController {
}): Promise<object> {
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<object> {
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<object> {
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<object> {
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<object> {
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<object> {
return this.ecosystemService.declineEndorsementRequestByLead(payload.ecosystemId, payload.endorsementId);
}


}
2 changes: 1 addition & 1 deletion apps/ecosystem/src/ecosystem.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class EcosystemRepository {
* @returns Get specific organization details from ecosystem
*/
// eslint-disable-next-line camelcase
async checkEcosystemOrgs(orgId:string): Promise<ecosystem_orgs> {
async checkEcosystemOrgs(orgId: string): Promise<ecosystem_orgs> {
try {
if (!orgId) {
throw new BadRequestException(ResponseMessages.ecosystem.error.invalidOrgId);
Expand Down
3 changes: 2 additions & 1 deletion apps/ecosystem/src/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export class EcosystemService {
endorsementsCount: endorseMemberCount.endorsementsCount,
ecosystemLead:{
role: ecosystemDetails['ecosystemRole']['name'],
orgName: ecosystemDetails['orgName']
orgName: ecosystemDetails['orgName'],
config: endorseMemberCount.ecosystemConfigData
}
};

Expand Down
4 changes: 2 additions & 2 deletions libs/common/src/response-messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
}
},
Expand Down

0 comments on commit 2d37b90

Please sign in to comment.