Merge pull request #57 from poanetwork/revert-55-core

Revert "(Fix) Change metadata zipcode from numeric to short string and other fixes"
This commit is contained in:
Victor Baranov 2018-04-09 13:22:51 +03:00 committed by GitHub
commit 288ea4e3b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 12 deletions

View File

@ -43,7 +43,7 @@ class App extends Component {
}
async setMetadata(){
const currentData = await this.getMetadataContract().getValidatorData({votingKey: this.getVotingKey()});
const hasData = currentData.postal_code ? true : false
const hasData = Number(currentData.postal_code) > 0 ? true : false
this.defaultValues = currentData;
const pendingChange = await this.getMetadataContract().getPendingChange({votingKey: this.getVotingKey()});
if(Number(pendingChange.minThreshold) > 0 ) {
@ -105,7 +105,7 @@ class App extends Component {
var addressType = place[0].address_components[i].types[0];
switch(addressType) {
case "postal_code":
address_components.postal_code = place[0].address_components[i].short_name;
address_components.postal_code = Number(place[0].address_components[i].short_name);
break;
case "street_number":
address_components.street_number = place[0].address_components[i].short_name;
@ -217,7 +217,7 @@ class App extends Component {
</div>
<div className="create-keys-form-i">
<label htmlFor="zip">Zip code</label>
<input type="text" id="postal_code" value={this.state.form.postal_code} onChange={this.onChangeFormField}/>
<input type="number" id="postal_code" value={this.state.form.postal_code} onChange={this.onChangeFormField}/>
<label htmlFor="licenseId">License id</label>
<input type="text" id="licenseId" value={this.state.form.licenseId} onChange={this.onChangeFormField}/>
<label htmlFor="expirationDate">License expiration</label>

View File

@ -7,7 +7,7 @@ class Validator extends Component {
confirmation: null
}
this.props.metadataContract.getConfirmations({miningKey: this.props.address}).then((confirmation) => {
this.setState({confirmation: confirmation[0]})
this.setState({confirmation})
})
}
render(){

View File

@ -51,7 +51,7 @@ export default class Metadata {
this.web3_10.utils.fromAscii(licenseId),
fullAddress,
this.web3_10.utils.fromAscii(state),
this.web3_10.utils.fromAscii(zipcode),
zipcode,
expirationDate
).send({from: votingKey, gasPrice});
}
@ -67,7 +67,7 @@ export default class Metadata {
expirationDate: '2021-07-23',
licenseId: '2206724',
us_state: 'CA',
postal_code: '94404',
postal_code: 94404,
}
}
@ -82,10 +82,10 @@ 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) {
if(validatorData.zipcode.length === 4){
validatorData.zipcode = "0" + validatorData.zipcode;
}
if (validatorData.zipcode === "0") {
if(validatorData.zipcode === "0"){
validatorData.zipcode = '';
}
return {
@ -97,7 +97,7 @@ export default class Metadata {
expirationDate,
licenseId: toAscii(validatorData.licenseId),
us_state: toAscii(validatorData.state),
postal_code: toAscii(validatorData.zipcode),
postal_code: validatorData.zipcode,
}
}
@ -141,6 +141,7 @@ export default class Metadata {
let createdDate = pendingChanges.createdDate > 0 ? moment.unix(pendingChanges.createdDate).format('YYYY-MM-DD') : ''
let updatedDate = pendingChanges.updatedDate > 0 ? moment.unix(pendingChanges.updatedDate).format('YYYY-MM-DD') : ''
let expirationDate = pendingChanges.expirationDate > 0 ? moment.unix(pendingChanges.expirationDate).format('YYYY-MM-DD') : ''
let postal_code = Number(pendingChanges.zipcode) || ''
return {
firstName: toAscii(pendingChanges.firstName),
lastName: toAscii(pendingChanges.lastName),
@ -150,7 +151,7 @@ export default class Metadata {
expirationDate,
licenseId: toAscii(pendingChanges.licenseId),
us_state: toAscii(pendingChanges.state),
postal_code: toAscii(pendingChanges.zipcode),
postal_code,
minThreshold: pendingChanges.minThreshold
}
}
@ -162,7 +163,7 @@ export default class Metadata {
for (let key of miningKeys) {
let pendingChange = await this.getPendingChange({miningKey: key})
pendingChange.address = key;
if (pendingChange.postal_code) {
if(pendingChange.postal_code > 0){
pendingChanges.push(pendingChange)
}
}
@ -200,7 +201,7 @@ export default class Metadata {
async finalize({miningKeyToConfirm, senderVotingKey}) {
const confirmations = await this.getConfirmations({miningKey: miningKeyToConfirm});
const getMinThreshold = await this.getMinThreshold({miningKey: miningKeyToConfirm});
if(Number(confirmations[0]) < Number(getMinThreshold)){
if(Number(confirmations) < Number(getMinThreshold)){
throw(
{message:
`There is not enough confimations.\n