Voting form did not display during pagination

This commit is contained in:
Richard Ramos 2018-06-25 10:19:10 -04:00
parent 723b5a2cac
commit e160a028cf
4 changed files with 20 additions and 15 deletions

View File

@ -21,14 +21,14 @@ class InnerForm extends PureComponent {
}
componentDidMount(){
this.loadPrice();
this._loadPrice();
}
componentWillReceiveProps(){
this.loadPrice();
this._loadPrice();
}
async loadPrice(){
_loadPrice(){
__embarkContext.execWhenReady(async () => {
try {
let _b = await ProposalCuration.methods.getSubmitPrice(web3.eth.defaultAccount).call();

View File

@ -15,9 +15,20 @@ class Voting extends Component {
};
}
componentWillReceiveProps(){
__embarkContext.execWhenReady(async () => {
this._loadProposalData();
});
}
componentDidMount(){
__embarkContext.execWhenReady(async () => {
ProposalManager.options.address = await ProposalCuration.methods.proposalManager().call();
this._loadProposalData();
});
}
async _loadProposalData() {
ProposalManager.options.address = await ProposalCuration.methods.proposalManager().call();
let _proposal = await ProposalManager.methods.getVoteInfo(this.props.proposalId, web3.eth.defaultAccount).call();
let blockNum = await web3.eth.getBlockNumber();
let _data = await ProposalManager.methods.proposals(this.props.proposalId).call();
@ -28,7 +39,6 @@ class Voting extends Component {
block: blockNum,
finalResult: _data.result
});
});
}
async determineFinalResult(e){
@ -39,9 +49,7 @@ class Voting extends Component {
if(receipt.status == '0x1'){
this.setState({
decision: choice,
block: blockNum,
finalResult: receipt.events.ProposalResult.finalResult
finalResult: receipt.events.ProposalResult.returnValues.finalResult
});
}
}
@ -71,7 +79,6 @@ class Voting extends Component {
}
render(){
console.log(this.state);
return <div>
{
this.state.decision != 0 ?

View File

@ -56,7 +56,7 @@ contract ProposalCuration is Controlled {
uint256 submitPrice = getSubmitPrice(msg.sender);
require(token.allowance(msg.sender, address(this)) >= submitPrice);
require(token.transferFrom(msg.sender, address(this), submitPrice));
proposalId = proposalManager.addProposal(_topic,keccak256(_to,_value,_data), 0, 1000);
proposalId = proposalManager.addProposal(_topic,keccak256(_to,_value,_data));
proposals[proposalId] = ProposalData(
msg.sender,
_to,

View File

@ -58,9 +58,7 @@ contract ProposalManager is Controlled {
function addProposal(
bytes32 _topic,
bytes32 _txHash,
uint blocksUntilVotingStart,
uint voteDuration
bytes32 _txHash
)
public
returns (uint proposalId)
@ -72,8 +70,8 @@ contract ProposalManager is Controlled {
p.topic = _topic;
p.txHash = _txHash;
p.blockStart = block.number + blocksUntilVotingStart; //will be replaced by configurations
p.voteBlockEnd = p.blockStart + voteDuration; //dummy value
p.blockStart = block.number + 1; //TODO: will be replaced by configurations
p.voteBlockEnd = p.blockStart + 10; //TODO: dummy value
emit ProposalSet(_topic, proposalId, _txHash);
}