From 7751131d62eaf502082d2137c54ad84fe2205158 Mon Sep 17 00:00:00 2001 From: tomiir Date: Thu, 15 Feb 2024 10:08:59 -0600 Subject: [PATCH] fix: use start time to check for new transactions --- .../scaffold/src/views/w3m-buy-in-progress-view/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/scaffold/src/views/w3m-buy-in-progress-view/index.ts b/packages/scaffold/src/views/w3m-buy-in-progress-view/index.ts index 22455acfdc..42ad97697f 100644 --- a/packages/scaffold/src/views/w3m-buy-in-progress-view/index.ts +++ b/packages/scaffold/src/views/w3m-buy-in-progress-view/index.ts @@ -142,7 +142,7 @@ export class W3mBuyInProgressView extends LitElement { private async initializeCoinbaseTransactions() { await this.watchCoinbaseTransactions() - this.intervalId = setInterval(() => this.watchCoinbaseTransactions(), 10000) + this.intervalId = setInterval(() => this.watchCoinbaseTransactions(), 4000) } private async watchCoinbaseTransactions() { @@ -166,11 +166,12 @@ export class W3mBuyInProgressView extends LitElement { projectId }) - const pendingTransactions = coinbaseResponse.data.filter( - tx => tx.metadata.status === 'ONRAMP_TRANSACTION_STATUS_IN_PROGRESS' + const newTransactions = coinbaseResponse.data.filter( + // @ts-expect-error - start time will always be set at this point + tx => new Date(tx.metadata.minedAt) > new Date(this.startTime) ) - if (pendingTransactions.length && this.intervalId) { + if (newTransactions.length && this.intervalId) { clearInterval(this.intervalId) RouterController.replace('OnRampActivity') } else if (this.startTime && Date.now() - this.startTime >= 180_000 && this.intervalId) {