Format docs using linter and prettier.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import Web3 from 'web3';
|
||||
|
||||
// Application imports
|
||||
import {environment} from '@src/environments/environment';
|
||||
import { environment } from '@src/environments/environment';
|
||||
|
||||
/** Fetch the account registry contract's ABI. */
|
||||
const abi: Array<any> = require('@src/assets/js/block-sync/data/AccountRegistry.json');
|
||||
@@ -55,8 +55,8 @@ export class AccountIndex {
|
||||
* @returns true - If registration is successful or account had already been registered.
|
||||
*/
|
||||
public async addToAccountRegistry(address: string): Promise<boolean> {
|
||||
if (!await this.haveAccount(address)) {
|
||||
return await this.contract.methods.add(address).send({from: this.signerAddress});
|
||||
if (!(await this.haveAccount(address))) {
|
||||
return await this.contract.methods.add(address).send({ from: this.signerAddress });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import Web3 from 'web3';
|
||||
// Application imports
|
||||
import { environment } from '@src/environments/environment';
|
||||
|
||||
|
||||
/** Fetch the token registry contract's ABI. */
|
||||
const abi: Array<any> = require('@src/assets/js/block-sync/data/TokenUniqueSymbolIndex.json');
|
||||
/** Establish a connection to the blockchain network. */
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
// Core imports
|
||||
import { Injectable } from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
|
||||
import {
|
||||
ActivatedRouteSnapshot,
|
||||
CanActivate,
|
||||
Router,
|
||||
RouterStateSnapshot,
|
||||
UrlTree,
|
||||
} from '@angular/router';
|
||||
|
||||
// Third party imports
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -8,14 +14,11 @@ import { Observable } from 'rxjs';
|
||||
/**
|
||||
* Auth guard implementation.
|
||||
* Dictates access to routes depending on the authentication status.
|
||||
*
|
||||
* @implements CanActivate
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthGuard implements CanActivate {
|
||||
|
||||
/**
|
||||
* Instantiates the auth guard class.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
// Core imports
|
||||
import { Injectable } from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
|
||||
import {
|
||||
ActivatedRouteSnapshot,
|
||||
CanActivate,
|
||||
Router,
|
||||
RouterStateSnapshot,
|
||||
UrlTree,
|
||||
} from '@angular/router';
|
||||
|
||||
// Third party imports
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -8,14 +14,11 @@ import { Observable } from 'rxjs';
|
||||
/**
|
||||
* Role guard implementation.
|
||||
* Dictates access to routes depending on the user's role.
|
||||
*
|
||||
* @implements CanActivate
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RoleGuard implements CanActivate {
|
||||
|
||||
/**
|
||||
* Instantiates the role guard class.
|
||||
*
|
||||
|
||||
@@ -14,6 +14,5 @@ function arraySum(arr: Array<number>): number {
|
||||
return arr.reduce((accumulator, current) => accumulator + current, 0);
|
||||
}
|
||||
|
||||
|
||||
/** @exports */
|
||||
export { arraySum };
|
||||
|
||||
@@ -5,7 +5,6 @@ import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
|
||||
/**
|
||||
* Custom provider that defines how form controls behave with regards to displaying error messages.
|
||||
*
|
||||
* @implements ErrorStateMatcher
|
||||
*/
|
||||
export class CustomErrorStateMatcher implements ErrorStateMatcher {
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Core imports
|
||||
import {HttpErrorResponse} from '@angular/common/http';
|
||||
import {ErrorHandler, Injectable} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
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.
|
||||
@@ -37,7 +37,6 @@ export class HttpError extends Error {
|
||||
export class GlobalErrorHandler extends ErrorHandler {
|
||||
/**
|
||||
* An array of sentence sections that denote warnings.
|
||||
* @private
|
||||
*/
|
||||
private sentencesForWarningLogging: Array<string> = [];
|
||||
|
||||
@@ -47,10 +46,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();
|
||||
}
|
||||
|
||||
@@ -84,7 +80,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;
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
// Core imports
|
||||
import {HTTP_INTERCEPTORS, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse} from '@angular/common/http';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {
|
||||
HTTP_INTERCEPTORS,
|
||||
HttpEvent,
|
||||
HttpHandler,
|
||||
HttpInterceptor,
|
||||
HttpRequest,
|
||||
HttpResponse,
|
||||
} from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
// Third party imports
|
||||
import {Observable, of, throwError} from 'rxjs';
|
||||
import {delay, dematerialize, materialize, mergeMap} from 'rxjs/operators';
|
||||
import { Observable, of, throwError } from 'rxjs';
|
||||
import { delay, dematerialize, materialize, mergeMap } from 'rxjs/operators';
|
||||
|
||||
// Application imports
|
||||
import {Action, AreaName, AreaType, Category, Token} from '@app/_models';
|
||||
import { Action, AreaName, AreaType, Category, Token } from '@app/_models';
|
||||
|
||||
/** A mock of the curated account types. */
|
||||
const accountTypes: Array<string> = ['user', 'cashier', 'vendor', 'tokenagent', 'group'];
|
||||
@@ -26,86 +33,328 @@ const actions: Array<Action> = [
|
||||
const areaNames: Array<AreaName> = [
|
||||
{
|
||||
name: 'Mukuru Nairobi',
|
||||
locations: ['kayaba', 'kayba', 'kambi', 'mukuru', 'masai', 'hazina', 'south', 'tetra', 'tetrapak', 'ruben', 'rueben', 'kingston',
|
||||
'korokocho', 'kingstone', 'kamongo', 'lungalunga', 'sinai', 'sigei', 'lungu', 'lunga lunga', 'owino road', 'seigei']
|
||||
locations: [
|
||||
'kayaba',
|
||||
'kayba',
|
||||
'kambi',
|
||||
'mukuru',
|
||||
'masai',
|
||||
'hazina',
|
||||
'south',
|
||||
'tetra',
|
||||
'tetrapak',
|
||||
'ruben',
|
||||
'rueben',
|
||||
'kingston',
|
||||
'korokocho',
|
||||
'kingstone',
|
||||
'kamongo',
|
||||
'lungalunga',
|
||||
'sinai',
|
||||
'sigei',
|
||||
'lungu',
|
||||
'lunga lunga',
|
||||
'owino road',
|
||||
'seigei',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Kinango Kwale',
|
||||
locations: ['amani', 'bofu', 'chibuga', 'chikomani', 'chilongoni', 'chigojoni', 'chinguluni', 'chigato', 'chigale', 'chikole',
|
||||
'chilongoni', 'chilumani', 'chigojoni', 'chikomani', 'chizini', 'chikomeni', 'chidzuvini', 'chidzivuni', 'chikuyu', 'chizingo',
|
||||
'doti', 'dzugwe', 'dzivani', 'dzovuni', 'hanje', 'kasemeni', 'katundani', 'kibandaogo', 'kibandaongo', 'kwale', 'kinango',
|
||||
'kidzuvini', 'kalalani', 'kafuduni', 'kaloleni', 'kilibole', 'lutsangani', 'peku', 'gona', 'guro', 'gandini', 'mkanyeni', 'myenzeni',
|
||||
'miyenzeni', 'miatsiani', 'mienzeni', 'mnyenzeni', 'minyenzeni', 'miyani', 'mioleni', 'makuluni', 'mariakani', 'makobeni', 'madewani',
|
||||
'mwangaraba', 'mwashanga', 'miloeni', 'mabesheni', 'mazeras', 'mazera', 'mlola', 'muugano', 'mulunguni', 'mabesheni', 'miatsani',
|
||||
'miatsiani', 'mwache', 'mwangani', 'mwehavikonje', 'miguneni', 'nzora', 'nzovuni', 'vikinduni', 'vikolani', 'vitangani', 'viogato',
|
||||
'vyogato', 'vistangani', 'yapha', 'yava', 'yowani', 'ziwani', 'majengo', 'matuga', 'vigungani', 'vidziweni', 'vinyunduni', 'ukunda',
|
||||
'kokotoni', 'mikindani']
|
||||
locations: [
|
||||
'amani',
|
||||
'bofu',
|
||||
'chibuga',
|
||||
'chikomani',
|
||||
'chilongoni',
|
||||
'chigojoni',
|
||||
'chinguluni',
|
||||
'chigato',
|
||||
'chigale',
|
||||
'chikole',
|
||||
'chilongoni',
|
||||
'chilumani',
|
||||
'chigojoni',
|
||||
'chikomani',
|
||||
'chizini',
|
||||
'chikomeni',
|
||||
'chidzuvini',
|
||||
'chidzivuni',
|
||||
'chikuyu',
|
||||
'chizingo',
|
||||
'doti',
|
||||
'dzugwe',
|
||||
'dzivani',
|
||||
'dzovuni',
|
||||
'hanje',
|
||||
'kasemeni',
|
||||
'katundani',
|
||||
'kibandaogo',
|
||||
'kibandaongo',
|
||||
'kwale',
|
||||
'kinango',
|
||||
'kidzuvini',
|
||||
'kalalani',
|
||||
'kafuduni',
|
||||
'kaloleni',
|
||||
'kilibole',
|
||||
'lutsangani',
|
||||
'peku',
|
||||
'gona',
|
||||
'guro',
|
||||
'gandini',
|
||||
'mkanyeni',
|
||||
'myenzeni',
|
||||
'miyenzeni',
|
||||
'miatsiani',
|
||||
'mienzeni',
|
||||
'mnyenzeni',
|
||||
'minyenzeni',
|
||||
'miyani',
|
||||
'mioleni',
|
||||
'makuluni',
|
||||
'mariakani',
|
||||
'makobeni',
|
||||
'madewani',
|
||||
'mwangaraba',
|
||||
'mwashanga',
|
||||
'miloeni',
|
||||
'mabesheni',
|
||||
'mazeras',
|
||||
'mazera',
|
||||
'mlola',
|
||||
'muugano',
|
||||
'mulunguni',
|
||||
'mabesheni',
|
||||
'miatsani',
|
||||
'miatsiani',
|
||||
'mwache',
|
||||
'mwangani',
|
||||
'mwehavikonje',
|
||||
'miguneni',
|
||||
'nzora',
|
||||
'nzovuni',
|
||||
'vikinduni',
|
||||
'vikolani',
|
||||
'vitangani',
|
||||
'viogato',
|
||||
'vyogato',
|
||||
'vistangani',
|
||||
'yapha',
|
||||
'yava',
|
||||
'yowani',
|
||||
'ziwani',
|
||||
'majengo',
|
||||
'matuga',
|
||||
'vigungani',
|
||||
'vidziweni',
|
||||
'vinyunduni',
|
||||
'ukunda',
|
||||
'kokotoni',
|
||||
'mikindani',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Misc Nairobi',
|
||||
locations: ['nairobi', 'west', 'lindi', 'kibera', 'kibira', 'kibra', 'makina', 'soweto', 'olympic', 'kangemi', 'ruiru', 'congo',
|
||||
'kawangware', 'kwangware', 'donholm', 'dagoreti', 'dandora', 'kabete', 'sinai', 'donhom', 'donholm', 'huruma', 'kitengela',
|
||||
'makadara', ',mlolongo', 'kenyatta', 'mlolongo', 'tassia', 'tasia', 'gatina', '56', 'industrial', 'kariobangi', 'kasarani', 'kayole',
|
||||
'mathare', 'pipe', 'juja', 'uchumi', 'jogoo', 'umoja', 'thika', 'kikuyu', 'stadium', 'buru buru', 'ngong', 'starehe', 'mwiki',
|
||||
'fuata', 'kware', 'kabiro', 'embakassi', 'embakasi', 'kmoja', 'east', 'githurai', 'landi', 'langata', 'limuru', 'mathere',
|
||||
'dagoretti', 'kirembe', 'muugano', 'mwiki', 'toi market']
|
||||
locations: [
|
||||
'nairobi',
|
||||
'west',
|
||||
'lindi',
|
||||
'kibera',
|
||||
'kibira',
|
||||
'kibra',
|
||||
'makina',
|
||||
'soweto',
|
||||
'olympic',
|
||||
'kangemi',
|
||||
'ruiru',
|
||||
'congo',
|
||||
'kawangware',
|
||||
'kwangware',
|
||||
'donholm',
|
||||
'dagoreti',
|
||||
'dandora',
|
||||
'kabete',
|
||||
'sinai',
|
||||
'donhom',
|
||||
'donholm',
|
||||
'huruma',
|
||||
'kitengela',
|
||||
'makadara',
|
||||
',mlolongo',
|
||||
'kenyatta',
|
||||
'mlolongo',
|
||||
'tassia',
|
||||
'tasia',
|
||||
'gatina',
|
||||
'56',
|
||||
'industrial',
|
||||
'kariobangi',
|
||||
'kasarani',
|
||||
'kayole',
|
||||
'mathare',
|
||||
'pipe',
|
||||
'juja',
|
||||
'uchumi',
|
||||
'jogoo',
|
||||
'umoja',
|
||||
'thika',
|
||||
'kikuyu',
|
||||
'stadium',
|
||||
'buru buru',
|
||||
'ngong',
|
||||
'starehe',
|
||||
'mwiki',
|
||||
'fuata',
|
||||
'kware',
|
||||
'kabiro',
|
||||
'embakassi',
|
||||
'embakasi',
|
||||
'kmoja',
|
||||
'east',
|
||||
'githurai',
|
||||
'landi',
|
||||
'langata',
|
||||
'limuru',
|
||||
'mathere',
|
||||
'dagoretti',
|
||||
'kirembe',
|
||||
'muugano',
|
||||
'mwiki',
|
||||
'toi market',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Misc Mombasa',
|
||||
locations: ['mombasa', 'likoni', 'bangla', 'bangladesh', 'kizingo', 'old town', 'makupa', 'mvita', 'ngombeni', 'ngómbeni', 'ombeni',
|
||||
'magongo', 'miritini', 'changamwe', 'jomvu', 'ohuru', 'tudor', 'diani']
|
||||
locations: [
|
||||
'mombasa',
|
||||
'likoni',
|
||||
'bangla',
|
||||
'bangladesh',
|
||||
'kizingo',
|
||||
'old town',
|
||||
'makupa',
|
||||
'mvita',
|
||||
'ngombeni',
|
||||
'ngómbeni',
|
||||
'ombeni',
|
||||
'magongo',
|
||||
'miritini',
|
||||
'changamwe',
|
||||
'jomvu',
|
||||
'ohuru',
|
||||
'tudor',
|
||||
'diani',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Kisauni',
|
||||
locations: ['bamburi', 'kisauni', 'mworoni', 'nyali', 'shanzu', 'bombolulu', 'mtopanga', 'mjambere', 'majaoni', 'manyani', 'magogoni',
|
||||
'junda', 'mwakirunge', 'mshomoroni']
|
||||
locations: [
|
||||
'bamburi',
|
||||
'kisauni',
|
||||
'mworoni',
|
||||
'nyali',
|
||||
'shanzu',
|
||||
'bombolulu',
|
||||
'mtopanga',
|
||||
'mjambere',
|
||||
'majaoni',
|
||||
'manyani',
|
||||
'magogoni',
|
||||
'junda',
|
||||
'mwakirunge',
|
||||
'mshomoroni',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Kilifi',
|
||||
locations: ['kilfi', 'kilifi', 'mtwapa', 'takaungu', 'makongeni', 'mnarani', 'mnarani', 'office', 'g.e', 'ge', 'raibai', 'ribe']
|
||||
locations: [
|
||||
'kilfi',
|
||||
'kilifi',
|
||||
'mtwapa',
|
||||
'takaungu',
|
||||
'makongeni',
|
||||
'mnarani',
|
||||
'mnarani',
|
||||
'office',
|
||||
'g.e',
|
||||
'ge',
|
||||
'raibai',
|
||||
'ribe',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Kakuma',
|
||||
locations: ['kakuma']
|
||||
locations: ['kakuma'],
|
||||
},
|
||||
{
|
||||
name: 'Kitui',
|
||||
locations: ['kitui', 'mwingi']
|
||||
locations: ['kitui', 'mwingi'],
|
||||
},
|
||||
{
|
||||
name: 'Nyanza',
|
||||
locations: ['busia', 'nyalgunga', 'mbita', 'siaya', 'kisumu', 'nyalenda', 'hawinga', 'rangala', 'uyoma', 'mumias', 'homabay', 'homaboy',
|
||||
'migori', 'kusumu']
|
||||
locations: [
|
||||
'busia',
|
||||
'nyalgunga',
|
||||
'mbita',
|
||||
'siaya',
|
||||
'kisumu',
|
||||
'nyalenda',
|
||||
'hawinga',
|
||||
'rangala',
|
||||
'uyoma',
|
||||
'mumias',
|
||||
'homabay',
|
||||
'homaboy',
|
||||
'migori',
|
||||
'kusumu',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Misc Rural Counties',
|
||||
locations: ['makueni', 'meru', 'kisii', 'bomet', 'machakos', 'bungoma', 'eldoret', 'kakamega', 'kericho', 'kajiado', 'nandi', 'nyeri',
|
||||
'wote', 'kiambu', 'mwea', 'nakuru', 'narok']
|
||||
locations: [
|
||||
'makueni',
|
||||
'meru',
|
||||
'kisii',
|
||||
'bomet',
|
||||
'machakos',
|
||||
'bungoma',
|
||||
'eldoret',
|
||||
'kakamega',
|
||||
'kericho',
|
||||
'kajiado',
|
||||
'nandi',
|
||||
'nyeri',
|
||||
'wote',
|
||||
'kiambu',
|
||||
'mwea',
|
||||
'nakuru',
|
||||
'narok',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'other',
|
||||
locations: ['other', 'none', 'unknown']
|
||||
}
|
||||
locations: ['other', 'none', 'unknown'],
|
||||
},
|
||||
];
|
||||
|
||||
/** A mock of curated area types. */
|
||||
const areaTypes: Array<AreaType> = [
|
||||
{
|
||||
name: 'urban',
|
||||
area: ['urban', 'nairobi', 'mombasa']
|
||||
area: ['urban', 'nairobi', 'mombasa'],
|
||||
},
|
||||
{
|
||||
name: 'rural',
|
||||
area: ['rural', 'kakuma', 'kwale', 'kinango', 'kitui', 'nyanza']
|
||||
area: ['rural', 'kakuma', 'kwale', 'kinango', 'kitui', 'nyanza'],
|
||||
},
|
||||
{
|
||||
name: 'periurban',
|
||||
area: ['kilifi', 'periurban']
|
||||
area: ['kilifi', 'periurban'],
|
||||
},
|
||||
{
|
||||
name: 'other',
|
||||
area: ['other']
|
||||
}
|
||||
area: ['other'],
|
||||
},
|
||||
];
|
||||
|
||||
/** A mock of the user's business categories */
|
||||
@@ -748,44 +997,93 @@ const genders: Array<string> = ['male', 'female', 'other'];
|
||||
/** A mock of the tokens in the system. */
|
||||
const tokens: Array<Token> = [
|
||||
{
|
||||
name: 'Giftable Reserve', symbol: 'GRZ', address: '0xa686005CE37Dce7738436256982C3903f2E4ea8E', supply: '1000000001000000000000000000',
|
||||
decimals: '18', reserves: {}
|
||||
name: 'Giftable Reserve',
|
||||
symbol: 'GRZ',
|
||||
address: '0xa686005CE37Dce7738436256982C3903f2E4ea8E',
|
||||
supply: '1000000001000000000000000000',
|
||||
decimals: '18',
|
||||
reserves: {},
|
||||
},
|
||||
{
|
||||
name: 'Demo Token', symbol: 'DEMO', address: '0xc80D6aFF8194114c52AEcD84c9f15fd5c8abb187', supply: '99999999999999998976',
|
||||
decimals: '18', reserves: {'0xa686005CE37Dce7738436256982C3903f2E4ea8E': {weight: '1000000', balance: '99999999999999998976'}},
|
||||
reserveRatio: '1000000', owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a'
|
||||
name: 'Demo Token',
|
||||
symbol: 'DEMO',
|
||||
address: '0xc80D6aFF8194114c52AEcD84c9f15fd5c8abb187',
|
||||
supply: '99999999999999998976',
|
||||
decimals: '18',
|
||||
reserves: {
|
||||
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': {
|
||||
weight: '1000000',
|
||||
balance: '99999999999999998976',
|
||||
},
|
||||
},
|
||||
reserveRatio: '1000000',
|
||||
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
||||
},
|
||||
{
|
||||
name: 'Foo Token', symbol: 'FOO', address: '0x9ceD86089f7aBB5A97B40eb0E7521e7aa308d354', supply: '1000000000000000001014',
|
||||
decimals: '18', reserves: {'0xa686005CE37Dce7738436256982C3903f2E4ea8E': {weight: '1000000', balance: '1000000000000000001014'}},
|
||||
reserveRatio: '1000000', owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a'
|
||||
name: 'Foo Token',
|
||||
symbol: 'FOO',
|
||||
address: '0x9ceD86089f7aBB5A97B40eb0E7521e7aa308d354',
|
||||
supply: '1000000000000000001014',
|
||||
decimals: '18',
|
||||
reserves: {
|
||||
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': {
|
||||
weight: '1000000',
|
||||
balance: '1000000000000000001014',
|
||||
},
|
||||
},
|
||||
reserveRatio: '1000000',
|
||||
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
||||
},
|
||||
{
|
||||
name: 'testb', symbol: 'tstb', address: '0xC63cFA91A3BFf41cE31Ff436f67D3ACBC977DB95', supply: '99000', decimals: '18',
|
||||
reserves: {'0xa686005CE37Dce7738436256982C3903f2E4ea8E': {weight: '1000000', balance: '99000'}}, reserveRatio: '1000000',
|
||||
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a'
|
||||
name: 'testb',
|
||||
symbol: 'tstb',
|
||||
address: '0xC63cFA91A3BFf41cE31Ff436f67D3ACBC977DB95',
|
||||
supply: '99000',
|
||||
decimals: '18',
|
||||
reserves: {
|
||||
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': { weight: '1000000', balance: '99000' },
|
||||
},
|
||||
reserveRatio: '1000000',
|
||||
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
||||
},
|
||||
{
|
||||
name: 'testa', symbol: 'tsta', address: '0x8fA4101ef19D0a078239d035659e92b278bD083C', supply: '9981', decimals: '18',
|
||||
reserves: {'0xa686005CE37Dce7738436256982C3903f2E4ea8E': {weight: '1000000', balance: '9981'}}, reserveRatio: '1000000',
|
||||
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a'
|
||||
name: 'testa',
|
||||
symbol: 'tsta',
|
||||
address: '0x8fA4101ef19D0a078239d035659e92b278bD083C',
|
||||
supply: '9981',
|
||||
decimals: '18',
|
||||
reserves: {
|
||||
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': { weight: '1000000', balance: '9981' },
|
||||
},
|
||||
reserveRatio: '1000000',
|
||||
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
||||
},
|
||||
{
|
||||
name: 'testc', symbol: 'tstc', address: '0x4A6fA6bc3BfE4C9661bC692D9798425350C9e3D4', supply: '100990', decimals: '18',
|
||||
reserves: {'0xa686005CE37Dce7738436256982C3903f2E4ea8E': {weight: '1000000', balance: '100990'}}, reserveRatio: '1000000',
|
||||
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a'
|
||||
}
|
||||
name: 'testc',
|
||||
symbol: 'tstc',
|
||||
address: '0x4A6fA6bc3BfE4C9661bC692D9798425350C9e3D4',
|
||||
supply: '100990',
|
||||
decimals: '18',
|
||||
reserves: {
|
||||
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': { weight: '1000000', balance: '100990' },
|
||||
},
|
||||
reserveRatio: '1000000',
|
||||
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
||||
},
|
||||
];
|
||||
|
||||
/** A mock of curated transaction types. */
|
||||
const transactionTypes: Array<string> = ['transactions', 'conversions', 'disbursements', 'rewards', 'reclamation'];
|
||||
const transactionTypes: Array<string> = [
|
||||
'transactions',
|
||||
'conversions',
|
||||
'disbursements',
|
||||
'rewards',
|
||||
'reclamation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Intercepts HTTP requests and handles some specified requests internally.
|
||||
* Provides a backend that can handle requests for certain data items.
|
||||
*
|
||||
* @implements HttpInterceptor
|
||||
*/
|
||||
@Injectable()
|
||||
export class MockBackendInterceptor implements HttpInterceptor {
|
||||
@@ -847,7 +1145,7 @@ export class MockBackendInterceptor implements HttpInterceptor {
|
||||
// route functions
|
||||
|
||||
function approveAction(): Observable<HttpResponse<any>> {
|
||||
const queriedAction: Action = actions.find(action => action.id === idFromUrl());
|
||||
const queriedAction: Action = actions.find((action) => action.id === idFromUrl());
|
||||
queriedAction.approval = body.approval;
|
||||
const message: string = `Action approval status set to ${body.approval} successfully!`;
|
||||
return ok(message);
|
||||
@@ -862,7 +1160,7 @@ export class MockBackendInterceptor implements HttpInterceptor {
|
||||
}
|
||||
|
||||
function getActionById(): Observable<HttpResponse<any>> {
|
||||
const queriedAction: Action = actions.find(action => action.id === idFromUrl());
|
||||
const queriedAction: Action = actions.find((action) => action.id === idFromUrl());
|
||||
return ok(queriedAction);
|
||||
}
|
||||
|
||||
@@ -891,12 +1189,14 @@ export class MockBackendInterceptor implements HttpInterceptor {
|
||||
}
|
||||
|
||||
function getCategories(): Observable<HttpResponse<any>> {
|
||||
const categoryList: Array<string> = categories.map(category => category.name);
|
||||
const categoryList: Array<string> = categories.map((category) => category.name);
|
||||
return ok(categoryList);
|
||||
}
|
||||
|
||||
function getCategoryByProduct(): Observable<HttpResponse<any>> {
|
||||
const queriedCategory: Category = categories.find(category => category.products.includes(stringFromUrl()));
|
||||
const queriedCategory: Category = categories.find((category) =>
|
||||
category.products.includes(stringFromUrl())
|
||||
);
|
||||
return ok(queriedCategory.name);
|
||||
}
|
||||
|
||||
@@ -909,7 +1209,7 @@ export class MockBackendInterceptor implements HttpInterceptor {
|
||||
}
|
||||
|
||||
function getTokenBySymbol(): Observable<HttpResponse<any>> {
|
||||
const queriedToken: Token = tokens.find(token => token.symbol === stringFromUrl());
|
||||
const queriedToken: Token = tokens.find((token) => token.symbol === stringFromUrl());
|
||||
return ok(queriedToken);
|
||||
}
|
||||
|
||||
@@ -939,11 +1239,7 @@ export class MockBackendInterceptor implements HttpInterceptor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the MockBackendInterceptor as an Angular provider.
|
||||
*
|
||||
* @exports
|
||||
*/
|
||||
/** Exports the MockBackendInterceptor as an Angular provider. */
|
||||
export const MockBackendProvider = {
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: MockBackendInterceptor,
|
||||
|
||||
@@ -22,26 +22,6 @@ describe('UserService', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return user for available id', () => {
|
||||
expect(service.getAccountById(1)).toEqual({
|
||||
id: 1,
|
||||
name: 'John Doe',
|
||||
phone: '+25412345678',
|
||||
address: '0xc86ff893ac40d3950b4d5f94a9b837258b0a9865',
|
||||
type: 'user',
|
||||
created: '08/16/2020',
|
||||
balance: '12987',
|
||||
failedPinAttempts: 1,
|
||||
status: 'approved',
|
||||
bio: 'Bodaboda',
|
||||
gender: 'male'
|
||||
});
|
||||
});
|
||||
|
||||
it('should not return user for unavailable id', () => {
|
||||
expect(service.getAccountById(9999999999)).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return action for available id', () => {
|
||||
expect(service.getActionById('1')).toEqual({
|
||||
id: 1,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {ChangeDetectionStrategy, Component, HostListener, OnInit} from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, HostListener, OnInit } from '@angular/core';
|
||||
import {
|
||||
AuthService,
|
||||
ErrorDialogService,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SafePipe } from './safe.pipe';
|
||||
import {DomSanitizer} from '@angular/platform-browser';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
|
||||
// tslint:disable-next-line:prefer-const
|
||||
let sanitizer: DomSanitizer;
|
||||
|
||||
Reference in New Issue
Block a user