Skip to content

Commit

Permalink
refactor: clean up unused code and improve useLogs hook structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mohandast52 committed Dec 19, 2024
1 parent f783aa9 commit d28fc6a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,32 +117,6 @@ const AlertNoSlots = () => (
/>
);

// TODO: uncomment when required
//
// const AlertUpdateToMigrate = () => (
// <CustomAlert
// type="warning"
// showIcon
// message={
// <Flex vertical gap={4}>
// <Text className="font-weight-600">App update required</Text>

// {/*
// TODO: Define version requirement in some JSON store?
// How do we access this date on a previous version?
// */}
// <Text>
// Update Pearl to the latest version to switch to the staking contract.
// </Text>
// {/* TODO: trigger update through IPC */}
// <a href="#" target="_blank">
// Update Pearl to the latest version {UNICODE_SYMBOLS.EXTERNAL_LINK}
// </a>
// </Flex>
// }
// />
// );

/**
* Displays alerts for specific non-migration reasons
*/
Expand Down
52 changes: 29 additions & 23 deletions frontend/hooks/useLogs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useMemo } from 'react';

import { EvmChainId } from '@/enums/Chain';
import { Eoa, WalletType } from '@/enums/Wallet';
import { Address } from '@/types/Address';
import { Service } from '@/types/Service';
import { Optional } from '@/types/Util';
import { asEvmChainId } from '@/utils/middlewareHelpers';

import { useBalanceContext } from './useBalanceContext';
import { useMultisigs } from './useMultisig';
Expand All @@ -13,6 +13,7 @@ import { useStore } from './useStore';
import { useMasterWalletContext } from './useWallet';

const useAddressesLogs = () => {
const { selectedService } = useServices();
const {
masterSafes,
masterEoa,
Expand Down Expand Up @@ -43,15 +44,16 @@ const useAddressesLogs = () => {
return result;
}, [masterSafesOwners, masterEoa]);

const masterSafe = masterSafes?.filter(
({ evmChainId }) =>
evmChainId === asEvmChainId(selectedService?.home_chain),
);

return {
isLoaded: masterWalletsIsFetched && masterSafesOwnersIsFetched,
data: [
{ masterEoa: masterEoa ?? 'undefined' },
{
masterSafes:
masterSafes?.find((safe) => safe.evmChainId === EvmChainId.Gnosis) ??
'undefined',
},
{ masterSafe: masterSafe ?? 'undefined' },
{ masterSafeBackups: backupEoas ?? 'undefined' },
],
};
Expand Down Expand Up @@ -81,21 +83,23 @@ const useBalancesLogs = () => {

const useServicesLogs = () => {
const { services, isFetched: isLoaded, selectedService } = useServices();
// const { getQueryData } = useQueryClient();

const formattedServices = useMemo(() => {
return (
services?.map((item: Service) => ({
...item,
keys: item.keys.map((key) => key.address),
deploymentStatus:
selectedService?.service_config_id === item.service_config_id
? selectedService.deploymentStatus
: item.deploymentStatus,
})) ?? 'undefined'
);
}, [services, selectedService]);

return {
isLoaded,
data: {
services:
services?.map((item: Service) => ({
...item,
keys: item.keys.map((key) => key.address),
deploymentStatus:
selectedService?.service_config_id === item.service_config_id
? selectedService.deploymentStatus
: item.deploymentStatus,
})) ?? 'undefined',
},
data: { services: formattedServices },
};
};

Expand All @@ -110,11 +114,7 @@ export const useLogs = () => {
if (isServicesLoaded && isBalancesLoaded && isAddressesLoaded) {
return {
store: storeState,
debugData: {
services,
addresses,
balances,
},
debugData: { services, addresses, balances },
};
}
}, [
Expand All @@ -129,3 +129,9 @@ export const useLogs = () => {

return logs;
};

/**
* - type of agent,
* - when was it last staked,
* - how long until it can be unstaked (we already have this),
*/

0 comments on commit d28fc6a

Please sign in to comment.