From 208da9b819f880fc11d35a0d3c5fd1bd02deb553 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Thu, 13 Feb 2025 10:20:52 +0100 Subject: [PATCH] Add saveProcessDataToDb --- src/services/service.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/services/service.ts b/src/services/service.ts index 60a338e..78c5894 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -655,6 +655,7 @@ export default class Services { // Save process to db try { await this.saveProcessToDb(processId, updatedProcess.current_process); + await this.saveProcessDataToDb(updatedProcess.current_process); } catch (e) { throw e; } @@ -863,6 +864,25 @@ export default class Services { } } + public async saveProcessDataToDb(process: Process) { + for (const state of process.states) { + if (state.state_id === "") continue + for (const field of Object.keys(state.pcd_commitment)) { + try { + const hash = state.pcd_commitment[field]; + const encrypted = state.encrypted_pcd[field]; + console.log(hash); + console.log(encrypted); + const blob = new Blob([encrypted], { type: 'text/plain' }); + console.log(blob); + await this.saveBlobToDb(hash, blob); + } catch (e) { + console.error(e); + } + } + } + } + public async saveProcessToDb(processId: string, process: Process) { const db = await Database.getInstance(); try {