Skip to content

Commit

Permalink
fix(poll-command): fixed poll command to support merged state root (p…
Browse files Browse the repository at this point in the history
…rivacy-scaling-explorations#1477)

* fix(poll-command): fixed poll command to support merged state root

* fix(poll-command): fixed comments

---------

Co-authored-by: Crisgarner <@crisgarner>
  • Loading branch information
crisgarner authored May 17, 2024
1 parent fe45574 commit ee6a16e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cli/tests/unit/poll.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("poll", () => {

expect(pollData.id).to.eq(finishedPollData.id);
expect(pollData.address).to.eq(finishedPollData.address);
expect(finishedPollData.isStateAqMerged).to.eq(true);
expect(finishedPollData.isMerged).to.eq(true);
});

it("should throw error if there are no signer and provider", async () => {
Expand Down
12 changes: 6 additions & 6 deletions cli/ts/commands/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export const getPoll = async ({

const pollContract = PollFactory.connect(pollAddress, signer ?? provider);

const [[deployTime, duration], isStateAqMerged] = await Promise.all([
const [[deployTime, duration], mergedStateRoot] = await Promise.all([
pollContract.getDeployTimeAndDuration(),
pollContract.stateMerged(),
pollContract.mergedStateRoot(),
]);

const numSignups = await (isStateAqMerged ? pollContract.numSignups() : maciContract.numSignUps());
const isMerged = mergedStateRoot !== BigInt(0);
const numSignups = await (isMerged ? pollContract.numSignups() : maciContract.numSignUps());

logGreen(
quiet,
Expand All @@ -55,7 +55,7 @@ export const getPoll = async ({
`Deploy time: ${new Date(Number(deployTime) * 1000).toString()}`,
`End time: ${new Date(Number(deployTime + duration) * 1000).toString()}`,
`Number of signups ${numSignups}`,
`State Aq merged: ${isStateAqMerged}`,
`State tree merged: ${mergedStateRoot}`,
].join("\n"),
),
);
Expand All @@ -66,6 +66,6 @@ export const getPoll = async ({
deployTime,
duration,
numSignups,
isStateAqMerged,
isMerged,
};
};
4 changes: 2 additions & 2 deletions cli/ts/utils/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,9 @@ export interface IGetPollData {
numSignups: BigNumberish;

/**
* Whether the MACI contract's stateAq has been merged by this contract
* Whether the MACI contract's state root has been merged
*/
isStateAqMerged: boolean;
isMerged: boolean;
}

/**
Expand Down

0 comments on commit ee6a16e

Please sign in to comment.