Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Get past logs for polling votes
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbennett committed Aug 11, 2020
1 parent 26b6c16 commit 5731edc
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
10 changes: 10 additions & 0 deletions packages/dai-plugin-governance/src/GovPollingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ export default class GovPollingService extends PrivateService {
return this.get('smartContract').getContractByName(BATCH_POLLING);
}

// For networks without Spock, e.g. the testchain
async getVoteLogs(from = 0, to = 'latest') {
const web3 = this.get('smartContract').get('web3');
return web3.getPastLogs({
address: this._batchPollingContract().address,
from,
to
});
}

//--- cache queries

async getPoll(multiHash) {
Expand Down
17 changes: 17 additions & 0 deletions packages/dai-plugin-governance/test/GovPollingService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,20 @@ test('ranked choice tally with multiple rounds', async () => {
JSON.stringify(dummyBallotMultipleRoundsExpect)
);
});

test('can get vote logs from contract', async () => {
const START_DATE = Math.floor(new Date().getTime() / 1000) + 100;
const END_DATE = START_DATE + 5000;
const MULTI_HASH = 'dummy hash';
const URL = 'dummy url';
const option = [1];
const pollId = await govPollingService.createPoll(
START_DATE,
END_DATE,
MULTI_HASH,
URL
);
await govPollingService.vote([pollId], [option]);
const voteLogs = await govPollingService.getVoteLogs();
expect(voteLogs[0].topics.length).toBe(4);
});
2 changes: 1 addition & 1 deletion packages/dai-plugin-governance/umd/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/dai-plugin-governance/umd/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6229,7 +6229,7 @@ functional-red-black-tree@^1.0.1:
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=

"ganache-cli@github:makerdao/ganache-cli#fix/gas-est-crash":
ganache-cli@makerdao/ganache-cli#fix/gas-est-crash:
version "6.4.3-beta.0"
resolved "https://codeload.github.com/makerdao/ganache-cli/tar.gz/3e512b61da2479042627e6155231dcb038110650"
dependencies:
Expand Down

0 comments on commit 5731edc

Please sign in to comment.