Skip to content

Commit

Permalink
refactor: simplify MainOlasBalance component and remove unused props
Browse files Browse the repository at this point in the history
  • Loading branch information
mohandast52 committed Dec 16, 2024
1 parent 34d0c74 commit 6a42a69
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 33 deletions.
28 changes: 2 additions & 26 deletions frontend/components/MainPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { Card, Flex } from 'antd';

import { StakingProgramId } from '@/enums/StakingProgram';
import { useFeatureFlag } from '@/hooks/useFeatureFlag';

// import { StakingProgramId } from '@/enums/StakingProgram';
// import { useMasterSafe } from '@/hooks/useMasterSafe';
import {
useStakingContractContext,
useStakingContractDetails,
} from '@/hooks/useStakingContractDetails';
import { useStakingProgram } from '@/hooks/useStakingProgram';

// import { useMasterWalletContext } from '@/hooks/useWallet';
import { MainHeader } from './header';
import { AddFundsSection } from './sections/AddFundsSection';
Expand All @@ -25,22 +19,12 @@ export const Main = () => {
const isStakingContractSectionEnabled = useFeatureFlag(
'staking-contract-section',
);
// const { backupSafeAddress } = useMasterWalletContext();
// const { refetch: updateServicesState } = useServices();
// const {
// updateBalances,
// isLoaded: isBalanceLoaded,
// setIsLoaded: setIsBalanceLoaded,
// } = useBalanceContext();
const { activeStakingProgramId } = useStakingProgram();

// TODO: reintroduce later, non critical
const { isAllStakingContractDetailsRecordLoaded } =
useStakingContractContext();

const { hasEnoughServiceSlots } = useStakingContractDetails(
activeStakingProgramId,
);

// TODO: reintroduce later, non critical
// useEffect(() => {
Expand All @@ -55,14 +39,6 @@ export const Main = () => {
// updateServicesState,
// ]);

// TODO: reintroduce later, non critical

const hideMainOlasBalanceTopBorder = [
// !backupSafeAddress, // TODO: update this condition to check backup safe relative to selectedService
activeStakingProgramId === StakingProgramId.PearlAlpha,
isAllStakingContractDetailsRecordLoaded && !hasEnoughServiceSlots,
].some((condition) => !!condition);

return (
<Card
styles={{ body: { paddingTop: 0, paddingBottom: 0 } }}
Expand All @@ -72,7 +48,7 @@ export const Main = () => {
<SwitchAgentSection />
<MainHeader />
<AlertSections />
<MainOlasBalance isBorderTopVisible={!hideMainOlasBalanceTopBorder} />
<MainOlasBalance />
<RewardsSection />
<KeepAgentRunningSection />
{isStakingContractSectionEnabled && <StakingContractSection />}
Expand Down
8 changes: 2 additions & 6 deletions frontend/components/MainPage/sections/OlasBalanceSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ const Balance = styled.span`
margin-right: 4px;
`;

type MainOlasBalanceProps = { isBorderTopVisible?: boolean };

export const MainOlasBalance = ({
isBorderTopVisible = true,
}: MainOlasBalanceProps) => {
export const MainOlasBalance = () => {
const { selectedService } = useServices();
const { isLoaded: isBalanceLoaded } = useBalanceContext();
const { masterWalletBalances } = useMasterBalances();
Expand Down Expand Up @@ -83,7 +79,7 @@ export const MainOlasBalance = ({
<CardSection
vertical
gap={8}
bordertop={isBorderTopVisible ? 'true' : 'false'}
bordertop="true"
borderbottom="true"
padding="16px 24px"
>
Expand Down
2 changes: 1 addition & 1 deletion frontend/service/agents/PredictTrader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export abstract class PredictTraderService extends StakedAgentService {
const { multicallProvider } = PROVIDERS[chainId];

const stakingTokenProxy =
STAKING_PROGRAMS[chainId]?.[stakingProgramId].contract;
STAKING_PROGRAMS[chainId]?.[stakingProgramId]?.contract;

if (!stakingTokenProxy) return;

Expand Down

0 comments on commit 6a42a69

Please sign in to comment.