aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-tracing-utils/src/types.ts
blob: 27568ae035175c1043c4b8997ff90d340b354d44 (plain) (blame)
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
import { StructLog } from 'ethereum-types';
import * as Parser from 'solidity-parser-antlr';

export interface LineColumn {
    line: number;
    column: number;
}

export interface SourceRange {
    location: SingleFileSourceRange;
    fileName: string;
}

export interface SingleFileSourceRange {
    start: LineColumn;
    end: LineColumn;
}

export interface OffsetToLocation {
    [offset: number]: LineColumn;
}

export interface FunctionDescription {
    name: string;
    line: number;
    loc: SingleFileSourceRange;
    skip?: boolean;
}

export type StatementDescription = SingleFileSourceRange;

export interface BranchDescription {
    line: number;
    type: 'if' | 'switch' | 'cond-expr' | 'binary-expr';
    locations: SingleFileSourceRange[];
}

export interface FnMap {
    [functionId: string]: FunctionDescription;
}

export interface BranchMap {
    [branchId: string]: BranchDescription;
}

export interface StatementMap {
    [statementId: string]: StatementDescription;
}

export interface LineCoverage {
    [lineNo: number]: number;
}

export interface FunctionCoverage {
    [functionId: string]: number;
}

export interface StatementCoverage {
    [statementId: string]: number;
}

export interface BranchCoverage {
    [branchId: string]: number[];
}

export interface Coverage {
    [fineName: string]: {
        l?: LineCoverage;
        f: FunctionCoverage;
        s: StatementCoverage;
        b: BranchCoverage;
        fnMap: FnMap;
        branchMap: BranchMap;
        statementMap: StatementMap;
        path: string;
    };
}

export interface SourceCodes {
    [sourceId: number]: string;
}
export interface Sources {
    [sourceId: number]: string;
}

export interface ContractData {
    bytecode: string;
    sourceMap: string;
    runtimeBytecode: string;
    sourceMapRuntime: string;
    sourceCodes: SourceCodes;
    sources: Sources;
}

// Part of the trace executed within the same context
export type Subtrace = StructLog[];

export interface TraceInfoBase {
    subtrace: Subtrace;
    txHash: string;
}

export interface TraceInfoNewContract extends TraceInfoBase {
    address: 'NEW_CONTRACT';
    bytecode: string;
}

export interface TraceInfoExistingContract extends TraceInfoBase {
    address: string;
    runtimeBytecode: string;
}

export type TraceInfo = TraceInfoNewContract | TraceInfoExistingContract;

export enum BlockParamLiteral {
    Latest = 'latest',
}

export interface EvmCallStackEntry {
    structLog: StructLog;
    address: string;
}

export type EvmCallStack = EvmCallStackEntry[];

export interface SourceSnippet {
    source: string;
    fileName: string;
    type: string;
    node: Parser.ASTNode;
    name: string | null;
    range: SingleFileSourceRange;
}