Reveal coinbase scriptsig and op_return scriptpubkey ascii on hover.

This commit is contained in:
softsimon 2020-05-22 00:35:45 +07:00
parent 58942ec88a
commit 565aa499e5
No known key found for this signature in database
GPG key ID: 488D7DCFB5A430D7
5 changed files with 35 additions and 2 deletions

View file

@ -50,6 +50,7 @@ import { ScriptpubkeyTypePipe } from './pipes/scriptpubkey-type-pipe/scriptpubke
import { AssetsComponent } from './assets/assets.component'; import { AssetsComponent } from './assets/assets.component';
import { RelativeUrlPipe } from './pipes/relative-url/relative-url.pipe'; import { RelativeUrlPipe } from './pipes/relative-url/relative-url.pipe';
import { MinerComponent } from './pipes/miner/miner.component'; import { MinerComponent } from './pipes/miner/miner.component';
import { Hex2asciiPipe } from './pipes/hex2ascii/hex2ascii.pipe';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -90,6 +91,7 @@ import { MinerComponent } from './pipes/miner/miner.component';
AssetsComponent, AssetsComponent,
RelativeUrlPipe, RelativeUrlPipe,
MinerComponent, MinerComponent,
Hex2asciiPipe,
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View file

@ -35,7 +35,7 @@
</td> </td>
<td> <td>
<div [ngSwitch]="true"> <div [ngSwitch]="true">
<ng-container *ngSwitchCase="vin.is_coinbase">Coinbase<ng-template [ngIf]="network !== 'liquid'"> (Newly Generated Coins)</ng-template></ng-container> <ng-container *ngSwitchCase="vin.is_coinbase"><a placement="bottom" [ngbTooltip]="vin.scriptsig | hex2ascii">Coinbase<ng-template [ngIf]="network !== 'liquid'"> (Newly Generated Coins)</ng-template></a></ng-container>
<ng-container *ngSwitchCase="vin.is_pegin"> <ng-container *ngSwitchCase="vin.is_pegin">
Peg-in Peg-in
</ng-container> </ng-container>
@ -79,7 +79,7 @@
</a> </a>
</ng-template> </ng-template>
<ng-template #defaultscriptpubkey_type> <ng-template #defaultscriptpubkey_type>
{{ vout.scriptpubkey_type | scriptpubkeyType }} <a placement="bottom" [ngbTooltip]="vout.scriptpubkey | hex2ascii">{{ vout.scriptpubkey_type | scriptpubkeyType }}</a>
</ng-template> </ng-template>
</ng-template> </ng-template>
</td> </td>

View file

@ -0,0 +1,8 @@
import { Hex2asciiPipe } from './hex2ascii.pipe';
describe('Hex2asciiPipe', () => {
it('create an instance', () => {
const pipe = new Hex2asciiPipe();
expect(pipe).toBeTruthy();
});
});

View file

@ -0,0 +1,19 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'hex2ascii'
})
export class Hex2asciiPipe implements PipeTransform {
transform(hex: string): string {
if (!hex) {
return '';
}
let str = '';
for (let i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return str;
}
}

View file

@ -388,3 +388,7 @@ h1, h2, h3 {
.mt-2-5, .my-2-5 { .mt-2-5, .my-2-5 {
margin-top: 0.75rem !important; margin-top: 0.75rem !important;
} }
.tooltip-inner {
max-width: inherit;
}