(Fix) Light optimization
This commit is contained in:
parent
ca50f9e999
commit
b07af3dba9
|
@ -164,6 +164,42 @@ export class BallotCard extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
@action("Get votingState")
|
||||
getVotingState = async () => {
|
||||
const { contractsStore, id, votingType } = this.props;
|
||||
const votingState = await this.repeatGetProperty(contractsStore, votingType, id, "votingState", 0);
|
||||
if (votingState) {
|
||||
// getTimes
|
||||
this.startTime = moment.utc(votingState.startTime * 1000).format(USDateTimeFormat);
|
||||
this.endTime = moment.utc(votingState.endTime * 1000).format(USDateTimeFormat);
|
||||
this.calcTimeTo();
|
||||
// getCreator
|
||||
this.getValidatorFullname(votingState.creator);
|
||||
// getTotalVoters
|
||||
if (votingState.totalVoters) {
|
||||
this.totalVoters = Number(votingState.totalVoters);
|
||||
}
|
||||
// getProgress
|
||||
if (votingState.progress) {
|
||||
this.progress = Number(votingState.progress);
|
||||
}
|
||||
// getIsFinalized
|
||||
this.isFinalized = votingState.isFinalized;
|
||||
// getMemo
|
||||
this.memo = votingState.memo;
|
||||
} else {
|
||||
this.getTimes();
|
||||
const creator = await this.repeatGetProperty(contractsStore, votingType, id, "getCreator", 0);
|
||||
if (creator) {
|
||||
this.getValidatorFullname(creator);
|
||||
}
|
||||
this.getTotalVoters();
|
||||
this.getProgress();
|
||||
this.getIsFinalized();
|
||||
this.getMemo();
|
||||
}
|
||||
}
|
||||
|
||||
@action("Get progress")
|
||||
getProgress = async () => {
|
||||
const { contractsStore, id, votingType } = this.props;
|
||||
|
@ -371,13 +407,8 @@ export class BallotCard extends React.Component {
|
|||
super(props);
|
||||
this.isFinalized = false;
|
||||
this.hasAlreadyVoted = false;
|
||||
this.getTimes();
|
||||
this.getCreator();
|
||||
this.getTotalVoters();
|
||||
this.getProgress();
|
||||
this.getVotingState();
|
||||
this.getHasAlreadyVoted();
|
||||
this.getIsFinalized();
|
||||
this.getMemo();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
|
@ -33,6 +33,43 @@ export class BallotKeysCard extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
@action("Get votingState of keys ballot")
|
||||
getVotingState = async () => {
|
||||
const { contractsStore, id } = this.props;
|
||||
let votingState;
|
||||
try {
|
||||
votingState = await contractsStore.votingToChangeKeys.votingState(id);
|
||||
} catch(e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
if (votingState) {
|
||||
this.affectedKey = votingState.affectedKey;
|
||||
this.affectedKeyType = votingState.affectedKeyType;
|
||||
this.ballotType = votingState.ballotType;
|
||||
this.getBallotTypeDisplayName(this.ballotType);
|
||||
this.miningKey = votingState.miningKey;
|
||||
|
||||
if (this.miningKey && this.miningKey !== '0x0000000000000000000000000000000000000000') {
|
||||
let metadata;
|
||||
try {
|
||||
metadata = await contractsStore.getValidatorMetadata(this.miningKey);
|
||||
} catch(e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
if (metadata) {
|
||||
this.miningKey = `${metadata.lastName} ${this.miningKey}`;
|
||||
} else {
|
||||
this.miningKey = `${this.miningKey}`;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.getAffectedKey();
|
||||
this.getAffectedKeyType();
|
||||
this.getBallotType();
|
||||
this.getMiningKey();
|
||||
}
|
||||
}
|
||||
|
||||
@action("Get ballot type of keys ballot")
|
||||
getBallotType = async () => {
|
||||
const { contractsStore, id } = this.props;
|
||||
|
@ -109,6 +146,7 @@ export class BallotKeysCard extends React.Component {
|
|||
} catch(e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
if (miningKey && miningKey !== '0x0000000000000000000000000000000000000000') {
|
||||
try {
|
||||
metadata = await contractsStore.getValidatorMetadata(miningKey);
|
||||
} catch(e) {
|
||||
|
@ -120,15 +158,13 @@ export class BallotKeysCard extends React.Component {
|
|||
this.miningKey = `${miningKey}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.getAffectedKey();
|
||||
this.getVotingState();
|
||||
this.getNewVotingKey();
|
||||
this.getNewPayoutKey();
|
||||
this.getAffectedKeyType();
|
||||
this.getBallotType();
|
||||
this.getMiningKey();
|
||||
}
|
||||
|
||||
getAffectedKeyTypeDisplayName = () => {
|
||||
|
|
Loading…
Reference in New Issue