From 4d428ea566763e77fdbde73c0bd78f6adea41e67 Mon Sep 17 00:00:00 2001 From: Eugene Chybisov Date: Fri, 25 Oct 2024 11:49:02 +0200 Subject: [PATCH] fix: always update the destination chain to match the source one --- .../src/components/TokenList/useTokenSelect.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/widget/src/components/TokenList/useTokenSelect.ts b/packages/widget/src/components/TokenList/useTokenSelect.ts index 7e9ece750..63318b0cc 100644 --- a/packages/widget/src/components/TokenList/useTokenSelect.ts +++ b/packages/widget/src/components/TokenList/useTokenSelect.ts @@ -48,18 +48,14 @@ export const useTokenSelect = (formType: FormType, onClick?: () => void) => { }) } - // Check if the selected source chain matches any chain on the destination chain selection view (chainOrder array). - // If a match exists and the destination token is not selected, update the destination chain to match the source. - if ( - formType === 'from' && - !selectedOppositeToken && - selectedChainId && - chainOrderStore.getState().chainOrder.to.includes(selectedChainId) - ) { + // If the destination token is not selected, update the destination chain to match the source one. + const { setChain } = chainOrderStore.getState() + if (formType === 'from' && !selectedOppositeToken && selectedChainId) { setFieldValue(FormKeyHelper.getChainKey('to'), selectedChainId, { isDirty: true, isTouched: true, }) + setChain(selectedChainId, 'to') } const eventToEmit =