Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"qrcode.react": "^4.2.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-error-boundary": "^6.0.0",
"react-i18next": "^16.4.0",
"react-inspector": "^9.0.0",
"tailwind-merge": "^3.4.0",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions src/components/common/error-boundary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ErrorBoundary as BaseErrorBoundary, useErrorBoundary } from 'react-error-boundary'
import type { ReactNode } from 'react'
import { Button } from '@/components/ui/button'

interface ErrorFallbackProps {
error: Error
resetErrorBoundary: () => void
}

function ErrorFallback({ error, resetErrorBoundary }: ErrorFallbackProps) {
return (
<div className="flex min-h-[200px] flex-col items-center justify-center gap-4 p-4">
<div className="text-center">
<h3 className="text-lg font-semibold text-destructive">Something went wrong</h3>
<p className="text-muted-foreground mt-1 text-sm">
{error.message || 'An unexpected error occurred'}
</p>
</div>
<Button variant="outline" onClick={resetErrorBoundary}>
Try again
</Button>
</div>
)
}

interface ErrorBoundaryProps {
children: ReactNode
fallback?: ReactNode
onError?: (error: Error, info: React.ErrorInfo) => void
}

export function ErrorBoundary({ children, fallback, onError }: ErrorBoundaryProps) {
return (
<BaseErrorBoundary
FallbackComponent={fallback ? () => <>{fallback}</> : ErrorFallback}
onError={(error, info) => {
console.error('ErrorBoundary caught an error:', error, info)
onError?.(error, info)
}}
>
{children}
</BaseErrorBoundary>
)
}

export { useErrorBoundary }
1 change: 1 addition & 0 deletions src/components/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export { IconCircle } from './icon-circle'
export { FormField } from './form-field'
export { Alert } from './alert'
export { StepIndicator, ProgressSteps } from './step-indicator'
export { ErrorBoundary } from './error-boundary'
5 changes: 4 additions & 1 deletion src/stackflow/activities/SendActivity.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ActivityComponentType } from "@stackflow/react";
import { AppScreen } from "@stackflow/plugin-basic-ui";
import { ActivityParamsProvider } from "../hooks";
import { ErrorBoundary } from "@/components/common/error-boundary";
import { SendPage } from "@/pages/send";

type SendParams = {
Expand All @@ -13,7 +14,9 @@ export const SendActivity: ActivityComponentType<SendParams> = ({ params }) => {
return (
<AppScreen>
<ActivityParamsProvider params={params}>
<SendPage />
<ErrorBoundary>
<SendPage />
</ErrorBoundary>
</ActivityParamsProvider>
</AppScreen>
);
Expand Down
4 changes: 3 additions & 1 deletion src/stackflow/stackflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ export const { Stack, useFlow, useStepFlow, activities } = stackflow({
WalletAddSheetActivity,
SecurityWarningSheetActivity,
},
initialActivity: () => "MainTabsActivity",
// Note: Don't set initialActivity when using historySyncPlugin
// The plugin will determine the initial activity based on the URL
// and use fallbackActivity when no route matches
});

export type ActivityName = keyof typeof activities;
6 changes: 5 additions & 1 deletion src/stores/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,11 @@ export const walletActions = {
const adapter = registry.getAdapter(chain)

if (!adapter) {
console.warn(`[refreshBalance] No adapter for chain: ${chain}`)
// This is expected during initialization or for unsupported chains
// Only log in development to avoid console noise
if (import.meta.env.DEV) {
console.debug(`[refreshBalance] Skipping chain without adapter: ${chain}`)
}
return
}

Expand Down