From 67d94f525f165d637f48f3e3d311a46555837353 Mon Sep 17 00:00:00 2001 From: truemiller <31908788+truemiller@users.noreply.github.com> Date: Wed, 29 May 2024 17:39:01 +0100 Subject: [PATCH] edit to start agent logic --- frontend/components/Main/MainHeader.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/components/Main/MainHeader.tsx b/frontend/components/Main/MainHeader.tsx index bb12dd908..67b67f17d 100644 --- a/frontend/components/Main/MainHeader.tsx +++ b/frontend/components/Main/MainHeader.tsx @@ -33,12 +33,18 @@ export const MainHeader = () => { const { wallets, masterSafeAddress } = useWallet(); const { safeBalance, - totalOlasBalance, + totalOlasStakedBalance, totalEthBalance, isBalanceLoaded, setIsPaused: setIsBalancePollingPaused, } = useBalance(); + const safeOlasBalanceWithStaked = useMemo(() => { + if (safeBalance?.OLAS === undefined) return; + if (totalOlasStakedBalance === undefined) return; + return totalOlasStakedBalance + safeBalance.OLAS; + }, [safeBalance?.OLAS, totalOlasStakedBalance]); + const [serviceButtonState, setServiceButtonState] = useState(ServiceButtonLoadingState.NotLoading); @@ -226,7 +232,7 @@ export const MainHeader = () => { const isDeployable = (() => { // case where required values are undefined (not fetched from the server) if (totalEthBalance === undefined) return false; - if (totalOlasBalance === undefined) return false; + if (safeOlasBalanceWithStaked === undefined) return false; if (!services) return false; // deployment statuses where agent should not be deployed @@ -236,9 +242,12 @@ export const MainHeader = () => { // case where service exists & user has initial funded if (services[0] && storeState?.isInitialFunded) - return totalOlasBalance >= requiredOlas; // at present agent will always require staked/bonded OLAS + return safeOlasBalanceWithStaked >= requiredOlas; // at present agent will always require staked/bonded OLAS - return totalOlasBalance >= requiredOlas && totalEthBalance > requiredGas; + return ( + safeOlasBalanceWithStaked >= requiredOlas && + totalEthBalance > requiredGas + ); })(); if (!isDeployable) { @@ -258,12 +267,12 @@ export const MainHeader = () => { handlePause, handleStart, isBalanceLoaded, + safeOlasBalanceWithStaked, serviceButtonState, serviceStatus, services, storeState?.isInitialFunded, totalEthBalance, - totalOlasBalance, ]); return (