Skip to content

Commit

Permalink
feat:endorser sumbit transaction
Browse files Browse the repository at this point in the history
Signed-off-by: tipusinghaw <[email protected]>
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
tipusinghaw authored and KulkarniShashank committed Sep 11, 2024
1 parent 8514b05 commit 24db899
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
4 changes: 4 additions & 0 deletions apps/agent-service/src/agent-service.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,8 @@ export class AgentServiceController {
async signTransaction(payload: { url: string, apiKey: string, signEndorsementPayload:string }): Promise<object> {
return this.agentServiceService.signTransaction(payload.url, payload.apiKey, payload.signEndorsementPayload);
}
@MessagePattern({ cmd: 'agent-submit-transaction' })
async submitTransaction(payload: { url: string, apiKey: string, submitEndorsementPayload:string }): Promise<object> {
return this.agentServiceService.sumbitTransaction(payload.url, payload.apiKey, payload.submitEndorsementPayload);
}
}
17 changes: 15 additions & 2 deletions apps/api-gateway/src/ecosystem/ecosystem.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class EcosystemController {
@Post('/:orgId/transaction/schema')
@ApiOperation({ summary: 'Request new schema', description: 'Request new schema' })
@ApiResponse({ status: 201, description: 'Success', type: ApiResponseDto })
@UseGuards(AuthGuard('jwt'))
// @UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
async requestSchemaTransaction(@Body() requestSchemaPayload: RequestSchemaDto, @Param('orgId') orgId: number, @Res() res: Response): Promise<Response> {
await this.ecosystemService.schemaEndorsementRequest(requestSchemaPayload, orgId);
Expand All @@ -173,7 +173,7 @@ export class EcosystemController {
@Post('transaction/sign/:endorsementId')
@ApiOperation({ summary: 'Sign transaction', description: 'Sign transaction' })
@ApiResponse({ status: 201, description: 'Success', type: ApiResponseDto })
@UseGuards(AuthGuard('jwt'))
// @UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
async SignEndorsementRequests(@Param('endorsementId') endorsementId: string, @Res() res: Response): Promise<Response> {
await this.ecosystemService.signTransaction(endorsementId);
Expand All @@ -184,6 +184,19 @@ export class EcosystemController {
return res.status(HttpStatus.CREATED).json(finalResponse);
}

@Post('transaction/sumbit/:endorsementId')
@ApiOperation({ summary: 'Sumbit transaction', description: 'Sumbit transaction' })
@ApiResponse({ status: 201, description: 'Success', type: ApiResponseDto })
// @UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
async SumbitEndorsementRequests(@Param('endorsementId') endorsementId: string, @Res() res: Response): Promise<Response> {
await this.ecosystemService.submitTransaction(endorsementId);
const finalResponse: IResponseType = {
statusCode: HttpStatus.CREATED,
message: ResponseMessages.ecosystem.success.sign
};
return res.status(HttpStatus.CREATED).json(finalResponse);
}
/**
*
* @param bulkInvitationDto
Expand Down
13 changes: 13 additions & 0 deletions apps/ecosystem/interfaces/ecosystem.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,16 @@ export interface SignedTransactionMessage {
signedTransaction: string;
};
}

export interface EndorsementTransactionPayload {
id: string;
endorserDid: string;
authorDid: string;
requestPayload: string;
responsePayload: string;
status: string;
ecosystemOrgId: string;
ecosystemOrgs?: {
orgId: string;
};
}
10 changes: 5 additions & 5 deletions apps/ecosystem/src/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ export class EcosystemService {
try {
const { orgId, status, invitationId } = acceptRejectInvitation;
const invitation = await this.ecosystemRepository.getEcosystemInvitationById(invitationId);

if (!invitation) {
throw new NotFoundException(ResponseMessages.ecosystem.error.invitationNotFound);
}

const updatedInvitation = await this.updateEcosystemInvitation(invitationId, orgId, status);
if (!updatedInvitation) {
throw new NotFoundException(ResponseMessages.ecosystem.error.invitationNotUpdate);
throw new NotFoundException(ResponseMessages.ecosystem.error.invitationNotUpdate);
}

if (status === Invitation.REJECTED) {
Expand All @@ -124,13 +124,13 @@ export class EcosystemService {
throw new NotFoundException(ResponseMessages.ecosystem.error.orgsNotUpdate);
}
return ResponseMessages.ecosystem.success.invitationAccept;

} catch (error) {
this.logger.error(`acceptRejectInvitations: ${error}`);
throw new RpcException(error.response ? error.response : error);
}
}

async updatedEcosystemOrgs(orgId: string, ecosystemId: string, ecosystemRoleId: string): Promise<object> {
try {
const data = {
Expand All @@ -153,7 +153,7 @@ export class EcosystemService {
*/
async updateEcosystemInvitation(invitationId: string, orgId: string, status: string): Promise<object> {
try {

const data = {
status,
orgId: String(orgId)
Expand Down

0 comments on commit 24db899

Please sign in to comment.