Skip to content

Commit

Permalink
feat: get endorsement transactions (#131)
Browse files Browse the repository at this point in the history
* worked on the GET API for endorsement transactions

Signed-off-by: Nishad <[email protected]>

* Implemented type parameter in the GET API of endorser transactions

Signed-off-by: Nishad <[email protected]>

---------

Signed-off-by: Nishad <[email protected]>
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
nishad-ayanworks authored and KulkarniShashank committed Sep 11, 2024
1 parent 1f32ba1 commit dc6a951
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 8 deletions.
35 changes: 35 additions & 0 deletions apps/api-gateway/src/ecosystem/dtos/get-all-endorsements.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

import { Transform, Type } from 'class-transformer';
import { toNumber } from '@credebl/common/cast.helper';

import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsOptional, IsString } from 'class-validator';
import { EndorserTransactionType } from '@credebl/enum/enum';

export class GetAllEndorsementsDto {
@ApiProperty({ required: false, default: 1 })
@IsOptional()
@Type(() => Number)
@Transform(({ value }) => toNumber(value))
pageNumber = 1;

@ApiProperty({ required: false })
@IsOptional()
@IsString()
@Type(() => String)
search = '';

@ApiProperty({ required: false })
@IsOptional()
@Type(() => Number)
@Transform(({ value }) => toNumber(value))
pageSize = 10;

@ApiProperty({
enum: [EndorserTransactionType.SCHEMA, EndorserTransactionType.CREDENTIAL_DEFINITION]
})
@IsOptional()
@IsEnum(EndorserTransactionType)
type: EndorserTransactionType.SCHEMA | EndorserTransactionType.CREDENTIAL_DEFINITION;

}
38 changes: 38 additions & 0 deletions apps/api-gateway/src/ecosystem/ecosystem.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,44 @@ export class EcosystemController {

}

@Get('/:ecosystemId/:orgId/endorsement-transactions')
@ApiOperation({ summary: 'Get all endorsement transactions', description: 'Get all endorsement transactions' })
@ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto })
@UseGuards(AuthGuard('jwt'), EcosystemRolesGuard, OrgRolesGuard)
@ApiBearerAuth()
@EcosystemsRoles(EcosystemRoles.ECOSYSTEM_OWNER, EcosystemRoles.ECOSYSTEM_LEAD, EcosystemRoles.ECOSYSTEM_MEMBER)
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER)
@ApiQuery({
name: 'pageNumber',
type: Number,
required: false
})
@ApiQuery({
name: 'pageSize',
type: Number,
required: false
})
@ApiQuery({
name: 'search',
type: String,
required: false
})
async getEndorsementTranasactions(
@Param('ecosystemId') ecosystemId: string,
@Param('orgId') orgId: string,
@Query() getAllEndorsementsDto: GetAllEndorsementsDto,
@Res() res: Response
): Promise<Response> {
const ecosystemList = await this.ecosystemService.getEndorsementTranasactions(ecosystemId, orgId, getAllEndorsementsDto);
const finalResponse: IResponseType = {
statusCode: HttpStatus.OK,
message: `Endorser transactions fetched successfully`,
data: ecosystemList.response
};
return res.status(HttpStatus.OK).json(finalResponse);
}


@Get('/:ecosystemId/:orgId/invitations')
@ApiOperation({ summary: 'Get all sent invitations', description: 'Get all sent invitations' })
@ApiResponse({ status: 200, description: 'Success', type: ApiResponseDto })
Expand Down
9 changes: 9 additions & 0 deletions apps/ecosystem/interfaces/endorsements.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface GetEndorsementsPayload {
ecosystemId: string;
orgId: string;
status: string;
pageNumber: number;
pageSize: number;
search: string;
type: string;
}
5 changes: 5 additions & 0 deletions libs/enum/src/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export enum EcosystemRoles {
ECOSYSTEM_OWNER = 'Ecosystem Owner'
}

export enum EndorserTransactionType{
SCHEMA = 'schema',
CREDENTIAL_DEFINITION = 'credential-definition',
}

export enum OrgAgentType {
DEDICATED = 1,
SHARED = 2
Expand Down
38 changes: 38 additions & 0 deletions libs/prisma-service/prisma/data/credebl-master-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,43 @@
"registerDIDPayload": "",
"indyNamespace": "indicio:testnet"
}
],
"endorseData": [
{
"id": "0f8fad5b-d9cb-469f-a165-70867728950f",
"endorserDid": "endorser123",
"authorDid": "author456",
"requestPayload": "{\"type\": \"dummy_request_1\"}",
"responsePayload": "{\"type\": \"dummy_response_1\"}",
"status": "Requested",
"ecosystemOrgId": "1c247b4a-e2f6-48c0-8aa2-65ea47474294"
},
{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"endorserDid": "endorser789",
"authorDid": "author101",
"requestPayload": "{\"type\": \"dummy_request_2\"}",
"responsePayload": "{\"type\": \"dummy_response_2\"}",
"status": "Signed",
"ecosystemOrgId": "1c247b4a-e2f6-48c0-8aa2-65ea47474294"
},
{
"id": "a89b6e81-a1ff-4d13-a9e2-17176e707aac",
"endorserDid": "endorser321",
"authorDid": "author654",
"requestPayload": "{\"type\": \"dummy_request_3\"}",
"responsePayload": "{\"type\": \"dummy_response_3\"}",
"status": "Declined",
"ecosystemOrgId": "a2443e09-45be-4739-b8b3-0d4ffaecea94"
},
{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d47c",
"endorserDid": "endorser999",
"authorDid": "author777",
"requestPayload": "{\"type\": \"dummy_request_4\"}",
"responsePayload": "{\"type\": \"dummy_response_4\"}",
"status": "Submitted",
"ecosystemOrgId": "ca6ee687-a3a9-42ce-9e49-02bf62f5c93a"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- AlterTable
ALTER TABLE "endorsement_transaction" ADD COLUMN "createDateTime" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "createdBy" INTEGER NOT NULL DEFAULT 1,
ADD COLUMN "deletedAt" TIMESTAMP(6),
ADD COLUMN "lastChangedBy" INTEGER NOT NULL DEFAULT 1,
ADD COLUMN "lastChangedDateTime" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "type" TEXT;
22 changes: 14 additions & 8 deletions libs/prisma-service/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,18 @@ model ecosystem_orgs {
}

model endorsement_transaction {
id String @id @default(uuid())
endorserDid String
authorDid String
requestPayload String
responsePayload String
status String
ecosystemOrgId String
ecosystemOrgs ecosystem_orgs @relation(fields: [ecosystemOrgId], references: [id])
id String @id @default(uuid())
endorserDid String
authorDid String
requestPayload String
responsePayload String
type String?
createDateTime DateTime @default(now()) @db.Timestamptz(6)
createdBy Int @default(1)
lastChangedDateTime DateTime @default(now()) @db.Timestamptz(6)
lastChangedBy Int @default(1)
deletedAt DateTime? @db.Timestamp(6)
status String
ecosystemOrgId String
ecosystemOrgs ecosystem_orgs @relation(fields: [ecosystemOrgId], references: [id])
}

0 comments on commit dc6a951

Please sign in to comment.