From e101c4e218049552c43b557a9fa2a071b25c072d Mon Sep 17 00:00:00 2001 From: nymkappa Date: Fri, 20 May 2022 09:44:29 +0200 Subject: [PATCH 01/29] Replace all `avg_XXX` with `avgXXX` for consistency --- backend/src/repositories/BlocksRepository.ts | 32 +++++++++---------- .../block-fee-rates-graph.component.ts | 14 ++++---- .../block-fees-graph.component.ts | 2 +- .../block-rewards-graph.component.ts | 2 +- .../block-sizes-weights-graph.component.ts | 4 +-- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/backend/src/repositories/BlocksRepository.ts b/backend/src/repositories/BlocksRepository.ts index 47a18fc9b..c22491839 100644 --- a/backend/src/repositories/BlocksRepository.ts +++ b/backend/src/repositories/BlocksRepository.ts @@ -474,9 +474,9 @@ class BlocksRepository { public async $getHistoricalBlockFees(div: number, interval: string | null): Promise { try { let query = `SELECT - CAST(AVG(height) as INT) as avg_height, + CAST(AVG(height) as INT) as avgHeight, CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp, - CAST(AVG(fees) as INT) as avg_fees + CAST(AVG(fees) as INT) as avgFees FROM blocks`; if (interval !== null) { @@ -499,9 +499,9 @@ class BlocksRepository { public async $getHistoricalBlockRewards(div: number, interval: string | null): Promise { try { let query = `SELECT - CAST(AVG(height) as INT) as avg_height, + CAST(AVG(height) as INT) as avgHeight, CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp, - CAST(AVG(reward) as INT) as avg_rewards + CAST(AVG(reward) as INT) as avgRewards FROM blocks`; if (interval !== null) { @@ -524,15 +524,15 @@ class BlocksRepository { public async $getHistoricalBlockFeeRates(div: number, interval: string | null): Promise { try { let query = `SELECT - CAST(AVG(height) as INT) as avg_height, + CAST(AVG(height) as INT) as avgHeight, CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp, - CAST(AVG(JSON_EXTRACT(fee_span, '$[0]')) as INT) as avg_fee_0, - CAST(AVG(JSON_EXTRACT(fee_span, '$[1]')) as INT) as avg_fee_10, - CAST(AVG(JSON_EXTRACT(fee_span, '$[2]')) as INT) as avg_fee_25, - CAST(AVG(JSON_EXTRACT(fee_span, '$[3]')) as INT) as avg_fee_50, - CAST(AVG(JSON_EXTRACT(fee_span, '$[4]')) as INT) as avg_fee_75, - CAST(AVG(JSON_EXTRACT(fee_span, '$[5]')) as INT) as avg_fee_90, - CAST(AVG(JSON_EXTRACT(fee_span, '$[6]')) as INT) as avg_fee_100 + CAST(AVG(JSON_EXTRACT(fee_span, '$[0]')) as INT) as avgFee_0, + CAST(AVG(JSON_EXTRACT(fee_span, '$[1]')) as INT) as avgFee_10, + CAST(AVG(JSON_EXTRACT(fee_span, '$[2]')) as INT) as avgFee_25, + CAST(AVG(JSON_EXTRACT(fee_span, '$[3]')) as INT) as avgFee_50, + CAST(AVG(JSON_EXTRACT(fee_span, '$[4]')) as INT) as avgFee_75, + CAST(AVG(JSON_EXTRACT(fee_span, '$[5]')) as INT) as avgFee_90, + CAST(AVG(JSON_EXTRACT(fee_span, '$[6]')) as INT) as avgFee_100 FROM blocks`; if (interval !== null) { @@ -555,9 +555,9 @@ class BlocksRepository { public async $getHistoricalBlockSizes(div: number, interval: string | null): Promise { try { let query = `SELECT - CAST(AVG(height) as INT) as avg_height, + CAST(AVG(height) as INT) as avgHeight, CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp, - CAST(AVG(size) as INT) as avg_size + CAST(AVG(size) as INT) as avgSize FROM blocks`; if (interval !== null) { @@ -580,9 +580,9 @@ class BlocksRepository { public async $getHistoricalBlockWeights(div: number, interval: string | null): Promise { try { let query = `SELECT - CAST(AVG(height) as INT) as avg_height, + CAST(AVG(height) as INT) as avgHeight, CAST(AVG(UNIX_TIMESTAMP(blockTimestamp)) as INT) as timestamp, - CAST(AVG(weight) as INT) as avg_weight + CAST(AVG(weight) as INT) as avgWeight FROM blocks`; if (interval !== null) { diff --git a/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.ts b/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.ts index 656a00d45..2cd421f26 100644 --- a/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.ts +++ b/frontend/src/app/components/block-fee-rates-graph/block-fee-rates-graph.component.ts @@ -89,13 +89,13 @@ export class BlockFeeRatesGraphComponent implements OnInit { }; for (const rate of data.blockFeeRates) { const timestamp = rate.timestamp * 1000; - seriesData['Min'].push([timestamp, rate.avg_fee_0, rate.avg_height]); - seriesData['10th'].push([timestamp, rate.avg_fee_10, rate.avg_height]); - seriesData['25th'].push([timestamp, rate.avg_fee_25, rate.avg_height]); - seriesData['Median'].push([timestamp, rate.avg_fee_50, rate.avg_height]); - seriesData['75th'].push([timestamp, rate.avg_fee_75, rate.avg_height]); - seriesData['90th'].push([timestamp, rate.avg_fee_90, rate.avg_height]); - seriesData['Max'].push([timestamp, rate.avg_fee_100, rate.avg_height]); + seriesData['Min'].push([timestamp, rate.avgFee_0, rate.avgHeight]); + seriesData['10th'].push([timestamp, rate.avgFee_10, rate.avgHeight]); + seriesData['25th'].push([timestamp, rate.avgFee_25, rate.avgHeight]); + seriesData['Median'].push([timestamp, rate.avgFee_50, rate.avgHeight]); + seriesData['75th'].push([timestamp, rate.avgFee_75, rate.avgHeight]); + seriesData['90th'].push([timestamp, rate.avgFee_90, rate.avgHeight]); + seriesData['Max'].push([timestamp, rate.avgFee_100, rate.avgHeight]); } // Prepare chart diff --git a/frontend/src/app/components/block-fees-graph/block-fees-graph.component.ts b/frontend/src/app/components/block-fees-graph/block-fees-graph.component.ts index c938b351f..185938d5d 100644 --- a/frontend/src/app/components/block-fees-graph/block-fees-graph.component.ts +++ b/frontend/src/app/components/block-fees-graph/block-fees-graph.component.ts @@ -71,7 +71,7 @@ export class BlockFeesGraphComponent implements OnInit { .pipe( tap((response) => { this.prepareChartOptions({ - blockFees: response.body.map(val => [val.timestamp * 1000, val.avg_fees / 100000000]), + blockFees: response.body.map(val => [val.timestamp * 1000, val.avgFees / 100000000]), }); this.isLoading = false; }), diff --git a/frontend/src/app/components/block-rewards-graph/block-rewards-graph.component.ts b/frontend/src/app/components/block-rewards-graph/block-rewards-graph.component.ts index 48d7ec10c..24614903c 100644 --- a/frontend/src/app/components/block-rewards-graph/block-rewards-graph.component.ts +++ b/frontend/src/app/components/block-rewards-graph/block-rewards-graph.component.ts @@ -69,7 +69,7 @@ export class BlockRewardsGraphComponent implements OnInit { .pipe( tap((response) => { this.prepareChartOptions({ - blockRewards: response.body.map(val => [val.timestamp * 1000, val.avg_rewards / 100000000]), + blockRewards: response.body.map(val => [val.timestamp * 1000, val.avgRewards / 100000000]), }); this.isLoading = false; }), diff --git a/frontend/src/app/components/block-sizes-weights-graph/block-sizes-weights-graph.component.ts b/frontend/src/app/components/block-sizes-weights-graph/block-sizes-weights-graph.component.ts index 7c72b42ef..3255fc4af 100644 --- a/frontend/src/app/components/block-sizes-weights-graph/block-sizes-weights-graph.component.ts +++ b/frontend/src/app/components/block-sizes-weights-graph/block-sizes-weights-graph.component.ts @@ -83,8 +83,8 @@ export class BlockSizesWeightsGraphComponent implements OnInit { tap((response) => { const data = response.body; this.prepareChartOptions({ - sizes: data.sizes.map(val => [val.timestamp * 1000, val.avg_size / 1000000, val.avg_height]), - weights: data.weights.map(val => [val.timestamp * 1000, val.avg_weight / 1000000, val.avg_height]), + sizes: data.sizes.map(val => [val.timestamp * 1000, val.avgSize / 1000000, val.avgHeight]), + weights: data.weights.map(val => [val.timestamp * 1000, val.avgWeight / 1000000, val.avgHeight]), }); this.isLoading = false; }), From 897126d56f60228c08c27a645957c95fec03bbb1 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Fri, 20 May 2022 09:49:13 +0200 Subject: [PATCH 02/29] Update API documentation for e101c4e2 --- .../src/app/docs/api-docs/api-docs-data.ts | 252 +++++++++--------- 1 file changed, 126 insertions(+), 126 deletions(-) diff --git a/frontend/src/app/docs/api-docs/api-docs-data.ts b/frontend/src/app/docs/api-docs/api-docs-data.ts index ff57aeb82..4737b27c7 100644 --- a/frontend/src/app/docs/api-docs/api-docs-data.ts +++ b/frontend/src/app/docs/api-docs/api-docs-data.ts @@ -3833,34 +3833,34 @@ export const restApiDocsData = [ curl: [`1w`], response: `[ { - "avg_height": 735644, + "avgHeight": 735644, "timestamp": 1652119111, - "avg_fees": 24212890 + "avgFees": 24212890 }, { - "avg_height": 735646, + "avgHeight": 735646, "timestamp": 1652120252, - "avg_fees": 21655996 + "avgFees": 21655996 }, { - "avg_height": 735648, + "avgHeight": 735648, "timestamp": 1652121214, - "avg_fees": 20678859 + "avgFees": 20678859 }, { - "avg_height": 735649, + "avgHeight": 735649, "timestamp": 1652121757, - "avg_fees": 21020140 + "avgFees": 21020140 }, { - "avg_height": 735650, + "avgHeight": 735650, "timestamp": 1652122367, - "avg_fees": 23064200 + "avgFees": 23064200 }, { - "avg_height": 735652, + "avgHeight": 735652, "timestamp": 1652122893, - "avg_fees": 17620723 + "avgFees": 17620723 }, ... ]` @@ -3871,14 +3871,14 @@ export const restApiDocsData = [ curl: [`1w`], response: `[ { - "avg_height": 2224253, + "avgHeight": 2224253, "timestamp": 1652346420, - "avg_fees": 211686 + "avgFees": 211686 }, { - "avg_height": 2224254, + "avgHeight": 2224254, "timestamp": 1652346850, - "avg_fees": 2565952 + "avgFees": 2565952 }, ... ]` @@ -3889,14 +3889,14 @@ export const restApiDocsData = [ curl: [`1w`], response: `[ { - "avg_height": 89978, + "avgHeight": 89978, "timestamp": 1652346573, - "avg_fees": 1071 + "avgFees": 1071 }, { - "avg_height": 89979, + "avgHeight": 89979, "timestamp": 1652346970, - "avg_fees": 1224 + "avgFees": 1224 }, ... ]` @@ -3932,29 +3932,29 @@ export const restApiDocsData = [ curl: [`1d`], response: `[ { - "avg_height": 599992, + "avgHeight": 599992, "timestamp": 1571438412, - "avg_rewards": 1260530933 + "avgRewards": 1260530933 }, { - "avg_height": 600000, + "avgHeight": 600000, "timestamp": 1571443398, - "avg_rewards": 1264314538 + "avgRewards": 1264314538 }, { - "avg_height": 725441, + "avgHeight": 725441, "timestamp": 1646139035, - "avg_rewards": 637067563 + "avgRewards": 637067563 }, { - "avg_height": 725585, + "avgHeight": 725585, "timestamp": 1646222444, - "avg_rewards": 646519104 + "avgRewards": 646519104 }, { - "avg_height": 725727, + "avgHeight": 725727, "timestamp": 1646308374, - "avg_rewards": 638709605 + "avgRewards": 638709605 }, ... ]` @@ -3965,14 +3965,14 @@ export const restApiDocsData = [ curl: [`1d`], response: `[ { - "avg_height": 12, + "avgHeight": 12, "timestamp": 1296689648, - "avg_rewards": 5000000000 + "avgRewards": 5000000000 }, { - "avg_height": 269, + "avgHeight": 269, "timestamp": 1296717674, - "avg_rewards": 5000091820 + "avgRewards": 5000091820 }, ... ]` @@ -3983,14 +3983,14 @@ export const restApiDocsData = [ curl: [`1d`], response: `[ { - "avg_height": 183, + "avgHeight": 183, "timestamp": 1598962247, - "avg_rewards": 5000000000 + "avgRewards": 5000000000 }, { - "avg_height": 576, + "avgHeight": 576, "timestamp": 1599047892, - "avg_rewards": 5000000000 + "avgRewards": 5000000000 }, ... ]` @@ -4028,37 +4028,37 @@ export const restApiDocsData = [ "oldestIndexedBlockTimestamp": 1571434851, "blockFeeRates": [ { - "avg_height": 732152, + "avgHeight": 732152, "timestamp": 1650132959, - "avg_fee_0": 1, - "avg_fee_10": 2, - "avg_fee_25": 2, - "avg_fee_50": 3, - "avg_fee_75": 4, - "avg_fee_90": 8, - "avg_fee_100": 393 + "avgFee_0": 1, + "avgFee_10": 2, + "avgFee_25": 2, + "avgFee_50": 3, + "avgFee_75": 4, + "avgFee_90": 8, + "avgFee_100": 393 }, { - "avg_height": 732158, + "avgHeight": 732158, "timestamp": 1650134432, - "avg_fee_0": 1, - "avg_fee_10": 1, - "avg_fee_25": 2, - "avg_fee_50": 4, - "avg_fee_75": 6, - "avg_fee_90": 10, - "avg_fee_100": 240 + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 2, + "avgFee_50": 4, + "avgFee_75": 6, + "avgFee_90": 10, + "avgFee_100": 240 }, { - "avg_height": 732161, + "avgHeight": 732161, "timestamp": 1650135818, - "avg_fee_0": 1, - "avg_fee_10": 1, - "avg_fee_25": 1, - "avg_fee_50": 2, - "avg_fee_75": 5, - "avg_fee_90": 8, - "avg_fee_100": 251 + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 2, + "avgFee_75": 5, + "avgFee_90": 8, + "avgFee_100": 251 }, ... ] @@ -4072,26 +4072,26 @@ export const restApiDocsData = [ "oldestIndexedBlockTimestamp": 1296688602, "blockFeeRates": [ { - "avg_height": 2196306, + "avgHeight": 2196306, "timestamp": 1650360168, - "avg_fee_0": 1, - "avg_fee_10": 1, - "avg_fee_25": 1, - "avg_fee_50": 1, - "avg_fee_75": 2, - "avg_fee_90": 28, - "avg_fee_100": 2644 + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 1, + "avgFee_75": 2, + "avgFee_90": 28, + "avgFee_100": 2644 }, { - "avg_height": 2196308, + "avgHeight": 2196308, "timestamp": 1650361209, - "avg_fee_0": 1, - "avg_fee_10": 1, - "avg_fee_25": 1, - "avg_fee_50": 4, - "avg_fee_75": 12, - "avg_fee_90": 65, - "avg_fee_100": 102 + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 4, + "avgFee_75": 12, + "avgFee_90": 65, + "avgFee_100": 102 }, ... ] @@ -4105,26 +4105,26 @@ export const restApiDocsData = [ "oldestIndexedBlockTimestamp": 1598918400, "blockFeeRates": [ { - "avg_height": 86620, + "avgHeight": 86620, "timestamp": 1650360010, - "avg_fee_0": 1, - "avg_fee_10": 1, - "avg_fee_25": 1, - "avg_fee_50": 1, - "avg_fee_75": 1, - "avg_fee_90": 1, - "avg_fee_100": 1 + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 1, + "avgFee_75": 1, + "avgFee_90": 1, + "avgFee_100": 1 }, { - "avg_height": 86623, + "avgHeight": 86623, "timestamp": 1650361330, - "avg_fee_0": 1, - "avg_fee_10": 1, - "avg_fee_25": 1, - "avg_fee_50": 1, - "avg_fee_75": 1, - "avg_fee_90": 1, - "avg_fee_100": 1 + "avgFee_0": 1, + "avgFee_10": 1, + "avgFee_25": 1, + "avgFee_50": 1, + "avgFee_75": 1, + "avgFee_90": 1, + "avgFee_100": 1 }, ... ] @@ -4162,47 +4162,47 @@ export const restApiDocsData = [ response: `{ "sizes": [ { - "avg_height": 576650, + "avgHeight": 576650, "timestamp": 1558212081, - "avg_size": 1271404 + "avgSize": 1271404 }, { - "avg_height": 576715, + "avgHeight": 576715, "timestamp": 1558246272, - "avg_size": 1105893 + "avgSize": 1105893 }, { - "avg_height": 576797, + "avgHeight": 576797, "timestamp": 1558289379, - "avg_size": 1141071 + "avgSize": 1141071 }, { - "avg_height": 576885, + "avgHeight": 576885, "timestamp": 1558330184, - "avg_size": 1108166 + "avgSize": 1108166 }, ... ], "weights": [ { - "avg_height": 576650, + "avgHeight": 576650, "timestamp": 1558212081, - "avg_weight": 3994002 + "avgWeight": 3994002 }, { - "avg_height": 576715, + "avgHeight": 576715, "timestamp": 1558246272, - "avg_weight": 3756312 + "avgWeight": 3756312 }, { - "avg_height": 576797, + "avgHeight": 576797, "timestamp": 1558289379, - "avg_weight": 3719625 + "avgWeight": 3719625 }, { - "avg_height": 576885, + "avgHeight": 576885, "timestamp": 1558330184, - "avg_weight": 3631381 + "avgWeight": 3631381 }, ... ] @@ -4215,27 +4215,27 @@ export const restApiDocsData = [ response: `{ "sizes": [ { - "avg_height": 1517188, + "avgHeight": 1517188, "timestamp": 1558262730, - "avg_size": 25089 + "avgSize": 25089 }, { - "avg_height": 1517275, + "avgHeight": 1517275, "timestamp": 1558290933, - "avg_size": 21679 + "avgSize": 21679 }, ... ], "weights": [ { - "avg_height": 1517188, + "avgHeight": 1517188, "timestamp": 1558262730, - "avg_weight": 74921 + "avgWeight": 74921 }, { - "avg_height": 1517275, + "avgHeight": 1517275, "timestamp": 1558290933, - "avg_weight": 65164 + "avgWeight": 65164 }, ... ] @@ -4248,27 +4248,27 @@ export const restApiDocsData = [ response: `{ "sizes": [ { - "avg_height": 83, + "avgHeight": 83, "timestamp": 1598937527, - "avg_size": 329 + "avgSize": 329 }, { - "avg_height": 266, + "avgHeight": 266, "timestamp": 1598982991, - "avg_size": 330 + "avgSize": 330 }, ... ], "weights": [ { - "avg_height": 83, + "avgHeight": 83, "timestamp": 1598937527, - "avg_weight": 1209 + "avgWeight": 1209 }, { - "avg_height": 266, + "avgHeight": 266, "timestamp": 1598982991, - "avg_weight": 1212 + "avgWeight": 1212 }, ... ] From a1fb89963c5afd8b86a9d14cde2bfb52d11ef501 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sat, 21 May 2022 02:30:38 +0400 Subject: [PATCH 03/29] Block transactions list error handling --- .../app/components/block/block.component.html | 17 ++++++++++++++--- .../src/app/components/block/block.component.ts | 11 ++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index c0ff29889..07ac76c21 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -197,7 +197,18 @@ - + +
+
+ Error loading data. +

+ {{ transactionsError.status }}: {{ transactionsError.error }} +
+
+
+
+ +
@@ -271,9 +282,9 @@
- Error loading block data. + Error loading data.

- {{ error.error }} + {{ error.code }}: {{ error.error }}
diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts index 57417a5c3..bd70e8628 100644 --- a/frontend/src/app/components/block/block.component.ts +++ b/frontend/src/app/components/block/block.component.ts @@ -38,6 +38,7 @@ export class BlockComponent implements OnInit, OnDestroy { showDetails = false; showPreviousBlocklink = true; showNextBlocklink = true; + transactionsError: any = null; subscription: Subscription; keyNavigationSubscription: Subscription; @@ -152,12 +153,13 @@ export class BlockComponent implements OnInit, OnDestroy { this.stateService.markBlock$.next({ blockHeight: this.blockHeight }); this.isLoadingTransactions = true; this.transactions = null; + this.transactionsError = null; }), debounceTime(300), switchMap((block) => this.electrsApiService.getBlockTransactions$(block.id) .pipe( catchError((err) => { - console.log(err); + this.transactionsError = err; return of([]); })) ), @@ -218,9 +220,16 @@ export class BlockComponent implements OnInit, OnDestroy { const start = (page - 1) * this.itemsPerPage; this.isLoadingTransactions = true; this.transactions = null; + this.transactionsError = null; target.scrollIntoView(); // works for chrome this.electrsApiService.getBlockTransactions$(this.block.id, start) + .pipe( + catchError((err) => { + this.transactionsError = err; + return of([]); + }) + ) .subscribe((transactions) => { this.transactions = transactions; this.isLoadingTransactions = false; From 49074cc3dfe2529107a4445186c5292dfd49fb08 Mon Sep 17 00:00:00 2001 From: hunicus <93150691+hunicus@users.noreply.github.com> Date: Sat, 21 May 2022 08:20:35 -0400 Subject: [PATCH 04/29] Add role attributes for doc nav elements To address #1668. --- .../code-template/code-template.component.html | 14 +++++++------- frontend/src/app/docs/docs/docs.component.html | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/frontend/src/app/docs/code-template/code-template.component.html b/frontend/src/app/docs/code-template/code-template.component.html index 47cea6d03..373f7daf6 100644 --- a/frontend/src/app/docs/code-template/code-template.component.html +++ b/frontend/src/app/docs/code-template/code-template.component.html @@ -1,14 +1,14 @@
-