From 746134a1429ac96a9a2ff398b743e0e375fb322e Mon Sep 17 00:00:00 2001 From: JCNoguera <88061365+VmMad@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:49:57 +0100 Subject: [PATCH] fix: wait for transaciton and refetch stakes --- .../app/(protected)/staking/page.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/wallet-dashboard/app/(protected)/staking/page.tsx b/apps/wallet-dashboard/app/(protected)/staking/page.tsx index 6e0c37a73c7..e33b1253b95 100644 --- a/apps/wallet-dashboard/app/(protected)/staking/page.tsx +++ b/apps/wallet-dashboard/app/(protected)/staking/page.tsx @@ -28,17 +28,18 @@ import { StakedCard, useFormatCoin, } from '@iota/core'; -import { useCurrentAccount, useIotaClientQuery } from '@iota/dapp-kit'; +import { useCurrentAccount, useIotaClient, useIotaClientQuery } from '@iota/dapp-kit'; import { IotaSystemStateSummary } from '@iota/iota-sdk/client'; import { Info } from '@iota/ui-icons'; import { useMemo } from 'react'; import { useStakeDialog } from '@/components/Dialogs/Staking/hooks/useStakeDialog'; import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; -function StakingDashboardPage(): JSX.Element { +function StakingDashboardPage(): React.JSX.Element { const account = useCurrentAccount(); const { data: system } = useIotaClientQuery('getLatestIotaSystemState'); const activeValidators = (system as IotaSystemStateSummary)?.activeValidators; + const iotaClient = useIotaClient(); const { isDialogStakeOpen, @@ -52,7 +53,7 @@ function StakingDashboardPage(): JSX.Element { handleNewStake, } = useStakeDialog(); - const { data: delegatedStakeData } = useGetDelegatedStake({ + const { data: delegatedStakeData, refetch: refetchDelegatedStakes } = useGetDelegatedStake({ address: account?.address || '', staleTime: DELEGATED_STAKES_QUERY_STALE_TIME, refetchInterval: DELEGATED_STAKES_QUERY_REFETCH_INTERVAL, @@ -91,6 +92,14 @@ function StakingDashboardPage(): JSX.Element { setSelectedStake(extendedStake); }; + function handleOnStakeSuccess(digest: string): void { + iotaClient + .waitForTransaction({ + digest, + }) + .then(() => refetchDelegatedStakes()); + } + return (
@@ -164,6 +173,7 @@ function StakingDashboardPage(): JSX.Element {