2019-07-25 17:06:10 +00:00
|
|
|
import React from 'react';
|
|
|
|
import {Cristal} from "react-cristal";
|
|
|
|
import {BlockLinks} from "./BlockLink";
|
2019-08-10 01:54:45 +00:00
|
|
|
import Address from "./Address";
|
2019-07-25 17:06:10 +00:00
|
|
|
|
|
|
|
class Block extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
|
|
|
|
this.state = {}
|
|
|
|
|
|
|
|
this.loadHeader()
|
|
|
|
}
|
|
|
|
|
|
|
|
async loadHeader() {
|
|
|
|
const header = await this.props.conn.call('Filecoin.ChainGetBlock', [this.props.cid])
|
2019-08-19 14:47:09 +00:00
|
|
|
let messages = await this.props.conn.call('Filecoin.ChainGetBlockMessages', [this.props.cid])
|
|
|
|
let receipts = await this.props.conn.call('Filecoin.ChainGetBlockReceipts', [this.props.cid])
|
|
|
|
|
|
|
|
messages = [
|
|
|
|
...(messages.BlsMessages.map(m => ({...m, type: 'BLS'}))),
|
|
|
|
...(messages.SecpkMessages.map(m => ({...(m.Message), type: 'Secpk'})))
|
|
|
|
]
|
|
|
|
|
|
|
|
messages = messages.map((msg, k) => ({...msg, receipt: receipts[k]}))
|
|
|
|
|
2019-08-09 17:32:46 +00:00
|
|
|
this.setState({header: header, messages: messages})
|
2019-07-25 17:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let content = <div>Loading Block Info</div>
|
|
|
|
if (this.state.header) {
|
|
|
|
let head = this.state.header
|
|
|
|
|
2019-08-19 14:47:09 +00:00
|
|
|
const messages = this.state.messages.map(m => (
|
2019-07-25 17:06:10 +00:00
|
|
|
<div>
|
2019-08-16 17:37:04 +00:00
|
|
|
<Address client={this.props.conn} addr={m.From} mountWindow={this.props.mountWindow}/><b> => </b>
|
|
|
|
<Address client={this.props.conn} addr={m.To} mountWindow={this.props.mountWindow} transfer={m.Value} method={m.Method}/>
|
2019-09-16 14:26:31 +00:00
|
|
|
<span> N{m.Nonce}</span>
|
2019-08-19 14:47:09 +00:00
|
|
|
<span> {m.receipt.GasUsed}Gas</span>
|
|
|
|
{m.receipt.ExitCode !== 0 ? <span> <b>EXIT:{m.receipt.ExitCode}</b></span> : <span/>}
|
2019-08-09 17:32:46 +00:00
|
|
|
</div>
|
|
|
|
))
|
|
|
|
|
|
|
|
content = (
|
|
|
|
<div className="Block">
|
2019-07-25 17:06:10 +00:00
|
|
|
<div>Height: {head.Height}</div>
|
|
|
|
<div>Parents: <BlockLinks cids={head.Parents} conn={this.props.conn} mountWindow={this.props.mountWindow}/></div>
|
|
|
|
<div>Weight: {head.ParentWeight}</div>
|
2019-08-10 01:54:45 +00:00
|
|
|
<div>Miner: {<Address client={this.props.conn} addr={head.Miner} mountWindow={this.props.mountWindow}/>}</div>
|
2019-07-25 17:06:10 +00:00
|
|
|
<div>Messages: {head.Messages['/']} {/*TODO: link to message explorer */}</div>
|
|
|
|
<div>Receipts: {head.MessageReceipts['/']}</div>
|
2019-08-09 17:32:46 +00:00
|
|
|
<div>State Root: {head.StateRoot['/']}</div>
|
|
|
|
<div>----</div>
|
|
|
|
<div>{messages}</div>
|
2019-07-25 17:06:10 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-09-16 14:26:31 +00:00
|
|
|
return (<Cristal className="CristalScroll" initialSize={{width: 700, height: 400}} onClose={this.props.onClose} title={`Block ${this.props.cid['/']}`}>
|
2019-07-25 17:06:10 +00:00
|
|
|
{content}
|
|
|
|
</Cristal>)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Block
|