Skip to content

Commit

Permalink
Solved the credential-def bug in endorsement (#181)
Browse files Browse the repository at this point in the history
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
  • Loading branch information
KulkarniShashank authored and KulkarniShashank committed Sep 10, 2024
1 parent a661f3f commit ece287f
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions apps/ecosystem/src/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export class EcosystemService {

// eslint-disable-next-line camelcase
async createEcosystem(createEcosystemDto: CreateEcosystem): Promise<object> {
const checkOrganization = await this.ecosystemRepository.checkEcosystemOrgs(createEcosystemDto.orgId);
if (checkOrganization) {
throw new ConflictException(ResponseMessages.ecosystem.error.ecosystemOrgAlready);
};
const checkOrganization = await this.ecosystemRepository.checkEcosystemOrgs(createEcosystemDto.orgId);
if (checkOrganization) {
throw new ConflictException(ResponseMessages.ecosystem.error.ecosystemOrgAlready);
};
const createEcosystem = await this.ecosystemRepository.createNewEcosystem(createEcosystemDto);
if (!createEcosystem) {
throw new NotFoundException(ResponseMessages.ecosystem.error.notCreated);
Expand Down Expand Up @@ -104,11 +104,11 @@ export class EcosystemService {
ecosystem: ecosystemDetails['ecosystem'],
membersCount: endorseMemberCount.membersCount,
endorsementsCount: endorseMemberCount.endorsementsCount,
ecosystemLead:{
role: ecosystemDetails['ecosystemRole']['name'],
orgName: ecosystemDetails['orgName'],
config: endorseMemberCount.ecosystemConfigData
}
ecosystemLead: {
role: ecosystemDetails['ecosystemRole']['name'],
orgName: ecosystemDetails['orgName'],
config: endorseMemberCount.ecosystemConfigData
}
};

return dashboardDetails;
Expand Down Expand Up @@ -186,9 +186,9 @@ export class EcosystemService {
async acceptRejectEcosystemInvitations(acceptRejectInvitation: AcceptRejectEcosystemInvitationDto): Promise<string> {
try {
const checkOrganization = await this.ecosystemRepository.checkEcosystemOrgs(acceptRejectInvitation.orgId);

if (checkOrganization) {
throw new ConflictException(ResponseMessages.ecosystem.error.ecosystemOrgAlready);
throw new ConflictException(ResponseMessages.ecosystem.error.ecosystemOrgAlready);
};
const { orgId, status, invitationId, orgName, orgDid } = acceptRejectInvitation;
const invitation = await this.ecosystemRepository.getEcosystemInvitationById(invitationId);
Expand Down Expand Up @@ -280,12 +280,12 @@ export class EcosystemService {
let isAcceptedInvitation = false;

for (const invitation of invitations) {
if (invitation.status === Invitation.PENDING) {
if (invitation.status === Invitation.PENDING) {
isPendingInvitation = true;
}
if (invitation.status === Invitation.ACCEPTED) {
}
if (invitation.status === Invitation.ACCEPTED) {
isAcceptedInvitation = true;
}
}
}

if (isPendingInvitation || isAcceptedInvitation) {
Expand Down Expand Up @@ -354,7 +354,7 @@ export class EcosystemService {
* @param RequestSchemaEndorsement
* @returns
*/
async requestSchemaEndorsement(requestSchemaPayload:RequestSchemaEndorsement, orgId: number, ecosystemId: string): Promise<object> {
async requestSchemaEndorsement(requestSchemaPayload: RequestSchemaEndorsement, orgId: number, ecosystemId: string): Promise<object> {
try {
const getEcosystemLeadDetails = await this.ecosystemRepository.getEcosystemLeadDetails(ecosystemId);

Expand Down Expand Up @@ -424,7 +424,7 @@ export class EcosystemService {
}
}

async requestCredDeffEndorsement(requestCredDefPayload:RequestCredDeffEndorsement, orgId:number, ecosystemId:string): Promise<object> {
async requestCredDeffEndorsement(requestCredDefPayload: RequestCredDeffEndorsement, orgId: number, ecosystemId: string): Promise<object> {
try {

const getEcosystemLeadDetails = await this.ecosystemRepository.getEcosystemLeadDetails(ecosystemId);
Expand Down Expand Up @@ -477,6 +477,13 @@ export class EcosystemService {
throw new InternalServerErrorException(ResponseMessages.ecosystem.error.requestCredDefTransaction);
}

const requestBody = credDefTransactionRequest.message.credentialDefinitionState.credentialDefinition;

if (!requestBody) {
throw new NotFoundException(ResponseMessages.ecosystem.error.credentialDefinitionNotFound);
}

requestCredDefPayload["credentialDefinition"] = requestBody;
const schemaTransactionResponse = {
endorserDid: ecosystemLeadAgentDetails.orgDid,
authorDid: ecosystemMemberDetails.orgDid,
Expand Down Expand Up @@ -696,9 +703,9 @@ export class EcosystemService {
payload.credentialDefinition = {
tag: parsedRequestPayload.operation.tag,
issuerId: ecosystemMemberDetails.orgDid,
schemaId: endorsementTransactionPayload.requestBody['schemaId'],
type: endorsementTransactionPayload.requestBody['type'],
value: endorsementTransactionPayload.requestBody['value']
schemaId: endorsementTransactionPayload.requestBody.credentialDefinition['schemaId'],
type: endorsementTransactionPayload.requestBody.credentialDefinition['type'],
value: endorsementTransactionPayload.requestBody.credentialDefinition['value']
};
}

Expand Down

0 comments on commit ece287f

Please sign in to comment.