From 7c1f1c1dc142fb78035f3f8a0c933fe4babf702d Mon Sep 17 00:00:00 2001 From: mootz12 Date: Wed, 4 Dec 2024 11:33:10 -0500 Subject: [PATCH] fix: patch backstop emissions est sim and use better cache invalidation --- package-lock.json | 4 ++-- package.json | 2 +- src/contexts/wallet.tsx | 1 + src/hooks/api.ts | 13 ++++++++++++- src/pages/backstop.tsx | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1981c70..4fe4788 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "blend-ui", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "blend-ui", - "version": "1.3.0", + "version": "1.3.1", "dependencies": { "@blend-capital/blend-sdk": "2.2.0", "@creit.tech/stellar-wallets-kit": "1.2.3", diff --git a/package.json b/package.json index 4896c08..9911e9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blend-ui", - "version": "1.3.0", + "version": "1.3.1", "private": true, "type": "module", "scripts": { diff --git a/src/contexts/wallet.tsx b/src/contexts/wallet.tsx index 8f7d115..2be8f30 100644 --- a/src/contexts/wallet.tsx +++ b/src/contexts/wallet.tsx @@ -550,6 +550,7 @@ export const WalletProvider = ({ children = null as any }) => { } else { cleanBackstopPoolCache(claimArgs.pool_addresses[0].toString()); } + cleanBackstopCache(); cleanWalletCache(); } } diff --git a/src/hooks/api.ts b/src/hooks/api.ts index 3cd7ee8..fef3895 100644 --- a/src/hooks/api.ts +++ b/src/hooks/api.ts @@ -43,8 +43,19 @@ export function useQueryClientCacheCleaner(): { const cleanWalletCache = () => { queryClient.invalidateQueries({ - predicate: (query) => query.queryKey[0] === 'balance' || query.queryKey[0] === 'account', + predicate: (query) => + query.queryKey[0] === 'balance' || + query.queryKey[0] === 'account' || + query.queryKey[0] === 'sim', }); + + // Re-invalide the balance and account queries to ensure they are re-fetched after Horizon is updated + // This is a temporary solution until we have a better way to handle delayed Horizon updates + setTimeout(() => { + queryClient.invalidateQueries({ + predicate: (query) => query.queryKey[0] === 'balance' || query.queryKey[0] === 'account', + }); + }, 1000); }; const cleanBackstopCache = () => { diff --git a/src/pages/backstop.tsx b/src/pages/backstop.tsx index 7cc4df8..81f7ff4 100644 --- a/src/pages/backstop.tsx +++ b/src/pages/backstop.tsx @@ -101,7 +101,7 @@ const Backstop: NextPage = () => { depositTokenAddress: backstop.config.blndTkn, depositTokenAmount: FixedMath.toFixed(backstopUserEst.emissions, 7), minLPTokenAmount: BigInt(0), - user: walletAddress, + user: backstop.id, }) .toXDR('base64') : undefined;