pond: +10k, addr highlighting
This commit is contained in:
parent
2e7fb42a48
commit
4575c110e6
@ -11,6 +11,9 @@ function truncAddr(addr, len) {
|
|||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sheet = document.createElement('style')
|
||||||
|
document.body.appendChild(sheet);
|
||||||
|
|
||||||
class Address extends React.Component {
|
class Address extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
@ -32,6 +35,7 @@ class Address extends React.Component {
|
|||||||
let actor = {}
|
let actor = {}
|
||||||
let actorInfo
|
let actorInfo
|
||||||
let minerInfo
|
let minerInfo
|
||||||
|
let nonce
|
||||||
|
|
||||||
try {
|
try {
|
||||||
balance = await this.props.client.call('Filecoin.WalletBalance', [this.props.addr])
|
balance = await this.props.client.call('Filecoin.WalletBalance', [this.props.addr])
|
||||||
@ -41,11 +45,14 @@ class Address extends React.Component {
|
|||||||
if(this.props.miner) {
|
if(this.props.miner) {
|
||||||
minerInfo = await this.props.client.call('Filecoin.StateMinerPower', [this.props.addr, this.props.ts || null])
|
minerInfo = await this.props.client.call('Filecoin.StateMinerPower', [this.props.addr, this.props.ts || null])
|
||||||
}
|
}
|
||||||
|
if(this.props.nonce) {
|
||||||
|
nonce = await this.props.client.call('Filecoin.MpoolGetNonce', [this.props.addr])
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
balance = -1
|
balance = -1
|
||||||
}
|
}
|
||||||
this.setState({balance, actor, actorInfo, minerInfo})
|
this.setState({balance, actor, actorInfo, minerInfo, nonce})
|
||||||
}
|
}
|
||||||
|
|
||||||
openState() {
|
openState() {
|
||||||
@ -71,10 +78,17 @@ class Address extends React.Component {
|
|||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add10k = async () => {
|
||||||
|
[...Array(10).keys()].map(() => async () => await this.props.add1k(this.props.addr)).reduce(async (p, c) => [await p, await c()], Promise.resolve(null))
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let add1k = <span/>
|
let add1k = <span/>
|
||||||
if(this.props.add1k) {
|
if(this.props.add1k) {
|
||||||
add1k = <span> <a href="#" onClick={() => this.props.add1k(this.props.addr)}>[+1k]</a></span>
|
add1k = <span> <a href="#" onClick={() => this.props.add1k(this.props.addr)}>[+1k]</a></span>
|
||||||
|
if (this.props.add10k) {
|
||||||
|
add1k = <span>{add1k} <a href="#" onClick={this.add10k}>[+10k]</a></span>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let addr = truncAddr(this.props.addr, this.props.short ? 12 : 17)
|
let addr = truncAddr(this.props.addr, this.props.short ? 12 : 17)
|
||||||
|
|
||||||
@ -84,6 +98,16 @@ class Address extends React.Component {
|
|||||||
addr = <a href="#" onClick={this.openState}>{addr}</a>
|
addr = <a href="#" onClick={this.openState}>{addr}</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addr = <span className={`pondaddr-${this.props.addr}`}
|
||||||
|
onMouseEnter={() => sheet.sheet.insertRule(`.pondaddr-${this.props.addr}, .pondaddr-${this.props.addr} * { color: #11ee11; }`, 0)}
|
||||||
|
onMouseLeave={() => sheet.sheet.deleteRule(0)}
|
||||||
|
>{addr}</span>
|
||||||
|
|
||||||
|
let nonce = <span/>
|
||||||
|
if(this.props.nonce) {
|
||||||
|
nonce = <span> <abbr title={"Next nonce"}>Nc:{this.state.nonce}</abbr>{nonce}</span>
|
||||||
|
}
|
||||||
|
|
||||||
let balance = <span>: {this.state.balance} </span>
|
let balance = <span>: {this.state.balance} </span>
|
||||||
if(this.props.nobalance) {
|
if(this.props.nobalance) {
|
||||||
balance = <span/>
|
balance = <span/>
|
||||||
@ -103,7 +127,7 @@ class Address extends React.Component {
|
|||||||
minerInfo = <span> Power: {this.state.minerInfo.MinerPower} ({this.state.minerInfo.MinerPower/this.state.minerInfo.TotalPower*100}%)</span>
|
minerInfo = <span> Power: {this.state.minerInfo.MinerPower} ({this.state.minerInfo.MinerPower/this.state.minerInfo.TotalPower*100}%)</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
return <span>{addr}{balance}{actInfo}{add1k}{transfer}{minerInfo}</span>
|
return <span>{addr}{balance}{actInfo}{nonce}{add1k}{transfer}{minerInfo}</span>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ class Client extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
kbs: 1,
|
kbs: 1,
|
||||||
blocks: 12,
|
blocks: 12,
|
||||||
total: "1000",
|
total: 36000,
|
||||||
miner: "t0101"
|
miner: "t0101"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -16,9 +16,9 @@ class Client extends React.Component {
|
|||||||
update = (name) => (e) => this.setState({ [name]: e.target.value });
|
update = (name) => (e) => this.setState({ [name]: e.target.value });
|
||||||
|
|
||||||
makeDeal = async () => {
|
makeDeal = async () => {
|
||||||
let file = await this.props.pondClient.call('Pond.CreateRandomFile', [this.state.kbs * 1000]) // 1024 won't fit in 1x blocks :(
|
let file = await this.props.pondClient.call('Pond.CreateRandomFile', [this.state.kbs * 1000]) // 1024 won't fit in 1k blocks :(
|
||||||
let cid = await this.props.client.call('Filecoin.ClientImport', [file])
|
let cid = await this.props.client.call('Filecoin.ClientImport', [file])
|
||||||
let dealcid = await this.props.client.call('Filecoin.ClientStartDeal', [cid, this.state.miner, this.state.total, this.state.blocks])
|
let dealcid = await this.props.client.call('Filecoin.ClientStartDeal', [cid, this.state.miner, `${Math.round(this.state.total / this.state.blocks)}`, this.state.blocks])
|
||||||
console.log("deal cid: ", dealcid)
|
console.log("deal cid: ", dealcid)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ class Client extends React.Component {
|
|||||||
<select><option>t0101</option></select>
|
<select><option>t0101</option></select>
|
||||||
<abbr title="Data length">L:</abbr> <input placeholder="KBs" defaultValue={1} onChange={this.update("kbs")}/>
|
<abbr title="Data length">L:</abbr> <input placeholder="KBs" defaultValue={1} onChange={this.update("kbs")}/>
|
||||||
<abbr title="Deal duration">Dur:</abbr><input placeholder="blocks" defaultValue={12} onChange={this.update("blocks")}/>
|
<abbr title="Deal duration">Dur:</abbr><input placeholder="blocks" defaultValue={12} onChange={this.update("blocks")}/>
|
||||||
Total: <input placeholder="total price" defaultValue={1000} onChange={this.update("total")}/>
|
Total: <input placeholder="total price" defaultValue={36000} onChange={this.update("total")}/>
|
||||||
<span><abbr title="Price per block">PpB:</abbr> {ppb} </span>
|
<span><abbr title="Price per block">PpB:</abbr> {ppb} </span>
|
||||||
<span><abbr title="Price per block-MiB">PpMbB:</abbr> {ppmbb} </span>
|
<span><abbr title="Price per block-MiB">PpMbB:</abbr> {ppmbb} </span>
|
||||||
<button onClick={this.makeDeal}>Deal!</button>
|
<button onClick={this.makeDeal}>Deal!</button>
|
||||||
|
@ -47,12 +47,16 @@ class FullNode extends React.Component {
|
|||||||
|
|
||||||
let minerList = await this.props.client.call('Filecoin.MinerAddresses', [])
|
let minerList = await this.props.client.call('Filecoin.MinerAddresses', [])
|
||||||
|
|
||||||
|
let mpoolPending = (await this.props.client.call('Filecoin.MpoolPending', [tipset])).length
|
||||||
|
|
||||||
this.setState(() => ({
|
this.setState(() => ({
|
||||||
id: id,
|
id: id,
|
||||||
version: version,
|
version: version,
|
||||||
peers: peers.length,
|
peers: peers.length,
|
||||||
tipset: tipset,
|
tipset: tipset,
|
||||||
|
|
||||||
|
mpoolPending: mpoolPending,
|
||||||
|
|
||||||
addrs: addrs,
|
addrs: addrs,
|
||||||
paychs: paychs,
|
paychs: paychs,
|
||||||
vouchers: vouchers,
|
vouchers: vouchers,
|
||||||
@ -101,7 +105,7 @@ class FullNode extends React.Component {
|
|||||||
<div>
|
<div>
|
||||||
Head: {
|
Head: {
|
||||||
<BlockLinks cids={this.state.tipset.Cids} conn={this.props.client} mountWindow={this.props.mountWindow} />
|
<BlockLinks cids={this.state.tipset.Cids} conn={this.props.client} mountWindow={this.props.mountWindow} />
|
||||||
} H:{this.state.tipset.Height} <a href="#" onClick={this.explorer}>[Explore]</a> <a href="#" onClick={this.client}>[Client]</a>
|
} H:{this.state.tipset.Height} Mp:{this.state.mpoolPending} <a href="#" onClick={this.explorer}>[Explore]</a> <a href="#" onClick={this.client}>[Client]</a>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -114,14 +118,14 @@ class FullNode extends React.Component {
|
|||||||
let storageMine = <a href="#" onClick={this.startStorageMiner}>[Spawn Storage Miner]</a>
|
let storageMine = <a href="#" onClick={this.startStorageMiner}>[Spawn Storage Miner]</a>
|
||||||
|
|
||||||
let addresses = this.state.addrs.map((addr) => {
|
let addresses = this.state.addrs.map((addr) => {
|
||||||
let line = <Address client={this.props.client} add1k={this.add1k} addr={addr} mountWindow={this.props.mountWindow}/>
|
let line = <Address client={this.props.client} add1k={this.add1k} add10k={true} nonce={true} addr={addr} mountWindow={this.props.mountWindow}/>
|
||||||
if (this.state.defaultAddr === addr) {
|
if (this.state.defaultAddr === addr) {
|
||||||
line = <b>{line}</b>
|
line = <b>{line}</b>
|
||||||
}
|
}
|
||||||
return <div key={addr}>{line}</div>
|
return <div key={addr}>{line}</div>
|
||||||
})
|
})
|
||||||
let paychannels = this.state.paychs.map((addr, ak) => {
|
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 line = <Address client={this.props.client} add1k={this.add1k} add10k={true} addr={addr} mountWindow={this.props.mountWindow}/>
|
||||||
const vouchers = this.state.vouchers[ak].map(voucher => {
|
const vouchers = this.state.vouchers[ak].map(voucher => {
|
||||||
let extra = <span></span>
|
let extra = <span></span>
|
||||||
if(voucher.Extra) {
|
if(voucher.Extra) {
|
||||||
|
@ -81,7 +81,7 @@ class NodeList extends React.Component {
|
|||||||
return [addr, balance]
|
return [addr, balance]
|
||||||
}).reduce(async (c, n) => (await c)[1] > (await n)[1] ? await c : await n, Promise.resolve(['', -2]))
|
}).reduce(async (c, n) => (await c)[1] > (await n)[1] ? await c : await n, Promise.resolve(['', -2]))
|
||||||
|
|
||||||
pushMessage(this.state.nodes[1].conn, bestaddr, {
|
await pushMessage(this.state.nodes[1].conn, bestaddr, {
|
||||||
To: to,
|
To: to,
|
||||||
From: bestaddr,
|
From: bestaddr,
|
||||||
Value: "1000",
|
Value: "1000",
|
||||||
|
Loading…
Reference in New Issue
Block a user