Skip to content

fix: re-add error so SwapMessage renders #1153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2024
Merged
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
4 changes: 4 additions & 0 deletions src/swap/components/SwapProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useFromTo } from '../hooks/useFromTo';
import type {
LifeCycleStatus,
SwapContextType,
SwapError,
SwapProviderReact,
} from '../types';
import { isSwapError } from '../utils/isSwapError';
Expand Down Expand Up @@ -48,6 +49,7 @@ export function SwapProvider({
// Core Hooks
const config = useConfig();
const [loading, setLoading] = useState(false);
const [error, setError] = useState<SwapError>();
const [isTransactionPending, setPendingTransaction] = useState(false);
const [lifeCycleStatus, setLifeCycleStatus] = useState<LifeCycleStatus>({
statusName: 'init',
Expand All @@ -62,6 +64,7 @@ export function SwapProvider({
if (lifeCycleStatus.statusName === 'error') {
setLoading(false);
setPendingTransaction(false);
setError(lifeCycleStatus.statusData);
onError?.(lifeCycleStatus.statusData);
}
if (lifeCycleStatus.statusName === 'transactionPending') {
Expand Down Expand Up @@ -233,6 +236,7 @@ export function SwapProvider({
]);

const value = useValue({
error,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me think so much we need to refactor getErrorMessage. And this error story.

from,
loading,
handleAmountChange,
Expand Down