Merge pull request #4926 from mempool/nymkappa/duplicated-accel
[accelerator] fix possible duplicated accel request call
This commit is contained in:
commit
e849a31668
@ -59,6 +59,7 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
|
|||||||
defaultBid = 0;
|
defaultBid = 0;
|
||||||
maxCost = 0;
|
maxCost = 0;
|
||||||
userBid = 0;
|
userBid = 0;
|
||||||
|
accelerationUUID: string;
|
||||||
selectFeeRateIndex = 1;
|
selectFeeRateIndex = 1;
|
||||||
isMobile: boolean = window.innerWidth <= 767.98;
|
isMobile: boolean = window.innerWidth <= 767.98;
|
||||||
user: any = undefined;
|
user: any = undefined;
|
||||||
@ -102,6 +103,7 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.accelerationUUID = window.crypto.randomUUID();
|
||||||
if (this.stateService.ref === 'https://cash.app/') {
|
if (this.stateService.ref === 'https://cash.app/') {
|
||||||
this.paymentType = 'cashapp';
|
this.paymentType = 'cashapp';
|
||||||
} else {
|
} else {
|
||||||
@ -245,7 +247,8 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
|
|||||||
}
|
}
|
||||||
this.accelerationSubscription = this.servicesApiService.accelerate$(
|
this.accelerationSubscription = this.servicesApiService.accelerate$(
|
||||||
this.tx.txid,
|
this.tx.txid,
|
||||||
this.userBid
|
this.userBid,
|
||||||
|
this.accelerationUUID
|
||||||
).subscribe({
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.audioService.playSound('ascend-chime-cartoon');
|
this.audioService.playSound('ascend-chime-cartoon');
|
||||||
@ -315,6 +318,10 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
|
|||||||
|
|
||||||
this.conversionsSubscription = this.stateService.conversions$.subscribe(
|
this.conversionsSubscription = this.stateService.conversions$.subscribe(
|
||||||
async (conversions) => {
|
async (conversions) => {
|
||||||
|
if (this.cashAppPay) {
|
||||||
|
this.cashAppPay.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
const maxCostUsd = this.maxCost / 100_000_000 * conversions.USD;
|
const maxCostUsd = this.maxCost / 100_000_000 * conversions.USD;
|
||||||
const paymentRequest = this.payments.paymentRequest({
|
const paymentRequest = this.payments.paymentRequest({
|
||||||
countryCode: 'US',
|
countryCode: 'US',
|
||||||
@ -348,7 +355,8 @@ export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges
|
|||||||
that.userBid,
|
that.userBid,
|
||||||
tokenResult.token,
|
tokenResult.token,
|
||||||
tokenResult.details.cashAppPay.cashtag,
|
tokenResult.details.cashAppPay.cashtag,
|
||||||
tokenResult.details.cashAppPay.referenceId
|
tokenResult.details.cashAppPay.referenceId,
|
||||||
|
that.accelerationUUID
|
||||||
).subscribe({
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
that.audioService.playSound('ascend-chime-cartoon');
|
that.audioService.playSound('ascend-chime-cartoon');
|
||||||
|
@ -128,12 +128,12 @@ export class ServicesApiServices {
|
|||||||
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/estimate`, { txInput: txInput }, { observe: 'response' });
|
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/estimate`, { txInput: txInput }, { observe: 'response' });
|
||||||
}
|
}
|
||||||
|
|
||||||
accelerate$(txInput: string, userBid: number) {
|
accelerate$(txInput: string, userBid: number, accelerationUUID: string) {
|
||||||
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/accelerate`, { txInput: txInput, userBid: userBid });
|
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/accelerate`, { txInput: txInput, userBid: userBid, accelerationUUID: accelerationUUID });
|
||||||
}
|
}
|
||||||
|
|
||||||
accelerateWithCashApp$(txInput: string, userBid: number, token: string, cashtag: string, referenceId: string) {
|
accelerateWithCashApp$(txInput: string, userBid: number, token: string, cashtag: string, referenceId: string, accelerationUUID: string) {
|
||||||
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/accelerate/cashapp`, { txInput: txInput, userBid: userBid, token: token, cashtag: cashtag, referenceId: referenceId });
|
return this.httpClient.post<any>(`${SERVICES_API_PREFIX}/accelerator/accelerate/cashapp`, { txInput: txInput, userBid: userBid, token: token, cashtag: cashtag, referenceId: referenceId, accelerationUUID: accelerationUUID });
|
||||||
}
|
}
|
||||||
|
|
||||||
getAccelerations$(): Observable<Acceleration[]> {
|
getAccelerations$(): Observable<Acceleration[]> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user