Skip to content

Commit

Permalink
add delegator name-pipe (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
klassare authored Jul 10, 2018
1 parent 26cae95 commit b979ed8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -70,7 +71,8 @@ import { ErrorHandlingPipe } from './pipes/error-handling.pipe';
MnemonicImportComponent,
BakeryComponent,
ActivateComponent,
ErrorHandlingPipe
ErrorHandlingPipe,
DelegatorNamePipe
],
imports: [
BrowserModule,
Expand Down Expand Up @@ -101,7 +103,8 @@ import { ErrorHandlingPipe } from './pipes/error-handling.pipe';
ExportService,
DelegateService,
TzscanService,
ErrorHandlingPipe
ErrorHandlingPipe,
DelegatorNamePipe
],
bootstrap: [AppComponent]
})
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/bakery/bakery.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h4>
{{ account.balance.balanceXTZ / 1000000 | number:'1.00' }} &#42793;
</div>
<div class="col-sm-auto col-border border border-warning text-truncate min-size-address-cell mono">
<span *ngIf="account.delegate">{{ account.delegate }}</span>
<span *ngIf="account.delegate">{{ account.delegate | delegatorName }}</span>
</div>
<div class="col-sm-auto col-border" *ngIf="!this.walletService.isObserverWallet()">
<app-delegate [activePkh]="account.pkh"></app-delegate>
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/bakery/bakery.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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() {
Expand Down
8 changes: 8 additions & 0 deletions src/app/pipes/delegator-name.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { DelegatorNamePipe } from './delegator-name.pipe';

describe('DelegatorNamePipe', () => {
it('create an instance', () => {
const pipe = new DelegatorNamePipe();
expect(pipe).toBeTruthy();
});
});
31 changes: 31 additions & 0 deletions src/app/pipes/delegator-name.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'delegatorName'
})
export class DelegatorNamePipe implements PipeTransform {
map: Map<string, string> = 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 '';
}
}
}

0 comments on commit b979ed8

Please sign in to comment.