mirror of
https://github.com/mempool/mempool.git
synced 2024-11-20 10:21:52 +01:00
Liquid: suggest asset in search bar results
This commit is contained in:
parent
0663cc2cfa
commit
00613fe613
@ -170,6 +170,7 @@ export class SearchFormComponent implements OnInit {
|
|||||||
addresses: [],
|
addresses: [],
|
||||||
nodes: [],
|
nodes: [],
|
||||||
channels: [],
|
channels: [],
|
||||||
|
liquidAsset: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +188,7 @@ export class SearchFormComponent implements OnInit {
|
|||||||
const matchesBlockHash = this.regexBlockhash.test(searchText);
|
const matchesBlockHash = this.regexBlockhash.test(searchText);
|
||||||
let matchesAddress = !matchesTxId && this.regexAddress.test(searchText);
|
let matchesAddress = !matchesTxId && this.regexAddress.test(searchText);
|
||||||
const otherNetworks = findOtherNetworks(searchText, this.network as any || 'mainnet', this.env);
|
const otherNetworks = findOtherNetworks(searchText, this.network as any || 'mainnet', this.env);
|
||||||
|
const liquidAsset = this.assets ? (this.assets[searchText] || []) : [];
|
||||||
|
|
||||||
// Add B prefix to addresses in Bisq network
|
// Add B prefix to addresses in Bisq network
|
||||||
if (!matchesAddress && this.network === 'bisq' && getRegex('address', 'mainnet').test(searchText)) {
|
if (!matchesAddress && this.network === 'bisq' && getRegex('address', 'mainnet').test(searchText)) {
|
||||||
@ -211,6 +213,7 @@ export class SearchFormComponent implements OnInit {
|
|||||||
otherNetworks: otherNetworks,
|
otherNetworks: otherNetworks,
|
||||||
nodes: lightningResults.nodes,
|
nodes: lightningResults.nodes,
|
||||||
channels: lightningResults.channels,
|
channels: lightningResults.channels,
|
||||||
|
liquidAsset: liquidAsset,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -259,16 +262,16 @@ export class SearchFormComponent implements OnInit {
|
|||||||
} else if (this.regexTransaction.test(searchText)) {
|
} else if (this.regexTransaction.test(searchText)) {
|
||||||
const matches = this.regexTransaction.exec(searchText);
|
const matches = this.regexTransaction.exec(searchText);
|
||||||
if (this.network === 'liquid' || this.network === 'liquidtestnet') {
|
if (this.network === 'liquid' || this.network === 'liquidtestnet') {
|
||||||
if (this.assets[matches[1]]) {
|
if (this.assets[matches[0]]) {
|
||||||
this.navigate('/assets/asset/', matches[1]);
|
this.navigate('/assets/asset/', matches[0]);
|
||||||
}
|
}
|
||||||
this.electrsApiService.getAsset$(matches[1])
|
this.electrsApiService.getAsset$(matches[0])
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => { this.navigate('/assets/asset/', matches[1]); },
|
() => { this.navigate('/assets/asset/', matches[0]); },
|
||||||
() => {
|
() => {
|
||||||
this.electrsApiService.getBlock$(matches[1])
|
this.electrsApiService.getBlock$(matches[0])
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(block) => { this.navigate('/block/', matches[1], { state: { data: { block } } }); },
|
(block) => { this.navigate('/block/', matches[0], { state: { data: { block } } }); },
|
||||||
() => { this.navigate('/tx/', matches[0]); });
|
() => { this.navigate('/tx/', matches[0]); });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="dropdown-menu show" *ngIf="results" [hidden]="!results.hashQuickMatch && !results.otherNetworks.length && !results.addresses.length && !results.nodes.length && !results.channels.length">
|
<div class="dropdown-menu show" *ngIf="results" [hidden]="!results.hashQuickMatch && !results.otherNetworks.length && !results.addresses.length && !results.nodes.length && !results.channels.length && !results.liquidAsset.length">
|
||||||
<ng-template [ngIf]="results.blockHeight">
|
<ng-template [ngIf]="results.blockHeight">
|
||||||
<div class="card-title" i18n="search.bitcoin-block-height">Bitcoin Block Height</div>
|
<div class="card-title" i18n="search.bitcoin-block-height">Bitcoin Block Height</div>
|
||||||
<button (click)="clickItem(0)" [class.active]="0 === activeIdx" type="button" role="option" class="dropdown-item">
|
<button (click)="clickItem(0)" [class.active]="0 === activeIdx" type="button" role="option" class="dropdown-item">
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<ng-container *ngTemplateOutlet="goTo; context: { $implicit: results.searchText }"></ng-container>
|
<ng-container *ngTemplateOutlet="goTo; context: { $implicit: results.searchText }"></ng-container>
|
||||||
</button>
|
</button>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template [ngIf]="results.txId">
|
<ng-template [ngIf]="results.txId && !results.liquidAsset.length">
|
||||||
<div class="card-title" i18n="search.bitcoin-transaction">Bitcoin Transaction</div>
|
<div class="card-title" i18n="search.bitcoin-transaction">Bitcoin Transaction</div>
|
||||||
<button (click)="clickItem(0)" [class.active]="0 === activeIdx" type="button" role="option" class="dropdown-item">
|
<button (click)="clickItem(0)" [class.active]="0 === activeIdx" type="button" role="option" class="dropdown-item">
|
||||||
<ng-container *ngTemplateOutlet="goTo; context: { $implicit: results.searchText | shortenString : 13 }"></ng-container>
|
<ng-container *ngTemplateOutlet="goTo; context: { $implicit: results.searchText | shortenString : 13 }"></ng-container>
|
||||||
@ -67,6 +67,12 @@
|
|||||||
</button>
|
</button>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
<ng-template [ngIf]="results.liquidAsset.length">
|
||||||
|
<div class="card-title" i18n="search.liquid-asset">Liquid Asset</div>
|
||||||
|
<button (click)="clickItem(0)" [class.active]="0 === activeIdx" type="button" role="option" class="dropdown-item">
|
||||||
|
<ng-container *ngTemplateOutlet="goTo; context: { $implicit: results.searchText | shortenString : 11 }"></ng-container> <b>({{ results.liquidAsset[1] }})</b>
|
||||||
|
</button>
|
||||||
|
</ng-template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-template #goTo let-x i18n="search.go-to">Go to "{{ x }}"</ng-template>
|
<ng-template #goTo let-x i18n="search.go-to">Go to "{{ x }}"</ng-template>
|
||||||
|
Loading…
Reference in New Issue
Block a user