Skip to content

Commit

Permalink
refactor: move web utils to ui/react/internal/utils (#1716)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschlabach authored Dec 16, 2024
1 parent 185905e commit 1dd7a84
Show file tree
Hide file tree
Showing 23 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/checkout/components/CheckoutProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { openPopup } from '@/ui-react/internal/utils/openPopup';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import {
type Mock,
Expand All @@ -13,7 +14,6 @@ import { useWaitForTransactionReceipt } from 'wagmi';
import { useCallsStatus } from 'wagmi/experimental';
import { useWriteContracts } from 'wagmi/experimental';
import { useOnchainKit } from '../../core-react/useOnchainKit';
import { openPopup } from '../../internal/utils/openPopup';
import { useIsWalletACoinbaseSmartWallet } from '../../wallet/hooks/useIsWalletACoinbaseSmartWallet';
import { GENERIC_ERROR_MESSAGE } from '../constants';
import { useCommerceContracts } from '../hooks/useCommerceContracts';
Expand Down Expand Up @@ -43,7 +43,7 @@ vi.mock('../../core-react/useOnchainKit', () => ({
useOnchainKit: vi.fn(),
}));

vi.mock('../../internal/utils/openPopup', () => ({
vi.mock('@/ui-react/internal/utils/openPopup', () => ({
openPopup: vi.fn(),
}));

Expand Down
4 changes: 2 additions & 2 deletions src/checkout/components/CheckoutProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getWindowDimensions } from '@/ui-react/internal/utils/getWindowDimensions';
import { openPopup } from '@/ui-react/internal/utils/openPopup';
import {
createContext,
useCallback,
Expand All @@ -15,8 +17,6 @@ import { useWriteContracts } from 'wagmi/experimental';
import { useCallsStatus } from 'wagmi/experimental';
import { useValue } from '../../core-react/internal/hooks/useValue';
import { useOnchainKit } from '../../core-react/useOnchainKit';
import { getWindowDimensions } from '../../internal/utils/getWindowDimensions';
import { openPopup } from '../../internal/utils/openPopup';
import { isUserRejectedRequestError } from '../../transaction/utils/isUserRejectedRequestError';
import { useIsWalletACoinbaseSmartWallet } from '../../wallet/hooks/useIsWalletACoinbaseSmartWallet';
import {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setOnchainKitConfig } from '@/core/OnchainKitConfig';
import { describe, expect, it } from 'vitest';
import { setOnchainKitConfig } from '../../core/OnchainKitConfig';
import { getApiKey } from './getApiKey';

describe('getApiKey', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ONCHAIN_KIT_CONFIG } from '../../core/OnchainKitConfig';
import { ONCHAIN_KIT_CONFIG } from '@/core/OnchainKitConfig';

/**
* Get the API key for OnchainKit.
Expand Down
4 changes: 2 additions & 2 deletions src/fund/components/FundButton.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '@testing-library/jest-dom';
import { openPopup } from '@/ui-react/internal/utils/openPopup';
import { fireEvent, render, screen } from '@testing-library/react';
import { type Mock, afterEach, describe, expect, it, vi } from 'vitest';
import { openPopup } from '../../internal/utils/openPopup';
import { useGetFundingUrl } from '../hooks/useGetFundingUrl';
import { getFundingPopupSize } from '../utils/getFundingPopupSize';
import { FundButton } from './FundButton';
Expand All @@ -14,7 +14,7 @@ vi.mock('../utils/getFundingPopupSize', () => ({
getFundingPopupSize: vi.fn(),
}));

vi.mock('../../internal/utils/openPopup', () => ({
vi.mock('@/ui-react/internal/utils/openPopup', () => ({
openPopup: vi.fn(),
}));

Expand Down
3 changes: 2 additions & 1 deletion src/fund/components/FundButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useCallback } from 'react';
import { useTheme } from '../../core-react/internal/hooks/useTheme';
import { addSvg } from '../../internal/svg/addSvg';
import { openPopup } from '../../internal/utils/openPopup';
import { border, cn, color, pressable, text } from '../../styles/theme';

import { openPopup } from '@/ui-react/internal/utils/openPopup';
import { useGetFundingUrl } from '../hooks/useGetFundingUrl';
import type { FundButtonReact } from '../types';
import { getFundingPopupSize } from '../utils/getFundingPopupSize';
Expand Down
4 changes: 2 additions & 2 deletions src/fund/utils/fetchOnrampConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertSnakeToCamelCase } from '../../internal/utils/convertSnakeToCamelCase';
import { getApiKey } from '../../internal/utils/getApiKey';
import { convertSnakeToCamelCase } from '@/core/utils/convertSnakeToCamelCase';
import { getApiKey } from '@/core/utils/getApiKey';
import { ONRAMP_API_BASE_URL } from '../constants';
import type { OnrampPaymentMethod } from '../types';

Expand Down
4 changes: 2 additions & 2 deletions src/fund/utils/fetchOnrampOptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertSnakeToCamelCase } from '../../internal/utils/convertSnakeToCamelCase';
import { getApiKey } from '../../internal/utils/getApiKey';
import { convertSnakeToCamelCase } from '../../core/utils/convertSnakeToCamelCase';
import { getApiKey } from '../../core/utils/getApiKey';
import { ONRAMP_API_BASE_URL } from '../constants';
import type { OnrampPaymentCurrency, OnrampPurchaseCurrency } from '../types';

Expand Down
4 changes: 2 additions & 2 deletions src/fund/utils/fetchOnrampQuote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertSnakeToCamelCase } from '../../internal/utils/convertSnakeToCamelCase';
import { getApiKey } from '../../internal/utils/getApiKey';
import { convertSnakeToCamelCase } from '../../core/utils/convertSnakeToCamelCase';
import { getApiKey } from '../../core/utils/getApiKey';
import { ONRAMP_API_BASE_URL } from '../constants';
import type { OnrampAmount } from '../types';

Expand Down
4 changes: 2 additions & 2 deletions src/fund/utils/fetchOnrampTransactionStatus.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertSnakeToCamelCase } from '../../internal/utils/convertSnakeToCamelCase';
import { getApiKey } from '../../internal/utils/getApiKey';
import { convertSnakeToCamelCase } from '../../core/utils/convertSnakeToCamelCase';
import { getApiKey } from '../../core/utils/getApiKey';
import { ONRAMP_API_BASE_URL } from '../constants';
import type { OnrampTransaction } from '../types';

Expand Down
4 changes: 2 additions & 2 deletions src/fund/utils/getFundingPopupSize.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type Mock, afterEach, describe, expect, it, vi } from 'vitest';
import { getWindowDimensions } from '../../internal/utils/getWindowDimensions';
import { getWindowDimensions } from '../../ui/react/internal/utils/getWindowDimensions';
import { ONRAMP_POPUP_HEIGHT, ONRAMP_POPUP_WIDTH } from '../constants';
import { getFundingPopupSize } from './getFundingPopupSize';

vi.mock('../../internal/utils/getWindowDimensions', () => ({
vi.mock('../../ui/react/internal/utils/getWindowDimensions', () => ({
getWindowDimensions: vi.fn(),
}));

Expand Down
2 changes: 1 addition & 1 deletion src/fund/utils/getFundingPopupSize.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
getWindowDimensions,
type popupSizes,
} from '../../internal/utils/getWindowDimensions';
} from '../../ui/react/internal/utils/getWindowDimensions';
import { ONRAMP_POPUP_HEIGHT, ONRAMP_POPUP_WIDTH } from '../constants';
import { ONRAMP_BUY_URL } from '../constants';

Expand Down
2 changes: 1 addition & 1 deletion src/internal/components/Toast.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';
import { background, cn } from '../../styles/theme';
import { getToastPosition } from '../../ui/react/internal/utils/getToastPosition';
import { closeSvg } from '../svg/closeSvg';
import { getToastPosition } from '../utils/getToastPosition';

type ToastProps = {
className?: string;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/wallet/components/WalletDropdownFundLink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fireEvent, render, screen } from '@testing-library/react';
import { type Mock, afterEach, describe, expect, it, vi } from 'vitest';
import { useGetFundingUrl } from '../../fund/hooks/useGetFundingUrl';
import { getFundingPopupSize } from '../../fund/utils/getFundingPopupSize';
import { openPopup } from '../../internal/utils/openPopup';
import { openPopup } from '../../ui/react/internal/utils/openPopup';
import { WalletDropdownFundLink } from './WalletDropdownFundLink';

vi.mock('../../fund/hooks/useGetFundingUrl', () => ({
Expand All @@ -14,7 +14,7 @@ vi.mock('../../fund/utils/getFundingPopupSize', () => ({
getFundingPopupSize: vi.fn(),
}));

vi.mock('../../internal/utils/openPopup', () => ({
vi.mock('../../ui/react/internal/utils/openPopup', () => ({
openPopup: vi.fn(),
}));

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/components/WalletDropdownFundLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useCallback, useMemo } from 'react';
import { useIcon } from '../../core-react/internal/hooks/useIcon';
import { useGetFundingUrl } from '../../fund/hooks/useGetFundingUrl';
import { getFundingPopupSize } from '../../fund/utils/getFundingPopupSize';
import { openPopup } from '../../internal/utils/openPopup';
import { cn, color, pressable, text as themeText } from '../../styles/theme';
import { openPopup } from '../../ui/react/internal/utils/openPopup';
import type { WalletDropdownFundLinkReact } from '../types';

export function WalletDropdownFundLink({
Expand Down

0 comments on commit 1dd7a84

Please sign in to comment.