mirror of
https://github.com/status-im/snt-voting.git
synced 2025-02-23 15:48:10 +00:00
Obtaining SNT balance
This commit is contained in:
parent
55f1e283a1
commit
344efdd06e
@ -58,6 +58,7 @@ class AccList extends React.Component {
|
||||
if(defaultAcc){
|
||||
web3.eth.defaultAccount = defaultAcc;
|
||||
this.setState({defaultAccount: defaultAcc });
|
||||
this.props.accountUpdateHandler(defaultAcc);
|
||||
} else {
|
||||
console.log("invalid account")
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class TopNavbar extends React.Component {
|
||||
<a href="#home">Status.im Demo</a>
|
||||
</Navbar.Brand>
|
||||
</Navbar.Header>
|
||||
<AccountList classNameNavDropdown="pull-right" />
|
||||
<AccountList accountUpdateHandler={this.props.accountUpdateHandler} classNameNavDropdown="pull-right" />
|
||||
</Navbar>
|
||||
</React.Fragment>
|
||||
);
|
||||
|
2
app/components/voting-dapp/paginator.js
Normal file
2
app/components/voting-dapp/paginator.js
Normal file
@ -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 Proposal from './proposal';
|
||||
import ProposalList from './proposal-list';
|
||||
import Paginator from './paginator';
|
||||
|
||||
class ProposalContainer extends React.Component {
|
||||
|
||||
@ -25,7 +26,10 @@ class ProposalContainer extends React.Component {
|
||||
}
|
||||
|
||||
render(){
|
||||
return <ProposalList proposals={this.state.proposals} />;
|
||||
return <React.Fragment>
|
||||
<ProposalList proposals={this.state.proposals} />
|
||||
<Paginator />
|
||||
</React.Fragment>;
|
||||
}
|
||||
|
||||
}
|
||||
|
32
app/components/voting-dapp/status-bar.js
Normal file
32
app/components/voting-dapp/status-bar.js
Normal file
@ -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 ProposalContainer from './proposal-container';
|
||||
import StatusBar from './status-bar';
|
||||
|
||||
class VotingDapp extends React.Component {
|
||||
|
||||
@ -16,6 +17,7 @@ class VotingDapp extends React.Component {
|
||||
|
||||
render(){
|
||||
return <div>
|
||||
<StatusBar />
|
||||
<ProposalContainer />
|
||||
<ProposalForm />
|
||||
</div>;
|
||||
|
@ -60,4 +60,10 @@
|
||||
|
||||
input.form-control {
|
||||
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) {
|
||||
let className = available ? 'pull-right status-online' : 'pull-right status-offline';
|
||||
@ -34,7 +37,7 @@ class App extends React.Component {
|
||||
render(){
|
||||
return (
|
||||
<div>
|
||||
<TopNavbar />
|
||||
<TopNavbar accountUpdateHandler={(e) => this.setAccount(e)} />
|
||||
<Tabs defaultActiveKey={1} id="uncontrolled-tab-example">
|
||||
<Tab eventKey={0} title="VotingDapp">
|
||||
<VotingDapp />
|
||||
|
@ -58,7 +58,20 @@
|
||||
"deploy": false
|
||||
},
|
||||
"TestToken": {
|
||||
"deploy": false
|
||||
"deploy": true
|
||||
},
|
||||
"SNT": {
|
||||
"instanceOf": "MiniMeToken",
|
||||
"deploy": true,
|
||||
"args": [
|
||||
"$MiniMeTokenFactory",
|
||||
0,
|
||||
0,
|
||||
"TestMiniMeToken",
|
||||
18,
|
||||
"TST",
|
||||
true
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user