From db3db49fbc61e965157ae992937f163d7092832d Mon Sep 17 00:00:00 2001 From: Mononaut Date: Wed, 3 Jul 2024 18:07:41 +0900 Subject: [PATCH] [accelerator] success confirmation screen --- .../accelerate-checkout.component.html | 19 +++++++++++++++++++ .../accelerate-checkout.component.ts | 14 +++++++++++++- .../components/tracker/tracker.component.html | 13 ++++++++++++- .../components/tracker/tracker.component.ts | 2 +- .../transaction/transaction.component.html | 2 ++ .../transaction/transaction.component.ts | 15 ++++++--------- 6 files changed, 53 insertions(+), 12 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 3546003b2..0c2fce725 100644 --- a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.html +++ b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.html @@ -492,6 +492,25 @@ + } @else if (step === 'success') { +
+
+

Your transaction is being accelerated!

+
+
+
+
+
+ Your transaction has been accepted for acceleration by our mining pool partners. +
+
+
+
+
+
+ +
+
} 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 460ae25fd..9805b5e96 100644 --- a/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts +++ b/frontend/src/app/components/accelerate-checkout/accelerate-checkout.component.ts @@ -41,7 +41,7 @@ export const MIN_BID_RATIO = 1; export const DEFAULT_BID_RATIO = 2; export const MAX_BID_RATIO = 4; -type CheckoutStep = 'quote' | 'summary' | 'checkout' | 'cashapp' | 'processing' | 'paid'; +type CheckoutStep = 'quote' | 'summary' | 'checkout' | 'cashapp' | 'processing' | 'paid' | 'success'; @Component({ selector: 'app-accelerate-checkout', @@ -50,6 +50,7 @@ type CheckoutStep = 'quote' | 'summary' | 'checkout' | 'cashapp' | 'processing' }) export class AccelerateCheckout implements OnInit, OnDestroy { @Input() tx: Transaction; + @Input() accelerating: boolean = false; @Input() miningStats: MiningStats; @Input() eta: ETA; @Input() scrollEvent: boolean; @@ -58,6 +59,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy { @Input() forceMobile: boolean = false; @Input() showDetails: boolean = false; @Input() noCTA: boolean = false; + @Output() completed = new EventEmitter(); @Output() hasDetails = new EventEmitter(); @Output() changeMode = new EventEmitter(); @@ -167,6 +169,11 @@ export class AccelerateCheckout implements OnInit, OnDestroy { if (changes.scrollEvent && this.scrollEvent) { this.scrollToElement('acceleratePreviewAnchor', 'start'); } + if (changes.accelerating) { + if ((this.step === 'processing' || this.step === 'paid') && this.accelerating) { + this.moveToStep('success'); + } + } } moveToStep(step: CheckoutStep) { @@ -186,6 +193,11 @@ export class AccelerateCheckout implements OnInit, OnDestroy { this.hasDetails.emit(this._step === 'quote'); } + closeModal(): void { + this.completed.emit(true); + this.moveToStep('summary'); + } + /** * Scroll to element id with or without setTimeout */ diff --git a/frontend/src/app/components/tracker/tracker.component.html b/frontend/src/app/components/tracker/tracker.component.html index d865cc340..6071a55e4 100644 --- a/frontend/src/app/components/tracker/tracker.component.html +++ b/frontend/src/app/components/tracker/tracker.component.html @@ -122,7 +122,18 @@   } @else if (showAccelerationSummary) { - + } @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 3ed8d3dfd..698226d50 100644 --- a/frontend/src/app/components/tracker/tracker.component.ts +++ b/frontend/src/app/components/tracker/tracker.component.ts @@ -715,6 +715,7 @@ export class TrackerComponent implements OnInit, OnDestroy { this.miningStats = stats; this.isAccelerated$.next(this.isAcceleration); // hack to trigger recalculation of ETA without adding another source observable }); + this.accelerationFlowCompleted = true; } this.isAccelerated$.next(this.isAcceleration); } @@ -759,7 +760,6 @@ export class TrackerComponent implements OnInit, OnDestroy { this.tx && !this.replaced && !this.isCached - && !this.tx.acceleration && this.acceleratorAvailable && this.eligibleForAcceleration && !this.accelerationFlowCompleted diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index d4aa64526..1997c2bdd 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -139,12 +139,14 @@ [cashappEnabled]="cashappEligible" [advancedEnabled]="true" [tx]="tx" + [accelerating]="isAcceleration" [eta]="eta" [miningStats]="miningStats" [scrollEvent]="scrollIntoAccelPreview" [showDetails]="showAccelerationDetails" [noCTA]="true" (hasDetails)="setHasAccelerationDetails($event)" + (completed)="onAccelerationCompleted()" class="h-100 w-100" > diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index 467fa7065..1d545c407 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -424,10 +424,6 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { if (txPosition.position?.block > 0 && this.tx.weight < 4000) { this.cashappEligible = true; } - } else if (this.showAccelerationSummary) { - setTimeout(() => { - this.accelerationFlowCompleted = true; - }, 2000); } } } @@ -797,10 +793,6 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { if (this.isAcceleration) { if (initialState) { this.accelerationFlowCompleted = true; - } else if (this.showAccelerationSummary) { - setTimeout(() => { - this.accelerationFlowCompleted = true; - }, 2000); } } if (this.isAcceleration) { @@ -969,6 +961,12 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { return auth !== null; } + onAccelerationCompleted(): void { + document.location.hash = ''; + this.accelerationFlowCompleted = true; + this.forceAccelerationSummary = false; + } + closeAccelerator(): void { document.location.hash = ''; this.hideAccelerationSummary = true; @@ -987,7 +985,6 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { this.tx && !this.replaced && !this.isCached - && !this.tx.acceleration && this.acceleratorAvailable && this.eligibleForAcceleration && (