From 3a4f1252a902dfd96b1e1a9dd386d92fbe1713ca Mon Sep 17 00:00:00 2001 From: rodribp Date: Fri, 20 Feb 2026 12:26:22 -0600 Subject: [PATCH] added similarity support in chunked component --- .../transactions-list.component.html | 14 ++-- .../chunked-address.component.html | 67 ++++++++++++++----- .../chunked-address.component.scss | 43 +++++++++++- .../chunked-address.component.ts | 39 +++++++++-- 4 files changed, 133 insertions(+), 30 deletions(-) diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.html b/frontend/src/app/components/transactions-list/transactions-list.component.html index a6b0d2d7e..20a7b5890 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.html +++ b/frontend/src/app/components/transactions-list/transactions-list.component.html @@ -93,7 +93,7 @@ P2PK - + @@ -105,11 +105,12 @@ - + [link]="['/address/' | relativeUrl, vin.prevout.scriptpubkey_address]" + > {{ vin.prevout.scriptpubkey_type?.toUpperCase() }} @@ -326,15 +327,16 @@ 'sigged': selectedSig && selectedSig.txIndex === i && sigHighlights.vout[vindex], }"> - + [link]="['/address/' | relativeUrl, vout.scriptpubkey_address]" + > P2PK - + diff --git a/frontend/src/app/shared/components/chunked-address/chunked-address.component.html b/frontend/src/app/shared/components/chunked-address/chunked-address.component.html index 964902182..f432a7e4b 100644 --- a/frontend/src/app/shared/components/chunked-address/chunked-address.component.html +++ b/frontend/src/app/shared/components/chunked-address/chunked-address.component.html @@ -1,17 +1,54 @@ - - - - - - - +@if (similarity) { +
+ + + + + + + + + + + +
+} @else { +
+ + + + + - - - - - - + + + + + + + +
+} + + + + {{ chunk.text }} + + + {{ chunk.text }} + + + {{ chunk.text }} + + @@ -23,7 +60,7 @@ {{ address.slice(0, -lastChars) }} - + {{ address.slice(-lastChars) }} - + {{ chunk.text }} diff --git a/frontend/src/app/shared/components/chunked-address/chunked-address.component.scss b/frontend/src/app/shared/components/chunked-address/chunked-address.component.scss index fb284b54e..b74fc45fa 100644 --- a/frontend/src/app/shared/components/chunked-address/chunked-address.component.scss +++ b/frontend/src/app/shared/components/chunked-address/chunked-address.component.scss @@ -1,11 +1,43 @@ -.truncate { +.address-poisoned { text-overflow: unset; display: flex; flex-direction: row; align-items: start; position: relative; + font-family: monospace; - .truncate-link { + &:hover { + filter: brightness(0.85); + } + + .infix { + flex-grow: 0; + flex-shrink: 1; + overflow: hidden; + text-overflow: ellipsis; + user-select: none; + + text-decoration: underline 2px; + } + + .prefix, .postfix { + flex-shrink: 0; + flex-grow: 0; + user-select: none; + + text-decoration: underline var(--red) 2px; + } +} + +.address { + text-overflow: unset; + display: flex; + flex-direction: row; + align-items: start; + position: relative; + font-family: monospace; + + .address-link { display: flex; flex-direction: row; align-items: baseline; @@ -26,7 +58,7 @@ user-select: none; } - .last-four { + .last { flex-shrink: 0; flex-grow: 0; user-select: none; @@ -53,6 +85,11 @@ margin-right: 2px; } +.poison-alert { + margin-left: .5em; + color: var(--yellow); +} + @media (max-width: 567px) { .hidden-content { max-width: 150px !important; diff --git a/frontend/src/app/shared/components/chunked-address/chunked-address.component.ts b/frontend/src/app/shared/components/chunked-address/chunked-address.component.ts index ab90ae8bb..573ca216a 100644 --- a/frontend/src/app/shared/components/chunked-address/chunked-address.component.ts +++ b/frontend/src/app/shared/components/chunked-address/chunked-address.component.ts @@ -1,5 +1,5 @@ import { Component, Input, ChangeDetectionStrategy, OnChanges, OnInit, OnDestroy, LOCALE_ID, Inject } from '@angular/core'; -import { Subscription } from 'rxjs'; +import { AddressMatch } from '@app/shared/address-utils'; interface AddressChunk { text: string; @@ -16,6 +16,7 @@ interface AddressChunk { }) export class ChunkedAddressComponent implements OnChanges, OnInit, OnDestroy { @Input() address: string; + @Input() similarity: { score: number, match: AddressMatch, group: number } | null; @Input() link: any = null; @Input() external: boolean = false; @Input() queryParams: any = undefined; @@ -29,8 +30,21 @@ export class ChunkedAddressComponent implements OnChanges, OnInit, OnDestroy { headChunks: AddressChunk[] = []; tailChunks: AddressChunk[] = []; + prefixChunks: AddressChunk[] = []; + infixChunks: AddressChunk[] = []; + postfixChunks: AddressChunk[] = []; + private colors = ['var(--info)', 'var(--primary)']; + min = Math.min; + + groupColors: string[] = [ + 'var(--primary)', + 'var(--success)', + 'var(--info)', + 'white', + ]; + constructor( @Inject(LOCALE_ID) private locale: string ) { @@ -52,12 +66,25 @@ export class ChunkedAddressComponent implements OnChanges, OnInit, OnDestroy { return }; - const splitIndex = this.address.length - this.lastChars; - const headText = this.address.slice(0, splitIndex); - const tailText = this.address.slice(splitIndex); + if (this.similarity) { + const prefixLen = Math.min(this.similarity.match.prefix.length, 16) || 0; + const postfixLen = Math.min(this.similarity.match.postfix.length, 16) || 0; - this.headChunks = this.chunkify(headText, 0); - this.tailChunks = this.chunkify(tailText, splitIndex); + const prefixText = this.address.slice(0, prefixLen); + const infixText = this.address.slice(prefixLen, this.address.length - postfixLen); + const postfixText = this.address.slice(this.address.length - postfixLen); + + this.prefixChunks = this.chunkify(prefixText, 0); + this.infixChunks = this.chunkify(infixText, prefixLen); + this.postfixChunks = this.chunkify(postfixText, this.address.length - postfixLen); + } else { + const splitIndex = this.address.length - this.lastChars; + const headText = this.address.slice(0, splitIndex); + const tailText = this.address.slice(splitIndex); + + this.headChunks = this.chunkify(headText, 0); + this.tailChunks = this.chunkify(tailText, splitIndex); + } } private chunkify(chunk: string, offset: number): AddressChunk[] {