From 7bfe3bcad26445852dbf197bd8328555adef14d0 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Mon, 30 Jun 2025 22:39:44 +0200 Subject: [PATCH] Get merkle proof when generating certificate --- .../ClientView/DocumentTables/index.tsx | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx index acafddac..7ac93374 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/DocumentTables/index.tsx @@ -24,6 +24,7 @@ import FileService from "src/common/Api/LeCoffreApi/sdk/FileService"; import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService"; import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService"; import PdfService, { CertificateData, Metadata } from "@Front/Services/PdfService"; +import MessageBus from "src/sdk/MessageBus"; type IProps = { customerUid: string; @@ -206,7 +207,8 @@ export default function DocumentTables(props: IProps) { commitmentId: "N/A", createdAt: new Date(), documentUid: "N/A", - documentType: "N/A" + documentType: "N/A", + merkleProof: "N/A" } }; @@ -219,7 +221,7 @@ export default function DocumentTables(props: IProps) { const documentProcesses = await DocumentService.getDocuments(); 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 file of document.processData.files) { @@ -227,16 +229,21 @@ export default function DocumentTables(props: IProps) { console.log('[DocumentTables] onDownloadCertificate: fileProcess', res); const hash = res.lastUpdatedFileState.pcd_commitment.file_blob; certificateData.documentHash = hash; - const metadata: Metadata = { - fileName: res.processData.file_name, - isDeleted: false, - updatedAt: new Date(res.processData.updated_at), - commitmentId: res.lastUpdatedFileState.commited_in, - createdAt: new Date(res.processData.created_at), - documentUid: doc.document_type.uid, - documentType: doc.document_type.name - }; - certificateData.metadata = metadata; + + MessageBus.getInstance().generateMerkleProof(res.lastUpdatedFileState, 'file_blob').then((proof) => { + console.log('[DocumentTables] onDownloadCertificate: proof', proof); + const metadata: Metadata = { + fileName: res.processData.file_name, + isDeleted: false, + updatedAt: new Date(res.processData.updated_at), + commitmentId: res.lastUpdatedFileState.commited_in, + createdAt: new Date(res.processData.created_at), + documentUid: doc.document_type.uid, + documentType: doc.document_type.name, + merkleProof: proof + }; + certificateData.metadata = metadata; + }); } )} }