From b979ed8b283db2ed93fcd795ed14ee475c9ba7bd Mon Sep 17 00:00:00 2001
From: Klas <31806893+klassare@users.noreply.github.com>
Date: Tue, 10 Jul 2018 21:23:16 +0200
Subject: [PATCH] add delegator name-pipe (#2)
---
src/app/app.module.ts | 7 +++--
.../components/bakery/bakery.component.html | 2 +-
src/app/components/bakery/bakery.component.ts | 4 ++-
src/app/pipes/delegator-name.pipe.spec.ts | 8 +++++
src/app/pipes/delegator-name.pipe.ts | 31 +++++++++++++++++++
5 files changed, 48 insertions(+), 4 deletions(-)
create mode 100644 src/app/pipes/delegator-name.pipe.spec.ts
create mode 100644 src/app/pipes/delegator-name.pipe.ts
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 84e24fd82..1f32d87f8 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -48,6 +48,7 @@ import { ActivateComponent } from './components/activate/activate.component';
// Pipes
import { ErrorHandlingPipe } from './pipes/error-handling.pipe';
+import { DelegatorNamePipe } from './pipes/delegator-name.pipe';
@NgModule({
@@ -70,7 +71,8 @@ import { ErrorHandlingPipe } from './pipes/error-handling.pipe';
MnemonicImportComponent,
BakeryComponent,
ActivateComponent,
- ErrorHandlingPipe
+ ErrorHandlingPipe,
+ DelegatorNamePipe
],
imports: [
BrowserModule,
@@ -101,7 +103,8 @@ import { ErrorHandlingPipe } from './pipes/error-handling.pipe';
ExportService,
DelegateService,
TzscanService,
- ErrorHandlingPipe
+ ErrorHandlingPipe,
+ DelegatorNamePipe
],
bootstrap: [AppComponent]
})
diff --git a/src/app/components/bakery/bakery.component.html b/src/app/components/bakery/bakery.component.html
index 26b816511..461408257 100644
--- a/src/app/components/bakery/bakery.component.html
+++ b/src/app/components/bakery/bakery.component.html
@@ -38,7 +38,7 @@
{{ account.balance.balanceXTZ / 1000000 | number:'1.00' }} ꜩ
- {{ account.delegate }}
+ {{ account.delegate | delegatorName }}
diff --git a/src/app/components/bakery/bakery.component.ts b/src/app/components/bakery/bakery.component.ts
index 2e30b7dec..0aa2bce49 100644
--- a/src/app/components/bakery/bakery.component.ts
+++ b/src/app/components/bakery/bakery.component.ts
@@ -3,6 +3,7 @@ import { WalletService } from '../../services/wallet.service';
import { MessageService } from '../../services/message.service';
import { ActivityService } from '../../services/activity.service';
import { Account, Balance, Activity } from '../../interfaces';
+import { DelegatorNamePipe } from '../../pipes/delegator-name.pipe';
@Component({
@@ -15,7 +16,8 @@ export class BakeryComponent implements OnInit {
constructor(
public walletService: WalletService,
private messageService: MessageService,
- private activityService: ActivityService
+ private activityService: ActivityService,
+ private delegatorNamePipe: DelegatorNamePipe
) { }
ngOnInit() {
diff --git a/src/app/pipes/delegator-name.pipe.spec.ts b/src/app/pipes/delegator-name.pipe.spec.ts
new file mode 100644
index 000000000..c0dfa9c39
--- /dev/null
+++ b/src/app/pipes/delegator-name.pipe.spec.ts
@@ -0,0 +1,8 @@
+import { DelegatorNamePipe } from './delegator-name.pipe';
+
+describe('DelegatorNamePipe', () => {
+ it('create an instance', () => {
+ const pipe = new DelegatorNamePipe();
+ expect(pipe).toBeTruthy();
+ });
+});
diff --git a/src/app/pipes/delegator-name.pipe.ts b/src/app/pipes/delegator-name.pipe.ts
new file mode 100644
index 000000000..8ceaca8a5
--- /dev/null
+++ b/src/app/pipes/delegator-name.pipe.ts
@@ -0,0 +1,31 @@
+import { Pipe, PipeTransform } from '@angular/core';
+
+@Pipe({
+ name: 'delegatorName'
+})
+export class DelegatorNamePipe implements PipeTransform {
+ map: Map
= new Map([
+ ['tz1TDSmoZXwVevLTEvKCTHWpomG76oC9S2fJ', 'Tezos.Community'],
+ ['tz1WCd2jm4uSt4vntk4vSuUWoZQGhLcDuR9q', 'Happy Tezos'],
+ ['tz1XQ7SRj4QQWjaeebNd8dFwuTrCot3GGDRF', 'Tz Baker'],
+ ['tz1YKh8T79LAtWxX29N5VedCSmaZGw9LNVxQ', 'Tezos Brazil'],
+ ['tz3bEQoFCZEEfZMskefZ8q8e4eiHH1pssRax', 'Ceibo XTZ'],
+ ['tz1hThMBD8jQjFt78heuCnKxJnJtQo9Ao25X', 'Tezos Chef'],
+ ['tz1L3vFD8mFzBaS8yLHFsd7qDJY1t276Dh8i', 'Zednode'],
+ ['tz1Tnjaxk6tbAeC2TmMApPh8UsrEVQvhHvx5', 'My Crypto Delegate'],
+ ['tz1LesY3S4wfe15SNm1W3qJmQzWxLqVjTruH', 'Xtez.io'],
+ ['tz1L5GqtsKbasq9yD4hvtGC7VprPXDPmeb9V', 'Tezos Bakes']
+ ]);
+ transform(pkh: string): any {
+ console.log('Get delegator name');
+ if (!pkh) {
+ return '';
+ }
+ const name = this.map.get(pkh);
+ if (name) {
+ return name;
+ } else {
+ return '';
+ }
+ }
+}