This repository has been archived by the owner on Feb 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from etclabscore/feat/view-raw
feat: add view raw for blocks and transactions
- Loading branch information
Showing
10 changed files
with
1,082 additions
and
456 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from "react"; | ||
import { useHistory } from "react-router-dom"; | ||
import { Button } from "@material-ui/core"; | ||
import Editor from "@monaco-editor/react"; | ||
import useDarkMode from "use-dark-mode"; | ||
|
||
interface IProps { | ||
block: any; | ||
} | ||
|
||
const BlockRaw: React.FC<IProps> = (props) => { | ||
const history = useHistory(); | ||
const darkMode = useDarkMode(); | ||
const { block } = props; | ||
|
||
return ( | ||
<div style={{ margin: "0px -25px 0px -25px" }}> | ||
<Button | ||
onClick={() => { | ||
history.push(`/block/${block.hash}`); | ||
}} | ||
style={{ position: "absolute", right: "10px", top: "75px", zIndex: 1 }} | ||
>View Block</Button> | ||
<Editor | ||
options={{ | ||
minimap: { | ||
enabled: false, | ||
}, | ||
wordWrap: "on", | ||
lineNumbers: "off", | ||
wrappingIndent: "deepIndent", | ||
readOnly: true, | ||
showFoldingControls: "always", | ||
}} | ||
theme={darkMode.value ? "dark" : "light"} | ||
width="100vw" | ||
height="93vh" | ||
language="json" | ||
value={JSON.stringify(block, null, 4)} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BlockRaw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import BlockRaw from "./BlockRaw"; | ||
export default BlockRaw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from "react"; | ||
import { useHistory } from "react-router-dom"; | ||
import { Button, Typography } from "@material-ui/core"; | ||
import Editor from "@monaco-editor/react"; | ||
import useDarkMode from "use-dark-mode"; | ||
import { ObjectUAh7GW7V as ITransaction} from "@etclabscore/ethereum-json-rpc"; | ||
|
||
interface IProps { | ||
tx: ITransaction; | ||
receipt: any; | ||
} | ||
|
||
const TxRaw: React.FC<IProps> = (props) => { | ||
const history = useHistory(); | ||
const darkMode = useDarkMode(); | ||
const { tx, receipt } = props; | ||
|
||
return ( | ||
<div style={{ margin: "0px -25px 0px -25px" }}> | ||
<Button | ||
onClick={() => { | ||
history.push(`/tx/${tx.hash}`); | ||
}} | ||
style={{ position: "absolute", right: "10px", top: "75px", zIndex: 1 }} | ||
>View Transaction</Button> | ||
<br /> | ||
<Typography variant="h5" gutterBottom style={{marginLeft: "10px"}}>Transaction</Typography> | ||
<br /> | ||
<Editor | ||
options={{ | ||
minimap: { | ||
enabled: false, | ||
}, | ||
lineNumbers: "off", | ||
wordWrap: "on", | ||
wrappingIndent: "deepIndent", | ||
readOnly: true, | ||
showFoldingControls: "always", | ||
}} | ||
theme={darkMode.value ? "dark" : "light"} | ||
width="100vw" | ||
height="35vh" | ||
language="json" | ||
value={JSON.stringify(tx, null, 4)} | ||
/> | ||
<br /> | ||
<Typography variant="h6" gutterBottom style={{marginLeft: "10px"}}>Receipt</Typography> | ||
<br /> | ||
<Editor | ||
options={{ | ||
minimap: { | ||
enabled: false, | ||
}, | ||
lineNumbers: "off", | ||
wordWrap: "on", | ||
wrappingIndent: "deepIndent", | ||
readOnly: true, | ||
showFoldingControls: "always", | ||
}} | ||
theme={darkMode.value ? "dark" : "light"} | ||
width="100vw" | ||
height="35vh" | ||
language="json" | ||
value={JSON.stringify(receipt, null, 4)} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TxRaw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { CircularProgress } from "@material-ui/core"; | ||
import useMultiGethStore from "../stores/useMultiGethStore"; | ||
import * as React from "react"; | ||
import EthereumJSONRPC from "@etclabscore/ethereum-json-rpc"; | ||
import BlockRaw from "../components/BlockRaw"; | ||
|
||
export default function BlockRawContainer(props: any) { | ||
const { match: { params: { hash } } } = props; | ||
const [erpc]: [EthereumJSONRPC] = useMultiGethStore(); | ||
const [block, setBlock] = React.useState(); | ||
React.useEffect(() => { | ||
if (!erpc) { return; } | ||
erpc.eth_getBlockByHash(hash, true).then(setBlock); | ||
}, [hash, erpc]); | ||
if (!block) { return (<CircularProgress />); } | ||
return (<BlockRaw block={block} />); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { CircularProgress } from "@material-ui/core"; | ||
import * as React from "react"; | ||
import useMultiGethStore from "../stores/useMultiGethStore"; | ||
import EthereumJSONRPC from "@etclabscore/ethereum-json-rpc"; | ||
import TxRaw from "../components/TxRaw/TxRaw"; | ||
|
||
export default function TransactionRawContainer(props: any) { | ||
const hash = props.match.params.hash; | ||
const [erpc]: [EthereumJSONRPC] = useMultiGethStore(); | ||
const [transaction, setTransaction] = React.useState(); | ||
const [receipt, setReceipt] = React.useState(); | ||
|
||
React.useEffect(() => { | ||
if (!erpc) { return; } | ||
erpc.eth_getTransactionByHash(hash).then(setTransaction); | ||
}, [hash, erpc]); | ||
|
||
React.useEffect(() => { | ||
if (!erpc) { return; } | ||
erpc.eth_getTransactionReceipt(hash).then(setReceipt); | ||
}, [hash, erpc]); | ||
|
||
if (!transaction || !receipt) { | ||
return (<CircularProgress />); | ||
} | ||
|
||
return (<TxRaw tx={transaction} receipt={receipt} />); | ||
} |