forked from Uniswap/governance-seatbelt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
670 lines (611 loc) · 13.8 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
import { BigNumber, BigNumberish, Block, Contract } from 'ethers'
import { ContractTransaction } from '@ethersproject/contracts'
import { JsonRpcProvider } from '@ethersproject/providers'
// --- Simulation configurations ---
// TODO Consider refactoring to an enum instead of string.
export type GovernorType = 'oz' | 'bravo'
interface SimulationConfigBase {
type: 'executed' | 'proposed' | 'new'
daoName: string // e.g. 'Compound' or 'Uniswap'
governorAddress: string // address of the governor
governorType: GovernorType
}
export interface SimulationConfigExecuted extends SimulationConfigBase {
type: 'executed'
proposalId: BigNumberish // ID of the executed proposal
}
export interface SimulationConfigProposed extends SimulationConfigBase {
type: 'proposed'
proposalId: BigNumberish // ID of the executed proposal
}
export interface SimulationConfigNew extends SimulationConfigBase {
type: 'new'
targets: string[]
values: BigNumberish[]
signatures: string[]
calldatas: string[]
description: string
}
export type SimulationConfig = SimulationConfigExecuted | SimulationConfigProposed | SimulationConfigNew
export interface SimulationResult {
sim: TenderlySimulation
proposal: ProposalEvent
latestBlock: Block
}
export interface SimulationData extends SimulationResult {
config: SimulationConfig
}
// --- Proposal checks ---
export type ProposalActions = [
// defined as an array instead of an object because the return data from governor.getActions()
// has no `values` key if all values are zero
string[],
BigNumber[],
string[],
string[]
]
// TODO If adding support for a third governor, instead of hardcoding optional governor-specific
// fields, make this a union type of each governor's individual proposal type.
export interface ProposalStruct {
id: BigNumber
proposer?: string
eta: BigNumber
startBlock?: BigNumber // Compound governor
startTime?: BigNumber // OZ governor
endBlock?: BigNumber // Compound governor
endTime?: BigNumber // OZ governor
forVotes: BigNumber
againstVotes: BigNumber
abstainVotes: BigNumber
canceled: boolean
executed: boolean
}
export interface ProposalEvent {
id?: BigNumber // Bravo governor
proposalId?: BigNumber // OZ governor
proposer: string
startBlock: BigNumber
endBlock: BigNumber
description: string
targets: string[]
values: BigNumber[]
signatures: string[]
calldatas: string[]
}
export type Message = string
export type CheckResult = {
info: Message[]
warnings: Message[]
errors: Message[]
}
export type ProposalData = {
governor: Contract
timelock: Contract
provider: JsonRpcProvider
}
export interface ProposalCheck {
name: string
checkProposal(proposal: ProposalEvent, tx: TenderlySimulation, deps: ProposalData): Promise<CheckResult>
}
export interface AllCheckResults {
[checkId: string]: { name: string; result: CheckResult }
}
// --- Tenderly types, Request ---
// Response from tenderly endpoint that encodes state data
type StorageEncodingResponse = {
stateOverrides: {
// these keys are the contract addresses, all lower case
[key: string]: {
value: {
// these are the slot numbers, as 32 byte hex strings
[key: string]: string
}
}
}
}
type StateObject = {
balance?: string
code?: string
storage?: Record<string, string>
}
type ContractObject = {
contractName: string
source: string
sourcePath: string
compiler: {
name: 'solc'
version: string
}
networks: Record<
string,
{
events?: Record<string, string>
links?: Record<string, string>
address: string
transactionHash?: string
}
>
}
export type TenderlyPayload = {
network_id: '1' | '3' | '4' | '5' | '42'
block_number?: number
transaction_index?: number
from: string
to: string
input: string
gas: number
gas_price?: string
value?: string
simulation_type?: 'full' | 'quick'
save?: boolean
save_if_fails?: boolean
state_objects?: Record<string, StateObject>
contracts?: ContractObject[]
block_header?: {
number?: string
timestamp?: string
}
generate_access_list?: boolean
}
// --- Tenderly types, Response ---
// NOTE: These type definitions were autogenerated using https://app.quicktype.io/, so are almost
// certainly not entirely accurate (and they have some interesting type names)
export interface TenderlySimulation {
transaction: Transaction
simulation: Simulation
contracts: TenderlyContract[]
generated_access_list: GeneratedAccessList[]
}
interface TenderlyContract {
id: string
contract_id: string
balance: string
network_id: string
public: boolean
boolean
verified_by: string
verification_date: null
address: string
contract_name: string
ens_domain: null
type: string
evm_version: string
compiler_version: string
optimizations_used: boolean
optimization_runs: number
libraries: null
data: Data
creation_block: number
creation_tx: string
creator_address: string
created_at: Date
number_of_watches: null
language: string
in_project: boolean
number_of_files: number
standard?: string
standards?: string[]
token_data?: TokenData
}
interface Data {
main_contract: number
contract_info: ContractInfo[]
abi: ABI[]
raw_abi: null
}
interface ABI {
type: ABIType
name: string
constant: boolean
anonymous: boolean
inputs: SoltypeElement[]
outputs: Output[] | null
}
interface SoltypeElement {
name: string
type: SoltypeType
storage_location: StorageLocation
components: SoltypeElement[] | null
offset: number
index: string
indexed: boolean
simple_type?: Type
}
interface Type {
type: SimpleTypeType
}
enum SimpleTypeType {
Address = 'address',
Bool = 'bool',
Bytes = 'bytes',
Slice = 'slice',
String = 'string',
Uint = 'uint',
}
enum StorageLocation {
Calldata = 'calldata',
Default = 'default',
Memory = 'memory',
Storage = 'storage',
}
enum SoltypeType {
Address = 'address',
Bool = 'bool',
Bytes32 = 'bytes32',
MappingAddressUint256 = 'mapping (address => uint256)',
MappingUint256Uint256 = 'mapping (uint256 => uint256)',
String = 'string',
Tuple = 'tuple',
TypeAddress = 'address[]',
TypeTuple = 'tuple[]',
Uint16 = 'uint16',
Uint256 = 'uint256',
Uint48 = 'uint48',
Uint56 = 'uint56',
Uint8 = 'uint8',
}
interface Output {
name: string
type: SoltypeType
storage_location: StorageLocation
components: SoltypeElement[] | null
offset: number
index: string
indexed: boolean
simple_type?: SimpleType
}
interface SimpleType {
type: SimpleTypeType
nested_type?: Type
}
enum ABIType {
Constructor = 'constructor',
Event = 'event',
Function = 'function',
}
interface ContractInfo {
id: number
path: string
name: string
source: string
}
interface TokenData {
symbol: string
name: string
decimals: number
}
interface GeneratedAccessList {
address: string
storage_keys: string[]
}
interface Simulation {
id: string
project_id: string
owner_id: string
network_id: string
block_number: number
transaction_index: number
from: string
to: string
input: string
gas: number
gas_price: string
value: string
method: string
status: boolean
access_list: null
queue_origin: string
created_at: Date
}
interface Transaction {
hash: From
block_hash: string
block_number: number
from: From
gas: number
gas_price: number
gas_fee_cap: number
gas_tip_cap: number
cumulative_gas_used: number
gas_used: number
effective_gas_price: number
input: string
nonce: number
to: From
index: number
value: string
access_list: null
status: boolean
addresses: string[]
contract_ids: string[]
network_id: string
function_selector: string
transaction_info: TransactionInfo
timestamp: Date
method: string
decoded_input: null
}
interface TransactionInfo {
contract_id: string
block_number: number
transaction_id: From
contract_address: From
method: string
parameters: null
intrinsic_gas: number
refund_gas: number
call_trace: CallTrace
stack_trace: null | StackTrace[]
logs: Log[] | null
state_diff: StateDiff[]
raw_state_diff: null
console_logs: null
created_at: Date
}
interface StackTrace {
file_index: number
contract: string
name: string
line: number
error: string
error_reason: string
code: string
op: string
length: number
}
interface CallTrace {
hash: From
contract_name: string
function_name: string
function_pc: number
function_op: string
function_file_index: number
function_code_start: number
function_line_number: number
function_code_length: number
function_states: CallTraceFunctionState[]
caller_pc: number
caller_op: string
call_type: string
from: From
from_balance: string
to: From
to_balance: string
value: string
caller: Caller
block_timestamp: Date
gas: number
gas_used: number
intrinsic_gas: number
input: string
decoded_input: Input[]
state_diff: StateDiff[]
logs: Log[]
output: string
decoded_output: FunctionVariableElement[]
network_id: string
calls: CallTraceCall[]
}
interface Caller {
address: From
balance: string
}
interface CallTraceCall {
hash: string
contract_name: string
function_name: string
function_pc: number
function_op: string
function_file_index: number
function_code_start: number
function_line_number: number
function_code_length: number
function_states: CallTraceFunctionState[]
function_variables: FunctionVariableElement[]
caller_pc: number
caller_op: string
caller_file_index: number
caller_line_number: number
caller_code_start: number
caller_code_length: number
call_type: string
from: From
from_balance: null
to: From
to_balance: null
value: null
caller: Caller
block_timestamp: Date
gas: number
gas_used: number
input: string
decoded_input: Input[]
output: string
decoded_output: FunctionVariableElement[]
network_id: string
calls: PurpleCall[]
}
interface PurpleCall {
hash: string
contract_name: string
function_name: string
function_pc: number
function_op: string
function_file_index: number
function_code_start: number
function_line_number: number
function_code_length: number
function_states?: FluffyFunctionState[]
function_variables?: FunctionVariable[]
caller_pc: number
caller_op: string
caller_file_index: number
caller_line_number: number
caller_code_start: number
caller_code_length: number
call_type: string
from: From
from_balance: null | string
to: string
to_balance: null | string
value: null | string
caller: Caller
block_timestamp: Date
gas: number
gas_used: number
refund_gas?: number
input: string
decoded_input: Input[]
output: string
decoded_output: FunctionVariable[] | null
network_id: string
calls: FluffyCall[] | null
}
interface FluffyCall {
hash: string
contract_name: string
function_name?: string
function_pc: number
function_op: string
function_file_index?: number
function_code_start?: number
function_line_number?: number
function_code_length?: number
function_states?: FluffyFunctionState[]
function_variables?: FunctionVariable[]
caller_pc: number
caller_op: string
caller_file_index: number
caller_line_number: number
caller_code_start: number
caller_code_length: number
call_type: string
from: string
from_balance: null | string
to: string
to_balance: null | string
value: null | string
caller?: Caller
block_timestamp: Date
gas: number
gas_used: number
input: string
decoded_input?: FunctionVariable[]
output: string
decoded_output: PurpleDecodedOutput[] | null
network_id: string
calls: TentacledCall[] | null
refund_gas?: number
}
interface TentacledCall {
hash: string
contract_name: string
function_name: string
function_pc: number
function_op: string
function_file_index: number
function_code_start: number
function_line_number: number
function_code_length: number
function_states: PurpleFunctionState[]
caller_pc: number
caller_op: string
caller_file_index: number
caller_line_number: number
caller_code_start: number
caller_code_length: number
call_type: string
from: string
from_balance: null
to: string
to_balance: null
value: null
caller: Caller
block_timestamp: Date
gas: number
gas_used: number
input: string
decoded_input: FunctionVariableElement[]
output: string
decoded_output: FunctionVariable[]
network_id: string
calls: null
}
interface FunctionVariableElement {
soltype: SoltypeElement
value: string
}
interface FunctionVariable {
soltype: SoltypeElement
value: PurpleValue | string
}
interface PurpleValue {
ballot: string
basedOn: string
configured: string
currency: string
cycleLimit: string
discountRate: string
duration: string
fee: string
id: string
metadata: string
number: string
projectId: string
start: string
tapped: string
target: string
weight: string
}
interface PurpleFunctionState {
soltype: SoltypeElement
value: Record<string, string>
}
interface PurpleDecodedOutput {
soltype: SoltypeElement
value: boolean | PurpleValue | string
}
interface FluffyFunctionState {
soltype: PurpleSoltype
value: Record<string, string>
}
interface PurpleSoltype {
name: string
type: SoltypeType
storage_location: StorageLocation
components: null
offset: number
index: string
indexed: boolean
}
interface Input {
soltype: SoltypeElement | null
value: boolean | string
}
interface CallTraceFunctionState {
soltype: PurpleSoltype
value: Record<string, string>
}
interface Log {
name: string | null
anonymous: boolean
inputs: Input[]
raw: LogRaw
}
interface LogRaw {
address: string
topics: string[]
data: string
}
interface StateDiff {
soltype: SoltypeElement | null
original: string | Record<string, any>
dirty: string | Record<string, any>
raw: RawElement[]
}
interface RawElement {
address: string
key: string
original: string
dirty: string
}