From 538b3a347e15236a3c7435dfd92845f8e4322a86 Mon Sep 17 00:00:00 2001 From: Noah Prince <83885631+ChewingGlass@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:21:19 -0800 Subject: [PATCH] Bugfix/jup error (#836) * bump deps (#821) * bump deps 0.9.12 (#822) * Fix getPositionKeysForOwner args (#823) * 2.10.1 * update hooks to use prop conditional when fetching new output (#824) * Fix bug when claiming all with custom destination (#832) * Show jupiter error before tx error --------- Co-authored-by: Bryan --- package.json | 4 ++-- src/features/swaps/SwapScreen.tsx | 25 ++++++++++++++++++------- yarn.lock | 4 ++-- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 14848b8f..5089cd4e 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "@graphql-codegen/typescript": "^4.0.1", "@graphql-codegen/typescript-operations": "^4.0.1", "@graphql-codegen/typescript-rtk-query": "^3.1.1", - "@helium/account-fetch-cache": "0.9.7", - "@helium/account-fetch-cache-hooks": "0.9.7", + "@helium/account-fetch-cache": "0.9.14", + "@helium/account-fetch-cache-hooks": "0.9.14", "@helium/address": "4.10.2", "@helium/circuit-breaker-sdk": "^0.9.14", "@helium/crypto-react-native": "4.8.0", diff --git a/src/features/swaps/SwapScreen.tsx b/src/features/swaps/SwapScreen.tsx index a696a494..38c38de8 100644 --- a/src/features/swaps/SwapScreen.tsx +++ b/src/features/swaps/SwapScreen.tsx @@ -185,8 +185,8 @@ const SwapScreen = () => { return t('swapsScreen.insufficientTokensToSwap') if (hasInsufficientBalance) return t('generic.insufficientBalance') if (networkError) return networkError - if (transactionError) return transactionError if (jupiterError) return jupiterError + if (transactionError) return transactionError if (routeNotFound) return t('swapsScreen.routeNotFound') }, [ hasRecipientError, @@ -413,19 +413,30 @@ const SwapScreen = () => { ], ) + useEffect(() => { + setRecipient('') + setRecipientOpen(false) + setOutputAmount(0) + }, [ + inputMint, + inputAmount, + outputMint, + setRecipient, + setRecipientOpen, + setOutputAmount, + ]) + useEffect(() => { // if changing outputMint ensure we get new routes ;(async () => { if ( !isDevnet && - inputMintAcc && - outputMintAcc && + inputMintAcc?.address === inputMint && + outputMintAcc?.address === outputMint && typeof inputAmount !== 'undefined' && inputAmount > 0 && !outputMintAcc?.address.equals(DC_MINT) ) { - setRecipient('') - setRecipientOpen(false) await getOutputAmount({ balance: toBN(inputAmount || 0, inputMintAcc.decimals), }) @@ -433,12 +444,12 @@ const SwapScreen = () => { })() }, [ getOutputAmount, + inputMint, inputAmount, inputMintAcc, + outputMint, outputMintAcc, isDevnet, - setRecipient, - setRecipientOpen, ]) const getInputAmount = useCallback( diff --git a/yarn.lock b/yarn.lock index 4831d31e..0f0b60b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15097,8 +15097,8 @@ __metadata: "@graphql-codegen/typescript": ^4.0.1 "@graphql-codegen/typescript-operations": ^4.0.1 "@graphql-codegen/typescript-rtk-query": ^3.1.1 - "@helium/account-fetch-cache": 0.9.7 - "@helium/account-fetch-cache-hooks": 0.9.7 + "@helium/account-fetch-cache": 0.9.14 + "@helium/account-fetch-cache-hooks": 0.9.14 "@helium/address": 4.10.2 "@helium/circuit-breaker-sdk": ^0.9.14 "@helium/crypto-react-native": 4.8.0