@@ -14,6 +14,8 @@ import { coinbaseWallet } from 'wagmi/connectors';
14
14
import { useWriteContracts } from 'wagmi/experimental' ;
15
15
import { useCallsStatus } from 'wagmi/experimental' ;
16
16
import { useValue } from '../../internal/hooks/useValue' ;
17
+ import { getWindowDimensions } from '../../internal/utils/getWindowDimensions' ;
18
+ import { openPopup } from '../../internal/utils/openPopup' ;
17
19
import { isUserRejectedRequestError } from '../../transaction/utils/isUserRejectedRequestError' ;
18
20
import { useOnchainKit } from '../../useOnchainKit' ;
19
21
import { useIsWalletACoinbaseSmartWallet } from '../../wallet/hooks/useIsWalletACoinbaseSmartWallet' ;
@@ -23,12 +25,7 @@ import {
23
25
NO_CONTRACTS_ERROR ,
24
26
USER_REJECTED_ERROR ,
25
27
} from '../constants' ;
26
- import {
27
- CHECKOUT_INSUFFICIENT_BALANCE_ERROR ,
28
- CHECKOUT_INSUFFICIENT_BALANCE_ERROR_MESSAGE ,
29
- CHECKOUT_LIFECYCLESTATUS ,
30
- CheckoutErrorCode ,
31
- } from '../constants' ;
28
+ import { CHECKOUT_LIFECYCLESTATUS , CheckoutErrorCode } from '../constants' ;
32
29
import { useCommerceContracts } from '../hooks/useCommerceContracts' ;
33
30
import { useLifecycleStatus } from '../hooks/useLifecycleStatus' ;
34
31
import type { CheckoutContextType , CheckoutProviderReact } from '../types' ;
@@ -212,26 +209,6 @@ export function CheckoutProvider({
212
209
) ;
213
210
return ;
214
211
}
215
- // Open funding flow
216
- // TODO: Deprecate this once we have USDC Magic Spend
217
- if (
218
- lifecycleStatus . statusName === CHECKOUT_LIFECYCLESTATUS . ERROR &&
219
- lifecycleStatus . statusData ?. code ===
220
- CheckoutErrorCode . INSUFFICIENT_BALANCE
221
- ) {
222
- window . open (
223
- `https://keys.coinbase.com/fund?asset=USDC&chainId=8453&presetCryptoAmount=${ priceInUSDCRef . current } ` ,
224
- '_blank' ,
225
- 'noopener,noreferrer' ,
226
- ) ;
227
- // Reset status
228
- setErrorMessage ( '' ) ;
229
- updateLifecycleStatus ( {
230
- statusName : CHECKOUT_LIFECYCLESTATUS . INIT ,
231
- statusData : { } ,
232
- } ) ;
233
- return ;
234
- }
235
212
if ( errorMessage === USER_REJECTED_ERROR ) {
236
213
// Reset status if previous request was a rejection
237
214
setErrorMessage ( '' ) ;
@@ -285,18 +262,12 @@ export function CheckoutProvider({
285
262
286
263
// Check for sufficient balance
287
264
if ( insufficientBalanceRef . current && priceInUSDCRef . current ) {
288
- setErrorMessage (
289
- CHECKOUT_INSUFFICIENT_BALANCE_ERROR_MESSAGE ( priceInUSDCRef . current ) ,
290
- ) ;
291
- updateLifecycleStatus ( {
292
- statusName : CHECKOUT_LIFECYCLESTATUS . ERROR ,
293
- statusData : {
294
- code : CheckoutErrorCode . INSUFFICIENT_BALANCE ,
295
- error : CHECKOUT_INSUFFICIENT_BALANCE_ERROR ,
296
- message : CHECKOUT_INSUFFICIENT_BALANCE_ERROR_MESSAGE (
297
- priceInUSDCRef . current ,
298
- ) ,
299
- } ,
265
+ const { height, width } = getWindowDimensions ( 'md' ) ;
266
+ openPopup ( {
267
+ url : `https://keys.coinbase.com/fund?asset=USDC&chainId=8453&presetCryptoAmount=${ priceInUSDCRef . current } ` ,
268
+ target : '_blank' ,
269
+ height,
270
+ width,
300
271
} ) ;
301
272
return ;
302
273
}
@@ -362,7 +333,6 @@ export function CheckoutProvider({
362
333
isConnected ,
363
334
isSmartWallet ,
364
335
isSponsored ,
365
- lifecycleStatus . statusData ,
366
336
lifecycleStatus . statusName ,
367
337
paymaster ,
368
338
switchChainAsync ,
0 commit comments