Skip to content

Commit

Permalink
fix: use start time to check for new transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir committed Feb 15, 2024
1 parent 937edb0 commit 7751131
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/scaffold/src/views/w3m-buy-in-progress-view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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) {
Expand Down

0 comments on commit 7751131

Please sign in to comment.