From 7751131d62eaf502082d2137c54ad84fe2205158 Mon Sep 17 00:00:00 2001 From: tomiir Date: Thu, 15 Feb 2024 10:08:59 -0600 Subject: [PATCH 1/3] 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) { From 8171401b0c81f26e0158ac18540748cb52294dce Mon Sep 17 00:00:00 2001 From: tomiir Date: Fri, 16 Feb 2024 10:03:30 -0600 Subject: [PATCH 2/3] feat: add Base and debug logs --- packages/core/src/utils/ConstantsUtil.ts | 3 ++- .../scaffold/src/views/w3m-buy-in-progress-view/index.ts | 7 +++++++ .../scaffold/src/views/w3m-onramp-activity-view/index.ts | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/core/src/utils/ConstantsUtil.ts b/packages/core/src/utils/ConstantsUtil.ts index 15bea66fe6..0ef30e1870 100644 --- a/packages/core/src/utils/ConstantsUtil.ts +++ b/packages/core/src/utils/ConstantsUtil.ts @@ -59,7 +59,8 @@ export const ConstantsUtil = { Polygon: 'polygon', Avalanche: 'avalanche-c-chain', 'OP Mainnet': 'optimism', - Celo: 'celo' + Celo: 'celo', + Base: 'base' }, WC_COINBASE_ONRAMP_APP_ID: 'bf18c88d-495a-463b-b249-0b9d3656cf5e' 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 42ad97697f..3104dd760c 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 @@ -166,11 +166,18 @@ export class W3mBuyInProgressView extends LitElement { projectId }) + console.log('Coinbase respnose') + console.log(coinbaseResponse) + + console.log('Date of first render', this.startTime) + 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) ) + console.log('New transactions', newTransactions) + if (newTransactions.length && this.intervalId) { clearInterval(this.intervalId) RouterController.replace('OnRampActivity') diff --git a/packages/scaffold/src/views/w3m-onramp-activity-view/index.ts b/packages/scaffold/src/views/w3m-onramp-activity-view/index.ts index 103ae79387..2b1200e336 100644 --- a/packages/scaffold/src/views/w3m-onramp-activity-view/index.ts +++ b/packages/scaffold/src/views/w3m-onramp-activity-view/index.ts @@ -45,6 +45,7 @@ export class W3mOnRampActivityView extends LitElement { clearTimeout(this.refetchTimeout) }, TransactionsController.subscribe(val => { + console.log('Coinbase Transactions updated', val.coinbaseTransactions) this.coinbaseTransactions = { ...val.coinbaseTransactions } }) ] @@ -158,10 +159,14 @@ export class W3mOnRampActivityView extends LitElement { private refetchLoadingTransactions() { const today = new Date() const currentMonthTxs = this.coinbaseTransactions[today.getFullYear()]?.[today.getMonth()] || [] + + console.log('Activity - Current month transactions', currentMonthTxs) const loadingTransactions = currentMonthTxs.filter( transaction => transaction.metadata.status === 'ONRAMP_TRANSACTION_STATUS_IN_PROGRESS' ) + console.log('Activity - Loading Transactions', loadingTransactions) + if (loadingTransactions.length === 0) { clearTimeout(this.refetchTimeout) @@ -171,6 +176,7 @@ export class W3mOnRampActivityView extends LitElement { // Wait 2 seconds before refetching this.refetchTimeout = setTimeout(async () => { const address = AccountController.state.address + console.log('Refetching transactions') await TransactionsController.fetchTransactions(address, 'coinbase') this.refetchLoadingTransactions() }, 3000) From 5775d36788e20b0470cc90dd68b737cedf12c0c0 Mon Sep 17 00:00:00 2001 From: tomiir Date: Fri, 16 Feb 2024 10:03:55 -0600 Subject: [PATCH 3/3] --amend --- packages/core/src/utils/ConstantsUtil.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/src/utils/ConstantsUtil.ts b/packages/core/src/utils/ConstantsUtil.ts index 0ef30e1870..0035451b5b 100644 --- a/packages/core/src/utils/ConstantsUtil.ts +++ b/packages/core/src/utils/ConstantsUtil.ts @@ -48,7 +48,8 @@ export const ConstantsUtil = { 'polygon', 'avalanche-c-chain', 'optimism', - 'celo' + 'celo', + 'base' ], WC_COINBASE_PAY_SDK_FALLBACK_CHAIN: 'ethereum',