Skip to content

Commit

Permalink
edit to start agent logic
Browse files Browse the repository at this point in the history
  • Loading branch information
truemiller committed May 29, 2024
1 parent e454a3c commit 67d94f5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions frontend/components/Main/MainHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>(ServiceButtonLoadingState.NotLoading);

Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -258,12 +267,12 @@ export const MainHeader = () => {
handlePause,
handleStart,
isBalanceLoaded,
safeOlasBalanceWithStaked,
serviceButtonState,
serviceStatus,
services,
storeState?.isInitialFunded,
totalEthBalance,
totalOlasBalance,
]);

return (
Expand Down

0 comments on commit 67d94f5

Please sign in to comment.