Skip to content
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

CU-86a5xqdaq-NEON3 - Swap Request - Show error toast when Pair is una… #267

Merged
merged 1 commit into from
Dec 18, 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
13 changes: 9 additions & 4 deletions src/renderer/src/routes/pages/Swap/SwapPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { TransactionFeeActionStep } from '@renderer/components/TransactionFeeAct
import { SWAP_NETWORK_BY_BLOCKCHAIN_AND_NETWORK_ID } from '@renderer/constants/swap'
import { AccountHelper } from '@renderer/helpers/AccountHelper'
import { NumberHelper } from '@renderer/helpers/NumberHelper'
import { ToastHelper } from '@renderer/helpers/ToastHelper'
import { UtilsHelper } from '@renderer/helpers/UtilsHelper'
import { useAccountsSelector } from '@renderer/hooks/useAccountSelector'
import { useActions } from '@renderer/hooks/useActions'
Expand Down Expand Up @@ -168,11 +169,19 @@ export const SwapPageContent = ({ account }: TProps) => {
setData({ selectAmountToUseMinMax: amountToUseMinMax })
})

swapService.eventEmitter.on('error', error => {
ToastHelper.error({ message: error, duration: 6000 })
})

swapServiceRef.current = swapService

swapService.init()
}

const removeSwapServiceListeners = () => {
swapServiceRef.current?.eventEmitter.removeAllListeners()
}

const handleSelectTokenToUse = (token: SwapServiceToken<TBlockchainServiceKey>) => {
swapServiceRef.current.setTokenToUse(token)
}
Expand Down Expand Up @@ -278,10 +287,6 @@ export const SwapPageContent = ({ account }: TProps) => {
}
}

const removeSwapServiceListeners = () => {
swapServiceRef.current?.eventEmitter.removeAllListeners()
}

useEffect(() => {
if (balanceQuery.isLoading) return

Expand Down