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..b93b16e70 --- /dev/null +++ b/frontend/src/app/components/fees-box/fees-box.component.html @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + +
1 hour30 minutesNext block
{{ feeEstimations.fastestFee }} sat/vB (){{ feeEstimations.halfHourFee }} sat/vB (){{ feeEstimations.hourFee }} 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..e69de29bb 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..67c5daff3 --- /dev/null +++ b/frontend/src/app/components/fees-box/fees-box.component.ts @@ -0,0 +1,47 @@ +import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; +import { StateService } from 'src/app/services/state.service'; +import { map } 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( + 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..72659cf0b 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 @@ -
+ +