still kinda broken
This commit is contained in:
parent
e5fe424185
commit
5061dc0d32
@ -15,6 +15,7 @@ export class RegistryService {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);
|
this.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);
|
||||||
|
this.registry.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
getRegistry(): any {
|
getRegistry(): any {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {BehaviorSubject, Observable, Subject} from 'rxjs';
|
import {BehaviorSubject, Observable, Subject, throwError, of} from 'rxjs';
|
||||||
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||||
import {environment} from '@src/environments/environment';
|
import {environment} from '@src/environments/environment';
|
||||||
import {first} from 'rxjs/operators';
|
import {first} from 'rxjs/operators';
|
||||||
@ -40,17 +40,30 @@ export class UserService {
|
|||||||
private registryService: RegistryService,
|
private registryService: RegistryService,
|
||||||
private authService: AuthService
|
private authService: AuthService
|
||||||
) {
|
) {
|
||||||
this.authService = authService;
|
//this.authService.init().then(() => {
|
||||||
this.registryService = registryService;
|
// this.keystore = authService.mutableKeyStore;
|
||||||
|
// this.signer = new PGPSigner(this.keystore);
|
||||||
|
//});
|
||||||
|
//this.registry = registryService.getRegistry();
|
||||||
|
//this.registry.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
async load(): Promise<void> {
|
async load(): Promise<any> {
|
||||||
await this.authService.init();
|
try {
|
||||||
// TODO you don't have to do this reassignment
|
// TODO this method is called by ngOnInit so we need to
|
||||||
this.keystore = this.authService.mutableKeyStore;
|
// emit an observalbe or conver ngonInit to promise
|
||||||
this.signer = new PGPSigner(this.keystore);
|
// TODO alig the load/init methods naming
|
||||||
this.registry = this.registryService.getRegistry();
|
await this.authService.init();
|
||||||
await this.registry.load();
|
// await this.registryService.load();
|
||||||
|
// TODO key store is defined
|
||||||
|
this.keystore = this.authService.mutableKeyStore;
|
||||||
|
this.signer = new PGPSigner(this.keystore);
|
||||||
|
this.registry = this.registryService.getRegistry();
|
||||||
|
return of(0);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('ERROR: Failed to initiialize User Service', error)
|
||||||
|
return throwError(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPin(phone: string): Observable<any> {
|
resetPin(phone: string): Observable<any> {
|
||||||
@ -153,10 +166,17 @@ export class UserService {
|
|||||||
|
|
||||||
async loadAccounts(limit: number = 100, offset: number = 0): Promise<void> {
|
async loadAccounts(limit: number = 100, offset: number = 0): Promise<void> {
|
||||||
this.resetAccountsList();
|
this.resetAccountsList();
|
||||||
const accountIndexAddress: string = await this.registry.getContractAddressByName('AccountRegistry');
|
let accountAddresses: Array<string>;
|
||||||
const accountIndexQuery = new AccountIndex(accountIndexAddress);
|
try {
|
||||||
const accountAddresses: Array<string> = await accountIndexQuery.last(await accountIndexQuery.totalAccounts());
|
const accountIndexAddress: string = await this.registry.getContractAddressByName('AccountRegistry');
|
||||||
this.loggingService.sendInfoLevelMessage(accountAddresses);
|
const accountIndexQuery = new AccountIndex(accountIndexAddress);
|
||||||
|
const totalAccounts = await accountIndexQuery.totalAccounts()
|
||||||
|
const accountAddresses = await accountIndexQuery.last(totalAccounts);
|
||||||
|
this.loggingService.sendInfoLevelMessage(accountAddresses);
|
||||||
|
} catch (error){
|
||||||
|
// TODO real logging:
|
||||||
|
console.log("ERROR: failed to load accounts \n", error)
|
||||||
|
}
|
||||||
for (const accountAddress of accountAddresses.slice(offset, offset + limit)) {
|
for (const accountAddress of accountAddresses.slice(offset, offset + limit)) {
|
||||||
await this.getAccountByAddress(accountAddress, limit);
|
await this.getAccountByAddress(accountAddress, limit);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ import {strip0x} from '@src/assets/js/ethtx/dist/hex';
|
|||||||
import {first} from 'rxjs/operators';
|
import {first} from 'rxjs/operators';
|
||||||
import {environment} from '@src/environments/environment';
|
import {environment} from '@src/environments/environment';
|
||||||
import {AccountDetails} from '@app/_models';
|
import {AccountDetails} from '@app/_models';
|
||||||
|
import {Observable, of} from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-accounts',
|
selector: 'app-accounts',
|
||||||
@ -38,6 +40,7 @@ export class AccountsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
of(this.userService.load())
|
||||||
this.userService.getAccountTypes().pipe(first()).subscribe(res => this.accountTypes = res);
|
this.userService.getAccountTypes().pipe(first()).subscribe(res => this.accountTypes = res);
|
||||||
this.userService.accountsSubject.subscribe(accounts => {
|
this.userService.accountsSubject.subscribe(accounts => {
|
||||||
this.dataSource = new MatTableDataSource<any>(accounts);
|
this.dataSource = new MatTableDataSource<any>(accounts);
|
||||||
|
Loading…
Reference in New Issue
Block a user