Skip to content

Commit

Permalink
fix: always update the destination chain to match the source one
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Oct 25, 2024
1 parent 34d8528 commit 4d428ea
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/widget/src/components/TokenList/useTokenSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 4d428ea

Please sign in to comment.