From 776404dbdea891a65b69a7296e06898e838052ec Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sat, 29 Jun 2024 09:17:08 +0000 Subject: [PATCH] [accelerator] Pro for everyone --- .../accelerate-checkout.component.html | 89 +++++++++++-------- .../accelerate-checkout.component.ts | 19 +--- .../components/tracker/tracker.component.html | 2 +- .../components/tracker/tracker.component.ts | 11 ++- .../transaction/transaction.component.html | 5 +- .../transaction/transaction.component.ts | 30 +++++-- 6 files changed, 91 insertions(+), 65 deletions(-) diff --git a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.html b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.html index 0cd278f25..11ecd2b7e 100644 --- a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.html +++ b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.html @@ -107,25 +107,49 @@ - - Next block market rate - - {{ estimate.targetFeeRate | number : '1.0-0' }} - - sat/vB - - - - Estimated extra fee required - - - {{ math.max(0, estimate.nextBlockFee - estimate.txSummary.effectiveFee) | number }} - - - sats - - - + @if (isLoggedIn()) { + + Next block market rate + + {{ estimate.targetFeeRate | number : '1.0-0' }} + + sat/vB + + + + Estimated extra fee required + + + {{ math.max(0, estimate.nextBlockFee - estimate.txSummary.effectiveFee) | number }} + + + sats + + + + } + @else { + + + Target rate + + {{ maxRateOptions[selectFeeRateIndex].rate | number : '1.0-0' }} + + sat/vB + + + + Extra fee required + + + {{ maxRateOptions[selectFeeRateIndex].fee | number }} + + + sats + + + + } @@ -219,17 +243,10 @@
- @if (isLoggedIn() || canPayWithBitcoin || canPayWithCashapp) { - - } @else { - - } +
@@ -280,7 +297,7 @@
- @if (showSummary) { -
-
- -
+
+
+
- } +
} @else if (step === 'cashapp') {
diff --git a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts index 7de6a4a04..6c37663d0 100644 --- a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts +++ b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts @@ -55,7 +55,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy { @Input() scrollEvent: boolean; @Input() cashappEnabled: boolean = true; @Input() advancedEnabled: boolean = false; - @Input() forceSummary: boolean = false; @Input() forceMobile: boolean = false; @Output() changeMode = new EventEmitter(); @@ -122,10 +121,8 @@ export class AccelerateCheckout implements OnInit, OnDestroy { this.moveToStep('processing'); this.insertSquare(); this.setupSquare(); - } else if (this.isLoggedIn() || this.forceSummary) { - this.moveToStep('summary'); } else { - this.moveToStep('checkout'); + this.moveToStep('summary'); } this.servicesApiService.setupSquare$().subscribe(ids => { @@ -232,10 +229,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy { } this.cost = this.userBid + this.estimate.mempoolBaseFee + this.estimate.vsizeFee; - if (!this.canPay && this.advancedEnabled && this.step !== 'quote') { - this.moveToStep('quote'); - } - if (this.step === 'checkout' && this.canPayWithBitcoin && !this.loadingBtcpayInvoice) { this.loadingBtcpayInvoice = true; this.requestBTCPayInvoice(); @@ -272,11 +265,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy { accelerate(): void { if (this.canPay) { if (this.isLoggedIn()) { - if (this.step !== 'summary') { - this.moveToStep('summary'); - } else { - this.accelerateWithMempoolAccount(); - } + this.accelerateWithMempoolAccount(); } else { this.moveToStep('checkout'); } @@ -488,10 +477,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy { return this.canPayWithBalance || this.canPayWithBitcoin || this.canPayWithCashapp; } - get showSummary() { - return this.canPayWithBalance || this.forceSummary; - } - @HostListener('window:resize', ['$event']) onResize(): void { this.isMobile = window.innerWidth <= 767.98; diff --git a/frontend/src/app/components/tracker/tracker.component.html b/frontend/src/app/components/tracker/tracker.component.html index f65e1a204..5199897fc 100644 --- a/frontend/src/app/components/tracker/tracker.component.html +++ b/frontend/src/app/components/tracker/tracker.component.html @@ -122,7 +122,7 @@   } @else if (showAccelerationSummary && !accelerationFlowCompleted) { - + } @else { @if (tx?.acceleration && !tx.status?.confirmed) { diff --git a/frontend/src/app/components/tracker/tracker.component.ts b/frontend/src/app/components/tracker/tracker.component.ts index b9c2b5ae7..88a929bd7 100644 --- a/frontend/src/app/components/tracker/tracker.component.ts +++ b/frontend/src/app/components/tracker/tracker.component.ts @@ -151,6 +151,10 @@ export class TrackerComponent implements OnInit, OnDestroy { this.acceleratorAvailable = this.stateService.env.OFFICIAL_MEMPOOL_SPACE && this.stateService.env.ACCELERATOR && this.stateService.network === ''; + this.miningService.getMiningStats('1w').subscribe(stats => { + this.miningStats = stats; + }); + const urlParams = new URLSearchParams(window.location.search); if (urlParams.get('cash_request_id')) { this.showAccelerationSummary = true; @@ -382,7 +386,12 @@ export class TrackerComponent implements OnInit, OnDestroy { } if (!this.mempoolPosition.accelerated) { - this.showAccelerationSummary = true; + if (!this.showAccelerationSummary) { + this.showAccelerationSummary = true; + this.miningService.getMiningStats('1w').subscribe(stats => { + this.miningStats = stats; + }); + } if (txPosition.position?.block > 0 && this.tx.weight < 4000) { this.accelerationEligible = true; } diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index 0e67887dc..58322a72d 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -547,11 +547,8 @@ } @else if (network === 'liquid' || network === 'liquidtestnet') { } @else { - + - @if (!tx?.acceleration && acceleratorAvailable && accelerateCtaType === 'button') { - Accelerate - } } diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index 1e37ca3fc..7b12b3c7b 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -170,6 +170,15 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { ngOnInit() { this.enterpriseService.page(); + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.get('cash_request_id')) { + this.showAccelerationSummary = true; + } + + this.miningService.getMiningStats('1w').subscribe(stats => { + this.miningStats = stats; + }); + this.websocketService.want(['blocks', 'mempool-blocks']); this.stateService.networkChanged$.subscribe( (network) => { @@ -398,7 +407,22 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { } else if ((this.tx?.acceleration && txPosition.position.acceleratedBy)) { this.tx.acceleratedBy = txPosition.position.acceleratedBy; } - this.accelerationEligible = txPosition?.position?.block > 0 && this.tx?.weight < 4000; + + if (!this.mempoolPosition.accelerated) { + if (!this.showAccelerationSummary) { + this.showAccelerationSummary = true; + this.miningService.getMiningStats('1w').subscribe(stats => { + this.miningStats = stats; + }); + } + if (txPosition.position?.block > 0 && this.tx.weight < 4000) { + this.accelerationEligible = true; + } + } else if (this.showAccelerationSummary) { + setTimeout(() => { + this.showAccelerationSummary = false; + }, 2000); + } } } else { this.mempoolPosition = null; @@ -683,10 +707,6 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { return; } - this.miningService.getMiningStats('1w').subscribe(stats => { - this.miningStats = stats; - }); - document.location.hash = '#accelerate'; this.enterpriseService.goal(8); this.showAccelerationSummary = true && this.acceleratorAvailable;