Obtaining SNT balance
This commit is contained in:
parent
55f1e283a1
commit
344efdd06e
|
@ -58,6 +58,7 @@ class AccList extends React.Component {
|
||||||
if(defaultAcc){
|
if(defaultAcc){
|
||||||
web3.eth.defaultAccount = defaultAcc;
|
web3.eth.defaultAccount = defaultAcc;
|
||||||
this.setState({defaultAccount: defaultAcc });
|
this.setState({defaultAccount: defaultAcc });
|
||||||
|
this.props.accountUpdateHandler(defaultAcc);
|
||||||
} else {
|
} else {
|
||||||
console.log("invalid account")
|
console.log("invalid account")
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class TopNavbar extends React.Component {
|
||||||
<a href="#home">Status.im Demo</a>
|
<a href="#home">Status.im Demo</a>
|
||||||
</Navbar.Brand>
|
</Navbar.Brand>
|
||||||
</Navbar.Header>
|
</Navbar.Header>
|
||||||
<AccountList classNameNavDropdown="pull-right" />
|
<AccountList accountUpdateHandler={this.props.accountUpdateHandler} classNameNavDropdown="pull-right" />
|
||||||
</Navbar>
|
</Navbar>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
const Paginator = (props) => '<< | < | 1 | 2 | 3 | > | >>';
|
||||||
|
export default Paginator;
|
|
@ -5,6 +5,7 @@ import React from 'react';
|
||||||
import ProposalForm from './proposal-form';
|
import ProposalForm from './proposal-form';
|
||||||
import Proposal from './proposal';
|
import Proposal from './proposal';
|
||||||
import ProposalList from './proposal-list';
|
import ProposalList from './proposal-list';
|
||||||
|
import Paginator from './paginator';
|
||||||
|
|
||||||
class ProposalContainer extends React.Component {
|
class ProposalContainer extends React.Component {
|
||||||
|
|
||||||
|
@ -25,7 +26,10 @@ class ProposalContainer extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
return <ProposalList proposals={this.state.proposals} />;
|
return <React.Fragment>
|
||||||
|
<ProposalList proposals={this.state.proposals} />
|
||||||
|
<Paginator />
|
||||||
|
</React.Fragment>;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
import web3 from "Embark/web3"
|
||||||
|
import EmbarkJS from 'Embark/EmbarkJS';
|
||||||
|
import React from 'react';
|
||||||
|
import SNT from 'Embark/contracts/TestToken'; // TODO change this to SNT
|
||||||
|
|
||||||
|
class StatusBar extends React.Component {
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
balance: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(){
|
||||||
|
__embarkContext.execWhenReady(async () => {
|
||||||
|
let _b = await SNT.methods.balanceOf(web3.eth.defaultAccount).call();
|
||||||
|
this.setState({
|
||||||
|
balance: _b
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render(){
|
||||||
|
return <div className="SNTBalance">
|
||||||
|
SNT Voting Balance: <span>{this.state.balance}</span>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default StatusBar;
|
|
@ -4,6 +4,7 @@ import React from 'react';
|
||||||
|
|
||||||
import ProposalForm from './proposal-form';
|
import ProposalForm from './proposal-form';
|
||||||
import ProposalContainer from './proposal-container';
|
import ProposalContainer from './proposal-container';
|
||||||
|
import StatusBar from './status-bar';
|
||||||
|
|
||||||
class VotingDapp extends React.Component {
|
class VotingDapp extends React.Component {
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ class VotingDapp extends React.Component {
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
return <div>
|
return <div>
|
||||||
|
<StatusBar />
|
||||||
<ProposalContainer />
|
<ProposalContainer />
|
||||||
<ProposalForm />
|
<ProposalForm />
|
||||||
</div>;
|
</div>;
|
||||||
|
|
|
@ -61,3 +61,9 @@
|
||||||
input.form-control {
|
input.form-control {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.SNTBalance {
|
||||||
|
float: right;
|
||||||
|
display: block;
|
||||||
|
}
|
|
@ -22,6 +22,9 @@ class App extends React.Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setAccount(_account){
|
||||||
|
this.setState({account: _account});
|
||||||
|
}
|
||||||
|
|
||||||
_renderStatus(title, available) {
|
_renderStatus(title, available) {
|
||||||
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
|
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
|
||||||
|
@ -34,7 +37,7 @@ class App extends React.Component {
|
||||||
render(){
|
render(){
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<TopNavbar />
|
<TopNavbar accountUpdateHandler={(e) => this.setAccount(e)} />
|
||||||
<Tabs defaultActiveKey={1} id="uncontrolled-tab-example">
|
<Tabs defaultActiveKey={1} id="uncontrolled-tab-example">
|
||||||
<Tab eventKey={0} title="VotingDapp">
|
<Tab eventKey={0} title="VotingDapp">
|
||||||
<VotingDapp />
|
<VotingDapp />
|
||||||
|
|
|
@ -58,7 +58,20 @@
|
||||||
"deploy": false
|
"deploy": false
|
||||||
},
|
},
|
||||||
"TestToken": {
|
"TestToken": {
|
||||||
"deploy": false
|
"deploy": true
|
||||||
|
},
|
||||||
|
"SNT": {
|
||||||
|
"instanceOf": "MiniMeToken",
|
||||||
|
"deploy": true,
|
||||||
|
"args": [
|
||||||
|
"$MiniMeTokenFactory",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
"TestMiniMeToken",
|
||||||
|
18,
|
||||||
|
"TST",
|
||||||
|
true
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue