2019-07-25 17:06:10 +00:00
|
|
|
import React from 'react';
|
|
|
|
import {BlockLinks} from "./BlockLink";
|
2019-08-10 01:54:45 +00:00
|
|
|
import Address from "./Address";
|
2019-09-19 14:27:01 +00:00
|
|
|
import Window from "./Window";
|
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-10-06 00:37:28 +00:00
|
|
|
let messages = await this.props.conn.call('Filecoin.ChainGetParentMessages', [this.props.cid])
|
|
|
|
let receipts = await this.props.conn.call('Filecoin.ChainGetParentReceipts', [this.props.cid])
|
2019-08-19 14:47:09 +00:00
|
|
|
|
2019-10-10 03:43:19 +00:00
|
|
|
if (!messages) {
|
|
|
|
messages = []
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-06 00:37:28 +00:00
|
|
|
messages = messages.map((msg, k) => ({...msg.Message, cid: msg.Cid, receipt: receipts[k]}))
|
2019-08-19 14:47:09 +00:00
|
|
|
|
2019-09-23 11:15:16 +00:00
|
|
|
messages = await Promise.all(messages.map(async (msg, i) => {
|
|
|
|
if (msg.receipt.ExitCode !== 0) {
|
2019-10-06 00:37:28 +00:00
|
|
|
let reply = await this.props.conn.call('Filecoin.StateReplay', [{Cids: [this.props.cid], Blocks: [header], Height: header.Height}, msg.Cid])
|
2019-09-23 11:15:16 +00:00
|
|
|
if(!reply.Error) {
|
|
|
|
reply.Error = "reply: no error"
|
|
|
|
}
|
|
|
|
msg.Error = reply.Error
|
|
|
|
}
|
|
|
|
return msg
|
|
|
|
}))
|
|
|
|
|
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-10-10 03:43:19 +00:00
|
|
|
const messages = this.state.messages.map((m, k) => (
|
|
|
|
<div key={k}>
|
2019-09-23 11:15:16 +00:00
|
|
|
<div>
|
|
|
|
<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}/>
|
|
|
|
<span> N{m.Nonce}</span>
|
|
|
|
<span> {m.receipt.GasUsed}Gas</span>
|
|
|
|
{m.receipt.ExitCode !== 0 ? <span> <b>EXIT:{m.receipt.ExitCode}</b></span> : <span/>}
|
|
|
|
</div>
|
|
|
|
{m.receipt.ExitCode !== 0 ? <div> Error: <b>{m.Error}</b></div> : <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>
|
2019-10-06 00:37:28 +00:00
|
|
|
<div>Parent Receipts: {head.ParentMessageReceipts['/']}</div>
|
2019-10-22 19:29:05 +00:00
|
|
|
<div>
|
|
|
|
<span>Parent State Root: {head.ParentStateRoot['/']}</span>
|
|
|
|
<span> <Address client={this.props.conn} short={true} addr="t00" mountWindow={this.props.mountWindow}/></span>
|
|
|
|
<span> <Address client={this.props.conn} short={true} addr="t01" mountWindow={this.props.mountWindow}/></span>
|
|
|
|
<span> <Address client={this.props.conn} short={true} addr="t02" mountWindow={this.props.mountWindow}/></span>
|
|
|
|
<span> <Address client={this.props.conn} short={true} addr="t03" mountWindow={this.props.mountWindow}/></span>
|
2020-08-07 14:07:34 +00:00
|
|
|
<span> <Address client={this.props.conn} short={true} addr="t04" mountWindow={this.props.mountWindow}/></span>
|
|
|
|
<span> <Address client={this.props.conn} short={true} addr="t05" mountWindow={this.props.mountWindow}/></span>
|
2019-10-22 19:29:05 +00:00
|
|
|
<span> <Address client={this.props.conn} short={true} addr="t099" mountWindow={this.props.mountWindow}/></span>
|
|
|
|
</div>
|
2019-08-09 17:32:46 +00:00
|
|
|
<div>----</div>
|
|
|
|
<div>{messages}</div>
|
2019-07-25 17:06:10 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-10-27 10:27:21 +00:00
|
|
|
return (<Window className="CristalScroll" initialSize={{width: 1050, height: 400}} onClose={this.props.onClose} title={`Block ${this.props.cid['/']}`}>
|
2019-07-25 17:06:10 +00:00
|
|
|
{content}
|
2019-09-19 14:27:01 +00:00
|
|
|
</Window>)
|
2019-07-25 17:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Block
|