Skip to content

Commit

Permalink
feat: add initial vote impelmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Sep 7, 2023
1 parent 42526f7 commit 99666f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
28 changes: 25 additions & 3 deletions src/commands/governance-v3.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command } from '@commander-js/extra-typings';
import { Command, Option } from '@commander-js/extra-typings';
import { simulateProposal } from '../simulate/govv3/simulate';
import { GovernanceV3Sepolia } from '@bgd-labs/aave-address-book';
import { getGovernance } from '../simulate/govv3/governance';
import { State, getGovernance } from '../simulate/govv3/governance';
import { createPublicClient } from 'viem';
import { sepoliaClient } from '../utils/rpcClients';
import { logInfo } from '../utils/logger';
Expand Down Expand Up @@ -95,6 +95,28 @@ export function addCommand(program: Command) {
.description('generates the proof etc')
.requiredOption('--proposalId <number>', 'proposalId to generate the proof for')
.action((name, options) => {
console.log('simulate', options);
console.log('proof', options);
});

govV3
.command('vote')
.description('vote for or against any given proposal')
.requiredOption('--proposalId <number>', 'proposalId to vote for')
.option('--for', 'Vote in favour of the proposal')
.option('--against', 'vote against the proposal')
.action(async (name, options) => {
const governance = getGovernance(GovernanceV3Sepolia.GOVERNANCE, sepoliaClient);
const proposalId = BigInt(options.getOptionValue('proposalId'));
const proposal = await governance.governanceContract.read.getProposal([proposalId]);
if (proposal.state !== State.Active) {
throw new Error('can only vote on active proposals');
}
const voteFor = options.getOptionValue('for');
const voteAgainst = options.getOptionValue('against');
if (voteFor && voteAgainst) {
throw new Error('you must either vote --for, or --against');
}

logInfo('Vote', 'not yet implemented');
});
}
2 changes: 1 addition & 1 deletion src/simulate/govv3/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const SLOTS = {
PROPOSALS_MAPPING: 7n,
};

enum State {
export enum State {
Null, // proposal does not exists
Created, // created, waiting for a cooldown to initiate the balances snapshot
Active, // balances snapshot set, voting in progress
Expand Down

0 comments on commit 99666f8

Please sign in to comment.