Format docs using linter and prettier.

This commit is contained in:
Spencer Ofwiti
2021-05-11 20:51:48 +03:00
parent 5228842e61
commit 208c448984
309 changed files with 11327 additions and 3307 deletions

View File

@@ -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 &#x27;@angular/core&#x27;;
import {hobaParseChallengeHeader} from &#x27;@src/assets/js/hoba.js&#x27;;
import {signChallenge} from &#x27;@src/assets/js/hoba-pgp.js&#x27;;
import {environment} from &#x27;@src/environments/environment&#x27;;
import {LoggingService} from &#x27;@app/_services/logging.service&#x27;;
import {MutableKeyStore, MutablePgpKeyStore} from &#x27;@app/_pgp&#x27;;
import {ErrorDialogService} from &#x27;@app/_services/error-dialog.service&#x27;;
import {HttpClient} from &#x27;@angular/common/http&#x27;;
import {HttpError} from &#x27;@app/_helpers/global-error-handler&#x27;;
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from &#x27;@angular/core&#x27;;
import { hobaParseChallengeHeader } from &#x27;@src/assets/js/hoba.js&#x27;;
import { signChallenge } from &#x27;@src/assets/js/hoba-pgp.js&#x27;;
import { environment } from &#x27;@src/environments/environment&#x27;;
import { LoggingService } from &#x27;@app/_services/logging.service&#x27;;
import { MutableKeyStore, MutablePgpKeyStore } from &#x27;@app/_pgp&#x27;;
import { ErrorDialogService } from &#x27;@app/_services/error-dialog.service&#x27;;
import { HttpClient } from &#x27;@angular/common/http&#x27;;
import { HttpError } from &#x27;@app/_helpers/global-error-handler&#x27;;
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class AuthService {
sessionToken: any;
@@ -1027,8 +1027,8 @@ export class AuthService {
xhr.setRequestHeader(&#x27;x-cic-automerge&#x27;, &#x27;none&#x27;);
xhr.addEventListener(&#x27;load&#x27;, (e) &#x3D;&gt; {
if (xhr.status !&#x3D;&#x3D; 200) {
const error &#x3D; new HttpError(xhr.statusText, xhr.status);
return reject(error);
const error &#x3D; new HttpError(xhr.statusText, xhr.status);
return reject(error);
}
this.sessionToken &#x3D; xhr.getResponseHeader(&#x27;Token&#x27;);
sessionStorage.setItem(btoa(&#x27;CICADA_SESSION_TOKEN&#x27;), this.sessionToken);
@@ -1054,50 +1054,53 @@ export class AuthService {
xhr.send();
}
login(): boolean {
if (this.sessionToken !&#x3D;&#x3D; undefined) {
try {
this.getWithToken();
return true;
} catch (e) {
this.loggingService.sendErrorLevelMessage(&#x27;Login token failed&#x27;, this, {error: e});
this.loggingService.sendErrorLevelMessage(&#x27;Login token failed&#x27;, this, { error: e });
}
} else {
try {
this.getChallenge();
} catch (e) {
this.loggingService.sendErrorLevelMessage(&#x27;Login challenge failed&#x27;, this, {error: e});
this.loggingService.sendErrorLevelMessage(&#x27;Login challenge failed&#x27;, this, { error: e });
}
}
return false;
}
async loginResponse(o: { challenge: string, realm: any }): Promise&lt;any&gt; {
async loginResponse(o: { challenge: string; realm: any }): Promise&lt;any&gt; {
return new Promise(async (resolve, reject) &#x3D;&gt; {
try {
const r &#x3D; await signChallenge(o.challenge,
o.realm,
environment.cicMetaUrl,
this.mutableKeyStore);
const r &#x3D; await signChallenge(
o.challenge,
o.realm,
environment.cicMetaUrl,
this.mutableKeyStore
);
const sessionTokenResult: boolean &#x3D; await this.sendResponse(r);
} catch (error) {
if (error instanceof HttpError) {
if (error.status &#x3D;&#x3D;&#x3D; 403) {
this.errorDialogService.openDialog({ message: &#x27;You are not authorized to use this system&#x27; });
this.errorDialogService.openDialog({
message: &#x27;You are not authorized to use this system&#x27;,
});
}
if (error.status &#x3D;&#x3D;&#x3D; 401) {
this.errorDialogService.openDialog({
message: &#x27;Unable to authenticate with the service. &#x27; +
message:
&#x27;Unable to authenticate with the service. &#x27; +
&#x27;Please speak with the staff at Grassroots &#x27; +
&#x27;Economics for requesting access &#x27; +
&#x27;staff@grassrootseconomics.net.&#x27;
&#x27;staff@grassrootseconomics.net.&#x27;,
});
}
}
// TODO define this error
this.errorDialogService.openDialog({message: &#x27;Incorrect key passphrase.&#x27;});
this.errorDialogService.openDialog({ message: &#x27;Incorrect key passphrase.&#x27; });
resolve(false);
}
});
@@ -1109,10 +1112,6 @@ export class AuthService {
this.setState(&#x27;Click button to log in with PGP key &#x27; + this.mutableKeyStore.getPrivateKeyId());
}
/**
* @throws
* @param privateKeyArmored
*/
async setKey(privateKeyArmored): Promise&lt;boolean&gt; {
try {
const isValidKeyCheck &#x3D; await this.mutableKeyStore.isValidKey(privateKeyArmored);
@@ -1127,7 +1126,11 @@ export class AuthService {
const key &#x3D; await this.mutableKeyStore.importPrivateKey(privateKeyArmored);
localStorage.setItem(btoa(&#x27;CICADA_PRIVATE_KEY&#x27;), privateKeyArmored);
} catch (err) {
this.loggingService.sendErrorLevelMessage(&#x60;Failed to set key: ${err.message || err.statusText}&#x60;, this, {error: err});
this.loggingService.sendErrorLevelMessage(
&#x60;Failed to set key: ${err.message || err.statusText}&#x60;,
this,
{ error: err }
);
this.errorDialogService.openDialog({
message: &#x60;Failed to set key: ${err.message || err.statusText}&#x60;,
});
@@ -1140,28 +1143,27 @@ export class AuthService {
logout(): void {
sessionStorage.removeItem(btoa(&#x27;CICADA_SESSION_TOKEN&#x27;));
this.sessionToken &#x3D; undefined;
window.location.reload(true);
window.location.reload();
}
getTrustedUsers(): any {
const trustedUsers: Array&lt;any&gt; &#x3D; [];
this.mutableKeyStore.getPublicKeys().forEach(key &#x3D;&gt; trustedUsers.push(key.users[0].userId));
this.mutableKeyStore.getPublicKeys().forEach((key) &#x3D;&gt; trustedUsers.push(key.users[0].userId));
return trustedUsers;
}
async getPublicKeys(): Promise&lt;any&gt; {
return await fetch(environment.publicKeysUrl)
.then(res &#x3D;&gt; {
if (!res.ok) {
// TODO does angular recommend an error interface?
throw Error(&#x60;${res.statusText} - ${res.status}&#x60;);
}
return res.text();
});
return await fetch(environment.publicKeysUrl).then((res) &#x3D;&gt; {
if (!res.ok) {
// TODO does angular recommend an error interface?
throw Error(&#x60;${res.statusText} - ${res.status}&#x60;);
}
return res.text();
});
}
getPrivateKey(): any {
return this.mutableKeyStore.getPrivateKey();
return this.mutableKeyStore.getPrivateKey();
}
}
</code></pre>

View File

@@ -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 &#x27;@angular/core&#x27;;
import {Settings} from &#x27;@app/_models&#x27;;
import {TransactionHelper} from &#x27;cic-client&#x27;;
import {first} from &#x27;rxjs/operators&#x27;;
import {TransactionService} from &#x27;@app/_services/transaction.service&#x27;;
import {environment} from &#x27;@src/environments/environment&#x27;;
import {LoggingService} from &#x27;@app/_services/logging.service&#x27;;
import {RegistryService} from &#x27;@app/_services/registry.service&#x27;;
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from &#x27;@angular/core&#x27;;
import { Settings } from &#x27;@app/_models&#x27;;
import { TransactionHelper } from &#x27;cic-client&#x27;;
import { first } from &#x27;rxjs/operators&#x27;;
import { TransactionService } from &#x27;@app/_services/transaction.service&#x27;;
import { environment } from &#x27;@src/environments/environment&#x27;;
import { LoggingService } from &#x27;@app/_services/logging.service&#x27;;
import { RegistryService } from &#x27;@app/_services/registry.service&#x27;;
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class BlockSyncService {
readyStateTarget: number &#x3D; 2;
@@ -872,8 +872,8 @@ export class BlockSyncService {
constructor(
private transactionService: TransactionService,
private loggingService: LoggingService,
private registryService: RegistryService,
) { }
private registryService: RegistryService
) {}
blockSync(address: string &#x3D; null, offset: number &#x3D; 0, limit: number &#x3D; 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 |&#x3D; bit;
if (this.readyStateTarget &#x3D;&#x3D;&#x3D; this.readyState &amp;&amp; this.readyStateTarget) {
const wHeadSync: Worker &#x3D; new Worker(&#x27;./../assets/js/block-sync/head.js&#x27;);
@@ -909,13 +916,19 @@ export class BlockSyncService {
w3_provider: settings.w3.provider,
});
if (address &#x3D;&#x3D;&#x3D; null) {
this.transactionService.getAllTransactions(offset, limit).pipe(first()).subscribe(res &#x3D;&gt; {
this.fetcher(settings, res);
});
this.transactionService
.getAllTransactions(offset, limit)
.pipe(first())
.subscribe((res) &#x3D;&gt; {
this.fetcher(settings, res);
});
} else {
this.transactionService.getAddressTransactions(address, offset, limit).pipe(first()).subscribe(res &#x3D;&gt; {
this.fetcher(settings, res);
});
this.transactionService
.getAddressTransactions(address, offset, limit)
.pipe(first())
.subscribe((res) &#x3D;&gt; {
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&lt;void&gt; {
async scan(
settings: Settings,
lo: number,
hi: number,
bloomBlockBytes: Uint8Array,
bloomBlocktxBytes: Uint8Array,
bloomRounds: any
): Promise&lt;void&gt; {
const w: Worker &#x3D; new Worker(&#x27;./../assets/js/block-sync/ondemand.js&#x27;);
w.onmessage &#x3D; (m) &#x3D;&gt; {
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 &#x3D; window.atob(transactionsInfo.block_filter);
const bOne: Uint8Array &#x3D; new Uint8Array(blockFilterBinstr.length);
bOne.map((e, i, v) &#x3D;&gt; v[i] &#x3D; blockFilterBinstr.charCodeAt(i));
bOne.map((e, i, v) &#x3D;&gt; (v[i] &#x3D; blockFilterBinstr.charCodeAt(i)));
const blocktxFilterBinstr: string &#x3D; window.atob(transactionsInfo.blocktx_filter);
const bTwo: Uint8Array &#x3D; new Uint8Array(blocktxFilterBinstr.length);
bTwo.map((e, i, v) &#x3D;&gt; v[i] &#x3D; blocktxFilterBinstr.charCodeAt(i));
bTwo.map((e, i, v) &#x3D;&gt; (v[i] &#x3D; 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>

View File

@@ -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 &#x27;@angular/core&#x27;;
import {MatDialog, MatDialogRef} from &#x27;@angular/material/dialog&#x27;;
import {ErrorDialogComponent} from &#x27;@app/shared/error-dialog/error-dialog.component&#x27;;
import { MatDialog, MatDialogRef } from &#x27;@angular/material/dialog&#x27;;
import { ErrorDialogComponent } from &#x27;@app/shared/error-dialog/error-dialog.component&#x27;;
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class ErrorDialogService {
public isDialogOpen: boolean &#x3D; false;
constructor(
public dialog: MatDialog,
) { }
constructor(public dialog: MatDialog) {}
openDialog(data): any {
if (this.isDialogOpen) {
@@ -323,10 +321,10 @@ export class ErrorDialogService {
this.isDialogOpen &#x3D; true;
const dialogRef: MatDialogRef&lt;any&gt; &#x3D; this.dialog.open(ErrorDialogComponent, {
width: &#x27;300px&#x27;,
data
data,
});
dialogRef.afterClosed().subscribe(() &#x3D;&gt; this.isDialogOpen &#x3D; false);
dialogRef.afterClosed().subscribe(() &#x3D;&gt; (this.isDialogOpen &#x3D; false));
}
}
</code></pre>

View File

@@ -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 &#x27;@angular/common/http&#x27;;
import {ErrorHandler, Injectable} from &#x27;@angular/core&#x27;;
import {Router} from &#x27;@angular/router&#x27;;
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { HttpErrorResponse } from &#x27;@angular/common/http&#x27;;
import { ErrorHandler, Injectable } from &#x27;@angular/core&#x27;;
import { Router } from &#x27;@angular/router&#x27;;
// Application imports
import {LoggingService} from &#x27;@app/_services/logging.service&#x27;;
import { LoggingService } from &#x27;@app/_services/logging.service&#x27;;
/**
* 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&lt;string&gt; &#x3D; [];
@@ -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 &#x3D; 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&#x27;s stack trace.
* @returns true - If the error is of type warning.
* @private
*/
private isWarning(errorTraceString: string): boolean {
let isWarning: boolean &#x3D; true;
@@ -613,14 +608,30 @@ export class GlobalErrorHandler extends ErrorHandler {
const route: string &#x3D; this.router.url;
if (error instanceof HttpErrorResponse) {
this.loggingService.sendErrorLevelMessage(
&#x60;There was an HTTP error on route ${route}.\n${error.message}.\nStatus code: ${(error as HttpErrorResponse).status}&#x60;,
this, {error});
&#x60;There was an HTTP error on route ${route}.\n${error.message}.\nStatus code: ${
(error as HttpErrorResponse).status
}&#x60;,
this,
{ error }
);
} else if (error instanceof TypeError) {
this.loggingService.sendErrorLevelMessage(&#x60;There was a Type error on route ${route}.\n${error.message}&#x60;, this, {error});
this.loggingService.sendErrorLevelMessage(
&#x60;There was a Type error on route ${route}.\n${error.message}&#x60;,
this,
{ error }
);
} else if (error instanceof Error) {
this.loggingService.sendErrorLevelMessage(&#x60;There was a general error on route ${route}.\n${error.message}&#x60;, this, {error});
this.loggingService.sendErrorLevelMessage(
&#x60;There was a general error on route ${route}.\n${error.message}&#x60;,
this,
{ error }
);
} else {
this.loggingService.sendErrorLevelMessage(&#x60;Nobody threw an error but something happened on route ${route}!&#x60;, this, {error});
this.loggingService.sendErrorLevelMessage(
&#x60;Nobody threw an error but something happened on route ${route}!&#x60;,
this,
{ error }
);
}
}
}

View File

@@ -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 &#x27;@angular/core&#x27;;
import {Observable} from &#x27;rxjs&#x27;;
import {environment} from &#x27;@src/environments/environment&#x27;;
import {first} from &#x27;rxjs/operators&#x27;;
import {HttpClient} from &#x27;@angular/common/http&#x27;;
import { Observable } from &#x27;rxjs&#x27;;
import { environment } from &#x27;@src/environments/environment&#x27;;
import { first } from &#x27;rxjs/operators&#x27;;
import { HttpClient } from &#x27;@angular/common/http&#x27;;
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class LocationService {
constructor(
private httpClient: HttpClient,
) { }
constructor(private httpClient: HttpClient) {}
getAreaNames(): Observable&lt;any&gt; {
return this.httpClient.get(&#x60;${environment.cicMetaUrl}/areanames&#x60;);
@@ -405,7 +402,9 @@ export class LocationService {
}
getAreaTypeByArea(area: string): Observable&lt;any&gt; {
return this.httpClient.get(&#x60;${environment.cicMetaUrl}/areatypes/${area.toLowerCase()}&#x60;).pipe(first());
return this.httpClient
.get(&#x60;${environment.cicMetaUrl}/areatypes/${area.toLowerCase()}&#x60;)
.pipe(first());
}
}
</code></pre>

View File

@@ -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 &#x27;@angular/core&#x27;;
import {NGXLogger} from &#x27;ngx-logger&#x27;;
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable, isDevMode } from &#x27;@angular/core&#x27;;
import { NGXLogger } from &#x27;ngx-logger&#x27;;
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class LoggingService {
env: string;

View File

@@ -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, &#x27;CICRegistry&#x27;, this.fileGetter,
[&#x27;../../assets/js/block-sync/data&#x27;])</code>
<i>Default value : </i><code>new CICRegistry(
this.web3,
environment.registryAddress,
&#x27;CICRegistry&#x27;,
this.fileGetter,
[&#x27;../../assets/js/block-sync/data&#x27;]
)</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 &#x27;@angular/core&#x27;;
import Web3 from &#x27;web3&#x27;;
import {environment} from &#x27;@src/environments/environment&#x27;;
import {CICRegistry, FileGetter} from &#x27;cic-client&#x27;;
import {HttpGetter} from &#x27;@app/_helpers&#x27;;
import { environment } from &#x27;@src/environments/environment&#x27;;
import { CICRegistry, FileGetter } from &#x27;cic-client&#x27;;
import { HttpGetter } from &#x27;@app/_helpers&#x27;;
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class RegistryService {
web3: Web3 &#x3D; new Web3(environment.web3Provider);
fileGetter: FileGetter &#x3D; new HttpGetter();
registry: CICRegistry &#x3D; new CICRegistry(this.web3, environment.registryAddress, &#x27;CICRegistry&#x27;, this.fileGetter,
[&#x27;../../assets/js/block-sync/data&#x27;]);
registry: CICRegistry &#x3D; new CICRegistry(
this.web3,
environment.registryAddress,
&#x27;CICRegistry&#x27;,
this.fileGetter,
[&#x27;../../assets/js/block-sync/data&#x27;]
);
constructor() {
this.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);

View File

@@ -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 &#x27;@angular/core&#x27;;
import {environment} from &#x27;@src/environments/environment&#x27;;
import {BehaviorSubject, Observable} from &#x27;rxjs&#x27;;
import {CICRegistry} from &#x27;cic-client&#x27;;
import {TokenRegistry} from &#x27;@app/_eth&#x27;;
import {HttpClient} from &#x27;@angular/common/http&#x27;;
import {RegistryService} from &#x27;@app/_services/registry.service&#x27;;
import { environment } from &#x27;@src/environments/environment&#x27;;
import { BehaviorSubject, Observable } from &#x27;rxjs&#x27;;
import { CICRegistry } from &#x27;cic-client&#x27;;
import { TokenRegistry } from &#x27;@app/_eth&#x27;;
import { HttpClient } from &#x27;@angular/common/http&#x27;;
import { RegistryService } from &#x27;@app/_services/registry.service&#x27;;
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class TokenService {
registry: CICRegistry;
tokenRegistry: TokenRegistry;
LoadEvent: EventEmitter&lt;number&gt; &#x3D; new EventEmitter&lt;number&gt;();
constructor(
private httpClient: HttpClient,
private registryService: RegistryService,
) {
constructor(private httpClient: HttpClient, private registryService: RegistryService) {
this.registry &#x3D; registryService.getRegistry();
this.registry.load();
this.registry.onload &#x3D; async (address: string): Promise&lt;void&gt; &#x3D;&gt; {
this.tokenRegistry &#x3D; new TokenRegistry(await this.registry.getContractAddressByName(&#x27;TokenRegistry&#x27;));
this.tokenRegistry &#x3D; new TokenRegistry(
await this.registry.getContractAddressByName(&#x27;TokenRegistry&#x27;)
);
this.LoadEvent.next(Date.now());
};
}
async getTokens(): Promise&lt;Array&lt;Promise&lt;string&gt;&gt;&gt; {
const count: number &#x3D; await this.tokenRegistry.totalTokens();
return Array.from({length: count}, async (v, i) &#x3D;&gt; await this.tokenRegistry.entry(i));
return Array.from({ length: count }, async (v, i) &#x3D;&gt; await this.tokenRegistry.entry(i));
}
getTokenBySymbol(symbol: string): Observable&lt;any&gt; {

View File

@@ -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 &#x27;@angular/core&#x27;;
import {first} from &#x27;rxjs/operators&#x27;;
import {BehaviorSubject, Observable} from &#x27;rxjs&#x27;;
import {environment} from &#x27;@src/environments/environment&#x27;;
import {Envelope, User} from &#x27;cic-client-meta&#x27;;
import {UserService} from &#x27;@app/_services/user.service&#x27;;
import { first } from &#x27;rxjs/operators&#x27;;
import { BehaviorSubject, Observable } from &#x27;rxjs&#x27;;
import { environment } from &#x27;@src/environments/environment&#x27;;
import { Envelope, User } from &#x27;cic-client-meta&#x27;;
import { UserService } from &#x27;@app/_services/user.service&#x27;;
import { Keccak } from &#x27;sha3&#x27;;
import { utils } from &#x27;ethers&#x27;;
import {add0x, fromHex, strip0x, toHex} from &#x27;@src/assets/js/ethtx/dist/hex&#x27;;
import {Tx} from &#x27;@src/assets/js/ethtx/dist&#x27;;
import {toValue} from &#x27;@src/assets/js/ethtx/dist/tx&#x27;;
import { add0x, fromHex, strip0x, toHex } from &#x27;@src/assets/js/ethtx/dist/hex&#x27;;
import { Tx } from &#x27;@src/assets/js/ethtx/dist&#x27;;
import { toValue } from &#x27;@src/assets/js/ethtx/dist/tx&#x27;;
import * as secp256k1 from &#x27;secp256k1&#x27;;
import {AuthService} from &#x27;@app/_services/auth.service&#x27;;
import {defaultAccount} from &#x27;@app/_models&#x27;;
import {LoggingService} from &#x27;@app/_services/logging.service&#x27;;
import {HttpClient} from &#x27;@angular/common/http&#x27;;
import {CICRegistry} from &#x27;cic-client&#x27;;
import {RegistryService} from &#x27;@app/_services/registry.service&#x27;;
import { AuthService } from &#x27;@app/_services/auth.service&#x27;;
import { defaultAccount } from &#x27;@app/_models&#x27;;
import { LoggingService } from &#x27;@app/_services/logging.service&#x27;;
import { HttpClient } from &#x27;@angular/common/http&#x27;;
import { CICRegistry } from &#x27;cic-client&#x27;;
import { RegistryService } from &#x27;@app/_services/registry.service&#x27;;
import Web3 from &#x27;web3&#x27;;
const vCard &#x3D; require(&#x27;vcard-parser&#x27;);
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class TransactionService {
transactions: any[] &#x3D; [];
@@ -1095,7 +1095,7 @@ export class TransactionService {
private authService: AuthService,
private userService: UserService,
private loggingService: LoggingService,
private registryService: RegistryService,
private registryService: RegistryService
) {
this.web3 &#x3D; this.registryService.getWeb3();
this.registry &#x3D; registryService.getRegistry();
@@ -1111,36 +1111,58 @@ export class TransactionService {
}
async setTransaction(transaction, cacheSize: number): Promise&lt;void&gt; {
if (this.transactions.find(cachedTx &#x3D;&gt; cachedTx.tx.txHash &#x3D;&#x3D;&#x3D; transaction.tx.txHash)) { return; }
if (this.transactions.find((cachedTx) &#x3D;&gt; cachedTx.tx.txHash &#x3D;&#x3D;&#x3D; transaction.tx.txHash)) {
return;
}
transaction.value &#x3D; Number(transaction.value);
transaction.type &#x3D; &#x27;transaction&#x27;;
try {
this.userService.getAccountDetailsFromMeta(await User.toKey(transaction.from)).pipe(first()).subscribe((res) &#x3D;&gt; {
transaction.sender &#x3D; this.getAccountInfo(res.body);
}, error &#x3D;&gt; {
transaction.sender &#x3D; defaultAccount;
});
this.userService.getAccountDetailsFromMeta(await User.toKey(transaction.to)).pipe(first()).subscribe((res) &#x3D;&gt; {
transaction.recipient &#x3D; this.getAccountInfo(res.body);
}, error &#x3D;&gt; {
transaction.recipient &#x3D; defaultAccount;
});
this.userService
.getAccountDetailsFromMeta(await User.toKey(transaction.from))
.pipe(first())
.subscribe(
(res) &#x3D;&gt; {
transaction.sender &#x3D; this.getAccountInfo(res.body);
},
(error) &#x3D;&gt; {
transaction.sender &#x3D; defaultAccount;
}
);
this.userService
.getAccountDetailsFromMeta(await User.toKey(transaction.to))
.pipe(first())
.subscribe(
(res) &#x3D;&gt; {
transaction.recipient &#x3D; this.getAccountInfo(res.body);
},
(error) &#x3D;&gt; {
transaction.recipient &#x3D; defaultAccount;
}
);
} finally {
this.addTransaction(transaction, cacheSize);
}
}
async setConversion(conversion, cacheSize): Promise&lt;void&gt; {
if (this.transactions.find(cachedTx &#x3D;&gt; cachedTx.tx.txHash &#x3D;&#x3D;&#x3D; conversion.tx.txHash)) { return; }
if (this.transactions.find((cachedTx) &#x3D;&gt; cachedTx.tx.txHash &#x3D;&#x3D;&#x3D; conversion.tx.txHash)) {
return;
}
conversion.type &#x3D; &#x27;conversion&#x27;;
conversion.fromValue &#x3D; Number(conversion.fromValue);
conversion.toValue &#x3D; Number(conversion.toValue);
try {
this.userService.getAccountDetailsFromMeta(await User.toKey(conversion.trader)).pipe(first()).subscribe((res) &#x3D;&gt; {
conversion.sender &#x3D; conversion.recipient &#x3D; this.getAccountInfo(res.body);
}, error &#x3D;&gt; {
conversion.sender &#x3D; conversion.recipient &#x3D; defaultAccount;
});
this.userService
.getAccountDetailsFromMeta(await User.toKey(conversion.trader))
.pipe(first())
.subscribe(
(res) &#x3D;&gt; {
conversion.sender &#x3D; conversion.recipient &#x3D; this.getAccountInfo(res.body);
},
(error) &#x3D;&gt; {
conversion.sender &#x3D; conversion.recipient &#x3D; defaultAccount;
}
);
} finally {
this.addTransaction(conversion, cacheSize);
}
@@ -1160,19 +1182,29 @@ export class TransactionService {
}
getAccountInfo(account: string): any {
let accountInfo &#x3D; Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data;
const accountInfo &#x3D; Envelope.fromJSON(JSON.stringify(account)).unwrap().m.data;
accountInfo.vcard &#x3D; vCard.parse(atob(accountInfo.vcard));
return accountInfo;
}
async transferRequest(tokenAddress: string, senderAddress: string, recipientAddress: string, value: number): Promise&lt;any&gt; {
const transferAuthAddress &#x3D; await this.registry.getContractAddressByName(&#x27;TransferAuthorization&#x27;);
async transferRequest(
tokenAddress: string,
senderAddress: string,
recipientAddress: string,
value: number
): Promise&lt;any&gt; {
const transferAuthAddress &#x3D; await this.registry.getContractAddressByName(
&#x27;TransferAuthorization&#x27;
);
const hashFunction &#x3D; new Keccak(256);
hashFunction.update(&#x27;createRequest(address,address,address,uint256)&#x27;);
const hash &#x3D; hashFunction.digest();
const methodSignature &#x3D; hash.toString(&#x27;hex&#x27;).substring(0, 8);
const abiCoder &#x3D; new utils.AbiCoder();
const abi &#x3D; await abiCoder.encode([&#x27;address&#x27;, &#x27;address&#x27;, &#x27;address&#x27;, &#x27;uint256&#x27;], [senderAddress, recipientAddress, tokenAddress, value]);
const abi &#x3D; await abiCoder.encode(
[&#x27;address&#x27;, &#x27;address&#x27;, &#x27;address&#x27;, &#x27;uint256&#x27;],
[senderAddress, recipientAddress, tokenAddress, value]
);
const data &#x3D; fromHex(methodSignature + strip0x(abi));
const tx &#x3D; new Tx(environment.bloxbergChainId);
tx.nonce &#x3D; await this.web3.eth.getTransactionCount(senderAddress);
@@ -1182,7 +1214,7 @@ export class TransactionService {
tx.value &#x3D; toValue(value);
tx.data &#x3D; data;
const txMsg &#x3D; tx.message();
const privateKey &#x3D; this.authService.mutableKeyStore.getPrivateKey();
const privateKey &#x3D; this.authService.mutableKeyStore.getPrivateKey();
if (!privateKey.isDecrypted()) {
const password &#x3D; window.prompt(&#x27;password&#x27;);
await privateKey.decrypt(password);

View File

@@ -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&lt;Array&lt;AccountDetails&gt;&gt;(this.accounts)</code>
<i>Default value : </i><code>new BehaviorSubject&lt;
Array&lt;AccountDetails&gt;
&gt;(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({&#x27;x-cic-automerge&#x27;: &#x27;client&#x27;})</code>
<i>Default value : </i><code>new HttpHeaders({ &#x27;x-cic-automerge&#x27;: &#x27;client&#x27; })</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 &#x27;@angular/core&#x27;;
import {BehaviorSubject, Observable, Subject} from &#x27;rxjs&#x27;;
import {HttpClient, HttpHeaders, HttpParams} from &#x27;@angular/common/http&#x27;;
import {environment} from &#x27;@src/environments/environment&#x27;;
import {first} from &#x27;rxjs/operators&#x27;;
import {ArgPair, Envelope, Phone, Syncable, User} from &#x27;cic-client-meta&#x27;;
import {AccountDetails} from &#x27;@app/_models&#x27;;
import {LoggingService} from &#x27;@app/_services/logging.service&#x27;;
import {TokenService} from &#x27;@app/_services/token.service&#x27;;
import {AccountIndex} from &#x27;@app/_eth&#x27;;
import {MutableKeyStore, PGPSigner, Signer} from &#x27;@app/_pgp&#x27;;
import {RegistryService} from &#x27;@app/_services/registry.service&#x27;;
import {CICRegistry} from &#x27;cic-client&#x27;;
import {AuthService} from &#x27;@app/_services/auth.service&#x27;;
import {personValidation, vcardValidation} from &#x27;@app/_helpers&#x27;;
import {add0x} from &#x27;@src/assets/js/ethtx/dist/hex&#x27;;
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from &#x27;@angular/core&#x27;;
import { BehaviorSubject, Observable, Subject } from &#x27;rxjs&#x27;;
import { HttpClient, HttpHeaders, HttpParams } from &#x27;@angular/common/http&#x27;;
import { environment } from &#x27;@src/environments/environment&#x27;;
import { first } from &#x27;rxjs/operators&#x27;;
import { ArgPair, Envelope, Phone, Syncable, User } from &#x27;cic-client-meta&#x27;;
import { AccountDetails } from &#x27;@app/_models&#x27;;
import { LoggingService } from &#x27;@app/_services/logging.service&#x27;;
import { TokenService } from &#x27;@app/_services/token.service&#x27;;
import { AccountIndex } from &#x27;@app/_eth&#x27;;
import { MutableKeyStore, PGPSigner, Signer } from &#x27;@app/_pgp&#x27;;
import { RegistryService } from &#x27;@app/_services/registry.service&#x27;;
import { CICRegistry } from &#x27;cic-client&#x27;;
import { AuthService } from &#x27;@app/_services/auth.service&#x27;;
import { personValidation, vcardValidation } from &#x27;@app/_helpers&#x27;;
import { add0x } from &#x27;@src/assets/js/ethtx/dist/hex&#x27;;
const vCard &#x3D; require(&#x27;vcard-parser&#x27;);
@Injectable({
providedIn: &#x27;root&#x27;
providedIn: &#x27;root&#x27;,
})
export class UserService {
headers: HttpHeaders &#x3D; new HttpHeaders({&#x27;x-cic-automerge&#x27;: &#x27;client&#x27;});
headers: HttpHeaders &#x3D; new HttpHeaders({ &#x27;x-cic-automerge&#x27;: &#x27;client&#x27; });
keystore: MutableKeyStore;
signer: Signer;
registry: CICRegistry;
accounts: Array&lt;AccountDetails&gt; &#x3D; [];
private accountsList: BehaviorSubject&lt;Array&lt;AccountDetails&gt;&gt; &#x3D; new BehaviorSubject&lt;Array&lt;AccountDetails&gt;&gt;(this.accounts);
private accountsList: BehaviorSubject&lt;Array&lt;AccountDetails&gt;&gt; &#x3D; new BehaviorSubject&lt;
Array&lt;AccountDetails&gt;
&gt;(this.accounts);
accountsSubject: Observable&lt;Array&lt;AccountDetails&gt;&gt; &#x3D; this.accountsList.asObservable();
actions: Array&lt;any&gt; &#x3D; [];
@@ -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(() &#x3D;&gt; {
this.keystore &#x3D; authService.mutableKeyStore;
@@ -2188,28 +2192,38 @@ export class UserService {
resetPin(phone: string): Observable&lt;any&gt; {
const params: HttpParams &#x3D; new HttpParams().set(&#x27;phoneNumber&#x27;, phone);
return this.httpClient.get(&#x60;${environment.cicUssdUrl}/pin&#x60;, {params});
return this.httpClient.get(&#x60;${environment.cicUssdUrl}/pin&#x60;, { params });
}
getAccountStatus(phone: string): Observable&lt;any&gt; {
const params: HttpParams &#x3D; new HttpParams().set(&#x27;phoneNumber&#x27;, phone);
return this.httpClient.get(&#x60;${environment.cicUssdUrl}/pin&#x60;, {params});
return this.httpClient.get(&#x60;${environment.cicUssdUrl}/pin&#x60;, { params });
}
getLockedAccounts(offset: number, limit: number): Observable&lt;any&gt; {
return this.httpClient.get(&#x60;${environment.cicUssdUrl}/accounts/locked/${offset}/${limit}&#x60;);
}
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&lt;any&gt; {
const accountInfo: any &#x3D; {
vcard: {
fn: [{}],
n: [{}],
tel: [{}]
tel: [{}],
},
location: {}
location: {},
};
accountInfo.vcard.fn[0].value &#x3D; name;
accountInfo.vcard.n[0].value &#x3D; name.split(&#x27; &#x27;);
@@ -2225,33 +2239,52 @@ export class UserService {
await vcardValidation(accountInfo.vcard);
accountInfo.vcard &#x3D; btoa(vCard.generate(accountInfo.vcard));
const accountKey: string &#x3D; await User.toKey(address);
this.getAccountDetailsFromMeta(accountKey).pipe(first()).subscribe(async res &#x3D;&gt; {
const syncableAccount: Syncable &#x3D; Envelope.fromJSON(JSON.stringify(res)).unwrap();
const update: Array&lt;ArgPair&gt; &#x3D; [];
for (const prop in accountInfo) {
update.push(new ArgPair(prop, accountInfo[prop]));
}
syncableAccount.update(update, &#x27;client-branch&#x27;);
await personValidation(syncableAccount.m.data);
await this.updateMeta(syncableAccount, accountKey, this.headers);
}, async error &#x3D;&gt; {
this.loggingService.sendErrorLevelMessage(&#x27;Can\&#x27;t find account info in meta service&#x27;, this, {error});
const syncableAccount: Syncable &#x3D; new Syncable(accountKey, accountInfo);
await this.updateMeta(syncableAccount, accountKey, this.headers);
});
this.getAccountDetailsFromMeta(accountKey)
.pipe(first())
.subscribe(
async (res) &#x3D;&gt; {
const syncableAccount: Syncable &#x3D; Envelope.fromJSON(JSON.stringify(res)).unwrap();
const update: Array&lt;ArgPair&gt; &#x3D; [];
for (const prop of Object.keys(accountInfo)) {
update.push(new ArgPair(prop, accountInfo[prop]));
}
syncableAccount.update(update, &#x27;client-branch&#x27;);
await personValidation(syncableAccount.m.data);
await this.updateMeta(syncableAccount, accountKey, this.headers);
},
async (error) &#x3D;&gt; {
this.loggingService.sendErrorLevelMessage(
&#x27;Cannot find account info in meta service&#x27;,
this,
{ error }
);
const syncableAccount: Syncable &#x3D; new Syncable(accountKey, accountInfo);
await this.updateMeta(syncableAccount, accountKey, this.headers);
}
);
return accountKey;
}
async updateMeta(syncableAccount: Syncable, accountKey: string, headers: HttpHeaders): Promise&lt;any&gt; {
const envelope: Envelope &#x3D; await this.wrap(syncableAccount , this.signer);
async updateMeta(
syncableAccount: Syncable,
accountKey: string,
headers: HttpHeaders
): Promise&lt;any&gt; {
const envelope: Envelope &#x3D; await this.wrap(syncableAccount, this.signer);
const reqBody: string &#x3D; envelope.toJSON();
this.httpClient.put(&#x60;${environment.cicMetaUrl}/${accountKey}&#x60;, reqBody , { headers }).pipe(first()).subscribe(res &#x3D;&gt; {
this.loggingService.sendInfoLevelMessage(&#x60;Response: ${res}&#x60;);
});
this.httpClient
.put(&#x60;${environment.cicMetaUrl}/${accountKey}&#x60;, reqBody, { headers })
.pipe(first())
.subscribe((res) &#x3D;&gt; {
this.loggingService.sendInfoLevelMessage(&#x60;Response: ${res}&#x60;);
});
}
getActions(): void {
this.httpClient.get(&#x60;${environment.cicCacheUrl}/actions&#x60;).pipe(first()).subscribe(res &#x3D;&gt; this.actionsList.next(res));
this.httpClient
.get(&#x60;${environment.cicCacheUrl}/actions&#x60;)
.pipe(first())
.subscribe((res) &#x3D;&gt; this.actionsList.next(res));
}
getActionById(id: string): Observable&lt;any&gt; {
@@ -2286,44 +2319,60 @@ export class UserService {
async loadAccounts(limit: number &#x3D; 100, offset: number &#x3D; 0): Promise&lt;void&gt; {
this.resetAccountsList();
const accountIndexAddress: string &#x3D; await this.registry.getContractAddressByName(&#x27;AccountRegistry&#x27;);
const accountIndexAddress: string &#x3D; await this.registry.getContractAddressByName(
&#x27;AccountRegistry&#x27;
);
const accountIndexQuery &#x3D; new AccountIndex(accountIndexAddress);
const accountAddresses: Array&lt;string&gt; &#x3D; await accountIndexQuery.last(await accountIndexQuery.totalAccounts());
const accountAddresses: Array&lt;string&gt; &#x3D; 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 &#x3D; 100): Promise&lt;Observable&lt;AccountDetails&gt;&gt; {
let accountSubject: Subject&lt;any&gt; &#x3D; new Subject&lt;any&gt;();
this.getAccountDetailsFromMeta(await User.toKey(add0x(accountAddress))).pipe(first()).subscribe(async res &#x3D;&gt; {
const account: Syncable &#x3D; Envelope.fromJSON(JSON.stringify(res)).unwrap();
const accountInfo &#x3D; account.m.data;
await personValidation(accountInfo);
accountInfo.balance &#x3D; await this.tokenService.getTokenBalance(accountInfo.identities.evm[&#x60;bloxberg:${environment.bloxbergChainId}&#x60;][0]);
accountInfo.vcard &#x3D; vCard.parse(atob(accountInfo.vcard));
await vcardValidation(accountInfo.vcard);
this.accounts.unshift(accountInfo);
if (this.accounts.length &gt; limit) {
this.accounts.length &#x3D; limit;
}
this.accountsList.next(this.accounts);
accountSubject.next(accountInfo);
});
async getAccountByAddress(
accountAddress: string,
limit: number &#x3D; 100
): Promise&lt;Observable&lt;AccountDetails&gt;&gt; {
const accountSubject: Subject&lt;any&gt; &#x3D; new Subject&lt;any&gt;();
this.getAccountDetailsFromMeta(await User.toKey(add0x(accountAddress)))
.pipe(first())
.subscribe(async (res) &#x3D;&gt; {
const account: Syncable &#x3D; Envelope.fromJSON(JSON.stringify(res)).unwrap();
const accountInfo &#x3D; account.m.data;
await personValidation(accountInfo);
accountInfo.balance &#x3D; await this.tokenService.getTokenBalance(
accountInfo.identities.evm[&#x60;bloxberg:${environment.bloxbergChainId}&#x60;][0]
);
accountInfo.vcard &#x3D; vCard.parse(atob(accountInfo.vcard));
await vcardValidation(accountInfo.vcard);
this.accounts.unshift(accountInfo);
if (this.accounts.length &gt; limit) {
this.accounts.length &#x3D; limit;
}
this.accountsList.next(this.accounts);
accountSubject.next(accountInfo);
});
return accountSubject.asObservable();
}
async getAccountByPhone(phoneNumber: string, limit: number &#x3D; 100): Promise&lt;Observable&lt;AccountDetails&gt;&gt; {
let accountSubject: Subject&lt;any&gt; &#x3D; new Subject&lt;any&gt;();
this.getAccountDetailsFromMeta(await Phone.toKey(phoneNumber)).pipe(first()).subscribe(async res &#x3D;&gt; {
const response: Syncable &#x3D; Envelope.fromJSON(JSON.stringify(res)).unwrap();
const address: string &#x3D; response.m.data;
const account: Observable&lt;AccountDetails&gt; &#x3D; await this.getAccountByAddress(address, limit);
account.subscribe(result &#x3D;&gt; {
accountSubject.next(result);
async getAccountByPhone(
phoneNumber: string,
limit: number &#x3D; 100
): Promise&lt;Observable&lt;AccountDetails&gt;&gt; {
const accountSubject: Subject&lt;any&gt; &#x3D; new Subject&lt;any&gt;();
this.getAccountDetailsFromMeta(await Phone.toKey(phoneNumber))
.pipe(first())
.subscribe(async (res) &#x3D;&gt; {
const response: Syncable &#x3D; Envelope.fromJSON(JSON.stringify(res)).unwrap();
const address: string &#x3D; response.m.data;
const account: Observable&lt;AccountDetails&gt; &#x3D; await this.getAccountByAddress(address, limit);
account.subscribe((result) &#x3D;&gt; {
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&lt;any&gt; {
return this.httpClient.get(&#x60;${environment.cicMetaUrl}/categories&#x60;);