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

View File

@ -56,7 +56,7 @@ contract ProposalCuration is Controlled {
uint256 submitPrice = getSubmitPrice(msg.sender); uint256 submitPrice = getSubmitPrice(msg.sender);
require(token.allowance(msg.sender, address(this)) >= submitPrice); require(token.allowance(msg.sender, address(this)) >= submitPrice);
require(token.transferFrom(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( proposals[proposalId] = ProposalData(
msg.sender, msg.sender,
_to, _to,

View File

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