1
0
Fork 0
forked from lthn/blockchain

fix error start getting aliases after syncing

This commit is contained in:
wildkif 2019-02-07 17:36:07 +02:00
parent 444547341b
commit 1a589f693c
8 changed files with 48 additions and 51 deletions

View file

@ -13,7 +13,7 @@ export class Wallet {
mined_total: number;
tracking_hey: string;
alias?: string;
alias?: object;
staking?: boolean;
new_messages?: number;
new_contracts?: number;
@ -45,7 +45,7 @@ export class Wallet {
this.mined_total = mined;
this.tracking_hey = tracking;
this.alias = '';
this.alias = {};
this.staking = false;
this.new_messages = 0;
this.new_contracts = 0;

View file

@ -38,10 +38,10 @@ export class HistoryTypeMessagesPipe implements PipeTransform {
// return '';
// case 3:
// return '';
// case 4:
// return '';
// case 5:
// return '';
case 4:
return this.translate.instant('HISTORY.TYPE_MESSAGES.CREATE_ALIAS');
case 5:
return this.translate.instant('HISTORY.TYPE_MESSAGES.UPDATE_ALIAS');
case 6:
return this.translate.instant('HISTORY.TYPE_MESSAGES.MINED');
case 7:

View file

@ -511,12 +511,12 @@ export class BackendService {
}
registerAlias (wallet_id, alias, address, fee, comment, reward, callback) {
let params = {
const params = {
wallet_id: wallet_id,
alias: {
alias: alias,
address: address,
tracking_key: "",
tracking_key: '',
comment: comment
},
fee: this.moneyToIntPipe.transform(fee),
@ -526,12 +526,12 @@ export class BackendService {
}
updateAlias (wallet_id, alias, fee, callback) {
let params = {
const params = {
wallet_id: wallet_id,
alias: {
alias: alias.name.replace("@", ""),
alias: alias.name.replace('@', ''),
address: alias.address,
tracking_key: "",
tracking_key: '',
comment: alias.comment
},
fee: this.moneyToIntPipe.transform(fee)
@ -556,7 +556,7 @@ export class BackendService {
}
getWalletAlias(address) {
if (address != null) {
if (address != null && this.variablesService.daemon_state === 2) {
if (this.variablesService.aliasesChecked[address] == null) {
this.variablesService.aliasesChecked[address] = {};
if (this.variablesService.aliases.length) {
@ -580,7 +580,8 @@ export class BackendService {
return this.variablesService.aliasesChecked[address];
}
return {};
};
}
}

View file

@ -397,27 +397,27 @@ export class AppComponent implements OnInit, OnDestroy {
this.variablesService.aliasesChecked[data.events[i].details.address]['comment'] = data.events[i].details.comment;
}
if (this.variablesService.enableAliasSearch) {
let newAlias = {
const newAlias = {
name: '@' + data.events[i].details.alias,
address: data.events[i].details.address,
comment: data.events[i].details.comment
};
this.variablesService.aliases = this.variablesService.aliases.concat(newAlias);
this.variablesService.aliases = this.variablesService.aliases.sort((a, b) => {
if (a.name.length > b.name.length) return 1;
if (a.name.length < b.name.length) return -1;
if (a.name > b.name) return 1;
if (a.name < b.name) return -1;
return 0;
});
// this.variablesService.aliases = this.variablesService.aliases.sort((a, b) => {
// if (a.name.length > b.name.length) return 1;
// if (a.name.length < b.name.length) return -1;
// if (a.name > b.name) return 1;
// if (a.name < b.name) return -1;
// return 0;
// });
this.variablesService.changeAliases();
}
break;
case 'CORE_EVENT_UPDATE_ALIAS':
for (let address in this.variablesService.aliasesChecked) {
for (const address in this.variablesService.aliasesChecked) {
if (this.variablesService.aliasesChecked.hasOwnProperty(address)) {
if (this.variablesService.aliasesChecked[address].name === "@" + data.events[i].details.alias) {
if (this.variablesService.aliasesChecked[address].address != data.events[i].details.details.address) {
if (this.variablesService.aliasesChecked[address].name === '@' + data.events[i].details.alias) {
if (this.variablesService.aliasesChecked[address].address !== data.events[i].details.details.address) {
delete this.variablesService.aliasesChecked[address]['name'];
delete this.variablesService.aliasesChecked[address]['address'];
delete this.variablesService.aliasesChecked[address]['comment'];
@ -434,18 +434,10 @@ export class AppComponent implements OnInit, OnDestroy {
this.variablesService.aliasesChecked[data.events[i].details.details.address]['comment'] = data.events[i].details.details.comment;
}
if (this.variablesService.enableAliasSearch) {
let currentAlias;
for (let i = 0, length = this.variablesService.aliases.length; i < length; i++) {
if (i in this.variablesService.aliases) {
let element = this.variablesService.aliases[i];
if ('name' in element && element['name'] === '@' + data.events[i].details.alias) {
currentAlias = this.variablesService.aliases[i];
}
}
}
if (currentAlias) {
currentAlias.address = data.events[i].details.details.address;
currentAlias.comment = data.events[i].details.details.comment;
const CurrentAlias = this.variablesService.aliases.find((element) => element.name === '@' + data.events[i].details.alias);
if (CurrentAlias) {
CurrentAlias.address = data.events[i].details.details.address;
CurrentAlias.comment = data.events[i].details.details.comment;
}
}
this.variablesService.changeAliases();
@ -529,11 +521,11 @@ export class AppComponent implements OnInit, OnDestroy {
getAliases() {
this.backend.getAllAliases((status, data, error) => {
if (error == 'CORE_BUSY') {
if (error === 'CORE_BUSY') {
window.setTimeout(() => {
this.getAliases();
},10000);
} else if (error == 'OVERFLOW') {
}, 10000);
} else if (error === 'OVERFLOW') {
this.variablesService.aliases = [];
this.variablesService.enableAliasSearch = false;
} else {
@ -541,7 +533,7 @@ export class AppComponent implements OnInit, OnDestroy {
if (data.aliases && data.aliases.length) {
this.variablesService.aliases = [];
data.aliases.forEach(alias => {
let newAlias = {
const newAlias = {
name: '@' + alias.alias,
address: alias.address,
comment: alias.comment

View file

@ -1,14 +1,14 @@
import {Component, OnInit, NgZone} from '@angular/core';
import {FormGroup, FormControl, Validators} from '@angular/forms';
import {Location} from "@angular/common";
import {Location} from '@angular/common';
import {Router} from '@angular/router';
import {BackendService} from '../_helpers/services/backend.service';
import {VariablesService} from '../_helpers/services/variables.service';
import {ModalService} from "../_helpers/services/modal.service";
import {Wallet} from "../_helpers/models/wallet.model";
import {MoneyToIntPipe} from "../_helpers/pipes/money-to-int.pipe";
import {IntToMoneyPipe} from "../_helpers/pipes/int-to-money.pipe";
import BigNumber from "bignumber.js";
import {ModalService} from '../_helpers/services/modal.service';
import {Wallet} from '../_helpers/models/wallet.model';
import {MoneyToIntPipe} from '../_helpers/pipes/money-to-int.pipe';
import {IntToMoneyPipe} from '../_helpers/pipes/int-to-money.pipe';
import BigNumber from 'bignumber.js';
@Component({
selector: 'app-assign-alias',
@ -51,7 +51,7 @@ export class AssignAliasComponent implements OnInit {
this.assignForm.get('name').valueChanges.subscribe(value => {
this.canRegister = false;
this.alias.exists = false;
let newName = value.toLowerCase().replace('@', '');
const newName = value.toLowerCase().replace('@', '');
if (!(this.assignForm.controls['name'].errors && this.assignForm.controls['name'].errors.hasOwnProperty('pattern')) && newName.length >= 6 && newName.length <= 25) {
this.backend.getAliasByName(newName, status => {
this.ngZone.run(() => {
@ -86,15 +86,15 @@ export class AssignAliasComponent implements OnInit {
}
assignAlias() {
let alias = this.backend.getWalletAlias(this.wallet.address);
const alias = this.backend.getWalletAlias(this.wallet.address);
if (alias.hasOwnProperty('name')) {
this.modalService.prepareModal('info', 'ASSIGN_ALIAS.ONE_ALIAS');
} else {
this.alias.comment = this.assignForm.get('comment').value;
this.backend.registerAlias(this.wallet.wallet_id, this.alias.name, this.wallet.address, this.alias.fee, this.alias.comment, this.alias.rewardOriginal, (status, data) => {
this.backend.registerAlias(this.wallet.wallet_id, this.alias.name, this.wallet.address, this.alias.fee, this.alias.comment, this.alias.rewardOriginal, (status) => {
if (status) {
//service.unconfirmed_aliases.push({tx_hash: data.tx_hash, name: this.alias.name});
//wallet.wakeAlias = true;
// service.unconfirmed_aliases.push({tx_hash: data.tx_hash, name: this.alias.name});
// wallet.wakeAlias = true;
this.modalService.prepareModal('info', 'ASSIGN_ALIAS.REQUEST_ADD_REG');
this.router.navigate(['/wallet/' + this.wallet.wallet_id]);
}

View file

@ -98,6 +98,7 @@ export class OpenWalletComponent implements OnInit, OnDestroy {
open_data['wi'].mined_total,
open_data['wi'].tracking_hey
);
new_wallet.alias = this.backend.getWalletAlias(new_wallet.address);
if (open_data.recent_history && open_data.recent_history.history) {
new_wallet.prepareHistory(open_data.recent_history.history);
}

View file

@ -80,6 +80,7 @@ export class RestoreWalletComponent implements OnInit {
restore_data['wi'].mined_total,
restore_data['wi'].tracking_hey
);
this.variablesService.opening_wallet.alias = this.backend.getWalletAlias(this.variablesService.opening_wallet.address);
if (restore_data.recent_history && restore_data.recent_history.history) {
this.variablesService.opening_wallet.prepareHistory(restore_data.recent_history.history);
}

View file

@ -214,6 +214,8 @@
"UNDEFINED": "Undefined",
"COMPLETE_BUYER": "Successfully complete contract, return remaining pledge",
"COMPLETE_SELLER": "Successfully complete contract, receive payment on contract, and return pledge",
"CREATE_ALIAS": "Fee for assigning alias",
"UPDATE_ALIAS": "Fee for editing alias",
"MINED": "Mined funds",
"CREATE_CONTRACT": "Send contract offer",
"PLEDGE_CONTRACT": "Make pledge on offer",