(Update) Add isMasterOfCeremonyRemoved() and update web3
This commit is contained in:
parent
0f3e5fb40a
commit
38663f657c
File diff suppressed because it is too large
Load Diff
|
@ -20,7 +20,7 @@
|
|||
"react-scripts": "1.0.17",
|
||||
"react-select": "^1.2.1",
|
||||
"sweetalert": "^2.0.8",
|
||||
"web3": "^1.0.0-beta.26"
|
||||
"web3": "^1.0.0-beta.34"
|
||||
},
|
||||
"scripts": {
|
||||
"predeploy": "npm run build",
|
||||
|
|
|
@ -69,7 +69,7 @@ export default class AllValidators extends Component {
|
|||
</Validator>
|
||||
)
|
||||
}
|
||||
const isValidatorsPage = this.props.methodToCall == 'getAllValidatorsData';
|
||||
const isValidatorsPage = this.props.methodToCall === 'getAllValidatorsData';
|
||||
const validatorsCountObj = <div className="validators-count">
|
||||
<span className="validators-count-label">Total number of validators: </span>
|
||||
<span className="validators-count-val">{this.state.validators.length}</span>
|
||||
|
|
|
@ -82,12 +82,12 @@ export default class Metadata {
|
|||
let createdDate = validatorData.createdDate > 0 ? moment.unix(validatorData.createdDate).format('YYYY-MM-DD') : ''
|
||||
let updatedDate = validatorData.updatedDate > 0 ? moment.unix(validatorData.updatedDate).format('YYYY-MM-DD') : ''
|
||||
let expirationDate = validatorData.expirationDate > 0 ? moment.unix(validatorData.expirationDate).format('YYYY-MM-DD') : ''
|
||||
if (validatorData.zipcode.length === 4) {
|
||||
validatorData.zipcode = "0" + validatorData.zipcode;
|
||||
}
|
||||
if (validatorData.zipcode === "0") {
|
||||
validatorData.zipcode = '';
|
||||
}
|
||||
//if (validatorData.zipcode.length === 4) {
|
||||
// validatorData.zipcode = "0" + validatorData.zipcode;
|
||||
//}
|
||||
//if (validatorData.zipcode === "0") {
|
||||
// validatorData.zipcode = '';
|
||||
//}
|
||||
return {
|
||||
firstName: toAscii(validatorData.firstName),
|
||||
lastName: toAscii(validatorData.lastName),
|
||||
|
@ -114,17 +114,24 @@ export default class Metadata {
|
|||
async getAllValidatorsData(netId){
|
||||
let all = [];
|
||||
return new Promise(async(resolve, reject) => {
|
||||
const poaInstance = new PoaConsensus()
|
||||
await poaInstance.init({web3: this.web3_10, netId, addresses: this.addresses})
|
||||
const keys = await poaInstance.getValidators()
|
||||
console.log(keys)
|
||||
const poaInstance = new PoaConsensus();
|
||||
await poaInstance.init({web3: this.web3_10, netId, addresses: this.addresses});
|
||||
const keys = await poaInstance.getValidators();
|
||||
console.log(keys);
|
||||
const mocAddressLowercase = this.MOC_ADDRESS.toLowerCase();
|
||||
const mocRemoved = await poaInstance.isMasterOfCeremonyRemoved();
|
||||
for (let key of keys) {
|
||||
let data = await this.getValidatorData({miningKey: key})
|
||||
if(key.toLowerCase() === this.MOC_ADDRESS.toLowerCase()) {
|
||||
data = this.getMocData()
|
||||
let data;
|
||||
if (key.toLowerCase() === mocAddressLowercase) {
|
||||
if (mocRemoved) {
|
||||
continue;
|
||||
}
|
||||
data = this.getMocData();
|
||||
} else {
|
||||
data = await this.getValidatorData({miningKey: key});
|
||||
}
|
||||
data.address = key
|
||||
all.push(data)
|
||||
data.address = key;
|
||||
all.push(data);
|
||||
}
|
||||
resolve(all);
|
||||
})
|
||||
|
|
|
@ -17,4 +17,10 @@ export default class POAConsensus {
|
|||
console.log(this.poaInstance)
|
||||
return await this.poaInstance.methods.getValidators().call();
|
||||
}
|
||||
async isMasterOfCeremonyRemoved(){
|
||||
if (this.poaInstance.methods.isMasterOfCeremonyRemoved) {
|
||||
return await this.poaInstance.methods.isMasterOfCeremonyRemoved().call();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue