Skip to content

Commit 385d29c

Browse files
authored
Merge pull request #1329 from peanutprotocol/chore/pts_fixes
various fixes
2 parents 637e659 + f4e9618 commit 385d29c

280 files changed

Lines changed: 980 additions & 527 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

jest.setup.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ global.TextDecoder = TextDecoder
77

88
require('dotenv').config({ path: '.env.test' })
99

10+
// Setup minimal environment variables for tests
11+
process.env.NEXT_PUBLIC_ALCHEMY_API_KEY = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY || 'test-key'
12+
process.env.NEXT_PUBLIC_INFURA_API_KEY = process.env.NEXT_PUBLIC_INFURA_API_KEY || 'test-key'
13+
process.env.VAPID_PUBLIC_KEY = process.env.VAPID_PUBLIC_KEY || 'test-vapid-public'
14+
process.env.VAPID_PRIVATE_KEY = process.env.VAPID_PRIVATE_KEY || 'test-vapid-private'
15+
process.env.VAPID_SUBJECT = process.env.VAPID_SUBJECT || 'mailto:test@example.com'
16+
1017
// Add any global test setup here
1118
global.console = {
1219
...console,
@@ -21,3 +28,10 @@ global.console = {
2128
jest.mock('next/cache', () => ({
2229
unstable_cache: (fn: Function) => fn,
2330
}))
31+
32+
jest.mock('@/app/actions/tokens', () => ({
33+
fetchTokenPriceApi: jest.fn(() => Promise.resolve({ price: 100, symbol: 'TEST' })),
34+
getTokenBalances: jest.fn(() => Promise.resolve([])),
35+
getTokenPrice: jest.fn(() => Promise.resolve(100)),
36+
fetchERC20Data: jest.fn(() => Promise.resolve({ name: 'Test Token', symbol: 'TEST', decimals: 18 })),
37+
}))

next.config.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const os = require('os')
22
const withBundleAnalyzer = require('@next/bundle-analyzer')({
3-
enabled: process.env.ANALYZE === 'true',
3+
// Only enable in production builds when explicitly requested
4+
enabled: process.env.ANALYZE === 'true' && process.env.NODE_ENV !== 'development',
45
})
56

67
const redirectsConfig = require('./redirects.json')
@@ -36,6 +37,32 @@ let nextConfig = {
3637
},
3738
],
3839
},
40+
41+
// Turbopack configuration for faster dev builds
42+
turbopack: {
43+
resolveAlias: {
44+
// Optimize common aliases
45+
'@': './src',
46+
},
47+
},
48+
49+
// External packages that shouldn't be bundled (server-side only)
50+
serverExternalPackages: [],
51+
52+
// Disable source maps in production (already handled by Sentry)
53+
productionBrowserSourceMaps: false,
54+
55+
// Transpile packages for better compatibility
56+
transpilePackages: ['@squirrel-labs/peanut-sdk'],
57+
58+
// Experimental features for optimization
59+
experimental: {
60+
// Optimize package imports for tree-shaking
61+
optimizePackageImports: ['@chakra-ui/react', 'framer-motion', '@headlessui/react'],
62+
// Speed up webpack builds (fallback mode when not using --turbo)
63+
webpackBuildWorker: true,
64+
},
65+
3966
webpack: (config, { isServer, dev }) => {
4067
if (!dev || !process.env.NEXT_TURBO) {
4168
if (isServer) {

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,18 @@
137137
]
138138
},
139139
"transformIgnorePatterns": [
140-
"node_modules/(?!(@wagmi|wagmi|viem|@viem|@squirrel-labs)/)"
140+
"node_modules/(?!(@wagmi|wagmi|viem|@viem|@squirrel-labs|@reown|@walletconnect|@justaname\\.id|@zerodev|permissionless)/)"
141141
],
142142
"moduleNameMapper": {
143143
"\\.(svg|png|jpg|jpeg|gif)$": "jest-transform-stub",
144144
"^@/(.*)$": "<rootDir>/src/$1",
145145
"^wagmi/chains$": "<rootDir>/src/utils/__mocks__/wagmi.ts",
146146
"^@squirrel-labs/peanut-sdk$": "<rootDir>/src/utils/__mocks__/peanut-sdk.ts",
147-
"^next/cache$": "<rootDir>/src/utils/__mocks__/next-cache.ts"
147+
"^@reown/appkit/react$": "<rootDir>/src/utils/__mocks__/reown-appkit.ts",
148+
"^@justaname\\.id/react$": "<rootDir>/src/utils/__mocks__/justaname.ts",
149+
"^web-push$": "<rootDir>/src/utils/__mocks__/web-push.ts",
150+
"^next/cache$": "<rootDir>/src/utils/__mocks__/next-cache.ts",
151+
"^@zerodev/sdk(.*)$": "<rootDir>/src/utils/__mocks__/zerodev-sdk.ts"
148152
},
149153
"setupFilesAfterEnv": [
150154
"<rootDir>/jest.setup.ts"

src/app/(mobile-ui)/add-money/[country]/[regional-method]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22
import MantecaAddMoney from '@/components/AddMoney/components/MantecaAddMoney'
3-
import { CountryData, countryData } from '@/components/AddMoney/consts'
3+
import { type CountryData, countryData } from '@/components/AddMoney/consts'
44
import { MantecaSupportedExchanges } from '@/components/AddMoney/consts'
55
import { useParams } from 'next/navigation'
66

src/app/(mobile-ui)/add-money/[country]/bank/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useOnrampFlow } from '@/context/OnrampFlowContext'
99
import { useWallet } from '@/hooks/wallet/useWallet'
1010
import { formatAmount } from '@/utils'
1111
import { countryData } from '@/components/AddMoney/consts'
12-
import { BridgeKycStatus } from '@/utils/bridge-accounts.utils'
12+
import { type BridgeKycStatus } from '@/utils/bridge-accounts.utils'
1313
import { useWebSocket } from '@/hooks/useWebSocket'
1414
import { useAuth } from '@/context/authContext'
1515
import { useCreateOnramp } from '@/hooks/useCreateOnramp'

src/app/(mobile-ui)/add-money/crypto/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { CryptoSourceListCard } from '@/components/AddMoney/components/CryptoSou
44
import {
55
CRYPTO_EXCHANGES,
66
CRYPTO_WALLETS,
7-
CryptoSource,
8-
CryptoToken,
7+
type CryptoSource,
8+
type CryptoToken,
99
DEPOSIT_CRYPTO_TOKENS,
1010
} from '@/components/AddMoney/consts'
1111
import { CryptoDepositQR } from '@/components/AddMoney/views/CryptoDepositQR.view'
12-
import NetworkSelectionView, { SelectedNetwork } from '@/components/AddMoney/views/NetworkSelection.view'
12+
import NetworkSelectionView, { type SelectedNetwork } from '@/components/AddMoney/views/NetworkSelection.view'
1313
import TokenSelectionView from '@/components/AddMoney/views/TokenSelection.view'
1414
import NavHeader from '@/components/Global/NavHeader'
1515
import PeanutLoading from '@/components/Global/PeanutLoading'

src/app/(mobile-ui)/claim/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getLinkDetails } from '@/app/actions/claimLinks'
22
import { Claim } from '@/components'
33
import { BASE_URL } from '@/constants'
44
import { formatAmount, resolveAddressToUsername } from '@/utils'
5-
import { Metadata } from 'next'
5+
import { type Metadata } from 'next'
66
import getOrigin from '@/lib/hosting/get-origin'
77

88
export const dynamic = 'force-dynamic'

src/app/(mobile-ui)/dev/shake-test/page.tsx

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ export default function DevShakeTestPage() {
1515
const [holdTimer, setHoldTimer] = useState<NodeJS.Timeout | null>(null)
1616
const [progressInterval, setProgressInterval] = useState<NodeJS.Timeout | null>(null)
1717
const [showSuccess, setShowSuccess] = useState(false)
18+
const [holdStartTime, setHoldStartTime] = useState<number | null>(null)
1819

1920
const startHold = useCallback(() => {
2021
setHoldProgress(0)
2122
setIsShaking(true)
2223
setShowSuccess(false)
2324

2425
const startTime = Date.now()
26+
setHoldStartTime(startTime)
2527
let lastIntensity: 'weak' | 'medium' | 'strong' | 'intense' = 'weak'
2628

2729
// Update progress and shake intensity
@@ -94,25 +96,65 @@ export default function DevShakeTestPage() {
9496
}, [])
9597

9698
const cancelHold = useCallback(() => {
99+
const PREVIEW_DURATION_MS = 500
100+
101+
// Calculate how long the user held
102+
const elapsed = holdStartTime ? Date.now() - holdStartTime : 0
103+
104+
// Clear the completion timer (we'll never complete on release)
105+
if (holdTimer) clearTimeout(holdTimer)
106+
setHoldTimer(null)
107+
108+
// If it was a quick tap, let the preview animation continue for 500ms before resetting
109+
if (elapsed > 0 && elapsed < PREVIEW_DURATION_MS) {
110+
const remainingPreviewTime = PREVIEW_DURATION_MS - elapsed
111+
112+
// Let animations continue for the preview duration
113+
const resetTimer = setTimeout(() => {
114+
// Clean up after preview
115+
if (progressInterval) clearInterval(progressInterval)
116+
setProgressInterval(null)
117+
setHoldProgress(0)
118+
setIsShaking(false)
119+
setShakeIntensity('none')
120+
setHoldStartTime(null)
121+
122+
if ('vibrate' in navigator) {
123+
navigator.vibrate(0)
124+
}
125+
}, remainingPreviewTime)
126+
127+
setHoldTimer(resetTimer)
128+
} else {
129+
// Released after preview duration - reset immediately
130+
if (progressInterval) clearInterval(progressInterval)
131+
setProgressInterval(null)
132+
setHoldProgress(0)
133+
setIsShaking(false)
134+
setShakeIntensity('none')
135+
setHoldStartTime(null)
136+
137+
if ('vibrate' in navigator) {
138+
navigator.vibrate(0)
139+
}
140+
}
141+
}, [holdTimer, progressInterval, holdStartTime])
142+
143+
const reset = useCallback(() => {
97144
if (holdTimer) clearTimeout(holdTimer)
98145
if (progressInterval) clearInterval(progressInterval)
99146
setHoldTimer(null)
100147
setProgressInterval(null)
101148
setHoldProgress(0)
102149
setIsShaking(false)
103150
setShakeIntensity('none')
104-
105-
// Stop any ongoing vibration when user releases early
151+
setHoldStartTime(null)
152+
setShowSuccess(false)
106153
if ('vibrate' in navigator) {
107154
navigator.vibrate(0)
108155
}
109156
}, [holdTimer, progressInterval])
110157

111-
const reset = useCallback(() => {
112-
cancelHold()
113-
setShowSuccess(false)
114-
}, [cancelHold])
115-
116158
return (
117159
<div className={`flex min-h-[inherit] flex-col gap-8 ${getShakeClass(isShaking, shakeIntensity)}`}>
118160
<NavHeader title="🧪 Dev Shake Test" />
@@ -191,7 +233,7 @@ export default function DevShakeTestPage() {
191233
</Button>
192234

193235
<div className="text-center text-xs text-gray-500">
194-
Press and hold the button to test the progressive shake
236+
Hold the button for the full duration (quick taps show 500ms preview)
195237
</div>
196238
</div>
197239
) : (
@@ -216,7 +258,8 @@ export default function DevShakeTestPage() {
216258
<li>✓ Button fills with black as you hold</li>
217259
<li>✓ Shake starts weak and gets progressively stronger</li>
218260
<li>✓ Haptic feedback intensifies with shake (PWA only)</li>
219-
<li>✓ Shake stops when you release early</li>
261+
<li>✓ Quick tap shows preview but resets (must hold full duration)</li>
262+
<li>✓ Release early cancels the action</li>
220263
<li>✓ After full hold: shake stops, confetti appears, final haptic</li>
221264
<li>✓ Works on mobile touch and desktop mouse</li>
222265
</ul>

src/app/(mobile-ui)/history/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { CardPosition } from '@/components/Global/Card'
3+
import { type CardPosition } from '@/components/Global/Card'
44
import EmptyState from '@/components/Global/EmptyStates/EmptyState'
55
import NoDataEmptyState from '@/components/Global/EmptyStates/NoDataEmptyState'
66
import NavHeader from '@/components/Global/NavHeader'

src/app/(mobile-ui)/home/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { Button, ButtonSize, ButtonVariant } from '@/components/0_Bruddle'
3+
import { Button, type ButtonSize, type ButtonVariant } from '@/components/0_Bruddle'
44
import PageContainer from '@/components/0_Bruddle/PageContainer'
55
import { Icon } from '@/components/Global/Icons/Icon'
66
import IOSInstallPWAModal from '@/components/Global/IOSInstallPWAModal'

0 commit comments

Comments
 (0)