Skip to content

Commit c899a4f

Browse files
committed
fix: store commitment in promise
1 parent 5e00333 commit c899a4f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎nightfall-client/src/services/commitment-sync.mjs

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ decrypt commitments for a transaction given ivks and nsks.
1616
*/
1717
export async function decryptCommitment(transaction, ivk, nsk) {
1818
const nonZeroCommitments = transaction.commitments.flat().filter(n => n !== ZERO);
19+
const storeCommitments = [];
1920
ivk.forEach((key, j) => {
2021
// decompress the secrets first and then we will decryp t the secrets from this
2122
const decompressedSecrets = Secrets.decompressSecrets(transaction.compressedSecrets);
@@ -26,14 +27,16 @@ export async function decryptCommitment(transaction, ivk, nsk) {
2627
logger.info("This encrypted message isn't for this recipient");
2728
else {
2829
// console.log('PUSHED', commitment, 'nsks', nsks[i]);
29-
logger.info('This is encrpted and stored');
30-
storeCommitment(commitment, nsk[j]);
30+
storeCommitments.push(storeCommitment(commitment, nsk[j]));
3131
}
3232
} catch (err) {
3333
logger.info(err);
34-
logger.info('catch error');
34+
logger.info("This encrypted message isn't for this recipient");
3535
}
3636
});
37+
await Promise.all(storeCommitments).catch(function (err) {
38+
logger.info(err);
39+
});
3740
}
3841

3942
/**

0 commit comments

Comments
 (0)