Skip to content

Commit

Permalink
read tally.json locally
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Aug 2, 2023
1 parent 9f69695 commit f43e4ef
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions contracts/tasks/tally.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs'
import { Contract, Wallet } from 'ethers'
import { genProofs, proveOnChain, fetchLogs } from 'maci-cli'

import { getIpfsHash, Ipfs } from '../utils/ipfs'
import { getIpfsHash } from '../utils/ipfs'
import { addTallyResultsBatch } from '../utils/maci'

type TallyArgs = {
Expand Down Expand Up @@ -70,9 +70,12 @@ async function main(args: TallyArgs) {
await fundingRound.publishTallyHash(tallyHash)
console.log(`Tally hash is ${tallyHash}`)
} else {
// read the tally file from ipfs
// read the tally.json file
console.log(`Tally hash is ${publishedTallyHash}`)
try {
tally = await Ipfs.fetchJson(publishedTallyHash)
console.log(`Reading tally.json file...`)
const tallyStr = fs.readFileSync('tally.json').toString()
tally = JSON.parse(tallyStr)
} catch (err) {
console.log('Failed to get tally file', publishedTallyHash, err)
throw err
Expand Down Expand Up @@ -126,12 +129,6 @@ task('tally', 'Tally votes for the current round')
'maciStateFile',
'The MACI state file, genProof will continue from it last run'
)
.addOptionalParam(
'ipfsGateway',
'The IPFS gateway url',
'https://ipfs.io',
types.string
)
.setAction(
async (
{
Expand Down

0 comments on commit f43e4ef

Please sign in to comment.