Get merkle proof when generating certificate

This commit is contained in:
Sosthene 2025-06-30 22:39:44 +02:00
parent deca1c8eaf
commit 31ca61963a

View File

@ -26,6 +26,7 @@ import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService"; import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService"; import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
import PdfService, { CertificateData, Metadata } from "@Front/Services/PdfService"; import PdfService, { CertificateData, Metadata } from "@Front/Services/PdfService";
import MessageBus from "src/sdk/MessageBus";
type IProps = { type IProps = {
customerUid: string; customerUid: string;
@ -204,7 +205,8 @@ export default function DocumentTables(props: IProps) {
commitmentId: "N/A", commitmentId: "N/A",
createdAt: new Date(), createdAt: new Date(),
documentUid: "N/A", documentUid: "N/A",
documentType: "N/A" documentType: "N/A",
merkleProof: "N/A"
} }
}; };
@ -217,7 +219,7 @@ export default function DocumentTables(props: IProps) {
const documentProcesses = await DocumentService.getDocuments(); const documentProcesses = await DocumentService.getDocuments();
documentProcesses.filter((process: any) => process.processData.folder.uid === folderUid); documentProcesses.filter((process: any) => process.processData.folder.uid === folderUid);
console.log('[DocumentTables] onDownloadCertificate: documentProcesses', documentProcesses); // console.log('[DocumentTables] onDownloadCertificate: documentProcesses', documentProcesses);
for (const document of documentProcesses) { for (const document of documentProcesses) {
for (const file of document.processData.files) { for (const file of document.processData.files) {
@ -225,6 +227,9 @@ export default function DocumentTables(props: IProps) {
console.log('[DocumentTables] onDownloadCertificate: fileProcess', res); console.log('[DocumentTables] onDownloadCertificate: fileProcess', res);
const hash = res.lastUpdatedFileState.pcd_commitment.file_blob; const hash = res.lastUpdatedFileState.pcd_commitment.file_blob;
certificateData.documentHash = hash; certificateData.documentHash = hash;
MessageBus.getInstance().generateMerkleProof(res.lastUpdatedFileState, 'file_blob').then((proof) => {
console.log('[DocumentTables] onDownloadCertificate: proof', proof);
const metadata: Metadata = { const metadata: Metadata = {
fileName: res.processData.file_name, fileName: res.processData.file_name,
isDeleted: false, isDeleted: false,
@ -232,9 +237,11 @@ export default function DocumentTables(props: IProps) {
commitmentId: res.lastUpdatedFileState.commited_in, commitmentId: res.lastUpdatedFileState.commited_in,
createdAt: new Date(res.processData.created_at), createdAt: new Date(res.processData.created_at),
documentUid: doc.document_type.uid, documentUid: doc.document_type.uid,
documentType: doc.document_type.name documentType: doc.document_type.name,
merkleProof: proof
}; };
certificateData.metadata = metadata; certificateData.metadata = metadata;
});
} }
)} )}
} }