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
|
import * as React from 'react';
import styled from 'styled-components';
import { ContextInterface, ThemeContext } from 'ts/context';
import ExactLocation from 'ts/icons/exact-location.svg';
import NoLocation from 'ts/icons/no-location.svg';
import TimeConsuming from 'ts/icons/time-consuming.svg';
import TimeSaving from 'ts/icons/time-saving.svg';
import { colors, media } from 'ts/variables';
import { Breakout } from './breakout';
import { Code } from './code';
import { Container } from './container';
import { Alpha, Gamma, Lead } from './typography';
const Trace: React.StatelessComponent<{}> = () => (
<ThemeContext.Consumer>
{(props: ContextInterface) => (
<StyledSection background={props.colors.secondary}>
<Wrapper>
<Block>
<Alpha>The Issue</Alpha>
<MainCopy>
Every time an Ethereum transaction fails, it's extremely hard to trace down the
troublemaking line of code. The only hint you'll get is a generic error.
</MainCopy>
<Breakout>
<Code isLight={true}>Error: VM Exception while processing transaction: rever</Code>
</Breakout>
<List>
<Item>
<Copy dark={true}>
<Gamma as="h3">No location</Gamma>
<p>
The error basically says "anything could have gone wrong here", which keeps you
completely in the dark about its exact location.
</p>
</Copy>
<Icon as={NoLocation} />
</Item>
<Item>
<Copy dark={true}>
<Gamma as="h3">Time-consuming</Gamma>
<p>
Working with a large code-base that contains hundreds of smart contracts,
finding the failing line of code quickly becomes a daunting task.
</p>
</Copy>
<Icon as={TimeConsuming} />
</Item>
</List>
</Block>
<Block background={props.colors.secondary}>
<Alpha>The Fix</Alpha>
<MainCopy>
Sol-trace will give you full stack traces, including contract names, line numbers and code
snippets, every time you encounter an error.
</MainCopy>
<Breakout>
<Code isLight={true} language="javascript">
{`contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol:51:8
require(
isValidSignature(
hash,
signerAddress,
signature
),
"INVALID_SIGNATURE"
)`}
</Code>
</Breakout>
<List>
<Item>
<Copy>
<Gamma as="h3">Exact location</Gamma>
<p>
It shows you the exact location of the specific code linen and where it was
called from.
</p>
</Copy>
<Icon as={ExactLocation} />
</Item>
<Item>
<Copy>
<Gamma as="h3">Time-saving</Gamma>
<p>
Turning "Your code failed somewhere, good luck debugging it" into "Your code
failed on line X of contract Y", it drastically improves the developer
experience.
</p>
</Copy>
<Icon as={TimeSaving} />
</Item>
</List>
</Block>
</Wrapper>
</StyledSection>
)}
</ThemeContext.Consumer>
);
interface TraceProps {
background?: string;
}
const StyledSection =
styled.section <
TraceProps >
`
max-width: 90rem;
margin: 0 auto;
background: linear-gradient(to right, ${colors.black} 50%, ${props => props.background} 50%);
overflow: hidden;
${media.large`
background: none
padding-top: 0;
padding-bottom: 0;
`};
`;
const Wrapper = styled(Container)`
display: flex;
${Alpha} {
padding-bottom: 2.5rem;
${media.small`padding-bottom: 1.875rem;`};
}
${media.large`
display: block;
width: 100%;
`};
`;
const Block =
styled.div <
TraceProps >
`
width: 50%;
background: ${props => (props.background ? props.background : colors.black)};
color: ${props => (props.background ? 'inherit' : colors.white)};
padding-top: 6.25rem;
padding-bottom: 5.25rem;
:first-of-type {
padding-right: 6.25rem;
}
:last-of-type {
padding-left: 6.25rem;
}
${media.xlarge`
:first-of-type {
padding-right: 2.5rem;
}
:last-of-type {
padding-left: 2.5rem;
}
`}
${media.large`
width: 100%;
padding: 2.5rem;
`}
${media.small`
padding-left: 1.875rem;
padding-right: 1.875rem;
`};
`;
const MainCopy = styled(Lead)`
margin-bottom: 3.1875rem;
${media.small`
margin-bottom: 1.125rem;
`};
`;
const List = styled.ul`
margin-top: 6.25rem;
margin-bottom: 0;
padding: 0;
${media.small`margin-top: 3.4375rem;`};
`;
const Item = styled.li`
display: flex;
align-items: center;
:not(:last-child) {
margin-bottom: 4.4375rem;
${media.small`margin-bottom: 3.4375rem;`};
}
`;
const Copy =
styled.div <
{ dark: boolean } >
`
margin-right: 5.875rem;
${props =>
props.dark &&
`
p {
color: #ccc;
}
`}
${media.small`margin-right: 2.0625rem;`};
`;
const Icon = styled.div`
flex-shrink: 0;
`;
export { Trace };
|