diff --git a/docs/compodoc/classes/AccountIndex.html b/docs/compodoc/classes/AccountIndex.html index 9808103..f0cae83 100644 --- a/docs/compodoc/classes/AccountIndex.html +++ b/docs/compodoc/classes/AccountIndex.html @@ -8,7 +8,8 @@ - + + @@ -42,7 +43,7 @@ @@ -223,108 +221,105 @@ Allows querying of accounts that have been registered as valid accounts in the n
-

- Properties -

- - +

+ Properties +

+
+ + + + - - - - - + - + + - -
+ + + contract + + +
- - - - contract - - + Type : any +
- Type : any - +
- -
-

The instance of the account registry contract.

+
+

The instance of the account registry contract.

-
- - + +
+ + + + + - - - - - + - + + - -
+ + + contractAddress + + +
- - - - contractAddress - - + Type : string +
- Type : string - +
- -
-

The deployed account registry contract's address.

+
+

The deployed account registry contract's address.

-
- - + +
+ + + + + - - - - - + - + + - -
+ + + signerAddress + + +
- - - - signerAddress - - + Type : string +
- Type : string - +
- -
-

The account address of the account that deployed the account registry contract.

+
+

The account address of the account that deployed the account registry contract.

-
+ +
@@ -338,11 +333,9 @@ Allows querying of accounts that have been registered as valid accounts in the n - - Public - Async - addToAccountRegistry - + Public + Async + addToAccountRegistry @@ -357,8 +350,8 @@ Allows querying of accounts that have been registered as valid accounts in the n -
Defined in src/app/_eth/accountIndex.ts:58
+
Defined in src/app/_eth/accountIndex.ts:61
@@ -367,7 +360,8 @@ Allows querying of accounts that have been registered as valid accounts in the n

Registers an account to the accounts registry. Requires availability of the signer address.

-
+

Prints "true" for registration of '0xc0ffee254729296a45a3885639AC7E10F9d54979':

+
console.log(await addToAccountRegistry('0xc0ffee254729296a45a3885639AC7E10F9d54979'));
Parameters : @@ -406,11 +400,8 @@ Requires availability of the signer address.

Example :
Prints &quot;true&quot; for registration of &#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;:</p>
-<p>```typescript</p>
-<ul>
-<li>console.log(await addToAccountRegistry(&#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;));</li>
-<li>```</li>
-</ul>
+<pre><code class="language-typescript">console.log(await addToAccountRegistry(&#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;)); +</code></pre>
@@ -431,11 +422,9 @@ Requires availability of the signer address.

- - Public - Async - haveAccount - + Public + Async + haveAccount @@ -450,8 +439,8 @@ Requires availability of the signer address.

- + @@ -460,7 +449,8 @@ Requires availability of the signer address.

Checks whether a specific account address has been registered in the accounts registry. Returns "true" for available and "false" otherwise.

-
+

Prints "true" or "false" depending on whether '0xc0ffee254729296a45a3885639AC7E10F9d54979' has been registered:

+
console.log(await haveAccount('0xc0ffee254729296a45a3885639AC7E10F9d54979'));
Parameters : @@ -499,11 +489,8 @@ Returns "true" for available and "false" otherwise.

Example :
Prints &quot;true&quot; or &quot;false&quot; depending on whether &#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39; has been registered:</p>
-<p>```typescript</p>
-<ul>
-<li>console.log(await haveAccount(&#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;));</li>
-<li>```</li>
-</ul>
+<pre><code class="language-typescript">console.log(await haveAccount(&#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;)); +</code></pre>
@@ -524,11 +511,9 @@ Returns "true" for available and "false" otherwise.

- - Public - Async - last - + Public + Async + last @@ -543,8 +528,8 @@ Returns "true" for available and "false" otherwise.

- + @@ -552,7 +537,8 @@ Returns "true" for available and "false" otherwise.

Returns a specified number of the most recently registered accounts.

-
+

Prints an array of accounts:

+
console.log(await last(5));
Parameters : @@ -591,11 +577,8 @@ Returns "true" for available and "false" otherwise.

Example :
Prints an array of accounts:</p>
-<p>```typescript</p>
-<ul>
-<li>console.log(await last(5));</li>
-<li>```</li>
-</ul>
+<pre><code class="language-typescript">console.log(await last(5)); +</code></pre>
@@ -616,11 +599,9 @@ Returns "true" for available and "false" otherwise.

- - Public - Async - totalAccounts - + Public + Async + totalAccounts @@ -635,8 +616,8 @@ Returns "true" for available and "false" otherwise.

- + @@ -644,17 +625,15 @@ Returns "true" for available and "false" otherwise.

Returns the total number of accounts that have been registered in the network.

-
+

Prints the total number of registered accounts:

+
console.log(await totalAccounts());
Example :
Prints the total number of registered accounts:</p>
-<p>```typescript</p>
-<ul>
-<li>console.log(await totalAccounts());</li>
-<li>```</li>
-</ul>
+<pre><code class="language-typescript">console.log(await totalAccounts()); +</code></pre>
@@ -714,6 +693,9 @@ export class AccountIndex { constructor(contractAddress: string, signerAddress?: string) { this.contractAddress = contractAddress; this.contract = new web3.eth.Contract(abi, this.contractAddress); + // TODO this signer logic should be part of the web3service + // if signer address is not passed (for example in user service) then + // this fallsback to a web3 wallet that is not even connected??? if (signerAddress) { this.signerAddress = signerAddress; } else { @@ -837,9 +819,9 @@ export class AccountIndex { - - - + + + diff --git a/docs/compodoc/classes/ActivatedRouteStub.html b/docs/compodoc/classes/ActivatedRouteStub.html index bca779e..83cb688 100644 --- a/docs/compodoc/classes/ActivatedRouteStub.html +++ b/docs/compodoc/classes/ActivatedRouteStub.html @@ -8,7 +8,8 @@ - + + @@ -42,7 +43,7 @@
@@ -620,12 +860,16 @@
import { ChangeDetectionStrategy, Component, HostListener, OnInit } from '@angular/core';
 import {
   AuthService,
+  BlockSyncService,
   ErrorDialogService,
   LoggingService,
+  TokenService,
   TransactionService,
+  UserService,
 } from '@app/_services';
-import { catchError } from 'rxjs/operators';
 import { SwUpdate } from '@angular/service-worker';
+import { NavigationEnd, Router } from '@angular/router';
+import { filter } from 'rxjs/operators';
 
 @Component({
   selector: 'app-root',
@@ -635,16 +879,20 @@ import { SwUpdate } from '@angular/service-worker';
 })
 export class AppComponent implements OnInit {
   title = 'CICADA';
-  readyStateTarget: number = 3;
-  readyState: number = 0;
   mediaQuery: MediaQueryList = window.matchMedia('(max-width: 768px)');
+  url: string;
+  accountDetailsRegex = '/accounts/[a-z,A-Z,0-9]{40}';
 
   constructor(
     private authService: AuthService,
-    private transactionService: TransactionService,
-    private loggingService: LoggingService,
+    private blockSyncService: BlockSyncService,
     private errorDialogService: ErrorDialogService,
-    private swUpdate: SwUpdate
+    private loggingService: LoggingService,
+    private tokenService: TokenService,
+    private transactionService: TransactionService,
+    private userService: UserService,
+    private swUpdate: SwUpdate,
+    private router: Router
   ) {
     this.mediaQuery.addEventListener('change', this.onResize);
     this.onResize(this.mediaQuery);
@@ -652,6 +900,8 @@ export class AppComponent implements OnInit {
 
   async ngOnInit(): Promise<void> {
     await this.authService.init();
+    await this.tokenService.init();
+    await this.userService.init();
     await this.transactionService.init();
     try {
       const publicKeys = await this.authService.getPublicKeys();
@@ -670,6 +920,7 @@ export class AppComponent implements OnInit {
         }
       });
     }
+    await this.routeManagement();
   }
 
   // Load resize
@@ -708,6 +959,33 @@ export class AppComponent implements OnInit {
     const conversion: any = event.detail.tx;
     await this.transactionService.setConversion(conversion, 100);
   }
+
+  async routeManagement(): Promise<void> {
+    await this.router.events
+      .pipe(filter((e) => e instanceof NavigationEnd))
+      .forEach(async (routeInfo) => {
+        if (routeInfo instanceof NavigationEnd) {
+          this.url = routeInfo.url;
+          if (!this.url.match(this.accountDetailsRegex) || !this.url.includes('tx')) {
+            await this.blockSyncService.blockSync();
+          }
+          if (!this.url.includes('accounts')) {
+            try {
+              await this.userService.loadAccounts(100);
+            } catch (error) {
+              this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error });
+            }
+          }
+          if (!this.url.includes('tokens')) {
+            this.tokenService.load.subscribe(async (status: boolean) => {
+              if (status) {
+                await this.tokenService.getTokens();
+              }
+            });
+          }
+        }
+      });
+  }
 }
 
@@ -750,7 +1028,7 @@ export class AppComponent implements OnInit { @@ -793,9 +1071,9 @@ export class AppComponent implements OnInit { - - - + + + diff --git a/docs/compodoc/components/AuthComponent.html b/docs/compodoc/components/AuthComponent.html index bce0b2b..7682596 100644 --- a/docs/compodoc/components/AuthComponent.html +++ b/docs/compodoc/components/AuthComponent.html @@ -8,7 +8,8 @@ - + + @@ -35,7 +36,9 @@
-

- Properties -

- - +

+ Properties +

+
+ + + + - - - - -
+ + + keyForm + + +
- - - - keyForm - - + Type : FormGroup +
- Type : FormGroup - +
- -
- - + +
+ + + + + + + + - - - - - - - -
+ + + loading + + +
- - - - loading - - + Type : boolean + +
+ Default value : false
- Type : boolean - +
- Default value : false -
- -
- - + +
+ + + + + + + + - - - - - - - -
+ + + matcher + + +
- - - - matcher - - + Type : CustomErrorStateMatcher + +
+ Default value : new CustomErrorStateMatcher()
- Type : CustomErrorStateMatcher - +
- Default value : new CustomErrorStateMatcher() -
- -
- - + +
+ + + + + + + + - - - - - - - -
+ + + submitted + + +
- - - - submitted - - + Type : boolean + +
+ Default value : false
- Type : boolean - +
- Default value : false -
- -
+ +
@@ -678,7 +665,7 @@ - + @@ -694,7 +681,6 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { CustomErrorStateMatcher } from '@app/_helpers'; import { AuthService } from '@app/_services'; import { ErrorDialogService } from '@app/_services/error-dialog.service'; -import { LoggingService } from '@app/_services/logging.service'; import { Router } from '@angular/router'; @Component({ @@ -716,7 +702,7 @@ export class AuthComponent implements OnInit { private errorDialogService: ErrorDialogService ) {} - async ngOnInit(): Promise<void> { + ngOnInit(): void { this.keyForm = this.formBuilder.group({ key: ['', Validators.required], }); @@ -749,7 +735,7 @@ export class AuthComponent implements OnInit { } } catch (HttpError) { this.errorDialogService.openDialog({ - message: HttpError.message, + message: 'Failed to login please try again.', }); } } @@ -871,7 +857,7 @@ export class AuthComponent implements OnInit { @@ -914,9 +900,9 @@ export class AuthComponent implements OnInit { - - - + + + diff --git a/docs/compodoc/components/CreateAccountComponent.html b/docs/compodoc/components/CreateAccountComponent.html index 21cfc33..bcda900 100644 --- a/docs/compodoc/components/CreateAccountComponent.html +++ b/docs/compodoc/components/CreateAccountComponent.html @@ -8,7 +8,8 @@ - + + @@ -35,7 +36,9 @@
@@ -588,7 +618,7 @@ - + @@ -626,8 +656,7 @@ export class CreateAccountComponent implements OnInit { private userService: UserService ) {} - async ngOnInit(): Promise<void> { - await this.userService.init(); + ngOnInit(): void { this.createForm = this.formBuilder.group({ accountType: ['', Validators.required], idNumber: ['', Validators.required], @@ -640,6 +669,22 @@ export class CreateAccountComponent implements OnInit { referrer: ['', Validators.required], businessCategory: ['', Validators.required], }); + this.loadSearchData(); + } + + get createFormStub(): any { + return this.createForm.controls; + } + + onSubmit(): void { + this.submitted = true; + if (this.createForm.invalid || !confirm('Create account?')) { + return; + } + this.submitted = false; + } + + loadSearchData(): void { this.userService.getCategories(); this.userService.categoriesSubject.subscribe((res) => { this.categories = Object.keys(res); @@ -657,18 +702,6 @@ export class CreateAccountComponent implements OnInit { .pipe(first()) .subscribe((res) => (this.genders = res)); } - - get createFormStub(): any { - return this.createForm.controls; - } - - onSubmit(): void { - this.submitted = true; - if (this.createForm.invalid || !confirm('Create account?')) { - return; - } - this.submitted = false; - } } @@ -918,7 +951,7 @@ export class CreateAccountComponent implements OnInit { @@ -961,9 +994,9 @@ export class CreateAccountComponent implements OnInit { - - - + + + diff --git a/docs/compodoc/components/ErrorDialogComponent.html b/docs/compodoc/components/ErrorDialogComponent.html index 711b0b8..b3b0b19 100644 --- a/docs/compodoc/components/ErrorDialogComponent.html +++ b/docs/compodoc/components/ErrorDialogComponent.html @@ -8,7 +8,8 @@ - + + @@ -35,7 +36,9 @@
-

- Properties -

- - +

+ Properties +

+
+ + + + - - - - -
+ + + currentYear + + +
- - - - currentYear - - + Default value : new Date().getFullYear()
- Default value : new Date().getFullYear() +
- -
+ +
@@ -332,7 +333,7 @@ export class FooterComponent implements OnInit { @@ -375,9 +376,9 @@ export class FooterComponent implements OnInit { - - - + + + diff --git a/docs/compodoc/components/FooterStubComponent.html b/docs/compodoc/components/FooterStubComponent.html index 82df003..f27c7a2 100644 --- a/docs/compodoc/components/FooterStubComponent.html +++ b/docs/compodoc/components/FooterStubComponent.html @@ -8,7 +8,8 @@ - + + @@ -35,7 +36,9 @@