From 6f3285d2fbf182155a3cc123233c86029652ce80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 25 Jul 2019 16:57:30 +0200 Subject: [PATCH] pond: List node balances --- lotuspond/front/src/App.css | 10 ++++++++-- lotuspond/front/src/FullNode.js | 33 +++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/lotuspond/front/src/App.css b/lotuspond/front/src/App.css index 506b71a77..afa44fac2 100644 --- a/lotuspond/front/src/App.css +++ b/lotuspond/front/src/App.css @@ -6,8 +6,14 @@ .FullNode { background: #f9be77; - margin-bottom: 5px; - padding: 5px; user-select: text; font-family: monospace; + min-width: 40em; + width: 100%; +} + +.CristalScroll { + width: 100%; + height: 100%; + overflow: auto; } \ No newline at end of file diff --git a/lotuspond/front/src/FullNode.js b/lotuspond/front/src/FullNode.js index 848767825..1d17d067b 100644 --- a/lotuspond/front/src/FullNode.js +++ b/lotuspond/front/src/FullNode.js @@ -6,6 +6,10 @@ const stateConnected = 'connected' const stateConnecting = 'connecting' const stateGettingToken = 'getting-token' +async function awaitListReducer(prev, c) { + return [...await prev, await c] +} + class FullNode extends React.Component { constructor(props) { super(props) @@ -41,7 +45,8 @@ class FullNode extends React.Component { version: {Version: "~version~"}, id: "~peerid~", - peers: -1 + peers: -1, + balances: [] })) const id = await this.state.client.call("Filecoin.ID", []) @@ -50,7 +55,7 @@ class FullNode extends React.Component { this.props.onConnect(client, id) this.loadInfo() - setInterval(this.loadInfo, 1000) + setInterval(this.loadInfo, 2050) }) console.log(token) // todo: use @@ -65,6 +70,15 @@ class FullNode extends React.Component { const tipset = await this.state.client.call("Filecoin.ChainHead", []) this.setState(() => ({tipset: tipset})) + + const addrss = await this.state.client.call('Filecoin.WalletList', []) + + const balances = await addrss.map(async addr => { + const balance = await this.state.client.call('Filecoin.WalletBalance', [addr]) + return [addr, balance] + }).reduce(awaitListReducer, Promise.resolve([])) + + this.setState(() => ({balances: balances})) } async startMining() { @@ -89,12 +103,18 @@ class FullNode extends React.Component { mine = "Mining" } + let balances = this.state.balances.map(([addr, balance]) => (
{addr}: {balance} (ActTyp)
)) + runtime = (
v{this.state.version.Version}, {this.state.id.substr(-8)}, {this.state.peers} peers
Repo: LOTUS_PATH={this.props.node.Repo}
{chainInfo} {mine} +
+
Balances:
+
{balances}
+
) @@ -104,10 +124,11 @@ class FullNode extends React.Component { - -
-
{this.props.node.ID} - {this.state.state}
- {runtime} +
+
+
{this.props.node.ID} - {this.state.state}
+ {runtime} +
)