Skip to content

Commit

Permalink
fix undefined spent error
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Sep 25, 2023
1 parent 606adcc commit c80b389
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions contracts/utils/maci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,27 +227,27 @@ 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(
newResultCommitment,
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.')
Expand Down

0 comments on commit c80b389

Please sign in to comment.