Format docs using linter and prettier.
This commit is contained in:
@@ -289,8 +289,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="204"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:204</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="206"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:206</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -330,8 +330,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="193"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:193</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="196"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:196</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -369,8 +369,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="187"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:187</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="190"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:190</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -488,8 +488,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="99"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:99</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="98"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:98</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -529,8 +529,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="118"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:118</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="116"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:116</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -599,8 +599,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="147"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:147</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="150"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:150</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -638,8 +638,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="181"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:181</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="184"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:184</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -749,8 +749,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="157"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:157</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="156"
|
||||
class="link-to-prism">src/app/_services/auth.service.ts:156</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -957,18 +957,18 @@
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {Injectable} from '@angular/core';
|
||||
import {hobaParseChallengeHeader} from '@src/assets/js/hoba.js';
|
||||
import {signChallenge} from '@src/assets/js/hoba-pgp.js';
|
||||
import {environment} from '@src/environments/environment';
|
||||
import {LoggingService} from '@app/_services/logging.service';
|
||||
import {MutableKeyStore, MutablePgpKeyStore} from '@app/_pgp';
|
||||
import {ErrorDialogService} from '@app/_services/error-dialog.service';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {HttpError} from '@app/_helpers/global-error-handler';
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from '@angular/core';
|
||||
import { hobaParseChallengeHeader } from '@src/assets/js/hoba.js';
|
||||
import { signChallenge } from '@src/assets/js/hoba-pgp.js';
|
||||
import { environment } from '@src/environments/environment';
|
||||
import { LoggingService } from '@app/_services/logging.service';
|
||||
import { MutableKeyStore, MutablePgpKeyStore } from '@app/_pgp';
|
||||
import { ErrorDialogService } from '@app/_services/error-dialog.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpError } from '@app/_helpers/global-error-handler';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthService {
|
||||
sessionToken: any;
|
||||
@@ -1027,8 +1027,8 @@ export class AuthService {
|
||||
xhr.setRequestHeader('x-cic-automerge', 'none');
|
||||
xhr.addEventListener('load', (e) => {
|
||||
if (xhr.status !== 200) {
|
||||
const error = new HttpError(xhr.statusText, xhr.status);
|
||||
return reject(error);
|
||||
const error = new HttpError(xhr.statusText, xhr.status);
|
||||
return reject(error);
|
||||
}
|
||||
this.sessionToken = xhr.getResponseHeader('Token');
|
||||
sessionStorage.setItem(btoa('CICADA_SESSION_TOKEN'), this.sessionToken);
|
||||
@@ -1054,50 +1054,53 @@ export class AuthService {
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
|
||||
login(): boolean {
|
||||
if (this.sessionToken !== undefined) {
|
||||
try {
|
||||
this.getWithToken();
|
||||
return true;
|
||||
} catch (e) {
|
||||
this.loggingService.sendErrorLevelMessage('Login token failed', this, {error: e});
|
||||
this.loggingService.sendErrorLevelMessage('Login token failed', this, { error: e });
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
this.getChallenge();
|
||||
} catch (e) {
|
||||
this.loggingService.sendErrorLevelMessage('Login challenge failed', this, {error: e});
|
||||
this.loggingService.sendErrorLevelMessage('Login challenge failed', this, { error: e });
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
async loginResponse(o: { challenge: string, realm: any }): Promise<any> {
|
||||
async loginResponse(o: { challenge: string; realm: any }): Promise<any> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const r = await signChallenge(o.challenge,
|
||||
o.realm,
|
||||
environment.cicMetaUrl,
|
||||
this.mutableKeyStore);
|
||||
const r = await signChallenge(
|
||||
o.challenge,
|
||||
o.realm,
|
||||
environment.cicMetaUrl,
|
||||
this.mutableKeyStore
|
||||
);
|
||||
const sessionTokenResult: boolean = await this.sendResponse(r);
|
||||
} catch (error) {
|
||||
if (error instanceof HttpError) {
|
||||
if (error.status === 403) {
|
||||
this.errorDialogService.openDialog({ message: 'You are not authorized to use this system' });
|
||||
this.errorDialogService.openDialog({
|
||||
message: 'You are not authorized to use this system',
|
||||
});
|
||||
}
|
||||
if (error.status === 401) {
|
||||
this.errorDialogService.openDialog({
|
||||
message: 'Unable to authenticate with the service. ' +
|
||||
message:
|
||||
'Unable to authenticate with the service. ' +
|
||||
'Please speak with the staff at Grassroots ' +
|
||||
'Economics for requesting access ' +
|
||||
'staff@grassrootseconomics.net.'
|
||||
'staff@grassrootseconomics.net.',
|
||||
});
|
||||
}
|
||||
}
|
||||
// TODO define this error
|
||||
this.errorDialogService.openDialog({message: 'Incorrect key passphrase.'});
|
||||
this.errorDialogService.openDialog({ message: 'Incorrect key passphrase.' });
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
@@ -1109,10 +1112,6 @@ export class AuthService {
|
||||
this.setState('Click button to log in with PGP key ' + this.mutableKeyStore.getPrivateKeyId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws
|
||||
* @param privateKeyArmored
|
||||
*/
|
||||
async setKey(privateKeyArmored): Promise<boolean> {
|
||||
try {
|
||||
const isValidKeyCheck = await this.mutableKeyStore.isValidKey(privateKeyArmored);
|
||||
@@ -1127,7 +1126,11 @@ export class AuthService {
|
||||
const key = await this.mutableKeyStore.importPrivateKey(privateKeyArmored);
|
||||
localStorage.setItem(btoa('CICADA_PRIVATE_KEY'), privateKeyArmored);
|
||||
} catch (err) {
|
||||
this.loggingService.sendErrorLevelMessage(`Failed to set key: ${err.message || err.statusText}`, this, {error: err});
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
`Failed to set key: ${err.message || err.statusText}`,
|
||||
this,
|
||||
{ error: err }
|
||||
);
|
||||
this.errorDialogService.openDialog({
|
||||
message: `Failed to set key: ${err.message || err.statusText}`,
|
||||
});
|
||||
@@ -1140,28 +1143,27 @@ export class AuthService {
|
||||
logout(): void {
|
||||
sessionStorage.removeItem(btoa('CICADA_SESSION_TOKEN'));
|
||||
this.sessionToken = undefined;
|
||||
window.location.reload(true);
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
getTrustedUsers(): any {
|
||||
const trustedUsers: Array<any> = [];
|
||||
this.mutableKeyStore.getPublicKeys().forEach(key => trustedUsers.push(key.users[0].userId));
|
||||
this.mutableKeyStore.getPublicKeys().forEach((key) => trustedUsers.push(key.users[0].userId));
|
||||
return trustedUsers;
|
||||
}
|
||||
|
||||
async getPublicKeys(): Promise<any> {
|
||||
return await fetch(environment.publicKeysUrl)
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
// TODO does angular recommend an error interface?
|
||||
throw Error(`${res.statusText} - ${res.status}`);
|
||||
}
|
||||
return res.text();
|
||||
});
|
||||
return await fetch(environment.publicKeysUrl).then((res) => {
|
||||
if (!res.ok) {
|
||||
// TODO does angular recommend an error interface?
|
||||
throw Error(`${res.statusText} - ${res.status}`);
|
||||
}
|
||||
return res.text();
|
||||
});
|
||||
}
|
||||
|
||||
getPrivateKey(): any {
|
||||
return this.mutableKeyStore.getPrivateKey();
|
||||
return this.mutableKeyStore.getPrivateKey();
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
@@ -327,8 +327,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="101"
|
||||
class="link-to-prism">src/app/_services/block-sync.service.ts:101</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="118"
|
||||
class="link-to-prism">src/app/_services/block-sync.service.ts:118</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -409,8 +409,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="76"
|
||||
class="link-to-prism">src/app/_services/block-sync.service.ts:76</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="89"
|
||||
class="link-to-prism">src/app/_services/block-sync.service.ts:89</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -479,8 +479,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="68"
|
||||
class="link-to-prism">src/app/_services/block-sync.service.ts:68</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="81"
|
||||
class="link-to-prism">src/app/_services/block-sync.service.ts:81</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -669,8 +669,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="84"
|
||||
class="link-to-prism">src/app/_services/block-sync.service.ts:84</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="97"
|
||||
class="link-to-prism">src/app/_services/block-sync.service.ts:97</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -853,17 +853,17 @@
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {Injectable} from '@angular/core';
|
||||
import {Settings} from '@app/_models';
|
||||
import {TransactionHelper} from 'cic-client';
|
||||
import {first} from 'rxjs/operators';
|
||||
import {TransactionService} from '@app/_services/transaction.service';
|
||||
import {environment} from '@src/environments/environment';
|
||||
import {LoggingService} from '@app/_services/logging.service';
|
||||
import {RegistryService} from '@app/_services/registry.service';
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from '@angular/core';
|
||||
import { Settings } from '@app/_models';
|
||||
import { TransactionHelper } from 'cic-client';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { TransactionService } from '@app/_services/transaction.service';
|
||||
import { environment } from '@src/environments/environment';
|
||||
import { LoggingService } from '@app/_services/logging.service';
|
||||
import { RegistryService } from '@app/_services/registry.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BlockSyncService {
|
||||
readyStateTarget: number = 2;
|
||||
@@ -872,8 +872,8 @@ export class BlockSyncService {
|
||||
constructor(
|
||||
private transactionService: TransactionService,
|
||||
private loggingService: LoggingService,
|
||||
private registryService: RegistryService,
|
||||
) { }
|
||||
private registryService: RegistryService
|
||||
) {}
|
||||
|
||||
blockSync(address: string = null, offset: number = 0, limit: number = 100): void {
|
||||
this.transactionService.resetTransactionsList();
|
||||
@@ -898,7 +898,14 @@ export class BlockSyncService {
|
||||
settings.registry.load();
|
||||
}
|
||||
|
||||
readyStateProcessor(settings: Settings, bit: number, address: string, offset: number, limit: number): void {
|
||||
readyStateProcessor(
|
||||
settings: Settings,
|
||||
bit: number,
|
||||
address: string,
|
||||
offset: number,
|
||||
limit: number
|
||||
): void {
|
||||
// tslint:disable-next-line:no-bitwise
|
||||
this.readyState |= bit;
|
||||
if (this.readyStateTarget === this.readyState && this.readyStateTarget) {
|
||||
const wHeadSync: Worker = new Worker('./../assets/js/block-sync/head.js');
|
||||
@@ -909,13 +916,19 @@ export class BlockSyncService {
|
||||
w3_provider: settings.w3.provider,
|
||||
});
|
||||
if (address === null) {
|
||||
this.transactionService.getAllTransactions(offset, limit).pipe(first()).subscribe(res => {
|
||||
this.fetcher(settings, res);
|
||||
});
|
||||
this.transactionService
|
||||
.getAllTransactions(offset, limit)
|
||||
.pipe(first())
|
||||
.subscribe((res) => {
|
||||
this.fetcher(settings, res);
|
||||
});
|
||||
} else {
|
||||
this.transactionService.getAddressTransactions(address, offset, limit).pipe(first()).subscribe(res => {
|
||||
this.fetcher(settings, res);
|
||||
});
|
||||
this.transactionService
|
||||
.getAddressTransactions(address, offset, limit)
|
||||
.pipe(first())
|
||||
.subscribe((res) => {
|
||||
this.fetcher(settings, res);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -936,7 +949,14 @@ export class BlockSyncService {
|
||||
});
|
||||
}
|
||||
|
||||
async scan(settings: Settings, lo: number, hi: number, bloomBlockBytes: Uint8Array, bloomBlocktxBytes: Uint8Array, bloomRounds: any): Promise<void> {
|
||||
async scan(
|
||||
settings: Settings,
|
||||
lo: number,
|
||||
hi: number,
|
||||
bloomBlockBytes: Uint8Array,
|
||||
bloomBlocktxBytes: Uint8Array,
|
||||
bloomRounds: any
|
||||
): Promise<void> {
|
||||
const w: Worker = new Worker('./../assets/js/block-sync/ondemand.js');
|
||||
w.onmessage = (m) => {
|
||||
settings.txHelper.processReceipt(m.data);
|
||||
@@ -945,10 +965,7 @@ export class BlockSyncService {
|
||||
w3_provider: settings.w3.provider,
|
||||
lo,
|
||||
hi,
|
||||
filters: [
|
||||
bloomBlockBytes,
|
||||
bloomBlocktxBytes,
|
||||
],
|
||||
filters: [bloomBlockBytes, bloomBlocktxBytes],
|
||||
filter_rounds: bloomRounds,
|
||||
});
|
||||
}
|
||||
@@ -956,13 +973,20 @@ export class BlockSyncService {
|
||||
fetcher(settings: Settings, transactionsInfo: any): void {
|
||||
const blockFilterBinstr: string = window.atob(transactionsInfo.block_filter);
|
||||
const bOne: Uint8Array = new Uint8Array(blockFilterBinstr.length);
|
||||
bOne.map((e, i, v) => v[i] = blockFilterBinstr.charCodeAt(i));
|
||||
bOne.map((e, i, v) => (v[i] = blockFilterBinstr.charCodeAt(i)));
|
||||
|
||||
const blocktxFilterBinstr: string = window.atob(transactionsInfo.blocktx_filter);
|
||||
const bTwo: Uint8Array = new Uint8Array(blocktxFilterBinstr.length);
|
||||
bTwo.map((e, i, v) => v[i] = blocktxFilterBinstr.charCodeAt(i));
|
||||
bTwo.map((e, i, v) => (v[i] = blocktxFilterBinstr.charCodeAt(i)));
|
||||
|
||||
settings.scanFilter(settings, transactionsInfo.low, transactionsInfo.high, bOne, bTwo, transactionsInfo.filter_rounds);
|
||||
settings.scanFilter(
|
||||
settings,
|
||||
transactionsInfo.low,
|
||||
transactionsInfo.high,
|
||||
bOne,
|
||||
bTwo,
|
||||
transactionsInfo.filter_rounds
|
||||
);
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
@@ -185,8 +185,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="15"
|
||||
class="link-to-prism">src/app/_services/error-dialog.service.ts:15</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="13"
|
||||
class="link-to-prism">src/app/_services/error-dialog.service.ts:13</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -256,7 +256,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="12" class="link-to-prism">src/app/_services/error-dialog.service.ts:12</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="11" class="link-to-prism">src/app/_services/error-dialog.service.ts:11</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -303,18 +303,16 @@
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from '@angular/core';
|
||||
import {MatDialog, MatDialogRef} from '@angular/material/dialog';
|
||||
import {ErrorDialogComponent} from '@app/shared/error-dialog/error-dialog.component';
|
||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { ErrorDialogComponent } from '@app/shared/error-dialog/error-dialog.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ErrorDialogService {
|
||||
public isDialogOpen: boolean = false;
|
||||
|
||||
constructor(
|
||||
public dialog: MatDialog,
|
||||
) { }
|
||||
constructor(public dialog: MatDialog) {}
|
||||
|
||||
openDialog(data): any {
|
||||
if (this.isDialogOpen) {
|
||||
@@ -323,10 +321,10 @@ export class ErrorDialogService {
|
||||
this.isDialogOpen = true;
|
||||
const dialogRef: MatDialogRef<any> = this.dialog.open(ErrorDialogComponent, {
|
||||
width: '300px',
|
||||
data
|
||||
data,
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(() => this.isDialogOpen = false);
|
||||
dialogRef.afterClosed().subscribe(() => (this.isDialogOpen = false));
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="42" class="link-to-prism">src/app/_helpers/global-error-handler.ts:42</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="41" class="link-to-prism">src/app/_helpers/global-error-handler.ts:41</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -233,8 +233,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="62"
|
||||
class="link-to-prism">src/app/_helpers/global-error-handler.ts:62</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="58"
|
||||
class="link-to-prism">src/app/_helpers/global-error-handler.ts:58</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -314,8 +314,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="89"
|
||||
class="link-to-prism">src/app/_helpers/global-error-handler.ts:89</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="84"
|
||||
class="link-to-prism">src/app/_helpers/global-error-handler.ts:84</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -394,8 +394,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="109"
|
||||
class="link-to-prism">src/app/_helpers/global-error-handler.ts:109</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="104"
|
||||
class="link-to-prism">src/app/_helpers/global-error-handler.ts:104</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -483,7 +483,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="42" class="link-to-prism">src/app/_helpers/global-error-handler.ts:42</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="41" class="link-to-prism">src/app/_helpers/global-error-handler.ts:41</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -502,12 +502,12 @@
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {HttpErrorResponse} from '@angular/common/http';
|
||||
import {ErrorHandler, Injectable} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { ErrorHandler, Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
// Application imports
|
||||
import {LoggingService} from '@app/_services/logging.service';
|
||||
import { LoggingService } from '@app/_services/logging.service';
|
||||
|
||||
/**
|
||||
* A generalized http response error.
|
||||
@@ -540,7 +540,6 @@ export class HttpError extends Error {
|
||||
export class GlobalErrorHandler extends ErrorHandler {
|
||||
/**
|
||||
* An array of sentence sections that denote warnings.
|
||||
* @private
|
||||
*/
|
||||
private sentencesForWarningLogging: Array<string> = [];
|
||||
|
||||
@@ -550,10 +549,7 @@ export class GlobalErrorHandler extends ErrorHandler {
|
||||
* @param loggingService - A service that provides logging capabilities.
|
||||
* @param router - A service that provides navigation among views and URL manipulation capabilities.
|
||||
*/
|
||||
constructor(
|
||||
private loggingService: LoggingService,
|
||||
private router: Router
|
||||
) {
|
||||
constructor(private loggingService: LoggingService, private router: Router) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -574,9 +570,9 @@ export class GlobalErrorHandler extends ErrorHandler {
|
||||
|
||||
const isWarning: boolean = this.isWarning(errorTraceString);
|
||||
if (isWarning) {
|
||||
this.loggingService.sendWarnLevelMessage(errorTraceString, {error});
|
||||
this.loggingService.sendWarnLevelMessage(errorTraceString, { error });
|
||||
} else {
|
||||
this.loggingService.sendErrorLevelMessage(errorTraceString, this, {error});
|
||||
this.loggingService.sendErrorLevelMessage(errorTraceString, this, { error });
|
||||
}
|
||||
|
||||
throw error;
|
||||
@@ -587,7 +583,6 @@ export class GlobalErrorHandler extends ErrorHandler {
|
||||
*
|
||||
* @param errorTraceString - A description of the error and it's stack trace.
|
||||
* @returns true - If the error is of type warning.
|
||||
* @private
|
||||
*/
|
||||
private isWarning(errorTraceString: string): boolean {
|
||||
let isWarning: boolean = true;
|
||||
@@ -613,14 +608,30 @@ export class GlobalErrorHandler extends ErrorHandler {
|
||||
const route: string = this.router.url;
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
`There was an HTTP error on route ${route}.\n${error.message}.\nStatus code: ${(error as HttpErrorResponse).status}`,
|
||||
this, {error});
|
||||
`There was an HTTP error on route ${route}.\n${error.message}.\nStatus code: ${
|
||||
(error as HttpErrorResponse).status
|
||||
}`,
|
||||
this,
|
||||
{ error }
|
||||
);
|
||||
} else if (error instanceof TypeError) {
|
||||
this.loggingService.sendErrorLevelMessage(`There was a Type error on route ${route}.\n${error.message}`, this, {error});
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
`There was a Type error on route ${route}.\n${error.message}`,
|
||||
this,
|
||||
{ error }
|
||||
);
|
||||
} else if (error instanceof Error) {
|
||||
this.loggingService.sendErrorLevelMessage(`There was a general error on route ${route}.\n${error.message}`, this, {error});
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
`There was a general error on route ${route}.\n${error.message}`,
|
||||
this,
|
||||
{ error }
|
||||
);
|
||||
} else {
|
||||
this.loggingService.sendErrorLevelMessage(`Nobody threw an error but something happened on route ${route}!`, this, {error});
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
`Nobody threw an error but something happened on route ${route}!`,
|
||||
this,
|
||||
{ error }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,8 +175,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="20"
|
||||
class="link-to-prism">src/app/_services/location.service.ts:20</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="17"
|
||||
class="link-to-prism">src/app/_services/location.service.ts:17</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -245,8 +245,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="16"
|
||||
class="link-to-prism">src/app/_services/location.service.ts:16</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="13"
|
||||
class="link-to-prism">src/app/_services/location.service.ts:13</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -284,8 +284,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="28"
|
||||
class="link-to-prism">src/app/_services/location.service.ts:28</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="25"
|
||||
class="link-to-prism">src/app/_services/location.service.ts:25</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -354,8 +354,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="24"
|
||||
class="link-to-prism">src/app/_services/location.service.ts:24</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="21"
|
||||
class="link-to-prism">src/app/_services/location.service.ts:21</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -378,19 +378,16 @@
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {environment} from '@src/environments/environment';
|
||||
import {first} from 'rxjs/operators';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { environment } from '@src/environments/environment';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LocationService {
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
) { }
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
|
||||
getAreaNames(): Observable<any> {
|
||||
return this.httpClient.get(`${environment.cicMetaUrl}/areanames`);
|
||||
@@ -405,7 +402,9 @@ export class LocationService {
|
||||
}
|
||||
|
||||
getAreaTypeByArea(area: string): Observable<any> {
|
||||
return this.httpClient.get(`${environment.cicMetaUrl}/areatypes/${area.toLowerCase()}`).pipe(first());
|
||||
return this.httpClient
|
||||
.get(`${environment.cicMetaUrl}/areatypes/${area.toLowerCase()}`)
|
||||
.pipe(first());
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
@@ -867,11 +867,11 @@
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {Injectable, isDevMode} from '@angular/core';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable, isDevMode } from '@angular/core';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LoggingService {
|
||||
env: string;
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="14" class="link-to-prism">src/app/_services/registry.service.ts:14</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="19" class="link-to-prism">src/app/_services/registry.service.ts:19</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -159,8 +159,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="21"
|
||||
class="link-to-prism">src/app/_services/registry.service.ts:21</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="26"
|
||||
class="link-to-prism">src/app/_services/registry.service.ts:26</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -198,8 +198,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="25"
|
||||
class="link-to-prism">src/app/_services/registry.service.ts:25</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="30"
|
||||
class="link-to-prism">src/app/_services/registry.service.ts:30</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -273,8 +273,13 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Default value : </i><code>new CICRegistry(this.web3, environment.registryAddress, 'CICRegistry', this.fileGetter,
|
||||
['../../assets/js/block-sync/data'])</code>
|
||||
<i>Default value : </i><code>new CICRegistry(
|
||||
this.web3,
|
||||
environment.registryAddress,
|
||||
'CICRegistry',
|
||||
this.fileGetter,
|
||||
['../../assets/js/block-sync/data']
|
||||
)</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -326,18 +331,23 @@
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from '@angular/core';
|
||||
import Web3 from 'web3';
|
||||
import {environment} from '@src/environments/environment';
|
||||
import {CICRegistry, FileGetter} from 'cic-client';
|
||||
import {HttpGetter} from '@app/_helpers';
|
||||
import { environment } from '@src/environments/environment';
|
||||
import { CICRegistry, FileGetter } from 'cic-client';
|
||||
import { HttpGetter } from '@app/_helpers';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RegistryService {
|
||||
web3: Web3 = new Web3(environment.web3Provider);
|
||||
fileGetter: FileGetter = new HttpGetter();
|
||||
registry: CICRegistry = new CICRegistry(this.web3, environment.registryAddress, 'CICRegistry', this.fileGetter,
|
||||
['../../assets/js/block-sync/data']);
|
||||
registry: CICRegistry = new CICRegistry(
|
||||
this.web3,
|
||||
environment.registryAddress,
|
||||
'CICRegistry',
|
||||
this.fileGetter,
|
||||
['../../assets/js/block-sync/data']
|
||||
);
|
||||
|
||||
constructor() {
|
||||
this.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);
|
||||
|
||||
@@ -208,8 +208,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="38"
|
||||
class="link-to-prism">src/app/_services/token.service.ts:38</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="37"
|
||||
class="link-to-prism">src/app/_services/token.service.ts:37</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -278,8 +278,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="34"
|
||||
class="link-to-prism">src/app/_services/token.service.ts:34</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="33"
|
||||
class="link-to-prism">src/app/_services/token.service.ts:33</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -350,8 +350,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="29"
|
||||
class="link-to-prism">src/app/_services/token.service.ts:29</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="28"
|
||||
class="link-to-prism">src/app/_services/token.service.ts:28</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -466,36 +466,35 @@
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { EventEmitter, Injectable } from '@angular/core';
|
||||
import {environment} from '@src/environments/environment';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {CICRegistry} from 'cic-client';
|
||||
import {TokenRegistry} from '@app/_eth';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {RegistryService} from '@app/_services/registry.service';
|
||||
import { environment } from '@src/environments/environment';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { CICRegistry } from 'cic-client';
|
||||
import { TokenRegistry } from '@app/_eth';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { RegistryService } from '@app/_services/registry.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TokenService {
|
||||
registry: CICRegistry;
|
||||
tokenRegistry: TokenRegistry;
|
||||
LoadEvent: EventEmitter<number> = new EventEmitter<number>();
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
private registryService: RegistryService,
|
||||
) {
|
||||
constructor(private httpClient: HttpClient, private registryService: RegistryService) {
|
||||
this.registry = registryService.getRegistry();
|
||||
this.registry.load();
|
||||
this.registry.onload = async (address: string): Promise<void> => {
|
||||
this.tokenRegistry = new TokenRegistry(await this.registry.getContractAddressByName('TokenRegistry'));
|
||||
this.tokenRegistry = new TokenRegistry(
|
||||
await this.registry.getContractAddressByName('TokenRegistry')
|
||||
);
|
||||
this.LoadEvent.next(Date.now());
|
||||
};
|
||||
}
|
||||
|
||||
async getTokens(): Promise<Array<Promise<string>>> {
|
||||
const count: number = await this.tokenRegistry.totalTokens();
|
||||
return Array.from({length: count}, async (v, i) => await this.tokenRegistry.entry(i));
|
||||
return Array.from({ length: count }, async (v, i) => await this.tokenRegistry.entry(i));
|
||||
}
|
||||
|
||||
getTokenBySymbol(symbol: string): Observable<any> {
|
||||
|
||||
@@ -268,8 +268,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="89"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:89</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="111"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:111</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -349,8 +349,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="102"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:102</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="124"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:124</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -595,8 +595,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="97"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:97</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="119"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:119</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -636,8 +636,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="73"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:73</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="87"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:87</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -796,8 +796,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="108"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:108</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="130"
|
||||
class="link-to-prism">src/app/_services/transaction.service.ts:130</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1059,28 +1059,28 @@
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from '@angular/core';
|
||||
import {first} from 'rxjs/operators';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {environment} from '@src/environments/environment';
|
||||
import {Envelope, User} from 'cic-client-meta';
|
||||
import {UserService} from '@app/_services/user.service';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { environment } from '@src/environments/environment';
|
||||
import { Envelope, User } from 'cic-client-meta';
|
||||
import { UserService } from '@app/_services/user.service';
|
||||
import { Keccak } from 'sha3';
|
||||
import { utils } from 'ethers';
|
||||
import {add0x, fromHex, strip0x, toHex} from '@src/assets/js/ethtx/dist/hex';
|
||||
import {Tx} from '@src/assets/js/ethtx/dist';
|
||||
import {toValue} from '@src/assets/js/ethtx/dist/tx';
|
||||
import { add0x, fromHex, strip0x, toHex } from '@src/assets/js/ethtx/dist/hex';
|
||||
import { Tx } from '@src/assets/js/ethtx/dist';
|
||||
import { toValue } from '@src/assets/js/ethtx/dist/tx';
|
||||
import * as secp256k1 from 'secp256k1';
|
||||
import {AuthService} from '@app/_services/auth.service';
|
||||
import {defaultAccount} from '@app/_models';
|
||||
import {LoggingService} from '@app/_services/logging.service';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {CICRegistry} from 'cic-client';
|
||||
import {RegistryService} from '@app/_services/registry.service';
|
||||
import { AuthService } from '@app/_services/auth.service';
|
||||
import { defaultAccount } from '@app/_models';
|
||||
import { LoggingService } from '@app/_services/logging.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { CICRegistry } from 'cic-client';
|
||||
import { RegistryService } from '@app/_services/registry.service';
|
||||
import Web3 from 'web3';
|
||||
const vCard = require('vcard-parser');
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TransactionService {
|
||||
transactions: any[] = [];
|
||||
@@ -1095,7 +1095,7 @@ export class TransactionService {
|
||||
private authService: AuthService,
|
||||
private userService: UserService,
|
||||
private loggingService: LoggingService,
|
||||
private registryService: RegistryService,
|
||||
private registryService: RegistryService
|
||||
) {
|
||||
this.web3 = this.registryService.getWeb3();
|
||||
this.registry = registryService.getRegistry();
|
||||
@@ -1111,36 +1111,58 @@ export class TransactionService {
|
||||
}
|
||||
|
||||
async setTransaction(transaction, cacheSize: number): Promise<void> {
|
||||
if (this.transactions.find(cachedTx => cachedTx.tx.txHash === transaction.tx.txHash)) { return; }
|
||||
if (this.transactions.find((cachedTx) => cachedTx.tx.txHash === transaction.tx.txHash)) {
|
||||
return;
|
||||
}
|
||||
transaction.value = Number(transaction.value);
|
||||
transaction.type = 'transaction';
|
||||
try {
|
||||
this.userService.getAccountDetailsFromMeta(await User.toKey(transaction.from)).pipe(first()).subscribe((res) => {
|
||||
transaction.sender = this.getAccountInfo(res.body);
|
||||
}, error => {
|
||||
transaction.sender = defaultAccount;
|
||||
});
|
||||
this.userService.getAccountDetailsFromMeta(await User.toKey(transaction.to)).pipe(first()).subscribe((res) => {
|
||||
transaction.recipient = this.getAccountInfo(res.body);
|
||||
}, error => {
|
||||
transaction.recipient = defaultAccount;
|
||||
});
|
||||
this.userService
|
||||
.getAccountDetailsFromMeta(await User.toKey(transaction.from))
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
(res) => {
|
||||
transaction.sender = this.getAccountInfo(res.body);
|
||||
},
|
||||
(error) => {
|
||||
transaction.sender = defaultAccount;
|
||||
}
|
||||
);
|
||||
this.userService
|
||||
.getAccountDetailsFromMeta(await User.toKey(transaction.to))
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
(res) => {
|
||||
transaction.recipient = this.getAccountInfo(res.body);
|
||||
},
|
||||
(error) => {
|
||||
transaction.recipient = defaultAccount;
|
||||
}
|
||||
);
|
||||
} finally {
|
||||
this.addTransaction(transaction, cacheSize);
|
||||
}
|
||||
}
|
||||
|
||||
async setConversion(conversion, cacheSize): Promise<void> {
|
||||
if (this.transactions.find(cachedTx => cachedTx.tx.txHash === conversion.tx.txHash)) { return; }
|
||||
if (this.transactions.find((cachedTx) => cachedTx.tx.txHash === conversion.tx.txHash)) {
|
||||
return;
|
||||
}
|
||||
conversion.type = 'conversion';
|
||||
conversion.fromValue = Number(conversion.fromValue);
|
||||
conversion.toValue = Number(conversion.toValue);
|
||||
try {
|
||||
this.userService.getAccountDetailsFromMeta(await User.toKey(conversion.trader)).pipe(first()).subscribe((res) => {
|
||||
conversion.sender = conversion.recipient = this.getAccountInfo(res.body);
|
||||
}, error => {
|
||||
conversion.sender = conversion.recipient = defaultAccount;
|
||||
});
|
||||
this.userService
|
||||
.getAccountDetailsFromMeta(await User.toKey(conversion.trader))
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
(res) => {
|
||||
conversion.sender = conversion.recipient = this.getAccountInfo(res.body);
|
||||
},
|
||||
(error) => {
|
||||
conversion.sender = conversion.recipient = defaultAccount;
|
||||
}
|
||||
);
|
||||
} finally {
|
||||
this.addTransaction(conversion, cacheSize);
|
||||
}
|
||||
@@ -1160,19 +1182,29 @@ export class TransactionService {
|
||||
}
|
||||
|
||||
getAccountInfo(account: string): any {
|
||||
let accountInfo = Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data;
|
||||
const accountInfo = Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data;
|
||||
accountInfo.vcard = vCard.parse(atob(accountInfo.vcard));
|
||||
return accountInfo;
|
||||
}
|
||||
|
||||
async transferRequest(tokenAddress: string, senderAddress: string, recipientAddress: string, value: number): Promise<any> {
|
||||
const transferAuthAddress = await this.registry.getContractAddressByName('TransferAuthorization');
|
||||
async transferRequest(
|
||||
tokenAddress: string,
|
||||
senderAddress: string,
|
||||
recipientAddress: string,
|
||||
value: number
|
||||
): Promise<any> {
|
||||
const transferAuthAddress = await this.registry.getContractAddressByName(
|
||||
'TransferAuthorization'
|
||||
);
|
||||
const hashFunction = new Keccak(256);
|
||||
hashFunction.update('createRequest(address,address,address,uint256)');
|
||||
const hash = hashFunction.digest();
|
||||
const methodSignature = hash.toString('hex').substring(0, 8);
|
||||
const abiCoder = new utils.AbiCoder();
|
||||
const abi = await abiCoder.encode(['address', 'address', 'address', 'uint256'], [senderAddress, recipientAddress, tokenAddress, value]);
|
||||
const abi = await abiCoder.encode(
|
||||
['address', 'address', 'address', 'uint256'],
|
||||
[senderAddress, recipientAddress, tokenAddress, value]
|
||||
);
|
||||
const data = fromHex(methodSignature + strip0x(abi));
|
||||
const tx = new Tx(environment.bloxbergChainId);
|
||||
tx.nonce = await this.web3.eth.getTransactionCount(senderAddress);
|
||||
@@ -1182,7 +1214,7 @@ export class TransactionService {
|
||||
tx.value = toValue(value);
|
||||
tx.data = data;
|
||||
const txMsg = tx.message();
|
||||
const privateKey = this.authService.mutableKeyStore.getPrivateKey();
|
||||
const privateKey = this.authService.mutableKeyStore.getPrivateKey();
|
||||
if (!privateKey.isDecrypted()) {
|
||||
const password = window.prompt('password');
|
||||
await privateKey.decrypt(password);
|
||||
|
||||
@@ -209,7 +209,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="34" class="link-to-prism">src/app/_services/user.service.ts:34</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="36" class="link-to-prism">src/app/_services/user.service.ts:36</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -322,8 +322,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="123"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:123</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="154"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:154</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -394,8 +394,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="65"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:65</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="67"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:67</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -586,8 +586,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="160"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:160</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="195"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:195</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -676,8 +676,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="179"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:179</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="221"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:221</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -764,8 +764,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="131"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:131</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="162"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:162</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -834,8 +834,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="56"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:56</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="58"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:58</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -904,8 +904,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="207"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:207</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="256"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:256</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -943,8 +943,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="119"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:119</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="150"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:150</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1013,8 +1013,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="115"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:115</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="143"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:143</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1052,8 +1052,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="199"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:199</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="248"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:248</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1091,8 +1091,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="203"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:203</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="252"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:252</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1161,8 +1161,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="215"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:215</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="264"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:264</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1200,8 +1200,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="61"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:61</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="63"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:63</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1282,8 +1282,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="211"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:211</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="260"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:260</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1323,8 +1323,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="149"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:149</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="180"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:180</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1412,8 +1412,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="192"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:192</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="239"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:239</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1451,8 +1451,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="51"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:51</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="53"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:53</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1521,8 +1521,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="127"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:127</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="158"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:158</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1591,8 +1591,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="197"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:197</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="244"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:244</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1663,8 +1663,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="107"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:107</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="128"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:128</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1757,8 +1757,8 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="135"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:135</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="166"
|
||||
class="link-to-prism">src/app/_services/user.service.ts:166</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1876,7 +1876,9 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Default value : </i><code>new BehaviorSubject<Array<AccountDetails>>(this.accounts)</code>
|
||||
<i>Default value : </i><code>new BehaviorSubject<
|
||||
Array<AccountDetails>
|
||||
>(this.accounts)</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -1913,7 +1915,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="30" class="link-to-prism">src/app/_services/user.service.ts:30</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="32" class="link-to-prism">src/app/_services/user.service.ts:32</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1945,7 +1947,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="32" class="link-to-prism">src/app/_services/user.service.ts:32</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="34" class="link-to-prism">src/app/_services/user.service.ts:34</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1978,7 +1980,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="33" class="link-to-prism">src/app/_services/user.service.ts:33</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="35" class="link-to-prism">src/app/_services/user.service.ts:35</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -2010,7 +2012,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="34" class="link-to-prism">src/app/_services/user.service.ts:34</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="36" class="link-to-prism">src/app/_services/user.service.ts:36</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -2037,7 +2039,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Default value : </i><code>new HttpHeaders({'x-cic-automerge': 'client'})</code>
|
||||
<i>Default value : </i><code>new HttpHeaders({ 'x-cic-automerge': 'client' })</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -2136,35 +2138,37 @@
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, Observable, Subject} from 'rxjs';
|
||||
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||
import {environment} from '@src/environments/environment';
|
||||
import {first} from 'rxjs/operators';
|
||||
import {ArgPair, Envelope, Phone, Syncable, User} from 'cic-client-meta';
|
||||
import {AccountDetails} from '@app/_models';
|
||||
import {LoggingService} from '@app/_services/logging.service';
|
||||
import {TokenService} from '@app/_services/token.service';
|
||||
import {AccountIndex} from '@app/_eth';
|
||||
import {MutableKeyStore, PGPSigner, Signer} from '@app/_pgp';
|
||||
import {RegistryService} from '@app/_services/registry.service';
|
||||
import {CICRegistry} from 'cic-client';
|
||||
import {AuthService} from '@app/_services/auth.service';
|
||||
import {personValidation, vcardValidation} from '@app/_helpers';
|
||||
import {add0x} from '@src/assets/js/ethtx/dist/hex';
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { environment } from '@src/environments/environment';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { ArgPair, Envelope, Phone, Syncable, User } from 'cic-client-meta';
|
||||
import { AccountDetails } from '@app/_models';
|
||||
import { LoggingService } from '@app/_services/logging.service';
|
||||
import { TokenService } from '@app/_services/token.service';
|
||||
import { AccountIndex } from '@app/_eth';
|
||||
import { MutableKeyStore, PGPSigner, Signer } from '@app/_pgp';
|
||||
import { RegistryService } from '@app/_services/registry.service';
|
||||
import { CICRegistry } from 'cic-client';
|
||||
import { AuthService } from '@app/_services/auth.service';
|
||||
import { personValidation, vcardValidation } from '@app/_helpers';
|
||||
import { add0x } from '@src/assets/js/ethtx/dist/hex';
|
||||
const vCard = require('vcard-parser');
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserService {
|
||||
headers: HttpHeaders = new HttpHeaders({'x-cic-automerge': 'client'});
|
||||
headers: HttpHeaders = new HttpHeaders({ 'x-cic-automerge': 'client' });
|
||||
keystore: MutableKeyStore;
|
||||
signer: Signer;
|
||||
registry: CICRegistry;
|
||||
|
||||
accounts: Array<AccountDetails> = [];
|
||||
private accountsList: BehaviorSubject<Array<AccountDetails>> = new BehaviorSubject<Array<AccountDetails>>(this.accounts);
|
||||
private accountsList: BehaviorSubject<Array<AccountDetails>> = new BehaviorSubject<
|
||||
Array<AccountDetails>
|
||||
>(this.accounts);
|
||||
accountsSubject: Observable<Array<AccountDetails>> = this.accountsList.asObservable();
|
||||
|
||||
actions: Array<any> = [];
|
||||
@@ -2176,7 +2180,7 @@ export class UserService {
|
||||
private loggingService: LoggingService,
|
||||
private tokenService: TokenService,
|
||||
private registryService: RegistryService,
|
||||
private authService: AuthService,
|
||||
private authService: AuthService
|
||||
) {
|
||||
this.authService.init().then(() => {
|
||||
this.keystore = authService.mutableKeyStore;
|
||||
@@ -2188,28 +2192,38 @@ export class UserService {
|
||||
|
||||
resetPin(phone: string): Observable<any> {
|
||||
const params: HttpParams = new HttpParams().set('phoneNumber', phone);
|
||||
return this.httpClient.get(`${environment.cicUssdUrl}/pin`, {params});
|
||||
return this.httpClient.get(`${environment.cicUssdUrl}/pin`, { params });
|
||||
}
|
||||
|
||||
getAccountStatus(phone: string): Observable<any> {
|
||||
const params: HttpParams = new HttpParams().set('phoneNumber', phone);
|
||||
return this.httpClient.get(`${environment.cicUssdUrl}/pin`, {params});
|
||||
return this.httpClient.get(`${environment.cicUssdUrl}/pin`, { params });
|
||||
}
|
||||
|
||||
getLockedAccounts(offset: number, limit: number): Observable<any> {
|
||||
return this.httpClient.get(`${environment.cicUssdUrl}/accounts/locked/${offset}/${limit}`);
|
||||
}
|
||||
|
||||
async changeAccountInfo(address: string, name: string, phoneNumber: string, age: string, type: string, bio: string, gender: string,
|
||||
businessCategory: string, userLocation: string, location: string, locationType: string
|
||||
async changeAccountInfo(
|
||||
address: string,
|
||||
name: string,
|
||||
phoneNumber: string,
|
||||
age: string,
|
||||
type: string,
|
||||
bio: string,
|
||||
gender: string,
|
||||
businessCategory: string,
|
||||
userLocation: string,
|
||||
location: string,
|
||||
locationType: string
|
||||
): Promise<any> {
|
||||
const accountInfo: any = {
|
||||
vcard: {
|
||||
fn: [{}],
|
||||
n: [{}],
|
||||
tel: [{}]
|
||||
tel: [{}],
|
||||
},
|
||||
location: {}
|
||||
location: {},
|
||||
};
|
||||
accountInfo.vcard.fn[0].value = name;
|
||||
accountInfo.vcard.n[0].value = name.split(' ');
|
||||
@@ -2225,33 +2239,52 @@ export class UserService {
|
||||
await vcardValidation(accountInfo.vcard);
|
||||
accountInfo.vcard = btoa(vCard.generate(accountInfo.vcard));
|
||||
const accountKey: string = await User.toKey(address);
|
||||
this.getAccountDetailsFromMeta(accountKey).pipe(first()).subscribe(async res => {
|
||||
const syncableAccount: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap();
|
||||
const update: Array<ArgPair> = [];
|
||||
for (const prop in accountInfo) {
|
||||
update.push(new ArgPair(prop, accountInfo[prop]));
|
||||
}
|
||||
syncableAccount.update(update, 'client-branch');
|
||||
await personValidation(syncableAccount.m.data);
|
||||
await this.updateMeta(syncableAccount, accountKey, this.headers);
|
||||
}, async error => {
|
||||
this.loggingService.sendErrorLevelMessage('Can\'t find account info in meta service', this, {error});
|
||||
const syncableAccount: Syncable = new Syncable(accountKey, accountInfo);
|
||||
await this.updateMeta(syncableAccount, accountKey, this.headers);
|
||||
});
|
||||
this.getAccountDetailsFromMeta(accountKey)
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
async (res) => {
|
||||
const syncableAccount: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap();
|
||||
const update: Array<ArgPair> = [];
|
||||
for (const prop of Object.keys(accountInfo)) {
|
||||
update.push(new ArgPair(prop, accountInfo[prop]));
|
||||
}
|
||||
syncableAccount.update(update, 'client-branch');
|
||||
await personValidation(syncableAccount.m.data);
|
||||
await this.updateMeta(syncableAccount, accountKey, this.headers);
|
||||
},
|
||||
async (error) => {
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
'Cannot find account info in meta service',
|
||||
this,
|
||||
{ error }
|
||||
);
|
||||
const syncableAccount: Syncable = new Syncable(accountKey, accountInfo);
|
||||
await this.updateMeta(syncableAccount, accountKey, this.headers);
|
||||
}
|
||||
);
|
||||
return accountKey;
|
||||
}
|
||||
|
||||
async updateMeta(syncableAccount: Syncable, accountKey: string, headers: HttpHeaders): Promise<any> {
|
||||
const envelope: Envelope = await this.wrap(syncableAccount , this.signer);
|
||||
async updateMeta(
|
||||
syncableAccount: Syncable,
|
||||
accountKey: string,
|
||||
headers: HttpHeaders
|
||||
): Promise<any> {
|
||||
const envelope: Envelope = await this.wrap(syncableAccount, this.signer);
|
||||
const reqBody: string = envelope.toJSON();
|
||||
this.httpClient.put(`${environment.cicMetaUrl}/${accountKey}`, reqBody , { headers }).pipe(first()).subscribe(res => {
|
||||
this.loggingService.sendInfoLevelMessage(`Response: ${res}`);
|
||||
});
|
||||
this.httpClient
|
||||
.put(`${environment.cicMetaUrl}/${accountKey}`, reqBody, { headers })
|
||||
.pipe(first())
|
||||
.subscribe((res) => {
|
||||
this.loggingService.sendInfoLevelMessage(`Response: ${res}`);
|
||||
});
|
||||
}
|
||||
|
||||
getActions(): void {
|
||||
this.httpClient.get(`${environment.cicCacheUrl}/actions`).pipe(first()).subscribe(res => this.actionsList.next(res));
|
||||
this.httpClient
|
||||
.get(`${environment.cicCacheUrl}/actions`)
|
||||
.pipe(first())
|
||||
.subscribe((res) => this.actionsList.next(res));
|
||||
}
|
||||
|
||||
getActionById(id: string): Observable<any> {
|
||||
@@ -2286,44 +2319,60 @@ export class UserService {
|
||||
|
||||
async loadAccounts(limit: number = 100, offset: number = 0): Promise<void> {
|
||||
this.resetAccountsList();
|
||||
const accountIndexAddress: string = await this.registry.getContractAddressByName('AccountRegistry');
|
||||
const accountIndexAddress: string = await this.registry.getContractAddressByName(
|
||||
'AccountRegistry'
|
||||
);
|
||||
const accountIndexQuery = new AccountIndex(accountIndexAddress);
|
||||
const accountAddresses: Array<string> = await accountIndexQuery.last(await accountIndexQuery.totalAccounts());
|
||||
const accountAddresses: Array<string> = await accountIndexQuery.last(
|
||||
await accountIndexQuery.totalAccounts()
|
||||
);
|
||||
this.loggingService.sendInfoLevelMessage(accountAddresses);
|
||||
for (const accountAddress of accountAddresses.slice(offset, offset + limit)) {
|
||||
await this.getAccountByAddress(accountAddress, limit);
|
||||
}
|
||||
}
|
||||
|
||||
async getAccountByAddress(accountAddress: string, limit: number = 100): Promise<Observable<AccountDetails>> {
|
||||
let accountSubject: Subject<any> = new Subject<any>();
|
||||
this.getAccountDetailsFromMeta(await User.toKey(add0x(accountAddress))).pipe(first()).subscribe(async res => {
|
||||
const account: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap();
|
||||
const accountInfo = account.m.data;
|
||||
await personValidation(accountInfo);
|
||||
accountInfo.balance = await this.tokenService.getTokenBalance(accountInfo.identities.evm[`bloxberg:${environment.bloxbergChainId}`][0]);
|
||||
accountInfo.vcard = vCard.parse(atob(accountInfo.vcard));
|
||||
await vcardValidation(accountInfo.vcard);
|
||||
this.accounts.unshift(accountInfo);
|
||||
if (this.accounts.length > limit) {
|
||||
this.accounts.length = limit;
|
||||
}
|
||||
this.accountsList.next(this.accounts);
|
||||
accountSubject.next(accountInfo);
|
||||
});
|
||||
async getAccountByAddress(
|
||||
accountAddress: string,
|
||||
limit: number = 100
|
||||
): Promise<Observable<AccountDetails>> {
|
||||
const accountSubject: Subject<any> = new Subject<any>();
|
||||
this.getAccountDetailsFromMeta(await User.toKey(add0x(accountAddress)))
|
||||
.pipe(first())
|
||||
.subscribe(async (res) => {
|
||||
const account: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap();
|
||||
const accountInfo = account.m.data;
|
||||
await personValidation(accountInfo);
|
||||
accountInfo.balance = await this.tokenService.getTokenBalance(
|
||||
accountInfo.identities.evm[`bloxberg:${environment.bloxbergChainId}`][0]
|
||||
);
|
||||
accountInfo.vcard = vCard.parse(atob(accountInfo.vcard));
|
||||
await vcardValidation(accountInfo.vcard);
|
||||
this.accounts.unshift(accountInfo);
|
||||
if (this.accounts.length > limit) {
|
||||
this.accounts.length = limit;
|
||||
}
|
||||
this.accountsList.next(this.accounts);
|
||||
accountSubject.next(accountInfo);
|
||||
});
|
||||
return accountSubject.asObservable();
|
||||
}
|
||||
|
||||
async getAccountByPhone(phoneNumber: string, limit: number = 100): Promise<Observable<AccountDetails>> {
|
||||
let accountSubject: Subject<any> = new Subject<any>();
|
||||
this.getAccountDetailsFromMeta(await Phone.toKey(phoneNumber)).pipe(first()).subscribe(async res => {
|
||||
const response: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap();
|
||||
const address: string = response.m.data;
|
||||
const account: Observable<AccountDetails> = await this.getAccountByAddress(address, limit);
|
||||
account.subscribe(result => {
|
||||
accountSubject.next(result);
|
||||
async getAccountByPhone(
|
||||
phoneNumber: string,
|
||||
limit: number = 100
|
||||
): Promise<Observable<AccountDetails>> {
|
||||
const accountSubject: Subject<any> = new Subject<any>();
|
||||
this.getAccountDetailsFromMeta(await Phone.toKey(phoneNumber))
|
||||
.pipe(first())
|
||||
.subscribe(async (res) => {
|
||||
const response: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap();
|
||||
const address: string = response.m.data;
|
||||
const account: Observable<AccountDetails> = await this.getAccountByAddress(address, limit);
|
||||
account.subscribe((result) => {
|
||||
accountSubject.next(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
return accountSubject.asObservable();
|
||||
}
|
||||
|
||||
@@ -2332,7 +2381,9 @@ export class UserService {
|
||||
this.accountsList.next(this.accounts);
|
||||
}
|
||||
|
||||
searchAccountByName(name: string): any { return; }
|
||||
searchAccountByName(name: string): any {
|
||||
return;
|
||||
}
|
||||
|
||||
getCategories(): Observable<any> {
|
||||
return this.httpClient.get(`${environment.cicMetaUrl}/categories`);
|
||||
|
||||
Reference in New Issue
Block a user