pond: trunc long addrsesses, highlight default

This commit is contained in:
Łukasz Magiera 2019-07-25 17:13:45 +02:00
parent 6f3285d2fb
commit 1249d70529
2 changed files with 24 additions and 5 deletions

View File

@ -9,11 +9,11 @@
user-select: text;
font-family: monospace;
min-width: 40em;
width: 100%;
display: inline-block;
}
.CristalScroll {
width: 100%;
min-width: 100%;
height: 100%;
overflow: auto;
}

View File

@ -10,6 +10,13 @@ async function awaitListReducer(prev, c) {
return [...await prev, await c]
}
function truncAddr(addr) {
if (addr.length > 41) {
return <abbr title={addr}>{addr.substr(0, 38) + '...'}</abbr>
}
return addr
}
class FullNode extends React.Component {
constructor(props) {
super(props)
@ -72,13 +79,19 @@ class FullNode extends React.Component {
this.setState(() => ({tipset: tipset}))
const addrss = await this.state.client.call('Filecoin.WalletList', [])
const defaultAddr = await this.state.client.call('Filecoin.WalletDefaultAddress', [])
const balances = await addrss.map(async addr => {
const balance = await this.state.client.call('Filecoin.WalletBalance', [addr])
let balance = 0
try {
balance = await this.state.client.call('Filecoin.WalletBalance', [addr])
} catch {
balance = -1
}
return [addr, balance]
}).reduce(awaitListReducer, Promise.resolve([]))
this.setState(() => ({balances: balances}))
this.setState(() => ({balances: balances, defaultAddr: defaultAddr}))
}
async startMining() {
@ -103,7 +116,13 @@ class FullNode extends React.Component {
mine = "Mining"
}
let balances = this.state.balances.map(([addr, balance]) => (<div>{addr}: {balance} (ActTyp)</div>))
let balances = this.state.balances.map(([addr, balance]) => {
let line = <span>{truncAddr(addr)}:&nbsp;{balance}&nbsp;(ActTyp)</span>
if (this.state.defaultAddr === addr) {
line = <b>{line}</b>
}
return <div>{line}</div>
})
runtime = (
<div>