Add pipe for converting token values to Wei standards.
This commit is contained in:
parent
933d73e635
commit
bff58f7a43
@ -1,56 +0,0 @@
|
||||
<div *ngIf="conversion" class="mb-5">
|
||||
<div class="card text-center">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<strong>CONVERSION DETAILS</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h3>Exchange: </h3>
|
||||
<p><strong>Trader: {{conversion.user?.vcard.fn}}</strong></p>
|
||||
<p>Trader Address: {{conversion.trader}}</p>
|
||||
<button mat-raised-button class="btn btn-dark" routerLink="/accounts/1">View Trader</button>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h4>Source Token: </h4>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<p>Address: {{conversion.sourceToken.address}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Name: {{conversion.sourceToken.name}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Symbol: {{conversion.sourceToken.symbol}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Amount: {{conversion.sourceToken.symbol + ' ' + conversion.fromValue}}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h4>Destination Token: </h4>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<p>Address: {{conversion.destinationToken.address}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Name: {{conversion.destinationToken.name}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Symbol: {{conversion.destinationToken.symbol}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Amount: {{conversion.destinationToken.symbol + ' ' + conversion.toValue}}</p>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="mb-3">
|
||||
<button mat-raised-button type="button" class="btn btn-outline-success">Resend SMS</button>
|
||||
</div>
|
||||
<div>
|
||||
<button mat-raised-button type="button" class="btn btn-outline-danger">Reverse Transaction</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -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<ConversionDetailsComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ConversionDetailsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ConversionDetailsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -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 {
|
||||
}
|
||||
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
<!-- Begin page -->
|
||||
<div class="wrapper">
|
||||
<app-sidebar></app-sidebar>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start Page Content here -->
|
||||
<!-- ============================================================== -->
|
||||
|
||||
<div id="content">
|
||||
<app-topbar></app-topbar>
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid" appMenuSelection>
|
||||
<div class="card text-center">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<strong>USER DETAILS</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h4>Platform: </h4>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<p>Address: {{user.key.ethereum[1]}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>
|
||||
Selling: {{user.selling}}
|
||||
</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Location: </p>
|
||||
<p>Latitude: {{user.location.latitude}}</p>
|
||||
<p>Longitude: {{user.location.longitude}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Date registered: {{user.dateRegistered}}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h4>V Card: </h4>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<p>Name: {{parsedVcard['fn']}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Version: {{parsedVcard['version']}}</p>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<p>Tel: {{parsedVcard['tel'][0]['meta']['TYP']}} : {{parsedVcard['tel'][0]['value'][0]}}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<app-footer appMenuSelection></app-footer>
|
||||
</div>
|
||||
<!-- ============================================================== -->
|
||||
<!-- End Page content -->
|
||||
<!-- ============================================================== -->
|
||||
</div>
|
||||
|
@ -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<UserDetailsComponent>;
|
||||
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();
|
||||
});
|
||||
});
|
@ -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<void> {
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
@ -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 { }
|
@ -1,25 +0,0 @@
|
||||
<!-- Begin page -->
|
||||
<div class="wrapper">
|
||||
<app-sidebar></app-sidebar>
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start Page Content here -->
|
||||
<!-- ============================================================== -->
|
||||
|
||||
<div id="content">
|
||||
<app-topbar></app-topbar>
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid" appMenuSelection>
|
||||
<div class="container">
|
||||
<div class="row mt-5">
|
||||
<h2>Users</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<app-footer appMenuSelection></app-footer>
|
||||
</div>
|
||||
<!-- ============================================================== -->
|
||||
<!-- End Page content -->
|
||||
<!-- ============================================================== -->
|
||||
</div>
|
||||
|
@ -1,25 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UsersComponent } from './users.component';
|
||||
|
||||
describe('UsersComponent', () => {
|
||||
let component: UsersComponent;
|
||||
let fixture: ComponentFixture<UsersComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ UsersComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UsersComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -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 {
|
||||
}
|
||||
|
||||
}
|
@ -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 { }
|
8
src/app/shared/_pipes/token-ratio.pipe.ts
Normal file
8
src/app/shared/_pipes/token-ratio.pipe.ts
Normal file
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user