-
Notifications
You must be signed in to change notification settings - Fork 36
/
types.ts
169 lines (149 loc) · 4.2 KB
/
types.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
import { MinimalInterpreterStep } from "hardhat/internal/hardhat-network/provider/vm/types";
import { BigNumberish, PopulatedTransaction } from "ethers";
import { Artifacts } from "hardhat/types";
import { TracerCache } from "./cache";
import { Decoder } from "./decoder";
import { CALL } from "./opcodes/call";
import { TraceRecorder } from "./trace-recorder";
import { TransactionTrace } from "./transaction-trace";
import { Switch } from "./switch";
type PrintMode = "console" | "json";
export interface NameTags {
[address: string]: string;
}
export interface TracerEnvUser {
enabled?: boolean; // whether to enable tracer always, default: false
defaultVerbosity?: number; // default minimum verbosity level, default: 0
showAddresses?: boolean; // whether to show addresses, default: true
gasCost?: boolean; // print gas cost for calls, default: false
enableAllOpcodes?: boolean; // print all opcodes, default: false
use4bytesDirectory?: boolean; // consult 4byte.directory for ABIs, default: true
opcodes?: string[]; // list of extra opcodes to print, default: [CALLs, SLOAD, SSTORE, LOG*]
nameTags?: NameTags; // map of addresses to name strings, default: {}
stateOverrides?: StateOverrides; // map of addresses to their state overrides, default: {}
tasks?: string[]; // list of extra tasks to enable tracer on, default: []
}
export interface TracerEnv {
enabled: boolean;
ignoreNext: boolean;
printNext: boolean;
verbosity: number;
showAddresses: boolean;
gasCost: boolean;
enableAllOpcodes: boolean;
use4bytesDirectory: boolean;
opcodes: Map<string, boolean>; // string[]; // TODO have a map of opcode to boolean
nameTags: NameTags;
printMode: PrintMode;
_internal: {
cache: TracerCache;
printNameTagTip:
| undefined // meaning "no need to print"
| "print it"
| "already printed";
};
recorder?: TraceRecorder;
switch?: Switch;
lastTrace: () => TransactionTrace | undefined;
decoder?: Decoder;
stateOverrides?: StateOverrides;
}
export interface TracerDependencies {
artifacts: Artifacts;
tracerEnv: TracerEnv;
provider: ProviderLike;
}
export interface TracerDependenciesExtended extends TracerDependencies {
nameTags: NameTags;
}
export interface ProviderLike {
send(method: string, params?: any[] | undefined): Promise<any>;
}
export interface StructLog {
depth: number;
error: string;
gas: number;
gasCost: number;
memory: string[];
op: string;
pc: number;
stack: string[];
storage: {};
}
export interface StateOverrides {
[address: string]: {
storage?: {
[slot: string | number]: BigNumberish;
};
bytecode?: ContractInfo;
balance?: BigNumberish;
nonce?: BigNumberish;
};
}
export type ContractInfo =
| string // bytecode in hex or name of the contract
| {
name: string;
libraries?: {
[libraryName: string]: ContractInfo;
};
};
export interface Item<Params> {
opcode: string;
params: Params;
parent?: Item<Params>;
children?: Array<Item<Params>>;
format?: () => string;
noFormat?: boolean;
}
export interface AwaitedItem<T> {
isAwaitedItem: true;
next: number;
parse: (
step: MinimalInterpreterStep,
currentAddress?: { value: string }
) => Item<T>;
}
export interface CallItem extends Item<CALL> {
opcode: CALL_OPCODES;
children: Array<Item<any>>;
}
export type CALL_OPCODES =
| "CALL"
| "STATICCALL"
| "DELEGATECALL"
| "CALLCODE"
| "CREATE"
| "CREATE2";
export interface ChaiMessageCallOptions {
isStaticCall?: boolean;
isDelegateCall?: boolean;
isSuccess?: boolean;
returnData?: string;
from?: string;
}
export interface I4BytesEntry {
id: number; // 31780
created_at: string; // "2018-05-11T08:39:29.708250Z";
text_signature: string; // "many_msg_babbage(bytes1)";
hex_signature: string; // "0xa9059cbb";
bytes_signature: string; // "©\x05\x9C»";
}
export interface Obj<V> {
[key: string]: V;
}
export interface PrecompleResult {
name: string;
inputResult?: { [key: string]: any };
returnResult?: { [key: string]: any };
}
declare global {
export namespace Chai {
interface Assertion {
messageCall(
tx: PopulatedTransaction,
options?: ChaiMessageCallOptions
): Assertion;
}
}
}