From 83c04827499238fe8b51c780d5b839c21a5c8e63 Mon Sep 17 00:00:00 2001 From: jipstavenuiter Date: Thu, 8 Jan 2026 18:22:37 +0100 Subject: [PATCH] feat: add account data revalidation after undelegation Enhances the Undelegate component by introducing a revalidation mechanism for account data using SWR. After a successful undelegation, the account data is refreshed after a 15-second delay to ensure the UI reflects the latest state. --- components/DelegatingWidget/Undelegate.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/DelegatingWidget/Undelegate.tsx b/components/DelegatingWidget/Undelegate.tsx index 59fce36e..de919450 100644 --- a/components/DelegatingWidget/Undelegate.tsx +++ b/components/DelegatingWidget/Undelegate.tsx @@ -12,6 +12,7 @@ import { useAccountAddress } from "hooks"; import { useBondingManagerAddress } from "hooks/useContracts"; import { useHandleTransaction } from "hooks/useHandleTransaction"; import { useState } from "react"; +import { useSWRConfig } from "swr"; import { parseEther } from "viem"; import { useSimulateContract, useWriteContract } from "wagmi"; @@ -60,11 +61,17 @@ const Undelegate = ({ wasDeactivated: willDeactivate, }); + const { mutate } = useSWRConfig(); const handleUndelegate = () => { if (willDeactivate) { setShowConfirmDialog(true); } else if (config) { writeContract(config.request); + if (accountAddress) { + setTimeout(() => { + mutate(`/api/ssr/account/${accountAddress.toLowerCase()}`); + }, 15000); + } } };