Skip to content

Commit

Permalink
feat: payloads data service
Browse files Browse the repository at this point in the history
  • Loading branch information
grothem committed Dec 20, 2023
1 parent 69530bf commit ddd2484
Show file tree
Hide file tree
Showing 4 changed files with 549 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type ProposalV3 = {
forVotes: string;
againstVotes: string;
cancellationFee: string;
payloads: ProposalPayload[];
};

export type ProposalData = {
Expand Down Expand Up @@ -183,6 +184,16 @@ export class GovernanceDataHelperService
forVotes: proposalData.proposalData.forVotes.toString(),
againstVotes: proposalData.proposalData.againstVotes.toString(),
cancellationFee: proposalData.proposalData.cancellationFee.toString(),
payloads: proposalData.proposalData.payloads.map<ProposalPayload>(
payload => {
return {
chain: payload.chain.toNumber(),
accessLevel: payload.accessLevel,
payloadsController: payload.payloadsController,
payloadId: payload.payloadId,
};
},
),
},
};
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { providers } from 'ethers';
import { AccessLevel } from '../governance-data-helper';
import { PayloadsControllerDataHelper } from '../typechain/PayloadsControllerDataHelper';
import { PayloadsControllerDataHelper__factory } from '../typechain/factories/PayloadsControllerDataHelper__factory';

export enum PayloadState {
None,
Created,
Queued,
Executed,
Cancelled,
Expired,
}

export type ExecutionAction = {
target: string;
withDelegateCall: boolean;
accessLevel: AccessLevel;
value: string;
signature: string;
callData: string;
};

export type Payload = {
id: string;
creator: string;
maximumAccessLevelRequired: AccessLevel;
state: PayloadState;
createdAt: number;
queuedAt: number;
executedAt: number;
cancelledAt: number;
expirationTime: number;
delay: number;
gracePeriod: number;
actions: ExecutionAction[];
};
export class PayloadsDataHelperService {
private readonly _contract: PayloadsControllerDataHelper;

constructor(
payloadsHelperContracAddress: string,
provider: providers.Provider,
) {
this._contract = PayloadsControllerDataHelper__factory.connect(
payloadsHelperContracAddress,
provider,
);
}

public async getPayloadsData(
payloadsControllerAddress: string,
payloadsIds: number[],
): Promise<Payload[]> {
const data = await this._contract.getPayloadsData(
payloadsControllerAddress,
payloadsIds,
);

const payloads = data.map<Payload>(payload => {
return {
id: payload.id.toString(),
creator: payload.data.creator,
maximumAccessLevelRequired: payload.data.maximumAccessLevelRequired,
state: payload.data.state,
createdAt: payload.data.createdAt,
queuedAt: payload.data.queuedAt,
executedAt: payload.data.executedAt,
cancelledAt: payload.data.cancelledAt,
expirationTime: payload.data.expirationTime,
delay: payload.data.delay,
gracePeriod: payload.data.gracePeriod,
actions: payload.data.actions.map<ExecutionAction>(action => {
return {
target: action.target,
withDelegateCall: action.withDelegateCall,
accessLevel: action.accessLevel,
value: action.value.toString(),
signature: action.signature,
callData: action.callData,
};
}),
};
});

return payloads;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
/* 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 IPayloadsControllerCore {
export type ExecutorConfigStruct = { executor: string; delay: BigNumberish };

export type ExecutorConfigStructOutput = [string, number] & {
executor: string;
delay: number;
};

export type ExecutionActionStruct = {
target: string;
withDelegateCall: boolean;
accessLevel: BigNumberish;
value: BigNumberish;
signature: string;
callData: BytesLike;
};

export type ExecutionActionStructOutput = [
string,
boolean,
number,
BigNumber,
string,
string,
] & {
target: string;
withDelegateCall: boolean;
accessLevel: number;
value: BigNumber;
signature: string;
callData: string;
};

export type PayloadStruct = {
creator: string;
maximumAccessLevelRequired: BigNumberish;
state: BigNumberish;
createdAt: BigNumberish;
queuedAt: BigNumberish;
executedAt: BigNumberish;
cancelledAt: BigNumberish;
expirationTime: BigNumberish;
delay: BigNumberish;
gracePeriod: BigNumberish;
actions: IPayloadsControllerCore.ExecutionActionStruct[];
};

export type PayloadStructOutput = [
string,
number,
number,
number,
number,
number,
number,
number,
number,
number,
IPayloadsControllerCore.ExecutionActionStructOutput[],
] & {
creator: string;
maximumAccessLevelRequired: number;
state: number;
createdAt: number;
queuedAt: number;
executedAt: number;
cancelledAt: number;
expirationTime: number;
delay: number;
gracePeriod: number;
actions: IPayloadsControllerCore.ExecutionActionStructOutput[];
};
}

export declare namespace IPayloadsControllerDataHelper {
export type ExecutorConfigStruct = {
accessLevel: BigNumberish;
config: IPayloadsControllerCore.ExecutorConfigStruct;
};

export type ExecutorConfigStructOutput = [
number,
IPayloadsControllerCore.ExecutorConfigStructOutput,
] & {
accessLevel: number;
config: IPayloadsControllerCore.ExecutorConfigStructOutput;
};

export type PayloadStruct = {
id: BigNumberish;
data: IPayloadsControllerCore.PayloadStruct;
};

export type PayloadStructOutput = [
BigNumber,
IPayloadsControllerCore.PayloadStructOutput,
] & { id: BigNumber; data: IPayloadsControllerCore.PayloadStructOutput };
}

export interface PayloadsControllerDataHelperInterface extends utils.Interface {
functions: {
'getExecutorConfigs(address,uint8[])': FunctionFragment;
'getPayloadsData(address,uint40[])': FunctionFragment;
};

getFunction(
nameOrSignatureOrTopic: 'getExecutorConfigs' | 'getPayloadsData',
): FunctionFragment;

encodeFunctionData(
functionFragment: 'getExecutorConfigs',
values: [string, BigNumberish[]],
): string;
encodeFunctionData(
functionFragment: 'getPayloadsData',
values: [string, BigNumberish[]],
): string;

decodeFunctionResult(
functionFragment: 'getExecutorConfigs',
data: BytesLike,
): Result;
decodeFunctionResult(
functionFragment: 'getPayloadsData',
data: BytesLike,
): Result;

events: {};
}

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

interface: PayloadsControllerDataHelperInterface;

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: {
getExecutorConfigs(
payloadsController: string,
accessLevels: BigNumberish[],
overrides?: CallOverrides,
): Promise<[IPayloadsControllerDataHelper.ExecutorConfigStructOutput[]]>;

getPayloadsData(
payloadsController: string,
payloadsIds: BigNumberish[],
overrides?: CallOverrides,
): Promise<[IPayloadsControllerDataHelper.PayloadStructOutput[]]>;
};

getExecutorConfigs(
payloadsController: string,
accessLevels: BigNumberish[],
overrides?: CallOverrides,
): Promise<IPayloadsControllerDataHelper.ExecutorConfigStructOutput[]>;

getPayloadsData(
payloadsController: string,
payloadsIds: BigNumberish[],
overrides?: CallOverrides,
): Promise<IPayloadsControllerDataHelper.PayloadStructOutput[]>;

callStatic: {
getExecutorConfigs(
payloadsController: string,
accessLevels: BigNumberish[],
overrides?: CallOverrides,
): Promise<IPayloadsControllerDataHelper.ExecutorConfigStructOutput[]>;

getPayloadsData(
payloadsController: string,
payloadsIds: BigNumberish[],
overrides?: CallOverrides,
): Promise<IPayloadsControllerDataHelper.PayloadStructOutput[]>;
};

filters: {};

estimateGas: {
getExecutorConfigs(
payloadsController: string,
accessLevels: BigNumberish[],
overrides?: CallOverrides,
): Promise<BigNumber>;

getPayloadsData(
payloadsController: string,
payloadsIds: BigNumberish[],
overrides?: CallOverrides,
): Promise<BigNumber>;
};

populateTransaction: {
getExecutorConfigs(
payloadsController: string,
accessLevels: BigNumberish[],
overrides?: CallOverrides,
): Promise<PopulatedTransaction>;

getPayloadsData(
payloadsController: string,
payloadsIds: BigNumberish[],
overrides?: CallOverrides,
): Promise<PopulatedTransaction>;
};
}
Loading

0 comments on commit ddd2484

Please sign in to comment.