From 619c6c8ff482fa69ce0fb05978948dff67aa15b4 Mon Sep 17 00:00:00 2001 From: Vadim Arasev Date: Tue, 8 May 2018 11:49:56 +0300 Subject: [PATCH] (Update) "Contract Type" drop down list and getCreator method Add ValidatorMetadata and ProxyStorage to drop down list and getCreator method to VotingToChange* contracts --- src/components/BallotCard.jsx | 11 ++++++++--- src/components/BallotProxyMetadata.jsx | 2 ++ src/contracts/VotingToChangeKeys.contract.js | 12 +++++++++++- src/contracts/VotingToChangeMinThreshold.contract.js | 12 +++++++++++- src/contracts/VotingToChangeProxy.contract.js | 12 +++++++++++- src/stores/BallotStore.js | 4 +++- 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/components/BallotCard.jsx b/src/components/BallotCard.jsx index 9efea33..03331d8 100644 --- a/src/components/BallotCard.jsx +++ b/src/components/BallotCard.jsx @@ -147,9 +147,14 @@ export class BallotCard extends React.Component { @action("Get creator") getCreator = async () => { const { contractsStore, id, votingType } = this.props; - let votingState = await this.repeatGetProperty(contractsStore, votingType, id, "votingState", 0); - if (votingState) { - this.getValidatorFullname(votingState.creator); + let creator = await this.repeatGetProperty(contractsStore, votingType, id, "getCreator", 0); + if (creator) { + this.getValidatorFullname(creator); + } else { + let votingState = await this.repeatGetProperty(contractsStore, votingType, id, "votingState", 0); + if (votingState) { + this.getValidatorFullname(votingState.creator); + } } } diff --git a/src/components/BallotProxyMetadata.jsx b/src/components/BallotProxyMetadata.jsx index 1966fd7..b7b7488 100644 --- a/src/components/BallotProxyMetadata.jsx +++ b/src/components/BallotProxyMetadata.jsx @@ -35,6 +35,8 @@ export class BallotProxyMetadata extends React.Component { { value: '3', label: ballotStore.ProxyBallotType[3] }, { value: '4', label: ballotStore.ProxyBallotType[4] }, { value: '5', label: ballotStore.ProxyBallotType[5] }, + { value: '7', label: ballotStore.ProxyBallotType[7] }, + { value: '8', label: ballotStore.ProxyBallotType[8] }, ]} > diff --git a/src/contracts/VotingToChangeKeys.contract.js b/src/contracts/VotingToChangeKeys.contract.js index 320702a..f890ded 100644 --- a/src/contracts/VotingToChangeKeys.contract.js +++ b/src/contracts/VotingToChangeKeys.contract.js @@ -43,7 +43,17 @@ export default class VotingToChangeKeys { } votingState(_id) { - return this.votingToChangeKeysInstance.methods.votingState(_id).call(); + if (this.votingToChangeKeysInstance.methods.votingState) { + return this.votingToChangeKeysInstance.methods.votingState(_id).call(); + } + return null; + } + + getCreator(_id) { + if (this.votingToChangeKeysInstance.methods.getCreator) { + return this.votingToChangeKeysInstance.methods.getCreator(_id).call(); + } + return null; } getTotalVoters(_id) { diff --git a/src/contracts/VotingToChangeMinThreshold.contract.js b/src/contracts/VotingToChangeMinThreshold.contract.js index 586c51a..64a077f 100644 --- a/src/contracts/VotingToChangeMinThreshold.contract.js +++ b/src/contracts/VotingToChangeMinThreshold.contract.js @@ -39,7 +39,17 @@ export default class VotingToChangeMinThreshold { } votingState(_id) { - return this.votingToChangeMinThresholdInstance.methods.votingState(_id).call(); + if (this.votingToChangeMinThresholdInstance.methods.votingState) { + return this.votingToChangeMinThresholdInstance.methods.votingState(_id).call(); + } + return null; + } + + getCreator(_id) { + if (this.votingToChangeMinThresholdInstance.methods.getCreator) { + return this.votingToChangeMinThresholdInstance.methods.getCreator(_id).call(); + } + return null; } getTotalVoters(_id) { diff --git a/src/contracts/VotingToChangeProxy.contract.js b/src/contracts/VotingToChangeProxy.contract.js index 717f5cb..461b1eb 100644 --- a/src/contracts/VotingToChangeProxy.contract.js +++ b/src/contracts/VotingToChangeProxy.contract.js @@ -39,7 +39,17 @@ export default class VotingToChangeProxy { } votingState(_id) { - return this.votingToChangeProxyInstance.methods.votingState(_id).call(); + if (this.votingToChangeProxyInstance.methods.votingState) { + return this.votingToChangeProxyInstance.methods.votingState(_id).call(); + } + return null; + } + + getCreator(_id) { + if (this.votingToChangeProxyInstance.methods.getCreator) { + return this.votingToChangeProxyInstance.methods.getCreator(_id).call(); + } + return null; } getTotalVoters(_id) { diff --git a/src/stores/BallotStore.js b/src/stores/BallotStore.js index f06a20f..c399f6a 100644 --- a/src/stores/BallotStore.js +++ b/src/stores/BallotStore.js @@ -22,7 +22,9 @@ class BallotStore { 2: 'VotingToChangeKeys', 3: 'VotingToChangeMinThreshold', 4: 'VotingToChangeProxy', - 5: 'BallotsStorage' + 5: 'BallotsStorage', + 7: 'ValidatorMetadata', + 8: 'ProxyStorage' } @observable ballotType; @observable keysBallotType;