From bff58f7a43fea201ed968754e93b54b65f4bbacc Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Sat, 5 Dec 2020 09:28:40 +0300 Subject: [PATCH] Add pipe for converting token values to Wei standards. --- .../conversion-details.component.html | 56 -------------- .../conversion-details.component.scss | 0 .../conversion-details.component.spec.ts | 25 ------ .../conversion-details.component.ts | 17 ----- .../user-details/user-details.component.html | 64 ---------------- .../user-details/user-details.component.scss | 0 .../user-details.component.spec.ts | 76 ------------------- .../user-details/user-details.component.ts | 45 ----------- src/app/pages/users/users-routing.module.ts | 16 ---- src/app/pages/users/users.component.html | 25 ------ src/app/pages/users/users.component.scss | 0 src/app/pages/users/users.component.spec.ts | 25 ------ src/app/pages/users/users.component.ts | 15 ---- src/app/pages/users/users.module.ts | 18 ----- src/app/shared/_pipes/token-ratio.pipe.ts | 8 ++ 15 files changed, 8 insertions(+), 382 deletions(-) delete mode 100644 src/app/pages/transactions/conversion-details/conversion-details.component.html delete mode 100644 src/app/pages/transactions/conversion-details/conversion-details.component.scss delete mode 100644 src/app/pages/transactions/conversion-details/conversion-details.component.spec.ts delete mode 100644 src/app/pages/transactions/conversion-details/conversion-details.component.ts delete mode 100644 src/app/pages/users/user-details/user-details.component.html delete mode 100644 src/app/pages/users/user-details/user-details.component.scss delete mode 100644 src/app/pages/users/user-details/user-details.component.spec.ts delete mode 100644 src/app/pages/users/user-details/user-details.component.ts delete mode 100644 src/app/pages/users/users-routing.module.ts delete mode 100644 src/app/pages/users/users.component.html delete mode 100644 src/app/pages/users/users.component.scss delete mode 100644 src/app/pages/users/users.component.spec.ts delete mode 100644 src/app/pages/users/users.component.ts delete mode 100644 src/app/pages/users/users.module.ts create mode 100644 src/app/shared/_pipes/token-ratio.pipe.ts diff --git a/src/app/pages/transactions/conversion-details/conversion-details.component.html b/src/app/pages/transactions/conversion-details/conversion-details.component.html deleted file mode 100644 index 516ca71..0000000 --- a/src/app/pages/transactions/conversion-details/conversion-details.component.html +++ /dev/null @@ -1,56 +0,0 @@ -
-
-
- CONVERSION DETAILS -
-
-

Exchange:

-

Trader: {{conversion.user?.vcard.fn}}

-

Trader Address: {{conversion.trader}}

- -
-
-
-

Source Token:

-
    -
  • -

    Address: {{conversion.sourceToken.address}}

    -
  • -
  • -

    Name: {{conversion.sourceToken.name}}

    -
  • -
  • -

    Symbol: {{conversion.sourceToken.symbol}}

    -
  • -
  • -

    Amount: {{conversion.sourceToken.symbol + ' ' + conversion.fromValue}}

    -
  • -
-
-
-

Destination Token:

-
    -
  • -

    Address: {{conversion.destinationToken.address}}

    -
  • -
  • -

    Name: {{conversion.destinationToken.name}}

    -
  • -
  • -

    Symbol: {{conversion.destinationToken.symbol}}

    -
  • -
  • -

    Amount: {{conversion.destinationToken.symbol + ' ' + conversion.toValue}}

    -
  • -
-
- -
-
- -
-
-
-
-
-
diff --git a/src/app/pages/transactions/conversion-details/conversion-details.component.scss b/src/app/pages/transactions/conversion-details/conversion-details.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/pages/transactions/conversion-details/conversion-details.component.spec.ts b/src/app/pages/transactions/conversion-details/conversion-details.component.spec.ts deleted file mode 100644 index 8458bfd..0000000 --- a/src/app/pages/transactions/conversion-details/conversion-details.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ConversionDetailsComponent } from './conversion-details.component'; - -describe('ConversionDetailsComponent', () => { - let component: ConversionDetailsComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ ConversionDetailsComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(ConversionDetailsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/pages/transactions/conversion-details/conversion-details.component.ts b/src/app/pages/transactions/conversion-details/conversion-details.component.ts deleted file mode 100644 index 71ae993..0000000 --- a/src/app/pages/transactions/conversion-details/conversion-details.component.ts +++ /dev/null @@ -1,17 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {Conversion} from '../../../_models'; - -@Component({ - selector: 'app-conversion-details', - templateUrl: './conversion-details.component.html', - styleUrls: ['./conversion-details.component.scss'] -}) -export class ConversionDetailsComponent implements OnInit { - @Input() conversion: Conversion; - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/src/app/pages/users/user-details/user-details.component.html b/src/app/pages/users/user-details/user-details.component.html deleted file mode 100644 index ab655c6..0000000 --- a/src/app/pages/users/user-details/user-details.component.html +++ /dev/null @@ -1,64 +0,0 @@ - -
- - - - - - -
- - -
-
-
- USER DETAILS -
-
-
-
-

Platform:

-
    -
  • -

    Address: {{user.key.ethereum[1]}}

    -
  • -
  • -

    - Selling: {{user.selling}} -

    -
  • -
  • -

    Location:

    -

    Latitude: {{user.location.latitude}}

    -

    Longitude: {{user.location.longitude}}

    -
  • -
  • -

    Date registered: {{user.dateRegistered}}

    -
  • -
-
-
-

V Card:

-
    -
  • -

    Name: {{parsedVcard['fn']}}

    -
  • -
  • -

    Version: {{parsedVcard['version']}}

    -
  • -
  • -

    Tel: {{parsedVcard['tel'][0]['meta']['TYP']}} : {{parsedVcard['tel'][0]['value'][0]}}

    -
  • -
-
-
-
-
-
- -
- - - -
- diff --git a/src/app/pages/users/user-details/user-details.component.scss b/src/app/pages/users/user-details/user-details.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/pages/users/user-details/user-details.component.spec.ts b/src/app/pages/users/user-details/user-details.component.spec.ts deleted file mode 100644 index 90bf27e..0000000 --- a/src/app/pages/users/user-details/user-details.component.spec.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { UserDetailsComponent } from './user-details.component'; -import {ActivatedRouteStub, FooterStubComponent, SidebarStubComponent, TopbarStubComponent, UserServiceStub} from '../../../../testing'; -import {ActivatedRoute} from '@angular/router'; -import {HttpClient} from '@angular/common/http'; -import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; -import {UserService} from '../../../_services'; - - -describe('UserDetailsComponent', () => { - let component: UserDetailsComponent; - let fixture: ComponentFixture; - let httpClient: HttpClient; - let httpTestingController: HttpTestingController; - let route: ActivatedRouteStub; - - beforeEach(async () => { - route = new ActivatedRouteStub(); - route.setParamMap({ id: 'test' }); - await TestBed.configureTestingModule({ - declarations: [ - UserDetailsComponent, - FooterStubComponent, - SidebarStubComponent, - TopbarStubComponent - ], - imports: [HttpClientTestingModule], - providers: [ - { provide: ActivatedRoute, useValue: route }, - { provide: UserService, useClass: UserServiceStub } - ] - }) - .compileComponents(); - httpClient = TestBed.inject(HttpClient); - httpTestingController = TestBed.inject(HttpTestingController); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(UserDetailsComponent); - component = fixture.componentInstance; - component.user = { - dateRegistered: 1595537208, - key: { - ethereum: [ - '0x51d3c8e2e421604e2b644117a362d589c5434739', - '0x9D7c284907acbd4a0cE2dDD0AA69147A921a573D' - ] - }, - location: { - external: {}, - latitude: '22.430670', - longitude: '151.002995' - }, - selling: [ - 'environment', - 'health', - 'transport' - ], - vcard: { - fn: 'Test User', - tel: [{ - meta: {TYP: 'CELL'}, - value: ['25412345678'] - }], - version: '3.0' - } - }; - component.parsedVcard = component.user.vcard; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/pages/users/user-details/user-details.component.ts b/src/app/pages/users/user-details/user-details.component.ts deleted file mode 100644 index 8841959..0000000 --- a/src/app/pages/users/user-details/user-details.component.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import {ActivatedRoute, Params} from '@angular/router'; -import {User, Phone} from 'cic-client-meta'; -import {first} from 'rxjs/operators'; -import {User as UserModel} from '../../../_models'; -import {UserService} from '../../../_services'; -import {parse} from '../../../../assets/js/parse-vcard'; - -@Component({ - selector: 'app-user-details', - templateUrl: './user-details.component.html', - styleUrls: ['./user-details.component.scss'] -}) -export class UserDetailsComponent implements OnInit { - user: UserModel; - vcard: any; - parsedVcard: any; - - constructor( - private route: ActivatedRoute, - private userService: UserService - ) { - this.route.paramMap.subscribe( - (params: Params) => { - this.getUser(params.get('id')).then(); - // console.log(Phone.toKey(25412341234)); - // console.log(User.toKey('0x9D7c284907acD0AA69147A9bd4a0cE2dD21a573D')); - } - ); - } - - ngOnInit(): void { - } - - async getUser(address: string): Promise { - this.userService.getUser(await User.toKey(address)).pipe(first()).subscribe(res => { - console.log(res); - this.user = res; - this.vcard = atob(res.vcard); - this.parsedVcard = parse(this.vcard); - }, error => { - console.log(error); - }); - } -} diff --git a/src/app/pages/users/users-routing.module.ts b/src/app/pages/users/users-routing.module.ts deleted file mode 100644 index 7bb7f67..0000000 --- a/src/app/pages/users/users-routing.module.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; - -import { UsersComponent } from './users.component'; -import {UserDetailsComponent} from './user-details/user-details.component'; - -const routes: Routes = [ - { path: '', component: UsersComponent }, - { path: ':id', component: UserDetailsComponent } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class UsersRoutingModule { } diff --git a/src/app/pages/users/users.component.html b/src/app/pages/users/users.component.html deleted file mode 100644 index fbd9200..0000000 --- a/src/app/pages/users/users.component.html +++ /dev/null @@ -1,25 +0,0 @@ - -
- - - - - - -
- - -
-
-
-

Users

-
-
-
- -
- - - -
- diff --git a/src/app/pages/users/users.component.scss b/src/app/pages/users/users.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/pages/users/users.component.spec.ts b/src/app/pages/users/users.component.spec.ts deleted file mode 100644 index 2d6432f..0000000 --- a/src/app/pages/users/users.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { UsersComponent } from './users.component'; - -describe('UsersComponent', () => { - let component: UsersComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ UsersComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(UsersComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/pages/users/users.component.ts b/src/app/pages/users/users.component.ts deleted file mode 100644 index c2b342b..0000000 --- a/src/app/pages/users/users.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-users', - templateUrl: './users.component.html', - styleUrls: ['./users.component.scss'] -}) -export class UsersComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/src/app/pages/users/users.module.ts b/src/app/pages/users/users.module.ts deleted file mode 100644 index 003fa13..0000000 --- a/src/app/pages/users/users.module.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; - -import { UsersRoutingModule } from './users-routing.module'; -import { UsersComponent } from './users.component'; -import { UserDetailsComponent } from './user-details/user-details.component'; -import {SharedModule} from '../../shared/shared.module'; - - -@NgModule({ - declarations: [UsersComponent, UserDetailsComponent], - imports: [ - CommonModule, - UsersRoutingModule, - SharedModule - ] -}) -export class UsersModule { } diff --git a/src/app/shared/_pipes/token-ratio.pipe.ts b/src/app/shared/_pipes/token-ratio.pipe.ts new file mode 100644 index 0000000..14400c0 --- /dev/null +++ b/src/app/shared/_pipes/token-ratio.pipe.ts @@ -0,0 +1,8 @@ +import {Pipe, PipeTransform} from '@angular/core'; + +@Pipe({name: 'tokenRatio'}) +export class TokenRatioPipe implements PipeTransform { + transform(value: any, ...args): any { + return Number(value) / Math.pow(10, 18); + } +}