From bd72302c25be4e31f4a9f51554b1c572ad77cdd0 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Sat, 30 Nov 2024 20:08:32 +0100 Subject: [PATCH] Minor fixes --- src/services/service.ts | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/services/service.ts b/src/services/service.ts index 27ef0c1..097d6ad 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -215,17 +215,17 @@ export default class Services { } async sendNewTxMessage(message: string) { - await sendMessage('NewTx', message); + sendMessage('NewTx', message); } async sendCommitMessage(message: string) { - await sendMessage('Commit', message); + sendMessage('Commit', message); } async sendCipherMessages(ciphers: string[]) { for (let i = 0; i < ciphers.length; i++) { const cipher = ciphers[i]; - await sendMessage('Cipher', cipher); + sendMessage('Cipher', cipher); } } @@ -235,8 +235,8 @@ export default class Services { async parseCipher(message: string) { try { - console.log('parsing new cipher'); - const apiReturn = await this.sdkClient.parse_cipher(message); + // console.log('parsing new cipher'); + const apiReturn = this.sdkClient.parse_cipher(message); console.log('🚀 ~ Services ~ parseCipher ~ apiReturn:', apiReturn); await this.handleApiReturn(apiReturn); } catch (e) { @@ -247,12 +247,11 @@ export default class Services { async parseNewTx(tx: string) { try { - const parsedTx = await this.sdkClient.parse_new_tx(tx, 0); + const parsedTx = this.sdkClient.parse_new_tx(tx, 0); if (parsedTx) { - console.log('🚀 ~ Services ~ parseNewTx ~ parsedTx:', parsedTx); try { await this.handleApiReturn(parsedTx); - const newDevice = await this.dumpDevice(); + const newDevice = this.dumpDevice(); await this.saveDevice(newDevice); } catch (e) { console.error('Failed to update device with new tx'); @@ -296,11 +295,18 @@ export default class Services { } const entries = Object.entries(confirmedSecrets).map(([key, value]) => ({ key, value })); for (const entry of entries) { - db.addObject({ - storeName: 'shared_secrets', - object: entry.value, - key: entry.key, - }); + try { + db.addObject({ + storeName: 'shared_secrets', + object: entry.value, + key: entry.key, + }); + } catch (e) { + throw e; + } + + // We don't want to throw an error, it could simply be that we registered directly the shared secret + // this.removeUnconfirmedSecret(entry.value); } }