-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
549 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/contract-helpers/src/governance-v3/payloads-data-helper/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
247 changes: 247 additions & 0 deletions
247
packages/contract-helpers/src/governance-v3/typechain/PayloadsControllerDataHelper.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; | ||
} |
Oops, something went wrong.