pond: trunc long addrsesses, highlight default
This commit is contained in:
parent
6f3285d2fb
commit
1249d70529
@ -9,11 +9,11 @@
|
|||||||
user-select: text;
|
user-select: text;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
min-width: 40em;
|
min-width: 40em;
|
||||||
width: 100%;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CristalScroll {
|
.CristalScroll {
|
||||||
width: 100%;
|
min-width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
@ -10,6 +10,13 @@ async function awaitListReducer(prev, c) {
|
|||||||
return [...await prev, await 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 {
|
class FullNode extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
@ -72,13 +79,19 @@ class FullNode extends React.Component {
|
|||||||
this.setState(() => ({tipset: tipset}))
|
this.setState(() => ({tipset: tipset}))
|
||||||
|
|
||||||
const addrss = await this.state.client.call('Filecoin.WalletList', [])
|
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 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]
|
return [addr, balance]
|
||||||
}).reduce(awaitListReducer, Promise.resolve([]))
|
}).reduce(awaitListReducer, Promise.resolve([]))
|
||||||
|
|
||||||
this.setState(() => ({balances: balances}))
|
this.setState(() => ({balances: balances, defaultAddr: defaultAddr}))
|
||||||
}
|
}
|
||||||
|
|
||||||
async startMining() {
|
async startMining() {
|
||||||
@ -103,7 +116,13 @@ class FullNode extends React.Component {
|
|||||||
mine = "Mining"
|
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)}: {balance} (ActTyp)</span>
|
||||||
|
if (this.state.defaultAddr === addr) {
|
||||||
|
line = <b>{line}</b>
|
||||||
|
}
|
||||||
|
return <div>{line}</div>
|
||||||
|
})
|
||||||
|
|
||||||
runtime = (
|
runtime = (
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
Reference in New Issue
Block a user