Skip to content

Commit

Permalink
feat: voting machine data helper
Browse files Browse the repository at this point in the history
  • Loading branch information
grothem committed Dec 11, 2023
1 parent 91bcd5a commit fda96ff
Show file tree
Hide file tree
Showing 10 changed files with 542 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
import { providers } from 'ethers';
import { GovernanceDataHelper as GovernanceDataHelperContract } from '../typechain/GovernanceDataHelper';
import { GovernanceDataHelper__factory } from '../typechain/factories/GovernanceDataHelper__factory';

export enum AccessLevel {
/** Do not use */
None,
/** listing assets, changes of assets params, updates of the protocol etc */
Short_Executor,
/** payloads controller updates */
Long_Executor,
}

export enum ProposalV3State {
/** proposal does not exist */
Null,
/** created, waiting for a cooldown to initiate the balances snapshot */
Created,
/** balances snapshot set, voting in progress */
Active,
/** voting results submitted, but proposal is under grace period when guardian can cancel it */
Queued,
/** results sent to the execution chain(s) */
Executed,
/** voting was not successful */
Failed,
/** got cancelled by guardian, or because proposition power of creator dropped below allowed minimum */
Cancelled,
Expired,
}
import { AccessLevel, ProposalV3State } from '../types';

export type ProposalPayload = {
chain: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
/* Autogenerated file. Do not edit manually. */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers';
import type { FunctionFragment, Result } from '@ethersproject/abi';
import type { Listener, Provider } from '@ethersproject/providers';
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
} from './common';

export declare namespace IVotingMachineDataHelper {
export type InitialProposalStruct = {
id: BigNumberish;
snapshotBlockHash: BytesLike;
};

export type InitialProposalStructOutput = [BigNumber, string] & {
id: BigNumber;
snapshotBlockHash: string;
};

export type VotedInfoStruct = { support: boolean; votingPower: BigNumberish };

export type VotedInfoStructOutput = [boolean, BigNumber] & {
support: boolean;
votingPower: BigNumber;
};

export type ProposalStruct = {
proposalData: IVotingMachineWithProofs.ProposalWithoutVotesStruct;
votedInfo: IVotingMachineDataHelper.VotedInfoStruct;
strategy: string;
dataWarehouse: string;
votingAssets: string[];
hasRequiredRoots: boolean;
voteConfig: IVotingMachineWithProofs.ProposalVoteConfigurationStruct;
state: BigNumberish;
};

export type ProposalStructOutput = [
IVotingMachineWithProofs.ProposalWithoutVotesStructOutput,
IVotingMachineDataHelper.VotedInfoStructOutput,
string,
string,
string[],
boolean,
IVotingMachineWithProofs.ProposalVoteConfigurationStructOutput,
number,
] & {
proposalData: IVotingMachineWithProofs.ProposalWithoutVotesStructOutput;
votedInfo: IVotingMachineDataHelper.VotedInfoStructOutput;
strategy: string;
dataWarehouse: string;
votingAssets: string[];
hasRequiredRoots: boolean;
voteConfig: IVotingMachineWithProofs.ProposalVoteConfigurationStructOutput;
state: number;
};
}

export declare namespace IVotingMachineWithProofs {
export type ProposalWithoutVotesStruct = {
id: BigNumberish;
sentToGovernance: boolean;
startTime: BigNumberish;
endTime: BigNumberish;
votingClosedAndSentTimestamp: BigNumberish;
forVotes: BigNumberish;
againstVotes: BigNumberish;
creationBlockNumber: BigNumberish;
votingClosedAndSentBlockNumber: BigNumberish;
};

export type ProposalWithoutVotesStructOutput = [
BigNumber,
boolean,
number,
number,
number,
BigNumber,
BigNumber,
BigNumber,
BigNumber,
] & {
id: BigNumber;
sentToGovernance: boolean;
startTime: number;
endTime: number;
votingClosedAndSentTimestamp: number;
forVotes: BigNumber;
againstVotes: BigNumber;
creationBlockNumber: BigNumber;
votingClosedAndSentBlockNumber: BigNumber;
};

export type ProposalVoteConfigurationStruct = {
votingDuration: BigNumberish;
l1ProposalBlockHash: BytesLike;
};

export type ProposalVoteConfigurationStructOutput = [number, string] & {
votingDuration: number;
l1ProposalBlockHash: string;
};
}

export interface VotingMachineDataHelperInterface extends utils.Interface {
functions: {
'getProposalsData(address,(uint256,bytes32)[],address)': FunctionFragment;
};

getFunction(nameOrSignatureOrTopic: 'getProposalsData'): FunctionFragment;

encodeFunctionData(
functionFragment: 'getProposalsData',
values: [string, IVotingMachineDataHelper.InitialProposalStruct[], string],
): string;

decodeFunctionResult(
functionFragment: 'getProposalsData',
data: BytesLike,
): Result;

events: {};
}

export interface VotingMachineDataHelper extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;

interface: VotingMachineDataHelperInterface;

queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>;

listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>;
listeners(eventName?: string): Array<Listener>;
removeAllListeners<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>,
): this;
removeAllListeners(eventName?: string): this;
off: OnEvent<this>;
on: OnEvent<this>;
once: OnEvent<this>;
removeListener: OnEvent<this>;

functions: {
getProposalsData(
votingMachine: string,
initialProposals: IVotingMachineDataHelper.InitialProposalStruct[],
user: string,
overrides?: CallOverrides,
): Promise<[IVotingMachineDataHelper.ProposalStructOutput[]]>;
};

getProposalsData(
votingMachine: string,
initialProposals: IVotingMachineDataHelper.InitialProposalStruct[],
user: string,
overrides?: CallOverrides,
): Promise<IVotingMachineDataHelper.ProposalStructOutput[]>;

callStatic: {
getProposalsData(
votingMachine: string,
initialProposals: IVotingMachineDataHelper.InitialProposalStruct[],
user: string,
overrides?: CallOverrides,
): Promise<IVotingMachineDataHelper.ProposalStructOutput[]>;
};

filters: {};

estimateGas: {
getProposalsData(
votingMachine: string,
initialProposals: IVotingMachineDataHelper.InitialProposalStruct[],
user: string,
overrides?: CallOverrides,
): Promise<BigNumber>;
};

populateTransaction: {
getProposalsData(
votingMachine: string,
initialProposals: IVotingMachineDataHelper.InitialProposalStruct[],
user: string,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>;
};
}
Loading

0 comments on commit fda96ff

Please sign in to comment.