Skip to content

Commit

Permalink
Revert "Revert "feat: modify-constitution-response-fields - added new…
Browse files Browse the repository at this point in the history
… fields …" (#257)

This reverts commit 458c02f.
  • Loading branch information
BEdev24 authored Aug 16, 2024
1 parent 7f792c2 commit f1680bf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/src/common/constants/ipfs.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const IPFS_PUBLIC_URL: string = 'https://ipfs.io/ipfs/';
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ export class ConstitutionMetadataResponse {
@Expose({ name: 'cid' })
cid: string;

@ApiProperty({
description: 'Blake2b hash related to a deployed Constitution',
example: 'd9eeada848e4ffcbbb1be73421b47a960885954548aa44b2d46b2d84fb99141c',
})
@Expose({ name: 'blake2b' })
blake2b: string;

@ApiProperty({
description: 'Ipfs URL of the document',
example:
'https://ipfs.io/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n',
})
@Expose({ name: 'url' })
url: string;

@ApiProperty({
description: 'Title of the document',
example: 'Revision 1',
Expand Down
15 changes: 15 additions & 0 deletions backend/src/constitution/api/response/constitution.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ export class ConstitutionResponse {
@Expose({ name: 'cid' })
cid: string;

@ApiProperty({
description: 'Blake2b hash related to a deployed Constitution',
example: 'd9eeada848e4ffcbbb1be73421b47a960885954548aa44b2d46b2d84fb99141c',
})
@Expose({ name: 'blake2b' })
blake2b: string;

@ApiProperty({
description: 'Ipfs URL of the document',
example:
'https://ipfs.io/ipfs/QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n',
})
@Expose({ name: 'url' })
url: string;

@ApiProperty({
description: 'Version of the document',
example: '1713153716',
Expand Down
5 changes: 5 additions & 0 deletions backend/src/constitution/mapper/constitution.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import { CreateConstitutionDto } from '../dto/create-constitution.dto';
import { IpfsContentDto } from 'src/ipfs/dto/ipfs-content.dto';
import { IpfsMetadataDto } from 'src/ipfs/dto/ipfs-metadata.dto';
import { ConstitutionMetadataResponse } from '../api/response/constitution-metadata.response';
import { IPFS_PUBLIC_URL } from 'src/common/constants/ipfs.constants';

export class ConstitutionMapper {
static dtoToResponse(dto: ConstitutionDto): ConstitutionResponse {
const response = new ConstitutionResponse();
response.cid = dto.cid;
response.blake2b = dto.blake2b;
response.url = IPFS_PUBLIC_URL + dto.cid;
response.version = dto.version;
response.contents = dto.contents;
return response;
Expand Down Expand Up @@ -37,6 +40,8 @@ export class ConstitutionMapper {
): ConstitutionMetadataResponse {
const constitutionResponse = new ConstitutionMetadataResponse();
constitutionResponse.cid = ipfsMetadataDto.cid;
constitutionResponse.blake2b = ipfsMetadataDto.blake2b;
constitutionResponse.url = IPFS_PUBLIC_URL + ipfsMetadataDto.cid;
constitutionResponse.title = ipfsMetadataDto.title;
constitutionResponse.version = ipfsMetadataDto.version;
constitutionResponse.createdDate = ipfsMetadataDto.createdDate;
Expand Down

0 comments on commit f1680bf

Please sign in to comment.