diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 1b88951f4..8f8afd176 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -40,6 +40,7 @@ import { StatusViewComponent } from './components/status-view/status-view.compon import { MinerComponent } from './components/miner/miner.component'; import { SharedModule } from './shared/shared.module'; import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap'; +import { FeesBoxComponent } from './components/fees-box/fees-box.component'; @NgModule({ declarations: [ @@ -70,6 +71,7 @@ import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap'; AssetsComponent, MinerComponent, StatusViewComponent, + FeesBoxComponent, ], imports: [ BrowserModule, diff --git a/frontend/src/app/components/fees-box/fees-box.component.html b/frontend/src/app/components/fees-box/fees-box.component.html new file mode 100644 index 000000000..d2f9e0ba9 --- /dev/null +++ b/frontend/src/app/components/fees-box/fees-box.component.html @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + +
1 hour30 minutesNext block
{{ feeEstimations.hourFee }} sat/vB (){{ feeEstimations.halfHourFee }} sat/vB (){{ feeEstimations.fastestFee }} sat/vB ()
diff --git a/frontend/src/app/components/fees-box/fees-box.component.scss b/frontend/src/app/components/fees-box/fees-box.component.scss new file mode 100644 index 000000000..ab8257f06 --- /dev/null +++ b/frontend/src/app/components/fees-box/fees-box.component.scss @@ -0,0 +1,9 @@ +td { + width: 33%; +} + +@media (max-width: 767.98px) { + td { + width: 50%; + } +} diff --git a/frontend/src/app/components/fees-box/fees-box.component.ts b/frontend/src/app/components/fees-box/fees-box.component.ts new file mode 100644 index 000000000..c55c164a8 --- /dev/null +++ b/frontend/src/app/components/fees-box/fees-box.component.ts @@ -0,0 +1,48 @@ +import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; +import { StateService } from 'src/app/services/state.service'; +import { map, filter } from 'rxjs/operators'; +import { Observable } from 'rxjs'; + +interface FeeEstimations { + fastestFee: number; + halfHourFee: number; + hourFee: number; +} + +@Component({ + selector: 'app-fees-box', + templateUrl: './fees-box.component.html', + styleUrls: ['./fees-box.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class FeesBoxComponent implements OnInit { + feeEstimations$: Observable; + + constructor( + private stateService: StateService, + ) { } + + ngOnInit(): void { + this.feeEstimations$ = this.stateService.mempoolBlocks$ + .pipe( + filter((blocks) => !!blocks.length), + map((pBlocks) => { + let firstMedianFee = Math.ceil(pBlocks[0].medianFee); + + if (pBlocks.length === 1 && pBlocks[0].blockVSize <= 500000) { + firstMedianFee = 1; + } + + const secondMedianFee = pBlocks[1] ? Math.ceil(pBlocks[1].medianFee) : firstMedianFee; + const thirdMedianFee = pBlocks[2] ? Math.ceil(pBlocks[2].medianFee) : secondMedianFee; + + return { + 'fastestFee': firstMedianFee, + 'halfHourFee': secondMedianFee, + 'hourFee': thirdMedianFee, + }; + }) + ); + } + +} diff --git a/frontend/src/app/components/latest-blocks/latest-blocks.component.html b/frontend/src/app/components/latest-blocks/latest-blocks.component.html index e22fc04db..fd077080e 100644 --- a/frontend/src/app/components/latest-blocks/latest-blocks.component.html +++ b/frontend/src/app/components/latest-blocks/latest-blocks.component.html @@ -1,5 +1,6 @@ -
+ +