Skip to content

Commit

Permalink
refactor: add optional chaining to store state access for improved sa…
Browse files Browse the repository at this point in the history
…fety
  • Loading branch information
mohandast52 committed Dec 20, 2024
1 parent 311e20e commit 9a551e6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const LowOperatingBalanceAlert = () => {

if (!isBalanceLoaded) return null;
if (!masterThresholds) return null;
if (!storeState?.[selectedAgentType].isInitialFunded) return;
if (!storeState?.[selectedAgentType]?.isInitialFunded) return;
if (!isLowBalance) return null;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const BalanceStatus = () => {
useEffect(() => {
if (!isBalanceLoaded || !isServicesLoaded) return;
if (!showNotification) return;
if (!storeState?.[selectedAgentType].isInitialFunded) return;
if (!storeState?.[selectedAgentType]?.isInitialFunded) return;

if (isMasterSafeLowOnNativeGas && !isLowBalanceNotificationShown) {
showNotification('Operating balance is too low.');
Expand Down
2 changes: 1 addition & 1 deletion frontend/hooks/useNeedsFunds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useNeedsFunds = (stakingProgramId: Maybe<StakingProgramId>) => {
const { isLoaded: isBalanceLoaded } = useBalanceContext();
const { masterSafeBalances } = useMasterBalances();

const isInitialFunded = storeState?.[selectedAgentType].isInitialFunded;
const isInitialFunded = storeState?.[selectedAgentType]?.isInitialFunded;
const serviceFundRequirements = useMemo<{
[chainId: number]: {
[tokenSymbol: string]: number;
Expand Down

0 comments on commit 9a551e6

Please sign in to comment.