Merge branch 'master' into simon/angular-universal

* master:
  correcting merge
  Remove extra space in price server URL
  Modify upgrade script to append repo before tag name
  Merge "getInitData" method from simon/angular-universal.
  Replace opennode usd price source with wiz api. fixes #166
  Display confidential instead of nothing for confidential assets. fixes #110
  Detect confidential assets and display properly. fixes #109
  Allow searching for and viewing assets not in the asset registry. fixes #111

# Conflicts:
#	backend/src/api/websocket-handler.ts
This commit is contained in:
softsimon 2020-11-23 14:08:50 +07:00
commit aaf9d9be9f
No known key found for this signature in database
GPG key ID: 488D7DCFB5A430D7
9 changed files with 63 additions and 37 deletions

View file

@ -2,10 +2,8 @@ import logger from '../logger';
import axios from 'axios';
class FiatConversion {
private tickers = {
'BTCUSD': {
'USD': 4110.78
},
private conversionRates = {
'USD': 0
};
constructor() { }
@ -16,16 +14,19 @@ class FiatConversion {
this.updateCurrency();
}
public getTickers() {
return this.tickers;
public getConversionRates() {
return this.conversionRates;
}
private async updateCurrency(): Promise<void> {
try {
const response = await axios.get('https://api.opennode.co/v1/rates');
this.tickers = response.data.data;
const response = await axios.get('https://price.bisq.wiz.biz/getAllMarketPrices');
const usd = response.data.data.find((item: any) => item.currencyCode === 'USD');
this.conversionRates = {
'USD': usd.price,
};
} catch (e) {
logger.err('Error updating currency from OpenNode: ' + e);
logger.err('Error updating fiat conversion rates: ' + e);
}
}
}

View file

@ -126,7 +126,7 @@ class WebsocketHandler {
'vBytesPerSecond': memPool.getVBytesPerSecond(),
'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(),
'blocks': _blocks,
'conversions': fiatConversion.getTickers()['BTCUSD'],
'conversions': fiatConversion.getConversionRates(),
'mempool-blocks': mempoolBlocks.getMempoolBlocks(),
'transactions': memPool.getLatestTransactions(),
'git-commit': backendInfo.gitCommitHash,

View file

@ -18,15 +18,15 @@
<tbody>
<tr>
<td>Total received</td>
<td><app-amount [satoshis]="receieved" [noFiat]="true"></app-amount></td>
<td *ngIf="address.chain_stats.funded_txo_sum !== undefined; else confidentialTd"><app-amount [satoshis]="receieved" [noFiat]="true"></app-amount></td>
</tr>
<tr>
<td>Total sent</td>
<td><app-amount [satoshis]="sent" [noFiat]="true"></app-amount></td>
<td *ngIf="address.chain_stats.spent_txo_sum !== undefined; else confidentialTd"><app-amount [satoshis]="sent" [noFiat]="true"></app-amount></td>
</tr>
<tr>
<td>Balance</td>
<td><app-amount [satoshis]="receieved - sent" [noFiat]="true"></app-amount> (<app-fiat [value]="receieved - sent"></app-fiat>)</td>
<td *ngIf="address.chain_stats.funded_txo_sum !== undefined; else confidentialTd"><app-amount [satoshis]="receieved - sent" [noFiat]="true"></app-amount> (<app-fiat [value]="receieved - sent"></app-fiat>)</td>
</tr>
</tbody>
</table>
@ -106,4 +106,8 @@
</div>
<br>
<br>
<ng-template #confidentialTd>
<td>Confidential</td>
</ng-template>

View file

@ -24,7 +24,7 @@
<td>Precision</td>
<td>{{ assetContract[3] }}</td>
</tr>
<tr *ngIf="!isNativeAsset">
<tr *ngIf="!isNativeAsset && assetContract[0]">
<td>Issuer</td>
<td><a target="_blank" href="{{ 'http://' + assetContract[0] }}">{{ assetContract[0] }}</a></td>
</tr>
@ -49,15 +49,15 @@
</tr>
<tr *ngIf="!isNativeAsset">
<td>Issued amount</td>
<td>{{ formatAmount(asset.chain_stats.issued_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td>
<td *ngIf="!blindedIssuance; else confidentialTd">{{ formatAmount(asset.chain_stats.issued_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td>
</tr>
<tr>
<td>Burned amount</td>
<td>{{ formatAmount(asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td>
<td *ngIf="!blindedIssuance; else confidentialTd">{{ formatAmount(asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td>
</tr>
<tr *ngIf="!isNativeAsset">
<td>Circulating amount</td>
<td>{{ formatAmount(asset.chain_stats.issued_amount - asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td>
<td *ngIf="!blindedIssuance; else confidentialTd">{{ formatAmount(asset.chain_stats.issued_amount - asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td>
</tr>
<tr *ngIf="isNativeAsset">
<td>Circulating amount</td>
@ -137,4 +137,8 @@
</div>
<br>
<br>
<ng-template #confidentialTd>
<td>Confidential</td>
</ng-template>

View file

@ -11,7 +11,7 @@ import { of, merge, Subscription, combineLatest } from 'rxjs';
import { SeoService } from 'src/app/services/seo.service';
import { environment } from 'src/environments/environment';
import { AssetsService } from 'src/app/services/assets.service';
import { formatNumber, moveDec } from 'src/app/bitcoin.utils';
import { moveDec } from 'src/app/bitcoin.utils';
@Component({
selector: 'app-asset',
@ -23,6 +23,7 @@ export class AssetComponent implements OnInit, OnDestroy {
nativeAssetId = environment.nativeAssetId;
asset: Asset;
blindedIssuance: boolean;
assetContract: any;
assetString: string;
isLoadingAsset = true;
@ -98,6 +99,10 @@ export class AssetComponent implements OnInit, OnDestroy {
switchMap(([asset, assetsData]) => {
this.asset = asset;
this.assetContract = assetsData[this.asset.asset_id];
if (!this.assetContract) {
this.assetContract = [null, '?', 'Unknown', 0];
}
this.blindedIssuance = this.asset.chain_stats.has_blinded_issuances || this.asset.mempool_stats.has_blinded_issuances;
this.isNativeAsset = asset.asset_id === this.nativeAssetId;
this.updateChainStats();
this.websocketService.startTrackAsset(asset.asset_id);

View file

@ -4,7 +4,7 @@
<input #instance="ngbTypeahead" [ngbTypeahead]="typeaheadSearch" (selectItem)="itemSelected()" (focus)="focus$.next($any($event).target.value)" (click)="click$.next($any($event).target.value)" formControlName="searchText" type="text" class="form-control" placeholder="TXID, block height, hash or address">
</div>
<div>
<button type="submit" class="btn btn-block btn-primary"><fa-icon [icon]="['fas', 'search']" [fixedWidth]="true" title="Search"></fa-icon></button>
<button [disabled]="isSearching" type="submit" class="btn btn-block btn-primary"><fa-icon [icon]="['fas', 'search']" [fixedWidth]="true" title="Search"></fa-icon></button>
</div>
</div>
</form>

View file

@ -17,6 +17,7 @@ import { NgbTypeahead } from '@ng-bootstrap/ng-bootstrap';
export class SearchFormComponent implements OnInit {
network = '';
assets: object = {};
isSearching = false;
searchForm: FormGroup;
@Output() searchTriggered = new EventEmitter();
@ -74,25 +75,36 @@ export class SearchFormComponent implements OnInit {
search() {
const searchText = this.searchForm.value.searchText.trim();
if (searchText) {
this.isSearching = true;
if (this.regexAddress.test(searchText)) {
this.router.navigate([(this.network ? '/' + this.network : '') + '/address/', searchText]);
this.searchTriggered.emit();
this.navigate('/address/', searchText);
} else if (this.regexBlockhash.test(searchText) || this.regexBlockheight.test(searchText)) {
this.router.navigate([(this.network ? '/' + this.network : '') + '/block/', searchText]);
this.searchTriggered.emit();
this.navigate('/block/', searchText);
} else if (this.regexTransaction.test(searchText)) {
if (this.network === 'liquid' && this.assets[searchText]) {
this.router.navigate([(this.network ? '/' + this.network : '') + '/asset/', searchText]);
if (this.network === 'liquid') {
if (this.assets[searchText]) {
this.navigate('/asset/', searchText);
}
this.electrsApiService.getAsset$(searchText)
.subscribe(
() => { this.navigate('/asset/', searchText); },
() => { this.navigate('/tx/', searchText); }
);
} else {
this.router.navigate([(this.network ? '/' + this.network : '') + '/tx/', searchText]);
this.navigate('/tx/', searchText);
}
this.searchTriggered.emit();
} else {
return;
this.isSearching = false;
}
this.searchForm.setValue({
searchText: '',
});
}
}
navigate(url: string, searchText: string) {
this.router.navigate([(this.network ? '/' + this.network : '') + url, searchText]);
this.searchTriggered.emit();
this.searchForm.setValue({
searchText: '',
});
this.isSearching = false;
}
}

View file

@ -129,7 +129,7 @@
</ng-template>
<ng-template #defaultscriptpubkey_type>
<ng-template [ngIf]="vout.scriptpubkey_type === 'op_return'" [ngIfElse]="otherPubkeyType">
<a placement="bottom" [ngbTooltip]="vout.scriptpubkey | hex2ascii">OP_RETURN</a>&nbsp;<span class="badge badge-secondary scriptmessage">{{ vout.scriptpubkey_asm | hex2ascii }}</span>
<a placement="bottom" [ngbTooltip]="vout.scriptpubkey | hex2ascii">OP_RETURN</a>&nbsp;<span *ngIf="vout.scriptpubkey_asm !== 'OP_RETURN'" class="badge badge-secondary scriptmessage">{{ vout.scriptpubkey_asm | hex2ascii }}</span>
</ng-template>
<ng-template #otherPubkeyType>{{ vout.scriptpubkey_type | scriptpubkeyType }}</ng-template>
</ng-template>

View file

@ -14,21 +14,21 @@ source "$NVM_DIR/nvm.sh"
REPO=origin
BRANCH=master
TAG="${REPO}/${BRANCH}"
TAG="${BRANCH}"
[ ! -z "$1" ] && TAG=$1
echo "upgrading mempool to ${TAG}" | wall
cd "$HOME/mempool"
git fetch "${REPO}"
git reset --hard "${TAG}"
git reset --hard "${REPO}/${TAG}"
cd "$HOME/"
for site in mainnet liquid testnet bisq
do
cd "$HOME/${site}"
git fetch "${REPO}"
git reset --hard "${TAG}"
git reset --hard "${REPO}/${TAG}"
hash=$(git rev-parse HEAD)
if [ "${site}" = "mainnet" ]