mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-10 04:51:20 +00:00
c68f00045a
* Revert "remove tombstones (#426)"
This reverts commit aa6bab40e8
.
* tombstones don't hide storage or account anymore
* auto-format code by prettier (similar to gofmt)
* wow, it works.....
* small simplification, but need make it more clear
* rebase to master
* rebase to master
* rebase to master
* re-run ci
* clean test files
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
import React, { useState } from 'react';
|
|
|
|
import Row from 'react-bootstrap/Row';
|
|
import Col from 'react-bootstrap/Col';
|
|
import { Spinner, Table } from 'react-bootstrap';
|
|
|
|
import SearchField from './SearchField.js';
|
|
|
|
const search = (prefix, api, setState) => {
|
|
setState({ data: undefined, loading: true });
|
|
const lookupSuccess = (response) => setState({ data: response.data, loading: false });
|
|
const lookupFail = (error) => {
|
|
setState({ data: undefined, loading: false });
|
|
|
|
setState(() => {
|
|
throw error;
|
|
});
|
|
};
|
|
return api.lookupStorage(prefix).then(lookupSuccess).catch(lookupFail);
|
|
};
|
|
|
|
const LookupStorageForm = ({ api }) => {
|
|
const [state, setState] = useState({ data: undefined, loading: false });
|
|
|
|
return (
|
|
<div>
|
|
<SearchField
|
|
placeholder="lookup by prefix"
|
|
disabled={state.loading}
|
|
onSubmit={(data) => search(data.search, api, setState)}
|
|
/>
|
|
{state.loading && <Spinner animation="border" />}
|
|
{state.data && <Details data={state.data} />}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const Details = ({ data }) => (
|
|
<Row>
|
|
<Col>
|
|
<Table size="sm" borderless>
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
<strong>Key</strong>
|
|
</th>
|
|
<th>
|
|
<strong>Value</strong>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{data.map((item, i) => (
|
|
<TableRow key={i} item={item} />
|
|
))}
|
|
</tbody>
|
|
</Table>
|
|
</Col>
|
|
</Row>
|
|
);
|
|
|
|
const TableRow = ({ item }) => (
|
|
<tr>
|
|
<td className="text-monospace">{item.prefix}</td>
|
|
<td className="text-monospace">{item.value}</td>
|
|
</tr>
|
|
);
|
|
|
|
export default LookupStorageForm;
|