Skip to content

Commit 318c74e

Browse files
authored
Merge pull request #9 from fergarrui/add-storage-viewer-component
add storage viewer component
2 parents 1cb9d7e + f197dc3 commit 318c74e

File tree

9 files changed

+123
-57
lines changed

9 files changed

+123
-57
lines changed

src/client/components/InnerTab/InnerTab.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class InnerTab extends React.Component {
4343

4444
render() {
4545

46-
const { data, contractName, contractCode, contractPath, disassemblerResponse, graphResponse, debuggerResponse } = this.props;
46+
const { data, contractName, contractCode, contractPath, disassemblerResponse, graphResponse, debuggerResponse, storageResponse } = this.props;
4747
const { currentInnerTabIndex } = this.state;
4848

4949
return (
@@ -74,6 +74,7 @@ class InnerTab extends React.Component {
7474
disassemblerResponse={disassemblerResponse}
7575
debuggerResponse={debuggerResponse}
7676
graphResponse={graphResponse}
77+
storageResponse={storageResponse}
7778
/>
7879
)
7980
})}

src/client/components/InnerTab/InnerTabPanel/InnerTabPanel.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import React from 'react';
33
import TransactionDebugger from '../../TransactionDebugger/TransactionDebugger';
44
import Disassembler from '../../Disassembler/Disassembler';
55
import ControlFlowGraph from '../../ControlFlowGraph/ControlFlowGraph';
6-
import Storage from '../../Storage/Storage';
6+
import StorageViewer from '../../StorageViewer/StorageViewer';
77

88
import styles from './InnerTabPanel.scss';
99

1010
import classnames from 'classnames/bind';
1111

1212
const cx = classnames.bind(styles);
1313

14-
const InnerTabPanel = ({ type, active, contractName, contractCode, contractPath, debuggerResponse, graphResponse, disassemblerResponse }) => {
14+
const InnerTabPanel = ({ type, active, contractName, contractCode, contractPath, debuggerResponse, graphResponse, disassemblerResponse, storageResponse }) => {
1515
const tabPanelClasses = cx({
1616
'inner-tab-panel': true,
1717
'inner-tab-panel--active': !!active,
@@ -39,9 +39,8 @@ const InnerTabPanel = ({ type, active, contractName, contractCode, contractPath,
3939
graphResponse={graphResponse}
4040
/>
4141
}
42-
{type === 'View Storage' &&
43-
<Storage
44-
/>
42+
{type === 'Storage Viewer' &&
43+
<StorageViewer storageResponse={storageResponse} />
4544
}
4645
</div>
4746
);

src/client/components/SettingsBar/SettingsBar.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class SettingsBar extends React.Component {
1717
}
1818

1919
this.handleInputChange = this.handleInputChange.bind(this);
20-
this.handleKeyUp = this.handleKeyUp.bind(this);
2120
}
2221

2322
handleInputChange(event) {
@@ -31,16 +30,6 @@ class SettingsBar extends React.Component {
3130
localStorage.setItem(name, value);
3231
}
3332

34-
handleKeyUp(event) {
35-
const { onSaveButtonClick } = this.props;
36-
37-
if(event.keyCode !== 13) {
38-
return;
39-
}
40-
41-
onSaveButtonClick();
42-
}
43-
4433
handlClearClick() {
4534
localStorage.clear();
4635

src/client/components/Storage/Storage.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/client/components/Storage/Storage.scss

Whitespace-only changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react';
2+
3+
import styles from './StorageViewer.scss';
4+
5+
const StorageViewer = ({ storageResponse }) => {
6+
7+
return (
8+
<div className={styles['storage']}>
9+
<div className={styles['storage__header']}>
10+
<div className={styles['storage__header__item']}>
11+
<span>
12+
Slot
13+
</span>
14+
</div>
15+
<div className={styles['storage__header__item']}>
16+
<span>
17+
Value
18+
</span>
19+
</div>
20+
</div>
21+
<div className={styles['storage__body']}>
22+
{
23+
Object.entries(storageResponse.storage).map(([key, val]) => {
24+
return (
25+
<div className={styles['storage__body__item']} key={key}>
26+
<div className={styles['storage__body__item__col']}>
27+
<span>{key}</span>
28+
</div>
29+
<div className={styles['storage__body__item__col']}>
30+
<span>{val.value}</span>
31+
</div>
32+
</div>
33+
)
34+
})
35+
}
36+
</div>
37+
38+
</div>
39+
)
40+
}
41+
42+
export default StorageViewer;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.storage {
2+
padding: 15px;
3+
4+
&__header {
5+
display: flex;
6+
justify-content: space-around;
7+
border-bottom: 1px dotted $color-green;
8+
9+
&__item {
10+
flex: 0 1 50%;
11+
padding: 20px;
12+
text-align: center;
13+
14+
&:first-of-type {
15+
border-right: 1px dotted $color-green;
16+
}
17+
18+
span {
19+
text-transform: uppercase;
20+
color: $color-white;
21+
}
22+
}
23+
}
24+
25+
&__body {
26+
27+
&__item {
28+
display: flex;
29+
padding: 0 10px;
30+
border-bottom: 1px dotted $color-green;
31+
32+
&__col {
33+
flex: 0 1 50%;
34+
padding: 20px 10px;
35+
word-break: break-all;
36+
37+
span {
38+
color: $color-white;
39+
}
40+
41+
&:first-of-type {
42+
border-right: 1px dotted $color-green;
43+
}
44+
}
45+
}
46+
}
47+
}

src/client/components/Tab/TabPanel/TabPanel.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Form from '../../Form/Form';
1616

1717
import styles from './TabPanel.scss';
1818
import fade from '../../../styles/transitions/fade.scss';
19+
import scale from '../../../styles/transitions/scale.scss';
1920

2021
import classnames from 'classnames/bind';
2122

@@ -114,7 +115,7 @@ class TabPanel extends React.Component {
114115
});
115116
}
116117

117-
if(type === 'View Storage') {
118+
if(type === 'Storage Viewer') {
118119
this.setState({
119120
storageResponse: response,
120121
});
@@ -135,16 +136,7 @@ class TabPanel extends React.Component {
135136
this.props.getErrorMessage(message);
136137
}
137138

138-
// handleInputChange(event) {
139-
// const { value } = event.target;
140-
141-
// this.setState({
142-
// inputValue: value,
143-
// parameter: value,
144-
// });
145-
// }
146-
147-
handleInputSubmit() {
139+
handleTransactionFormSubmit() {
148140
const { name, path, code } = this.props;
149141

150142
const params = {
@@ -174,7 +166,7 @@ class TabPanel extends React.Component {
174166
endBlock: encodeURIComponent(this.state.endBlock)
175167
}
176168

177-
this.fetchData(this.getUrl('storage', params), 'View Storage');
169+
this.fetchData(this.getUrl(`storage/${this.state.contractAddress}/`, params), 'Storage Viewer');
178170

179171
document.removeEventListener('click', this.handleOutsideClick);
180172
}
@@ -276,7 +268,7 @@ class TabPanel extends React.Component {
276268

277269
const inputTypes = [
278270
{
279-
name: 'Address',
271+
name: 'contractAddress',
280272
placeholder: 'Enter contract address'
281273
},
282274
{
@@ -337,19 +329,26 @@ class TabPanel extends React.Component {
337329
</div>
338330
</div>
339331
<div className={styles['tab-panel__right']}>
340-
<InnerTab
341-
data={tabs}
342-
contractName={name}
343-
contractCode={code}
344-
contractPath={path}
345-
graphResponse={graphResponse}
346-
debuggerResponse={debuggerResponse}
347-
disassemblerResponse={disassemblerResponse}
348-
storageResponse={storageResponse}
349-
onMenuItemIconClick={this.handleMenuItemIconClick}
332+
<CSSTransitionGroup
333+
transitionName={scale}
334+
transitionAppear={true}
335+
trnasitionEnterTimeout={300}
336+
transitionLeaveTimeout={300}
350337
>
351-
{children}
352-
</InnerTab>
338+
<InnerTab
339+
data={tabs}
340+
contractName={name}
341+
contractCode={code}
342+
contractPath={path}
343+
graphResponse={graphResponse}
344+
debuggerResponse={debuggerResponse}
345+
disassemblerResponse={disassemblerResponse}
346+
storageResponse={storageResponse}
347+
onMenuItemIconClick={this.handleMenuItemIconClick}
348+
>
349+
{children}
350+
</InnerTab>
351+
</CSSTransitionGroup>
353352
</div>
354353
<CSSTransitionGroup
355354
transitionName={fade}
@@ -366,8 +365,8 @@ class TabPanel extends React.Component {
366365
inputTypes={[{ name: 'transactionHash', placeholder: 'Transaction Hash' }]}
367366
buttonValue='Debug'
368367
onInputChange={(e) => this.handleFormInputChange(e)}
369-
onInputKeyUp={() => this.handleInputSubmit()}
370-
onSubmitForm={() => this.handleInputSubmit()}
368+
onInputKeyUp={() => this.handleTransactionFormSubmit()}
369+
onSubmitForm={() => this.handleTransactionFormSubmit()}
371370
/>
372371
</Modal>
373372
}
@@ -388,6 +387,7 @@ class TabPanel extends React.Component {
388387
inputTypes={inputTypes}
389388
onInputChange={(e) => this.handleFormInputChange(e)}
390389
onSubmitForm={() => this.handleSubmitViewStorageForm()}
390+
onInputKeyUp={() => this.handleSubmitViewStorageForm()}
391391
/>
392392
</Modal>
393393
}

src/client/components/TopNavBar/TopNavBar.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.top-navbar {
22
display: flex;
3+
align-items: center;
34
width: 100%;
45
position: fixed;
56
top: 0;

0 commit comments

Comments
 (0)