Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pond: Translate method names #144

Merged
merged 2 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions lotuspond/front/src/Address.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import CID from 'cids'
import * as multihash from "multihashes";
import State from "./State";
import methods from "./chain/methods";

function truncAddr(addr) {
if (addr.length > 21) {
Expand Down Expand Up @@ -34,6 +35,7 @@ class Address extends React.Component {
try {
balance = await this.props.client.call('Filecoin.WalletBalance', [this.props.addr])
actor = await this.props.client.call('Filecoin.ChainGetActor', [this.props.addr, this.props.ts || null])

actorInfo = await this.actorInfo(actor)
} catch (err) {
console.log(err)
Expand All @@ -50,11 +52,16 @@ class Address extends React.Component {
const c = new CID(actor.Code['/'])
const mh = multihash.decode(c.multihash) // TODO: check identity

let info = <span>({mh.digest.toString()})</span>
let method = <span></span>
if(this.props.method !== undefined && mh.digest.toString()) {
method = <span>.{methods[mh.digest.toString()][this.props.method]}</span>
}

let info = <span>({mh.digest.toString()}{method})</span>
switch(mh.digest.toString()) {
case 'paych':
const actstate = await this.props.client.call('Filecoin.ChainReadState', [actor, this.props.ts || null])
info = <span>({mh.digest.toString()} to <Address nobalance={true} client={this.props.client} addr={actstate.State.To} mountWindow={this.props.mountWindow}/>)</span>
info = <span>({mh.digest.toString()}{method} to <Address nobalance={true} client={this.props.client} addr={actstate.State.To} mountWindow={this.props.mountWindow}/>)</span>
}

return info
Expand All @@ -78,7 +85,12 @@ class Address extends React.Component {
balance = <span></span>
}

return <span>{addr}{balance}&nbsp;{actInfo}{add1k}</span>
let transfer = <span></span>
if(this.props.transfer) {
transfer = <span>&nbsp;{this.props.transfer}FIL</span>
}

return <span>{addr}{balance}&nbsp;{actInfo}{add1k}{transfer}</span>
}
}

Expand Down
2 changes: 1 addition & 1 deletion lotuspond/front/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
background: #f9be77;
user-select: text;
font-family: monospace;
min-width: 40em;
min-width: 50em;
display: inline-block;
}

Expand Down
7 changes: 3 additions & 4 deletions lotuspond/front/src/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ class Block extends React.Component {
...(this.state.messages.SecpkMessages.map(m => ({...(m.Message), type: 'Secpk'})))
].map(m => (
<div>
<Address client={this.props.conn} addr={m.From} mountWindow={this.props.mountWindow}/><b>=>&nbsp;</b>
<Address client={this.props.conn} addr={m.To} mountWindow={this.props.mountWindow}/>
{m.Value}FIL&nbsp;M{m.Method}
<Address client={this.props.conn} addr={m.From} mountWindow={this.props.mountWindow}/><b>&nbsp;=>&nbsp;</b>
<Address client={this.props.conn} addr={m.To} mountWindow={this.props.mountWindow} transfer={m.Value} method={m.Method}/>
</div>
))

Expand All @@ -52,7 +51,7 @@ class Block extends React.Component {
)
}

return (<Cristal onClose={this.props.onClose} title={`Block ${this.props.cid['/']}`}>
return (<Cristal initialSize={{width: 700, height: 200}} onClose={this.props.onClose} title={`Block ${this.props.cid['/']}`}>
{content}
</Cristal>)
}
Expand Down
2 changes: 1 addition & 1 deletion lotuspond/front/src/Consensus.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Consensus extends React.Component {

async updateNodes() {
const nodes = this.props.nodes
let keys = Object.keys(nodes)
let keys = Object.keys(nodes).filter(k => !nodes[k].Storage)

const tipsets = await keys.map(async k => {
const tipset = await nodes[k].conn.call("Filecoin.ChainHead", [])
Expand Down
5 changes: 3 additions & 2 deletions lotuspond/front/src/FullNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class FullNode extends React.Component {
const vouchers = this.state.vouchers[ak].map(voucher => {
let extra = <span></span>
if(voucher.Extra) {
extra = <span>Verif: &lt;<b><Address nobalance={true} client={this.props.client} addr={voucher.Extra.Actor} mountWindow={this.props.mountWindow}/>&nbsp;M{voucher.Extra.Method}</b>&gt;</span>
extra = <span>Verif: &lt;<b><Address nobalance={true} client={this.props.client} addr={voucher.Extra.Actor} method={voucher.Extra.Method} mountWindow={this.props.mountWindow}/></b>&gt;</span>
}

return <div key={voucher.Nonce} className="FullNode-voucher">
Expand Down Expand Up @@ -158,7 +158,8 @@ class FullNode extends React.Component {
return (
<Cristal
title={"Node " + this.props.node.ID}
initialPosition={{x: this.props.node.ID*30, y: this.props.node.ID * 30}} >
initialPosition={{x: this.props.node.ID*30, y: this.props.node.ID * 30}}
initialSize={{width: 690, height: 300}} >
<div className="CristalScroll">
<div className="FullNode">
{runtime}
Expand Down
64 changes: 64 additions & 0 deletions lotuspond/front/src/chain/methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
export default {
"account": [
"Send",
"Constructor",
"GetAddress",
],
"smarket": [
"Send",
"Constructor",
"CreateStorageMiner",
"SlashConsensusFault",
"UpdateStorage",
"GetTotalStorage",
"PowerLookup",
"IsMiner",
"StorageCollateralForSize"
],
"sminer": [
"Send",
"Constructor",
"CommitSector",
"SubmitPost",
"SlashStorageFault",
"GetCurrentProvingSet",
"ArbitrateDeal",
"DePledge",
"GetOwner",
"GetWorkerAddr",
"GetPower",
"GetPeerID",
"GetSectorSize",
"UpdatePeerID",
"ChangeWorker",
"IsSlashed",
"IsLate",
"PaymentVerifyInclusion",
"PaymentVerifySector",
],
"multisig": [
"Send",
"Constructor",
"Propose",
"Approve",
"Cancel",
"ClearCompleted",
"AddSigner",
"RemoveSigner",
"SwapSigner",
"ChangeRequirement",
],
"init": [
"Send",
"Constructor",
"Exec",
"GetIdForAddress"
],
"paych": [
"Send",
"Constructor",
"UpdateChannelState",
"Close",
"Collect",
],
}