From c80b389a4c80a2c2b61cef2c523e34413c70748d Mon Sep 17 00:00:00 2001 From: yuetloo Date: Mon, 25 Sep 2023 12:38:06 -0400 Subject: [PATCH] fix undefined spent error --- contracts/utils/maci.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/utils/maci.ts b/contracts/utils/maci.ts index b37c3a5db..73a147e21 100644 --- a/contracts/utils/maci.ts +++ b/contracts/utils/maci.ts @@ -227,19 +227,19 @@ export async function addTallyResultsBatch( const { tally } = tallyData.results const spentVoiceCreditsHash = hashLeftRight( - BigInt(tally.totalSpentVoiceCredits.spent), - BigInt(tally.totalSpentVoiceCredits.salt) + BigInt(tallyData.totalSpentVoiceCredits.spent), + BigInt(tallyData.totalSpentVoiceCredits.salt) ) const perVOSpentVoiceCreditsHash = genTallyResultCommitment( - tally.perVOSpentVoiceCredits.tally.map((x) => BigInt(x)), - BigInt(tally.perVOSpentVoiceCredits.salt), + tallyData.perVOSpentVoiceCredits.tally.map((x) => BigInt(x)), + BigInt(tallyData.perVOSpentVoiceCredits.salt), recipientTreeDepth ) const newResultCommitment = genTallyResultCommitment( - tally.results.tally.map((x) => BigInt(x)), - BigInt(tally.results.salt), + tally.map((x) => BigInt(x)), + BigInt(tallyData.results.salt), recipientTreeDepth ) const newTallyCommitment = hash3( @@ -247,7 +247,7 @@ export async function addTallyResultsBatch( spentVoiceCreditsHash, perVOSpentVoiceCreditsHash ) - if ('0x' + newTallyCommitment.toString(16) === tally.newTallyCommitment) { + if ('0x' + newTallyCommitment.toString(16) === tallyData.newTallyCommitment) { console.log('OK') } else { console.error('Error: the newTallyCommitment is invalid.')