pond: Listing payment channels

This commit is contained in:
Łukasz Magiera 2019-08-15 17:46:34 +02:00
parent eb962940bd
commit b35f2942bb
3 changed files with 39 additions and 13 deletions

View File

@ -59,7 +59,12 @@ class Address extends React.Component {
addr = <a href="#" onClick={this.openState}>{addr}</a> addr = <a href="#" onClick={this.openState}>{addr}</a>
} }
return <span>{addr}:&nbsp;{this.state.balance}&nbsp;{actInfo}&nbsp;{add1k}</span> let balance = <span>:&nbsp;{this.state.balance}</span>
if(this.props.nobalance) {
balance = <span></span>
}
return <span>{addr}{balance}&nbsp;{actInfo}&nbsp;{add1k}</span>
} }
} }

View File

@ -16,10 +16,14 @@
background: #f9be77; background: #f9be77;
user-select: text; user-select: text;
font-family: monospace; font-family: monospace;
min-width: 40em; min-width: 50em;
display: inline-block; display: inline-block;
} }
.FullNode-voucher {
padding-left: 1em;
}
.StorageNode { .StorageNode {
background: #f9be77; background: #f9be77;
user-select: text; user-select: text;

View File

@ -36,21 +36,17 @@ class FullNode extends React.Component {
const tipset = await this.props.client.call("Filecoin.ChainHead", []) const tipset = await this.props.client.call("Filecoin.ChainHead", [])
const addrs = await this.props.client.call('Filecoin.WalletList', []) let addrs = await this.props.client.call('Filecoin.WalletList', [])
let defaultAddr = "" let defaultAddr = ""
if (addrs.length > 0) { if (addrs.length > 0) {
defaultAddr = await this.props.client.call('Filecoin.WalletDefaultAddress', []) defaultAddr = await this.props.client.call('Filecoin.WalletDefaultAddress', [])
} }
let paychs = await this.props.client.call('Filecoin.PaychList', [])
/* const balances = await addrss.map(async addr => { if(!paychs)
let balance = 0 paychs = []
try { const vouchers = await Promise.all(paychs.map(paych => {
balance = await this.props.client.call('Filecoin.WalletBalance', [addr]) return this.props.client.call('Filecoin.PaychVoucherList', [paych])
} catch { }))
balance = -1
}
return [addr, balance]
}).reduce(awaitListReducer, Promise.resolve([]))*/
this.setState(() => ({ this.setState(() => ({
id: id, id: id,
@ -59,6 +55,9 @@ class FullNode extends React.Component {
tipset: tipset, tipset: tipset,
addrs: addrs, addrs: addrs,
paychs: paychs,
vouchers: vouchers,
defaultAddr: defaultAddr})) defaultAddr: defaultAddr}))
} }
@ -118,6 +117,23 @@ class FullNode extends React.Component {
} }
return <div key={addr}>{line}</div> return <div key={addr}>{line}</div>
}) })
let paychannels = this.state.paychs.map((addr, ak) => {
const line = <Address client={this.props.client} add1k={this.add1k} addr={addr} mountWindow={this.props.mountWindow}/>
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}/>M{voucher.Extra.Method}</b>&gt;</span>
}
return <div key={voucher.Nonce} className="FullNode-voucher">
Voucher Nonce:<b>{voucher.Nonce}</b> Lane:<b>{voucher.Lane}</b> Amt:<b>{voucher.Amount}</b> TL:<b>{voucher.TimeLock}</b> MinCl:<b>{voucher.MinCloseHeight}</b> {extra}
</div>
})
return <div key={addr}>
{line}
{vouchers}
</div>
})
runtime = ( runtime = (
<div> <div>
@ -130,6 +146,7 @@ class FullNode extends React.Component {
<div> <div>
<div>Balances: [New <a href="#" onClick={this.newScepAddr}>[Secp256k1]</a>]</div> <div>Balances: [New <a href="#" onClick={this.newScepAddr}>[Secp256k1]</a>]</div>
<div>{addresses}</div> <div>{addresses}</div>
<div>{paychannels}</div>
</div> </div>
</div> </div>