From 11d67cf7566f5979e8ace00ce59ae08a35f6f74b Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 22 Nov 2020 16:03:23 +0700 Subject: [PATCH 1/8] Allow searching for and viewing assets not in the asset registry. fixes #111 --- .../app/components/asset/asset.component.html | 2 +- .../app/components/asset/asset.component.ts | 3 ++ .../search-form/search-form.component.html | 2 +- .../search-form/search-form.component.ts | 36 ++++++++++++------- .../transactions-list.component.html | 2 +- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/frontend/src/app/components/asset/asset.component.html b/frontend/src/app/components/asset/asset.component.html index b72c1c094..8e4f84ea4 100644 --- a/frontend/src/app/components/asset/asset.component.html +++ b/frontend/src/app/components/asset/asset.component.html @@ -24,7 +24,7 @@ Precision {{ assetContract[3] }} - + Issuer {{ assetContract[0] }} diff --git a/frontend/src/app/components/asset/asset.component.ts b/frontend/src/app/components/asset/asset.component.ts index 13775ba7c..25b6a6000 100644 --- a/frontend/src/app/components/asset/asset.component.ts +++ b/frontend/src/app/components/asset/asset.component.ts @@ -98,6 +98,9 @@ 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.isNativeAsset = asset.asset_id === this.nativeAssetId; this.updateChainStats(); this.websocketService.startTrackAsset(asset.asset_id); diff --git a/frontend/src/app/components/search-form/search-form.component.html b/frontend/src/app/components/search-form/search-form.component.html index 78fcd8078..f71ac0ec1 100644 --- a/frontend/src/app/components/search-form/search-form.component.html +++ b/frontend/src/app/components/search-form/search-form.component.html @@ -4,7 +4,7 @@
- +
\ No newline at end of file diff --git a/frontend/src/app/components/search-form/search-form.component.ts b/frontend/src/app/components/search-form/search-form.component.ts index 3bae9e803..c458d5a00 100644 --- a/frontend/src/app/components/search-form/search-form.component.ts +++ b/frontend/src/app/components/search-form/search-form.component.ts @@ -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; + } } 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 8290c2422..bf248e301 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.html +++ b/frontend/src/app/components/transactions-list/transactions-list.component.html @@ -129,7 +129,7 @@ - OP_RETURN {{ vout.scriptpubkey_asm | hex2ascii }} + OP_RETURN {{ vout.scriptpubkey_asm | hex2ascii }} {{ vout.scriptpubkey_type | scriptpubkeyType }} From 01689c84330d44fa3db459428aa554d6948073f7 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 22 Nov 2020 16:19:57 +0700 Subject: [PATCH 2/8] Detect confidential assets and display properly. fixes #109 --- .../src/app/components/asset/asset.component.html | 12 ++++++++---- frontend/src/app/components/asset/asset.component.ts | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/asset/asset.component.html b/frontend/src/app/components/asset/asset.component.html index 8e4f84ea4..7f8703f72 100644 --- a/frontend/src/app/components/asset/asset.component.html +++ b/frontend/src/app/components/asset/asset.component.html @@ -49,15 +49,15 @@ Issued amount - {{ formatAmount(asset.chain_stats.issued_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }} + {{ formatAmount(asset.chain_stats.issued_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }} Burned amount - {{ formatAmount(asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }} + {{ formatAmount(asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }} Circulating amount - {{ formatAmount(asset.chain_stats.issued_amount - asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }} + {{ formatAmount(asset.chain_stats.issued_amount - asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }} Circulating amount @@ -137,4 +137,8 @@ -
\ No newline at end of file +
+ + + Confidential + diff --git a/frontend/src/app/components/asset/asset.component.ts b/frontend/src/app/components/asset/asset.component.ts index 25b6a6000..0c80ec683 100644 --- a/frontend/src/app/components/asset/asset.component.ts +++ b/frontend/src/app/components/asset/asset.component.ts @@ -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; @@ -101,6 +102,7 @@ export class AssetComponent implements OnInit, OnDestroy { 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); From 6bc69660190b8d4269dc58c3407f44837ae77e87 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 22 Nov 2020 16:30:36 +0700 Subject: [PATCH 3/8] Display confidential instead of nothing for confidential assets. fixes #110 --- .../app/components/address/address.component.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/components/address/address.component.html b/frontend/src/app/components/address/address.component.html index 39ed2e22d..4552f9214 100644 --- a/frontend/src/app/components/address/address.component.html +++ b/frontend/src/app/components/address/address.component.html @@ -18,15 +18,15 @@ Total received - + Total sent - + Balance - () + () @@ -106,4 +106,8 @@ -
\ No newline at end of file +
+ + + Confidential + From 1521d47cc7079184f801a48777c458f5f4ecaaba Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 22 Nov 2020 16:48:55 +0700 Subject: [PATCH 4/8] Replace opennode usd price source with wiz api. fixes #166 --- backend/src/api/fiat-conversion.ts | 19 ++++++++++--------- backend/src/api/websocket-handler.ts | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/backend/src/api/fiat-conversion.ts b/backend/src/api/fiat-conversion.ts index 954b5c606..6b1038ff0 100644 --- a/backend/src/api/fiat-conversion.ts +++ b/backend/src/api/fiat-conversion.ts @@ -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 { 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); } } } diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index f66bdbe1a..e6401f508 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -86,7 +86,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, From c0d2430a84ccca07f4a023bd40d056e12dbe20ce Mon Sep 17 00:00:00 2001 From: softsimon Date: Mon, 23 Nov 2020 02:38:56 +0700 Subject: [PATCH 5/8] Merge "getInitData" method from simon/angular-universal. --- backend/src/api/websocket-handler.ts | 31 +++++++++++++++++----------- backend/src/index.ts | 1 + backend/src/routes.ts | 10 +++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index f66bdbe1a..b7f8b167e 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -81,18 +81,7 @@ class WebsocketHandler { if (!_blocks) { return; } - client.send(JSON.stringify({ - 'mempoolInfo': memPool.getMempoolInfo(), - 'vBytesPerSecond': memPool.getVBytesPerSecond(), - 'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(), - 'blocks': _blocks, - 'conversions': fiatConversion.getTickers()['BTCUSD'], - 'mempool-blocks': mempoolBlocks.getMempoolBlocks(), - 'transactions': memPool.getLatestTransactions(), - 'git-commit': backendInfo.gitCommitHash, - 'hostname': backendInfo.hostname, - ...this.extraInitProperties - })); + client.send(JSON.stringify(this.getInitData(_blocks))); } if (parsedMessage.action === 'ping') { @@ -128,6 +117,24 @@ class WebsocketHandler { }); } + getInitData(_blocks?: Block[]) { + if (!_blocks) { + _blocks = blocks.getBlocks(); + } + return { + 'mempoolInfo': memPool.getMempoolInfo(), + 'vBytesPerSecond': memPool.getVBytesPerSecond(), + 'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(), + 'blocks': _blocks, + 'conversions': fiatConversion.getTickers()['BTCUSD'], + 'mempool-blocks': mempoolBlocks.getMempoolBlocks(), + 'transactions': memPool.getLatestTransactions(), + 'git-commit': backendInfo.gitCommitHash, + 'hostname': backendInfo.hostname, + ...this.extraInitProperties + }; + } + handleNewStatistic(stats: OptimizedStatistic) { if (!this.wss) { throw new Error('WebSocket.Server is not set'); diff --git a/backend/src/index.ts b/backend/src/index.ts index f7591ecf6..ab50afc36 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -142,6 +142,7 @@ class Server { .get(config.MEMPOOL.API_URL_PREFIX + 'fees/recommended', routes.getRecommendedFees) .get(config.MEMPOOL.API_URL_PREFIX + 'fees/mempool-blocks', routes.getMempoolBlocks) .get(config.MEMPOOL.API_URL_PREFIX + 'backend-info', routes.getBackendInfo) + .get(config.MEMPOOL.API_URL_PREFIX + 'init-data', routes.getInitData) ; if (config.STATISTICS.ENABLED && config.DATABASE.ENABLED) { diff --git a/backend/src/routes.ts b/backend/src/routes.ts index 57ffe960c..3d60f7df2 100644 --- a/backend/src/routes.ts +++ b/backend/src/routes.ts @@ -6,6 +6,7 @@ import backendInfo from './api/backend-info'; import mempoolBlocks from './api/mempool-blocks'; import mempool from './api/mempool'; import bisq from './api/bisq/bisq'; +import websocketHandler from './api/websocket-handler'; import bisqMarket from './api/bisq/markets-api'; import { OptimizedStatistic, RequiredSpec } from './interfaces'; import { MarketsApiError } from './api/bisq/interfaces'; @@ -63,6 +64,15 @@ class Routes { res.json(this.cache['1y']); } + public getInitData(req: Request, res: Response) { + try { + const result = websocketHandler.getInitData(); + res.json(result); + } catch (e) { + res.status(500).send(e.message); + } + } + public async getRecommendedFees(req: Request, res: Response) { if (!mempool.isInSync()) { res.statusCode = 503; From 827c5d12a379365d8935b1f386af82f1913bf4b4 Mon Sep 17 00:00:00 2001 From: wiz Date: Mon, 23 Nov 2020 09:46:14 +0900 Subject: [PATCH 6/8] Modify upgrade script to append repo before tag name --- production/mempool-upgrade-all | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/production/mempool-upgrade-all b/production/mempool-upgrade-all index 029ff7d79..b8fdac452 100755 --- a/production/mempool-upgrade-all +++ b/production/mempool-upgrade-all @@ -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" ] From 8fab153fb0a64b3690f64a024538291edf7f7d7a Mon Sep 17 00:00:00 2001 From: wiz Date: Mon, 23 Nov 2020 09:48:06 +0900 Subject: [PATCH 7/8] Remove extra space in price server URL --- backend/src/api/fiat-conversion.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/api/fiat-conversion.ts b/backend/src/api/fiat-conversion.ts index 6b1038ff0..89916c91d 100644 --- a/backend/src/api/fiat-conversion.ts +++ b/backend/src/api/fiat-conversion.ts @@ -20,7 +20,7 @@ class FiatConversion { private async updateCurrency(): Promise { try { - const response = await axios.get('https://price.bisq.wiz.biz/getAllMarketPrices '); + 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, From bd67eec7771a60a90cd17d9f5687091c25f697c3 Mon Sep 17 00:00:00 2001 From: softsimon Date: Mon, 23 Nov 2020 11:46:04 +0700 Subject: [PATCH 8/8] correcting merge --- backend/src/api/websocket-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index b7f8b167e..76fb91583 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -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,