From 1dfa0c78581e028e478766f05483cd56a570220f Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 12:11:46 +0100 Subject: [PATCH 01/17] feat: add updateStakingContractInfo function to StakingContractInfoContext --- .../context/StakingContractInfoProvider.tsx | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/frontend/context/StakingContractInfoProvider.tsx b/frontend/context/StakingContractInfoProvider.tsx index c53300e0c..9509c560d 100644 --- a/frontend/context/StakingContractInfoProvider.tsx +++ b/frontend/context/StakingContractInfoProvider.tsx @@ -1,8 +1,10 @@ -import { createContext, PropsWithChildren, useEffect, useState } from 'react'; +import { createContext, PropsWithChildren, useCallback, useState } from 'react'; +import { useInterval } from 'usehooks-ts'; import { AutonolasService } from '@/service/Autonolas'; type StakingContractInfoContextProps = { + updateStakingContractInfo: () => Promise; isStakingContractInfoLoading: boolean; isRewardsAvailable: boolean; hasEnoughServiceSlots: boolean; @@ -12,6 +14,7 @@ type StakingContractInfoContextProps = { export const StakingContractInfoContext = createContext({ + updateStakingContractInfo: async () => {}, isStakingContractInfoLoading: true, isRewardsAvailable: false, hasEnoughServiceSlots: false, @@ -29,34 +32,34 @@ export const StakingContractInfoProvider = ({ const [isAgentEvicted, setIsAgentEvicted] = useState(false); const [canStartAgent, setCanStartAgent] = useState(false); - useEffect(() => { - (async () => { - try { - setIsStakingContractInfoLoading(true); + const updateStakingContractInfo = useCallback(async () => { + setIsStakingContractInfoLoading(true); + try { + const info = await AutonolasService.getStakingContractInfo(); + if (!info) return; - const info = await AutonolasService.getStakingContractInfo(); - if (!info) return; + const { availableRewards, maxNumServices, serviceIds } = info; + const isRewardsAvailable = availableRewards > 0; + const hasEnoughServiceSlots = serviceIds.length < maxNumServices; + const canStartAgent = isRewardsAvailable && hasEnoughServiceSlots; - const { availableRewards, maxNumServices, serviceIds } = info; - const isRewardsAvailable = availableRewards > 0; - const hasEnoughServiceSlots = serviceIds.length < maxNumServices; - const canStartAgent = isRewardsAvailable && hasEnoughServiceSlots; - - setIsRewardsAvailable(isRewardsAvailable); - setHasEnoughServiceSlots(hasEnoughServiceSlots); - setCanStartAgent(canStartAgent); - setIsAgentEvicted(false); // TODO: Implement this - } catch (error) { - console.error('Failed to fetch staking contract info', error); - } finally { - setIsStakingContractInfoLoading(false); - } - })(); + setIsRewardsAvailable(isRewardsAvailable); + setHasEnoughServiceSlots(hasEnoughServiceSlots); + setCanStartAgent(canStartAgent); + setIsAgentEvicted(false); // TODO: Implement this + } catch (error) { + console.error('Failed to fetch staking contract info', error); + } finally { + setIsStakingContractInfoLoading(false); + } }, []); + useInterval(updateStakingContractInfo, 5000); + return ( Date: Tue, 9 Jul 2024 15:17:22 +0100 Subject: [PATCH 02/17] chore: remove barrel files --- frontend/constants/index.ts | 7 ------- frontend/context/index.ts | 9 --------- frontend/enums/index.ts | 5 ----- frontend/hooks/index.ts | 6 ------ frontend/types/index.ts | 4 ---- 5 files changed, 31 deletions(-) delete mode 100644 frontend/constants/index.ts delete mode 100644 frontend/context/index.ts delete mode 100644 frontend/enums/index.ts delete mode 100644 frontend/hooks/index.ts delete mode 100644 frontend/types/index.ts diff --git a/frontend/constants/index.ts b/frontend/constants/index.ts deleted file mode 100644 index 92214652f..000000000 --- a/frontend/constants/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './chains'; -export * from './color'; -export * from './contractAddresses'; -export * from './serviceTemplates'; -export * from './thresholds'; -export * from './tokens'; -export * from './urls'; diff --git a/frontend/context/index.ts b/frontend/context/index.ts deleted file mode 100644 index c403c5aa0..000000000 --- a/frontend/context/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './BalanceProvider'; -export * from './ElectronApiProvider'; -export * from './MasterSafeProvider'; -export * from './PageStateProvider'; -export * from './ServicesProvider'; -export * from './SettingsProvider'; -export * from './SetupProvider'; -export * from './StoreProvider'; -export * from './WalletProvider'; diff --git a/frontend/enums/index.ts b/frontend/enums/index.ts deleted file mode 100644 index fe122149a..000000000 --- a/frontend/enums/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './PageState'; -export * from './ServiceRegistryL2ServiceState'; -export * from './SettingsScreen'; -export * from './SetupScreen'; -export * from './Token'; diff --git a/frontend/hooks/index.ts b/frontend/hooks/index.ts deleted file mode 100644 index 3f43ba7ba..000000000 --- a/frontend/hooks/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './useBalance'; -export * from './useLogs'; -export * from './usePageState'; -export * from './useServices'; -export * from './useServiceTemplates'; -export * from './useSetup'; diff --git a/frontend/types/index.ts b/frontend/types/index.ts deleted file mode 100644 index fa03db645..000000000 --- a/frontend/types/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type * from './Address'; -export type * from './Autonolas'; -export type * from './ElectronApi'; -export type * from './Records'; From 5521d141f82e8452853b053bd4394b3ae265c48f Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:17:49 +0100 Subject: [PATCH 03/17] chore: rename abi folder to plural, remove barrel --- frontend/abi/index.ts | 8 -------- frontend/{abi => abis}/agentMech.ts | 0 frontend/{abi => abis}/erc20.ts | 0 frontend/{abi => abis}/gnosisSafe.ts | 0 frontend/{abi => abis}/mechActivityChecker.ts | 0 frontend/{abi => abis}/multicall3.ts | 0 frontend/{abi => abis}/serviceRegistryL2.ts | 0 frontend/{abi => abis}/serviceRegistryTokenUtility.ts | 0 frontend/{abi => abis}/serviceStakingTokenMechUsage.ts | 0 9 files changed, 8 deletions(-) delete mode 100644 frontend/abi/index.ts rename frontend/{abi => abis}/agentMech.ts (100%) rename frontend/{abi => abis}/erc20.ts (100%) rename frontend/{abi => abis}/gnosisSafe.ts (100%) rename frontend/{abi => abis}/mechActivityChecker.ts (100%) rename frontend/{abi => abis}/multicall3.ts (100%) rename frontend/{abi => abis}/serviceRegistryL2.ts (100%) rename frontend/{abi => abis}/serviceRegistryTokenUtility.ts (100%) rename frontend/{abi => abis}/serviceStakingTokenMechUsage.ts (100%) diff --git a/frontend/abi/index.ts b/frontend/abi/index.ts deleted file mode 100644 index 83339be50..000000000 --- a/frontend/abi/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './agentMech'; -export * from './erc20'; -export * from './gnosisSafe'; -export * from './mechActivityChecker'; -export * from './multicall3'; -export * from './serviceRegistryL2'; -export * from './serviceRegistryTokenUtility'; -export * from './serviceStakingTokenMechUsage'; diff --git a/frontend/abi/agentMech.ts b/frontend/abis/agentMech.ts similarity index 100% rename from frontend/abi/agentMech.ts rename to frontend/abis/agentMech.ts diff --git a/frontend/abi/erc20.ts b/frontend/abis/erc20.ts similarity index 100% rename from frontend/abi/erc20.ts rename to frontend/abis/erc20.ts diff --git a/frontend/abi/gnosisSafe.ts b/frontend/abis/gnosisSafe.ts similarity index 100% rename from frontend/abi/gnosisSafe.ts rename to frontend/abis/gnosisSafe.ts diff --git a/frontend/abi/mechActivityChecker.ts b/frontend/abis/mechActivityChecker.ts similarity index 100% rename from frontend/abi/mechActivityChecker.ts rename to frontend/abis/mechActivityChecker.ts diff --git a/frontend/abi/multicall3.ts b/frontend/abis/multicall3.ts similarity index 100% rename from frontend/abi/multicall3.ts rename to frontend/abis/multicall3.ts diff --git a/frontend/abi/serviceRegistryL2.ts b/frontend/abis/serviceRegistryL2.ts similarity index 100% rename from frontend/abi/serviceRegistryL2.ts rename to frontend/abis/serviceRegistryL2.ts diff --git a/frontend/abi/serviceRegistryTokenUtility.ts b/frontend/abis/serviceRegistryTokenUtility.ts similarity index 100% rename from frontend/abi/serviceRegistryTokenUtility.ts rename to frontend/abis/serviceRegistryTokenUtility.ts diff --git a/frontend/abi/serviceStakingTokenMechUsage.ts b/frontend/abis/serviceStakingTokenMechUsage.ts similarity index 100% rename from frontend/abi/serviceStakingTokenMechUsage.ts rename to frontend/abis/serviceStakingTokenMechUsage.ts From adc4f175433bede8b07097bc4611a8b4b618e504 Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:18:23 +0100 Subject: [PATCH 04/17] chore: rename common-util to utils, utils are common. --- frontend/common-util/index.ts | 4 ---- frontend/{common-util => utils}/copyToClipboard.ts | 0 frontend/{common-util => utils}/isDev.ts | 0 frontend/{common-util => utils}/numberFormatters.ts | 0 frontend/{common-util => utils}/truncate.ts | 2 +- 5 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 frontend/common-util/index.ts rename frontend/{common-util => utils}/copyToClipboard.ts (100%) rename frontend/{common-util => utils}/isDev.ts (100%) rename frontend/{common-util => utils}/numberFormatters.ts (100%) rename frontend/{common-util => utils}/truncate.ts (77%) diff --git a/frontend/common-util/index.ts b/frontend/common-util/index.ts deleted file mode 100644 index de4d77e78..000000000 --- a/frontend/common-util/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './copyToClipboard'; -export * from './isDev'; -export * from './numberFormatters'; -export * from './truncate'; diff --git a/frontend/common-util/copyToClipboard.ts b/frontend/utils/copyToClipboard.ts similarity index 100% rename from frontend/common-util/copyToClipboard.ts rename to frontend/utils/copyToClipboard.ts diff --git a/frontend/common-util/isDev.ts b/frontend/utils/isDev.ts similarity index 100% rename from frontend/common-util/isDev.ts rename to frontend/utils/isDev.ts diff --git a/frontend/common-util/numberFormatters.ts b/frontend/utils/numberFormatters.ts similarity index 100% rename from frontend/common-util/numberFormatters.ts rename to frontend/utils/numberFormatters.ts diff --git a/frontend/common-util/truncate.ts b/frontend/utils/truncate.ts similarity index 77% rename from frontend/common-util/truncate.ts rename to frontend/utils/truncate.ts index 6f10ecc6d..ff8781d30 100644 --- a/frontend/common-util/truncate.ts +++ b/frontend/utils/truncate.ts @@ -1,4 +1,4 @@ -import { Address } from '@/types'; +import { Address } from '@/types/Address'; export const truncateAddress = (address: Address) => `${address?.substring(0, 6)}...${address?.substring(address.length - 4, address.length)}`; From 6888c8c6e8e1b2f0dc024a7784705fd55f97d777 Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:23:42 +0100 Subject: [PATCH 05/17] chore: remove common folder, components are generally common --- frontend/components/common/Alert.tsx | 28 ------------ frontend/components/common/CardTitle.tsx | 10 ----- .../components/common/ConfettiAnimation.jsx | 43 ------------------- 3 files changed, 81 deletions(-) delete mode 100644 frontend/components/common/Alert.tsx delete mode 100644 frontend/components/common/CardTitle.tsx delete mode 100644 frontend/components/common/ConfettiAnimation.jsx diff --git a/frontend/components/common/Alert.tsx b/frontend/components/common/Alert.tsx deleted file mode 100644 index 3cadd98b7..000000000 --- a/frontend/components/common/Alert.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { - ExclamationCircleOutlined, - InfoCircleOutlined, - WarningOutlined, -} from '@ant-design/icons'; -import { Alert as AlertAntd, AlertProps } from 'antd'; - -type AlertType = 'primary' | 'info' | 'warning' | 'error'; - -const icons = { - primary: , - info: , - warning: , - error: , -}; - -export const Alert = ({ - type, - fullWidth, - ...rest -}: { type: AlertType; fullWidth?: boolean } & Omit) => ( - -); diff --git a/frontend/components/common/CardTitle.tsx b/frontend/components/common/CardTitle.tsx deleted file mode 100644 index 41b35c231..000000000 --- a/frontend/components/common/CardTitle.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Flex, Typography } from 'antd'; -import { ReactNode } from 'react'; - -export const CardTitle = ({ title }: { title: string | ReactNode }) => ( - - - {title} - - -); diff --git a/frontend/components/common/ConfettiAnimation.jsx b/frontend/components/common/ConfettiAnimation.jsx deleted file mode 100644 index 9e02463ff..000000000 --- a/frontend/components/common/ConfettiAnimation.jsx +++ /dev/null @@ -1,43 +0,0 @@ -import { useCallback, useRef } from 'react'; -import ReactCanvasConfetti from 'react-canvas-confetti'; -import { useInterval } from 'usehooks-ts'; - -const canvasStyles = { - position: 'fixed', - pointerEvents: 'none', - width: '100%', - height: '100%', - top: 0, - left: 0, -}; - -export const ConfettiAnimation = () => { - const animationInstance = useRef(null); - - const makeShot = useCallback((particleRatio, opts) => { - if (!animationInstance.current) return; - - animationInstance.current({ - ...opts, - origin: { y: 0.45 }, - particleCount: Math.floor(200 * particleRatio), - }); - }, []); - - const fire = useCallback(() => { - makeShot(0.25, { spread: 26, startVelocity: 55 }); - makeShot(0.2, { spread: 60 }); - makeShot(0.35, { spread: 80, decay: 0.91, scalar: 0.8 }); - makeShot(0.1, { spread: 100, startVelocity: 25, decay: 0.92, scalar: 1.2 }); - makeShot(0.1, { spread: 100, startVelocity: 45 }); - }, [makeShot]); - - const getInstance = useCallback((instance) => { - animationInstance.current = instance; - }, []); - - // Fire confetti every 2.5 seconds - useInterval(() => fire(), 2500); - - return ; -}; From 20c6ae2b4cee12396af234d4ac176dcfd089ec24 Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:24:06 +0100 Subject: [PATCH 06/17] chore: rename constants to plural, fix types --- frontend/constants/{color.ts => colors.ts} | 0 frontend/constants/contractAddresses.ts | 2 +- frontend/constants/intervals.ts | 3 +-- frontend/constants/{unicode.ts => symbols.ts} | 0 frontend/constants/tokens.ts | 2 +- 5 files changed, 3 insertions(+), 4 deletions(-) rename frontend/constants/{color.ts => colors.ts} (100%) rename frontend/constants/{unicode.ts => symbols.ts} (100%) diff --git a/frontend/constants/color.ts b/frontend/constants/colors.ts similarity index 100% rename from frontend/constants/color.ts rename to frontend/constants/colors.ts diff --git a/frontend/constants/contractAddresses.ts b/frontend/constants/contractAddresses.ts index eaad19e04..823e9710b 100644 --- a/frontend/constants/contractAddresses.ts +++ b/frontend/constants/contractAddresses.ts @@ -1,5 +1,5 @@ import { Chain } from '@/client'; -import { Address } from '@/types'; +import { Address } from '@/types/Address'; export const MULTICALL_CONTRACT_ADDRESS: Address = '0xcA11bde05977b3631167028862bE2a173976CA11'; // https://github.com/mds1/multicall, https://www.multicall3.com/ diff --git a/frontend/constants/intervals.ts b/frontend/constants/intervals.ts index 8110e8dd3..50afd39d0 100644 --- a/frontend/constants/intervals.ts +++ b/frontend/constants/intervals.ts @@ -1,2 +1 @@ -export const SERVICE_CARD_STATUS_POLLING_INTERVAL = 5000; -export const SERVICE_CARD_RPC_POLLING_INTERVAL = 5000; +export const FIVE_SECONDS_INTERVAL = 5000; diff --git a/frontend/constants/unicode.ts b/frontend/constants/symbols.ts similarity index 100% rename from frontend/constants/unicode.ts rename to frontend/constants/symbols.ts diff --git a/frontend/constants/tokens.ts b/frontend/constants/tokens.ts index d5151e3ed..89940ab80 100644 --- a/frontend/constants/tokens.ts +++ b/frontend/constants/tokens.ts @@ -1,4 +1,4 @@ -import { Address } from '@/types'; +import { Address } from '@/types/Address'; export const TOKENS: { [chain: string]: { [token: string]: Address } } = { gnosis: { From 98f6fe9a71f0e81fc2dedf7f254a55df736a8b72 Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:24:21 +0100 Subject: [PATCH 07/17] chore: update client Address type --- frontend/client/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/client/types.ts b/frontend/client/types.ts index f4e6937bd..6b533f974 100644 --- a/frontend/client/types.ts +++ b/frontend/client/types.ts @@ -1,4 +1,4 @@ -import { Address } from '@/types'; +import { Address } from '@/types/Address'; import { Chain, DeploymentStatus, Ledger } from './enums'; From cd09d670744e7ac74e6c445bfd5d865983d9a206 Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:24:50 +0100 Subject: [PATCH 08/17] chore: remove barrels. update main export names --- frontend/components/Alert/index.tsx | 28 ++++++++++++ frontend/components/Card/CardTitle.tsx | 10 +++++ .../components/Confetti/ConfettiAnimation.jsx | 43 +++++++++++++++++++ .../{HelpAndSupport.tsx => index.tsx} | 11 ++--- frontend/components/Layout/TopBar.tsx | 2 +- frontend/components/Layout/index.ts | 1 - .../Layout/{Layout.tsx => index.tsx} | 2 +- frontend/components/Main/KeepAgentRunning.tsx | 4 +- frontend/components/Main/MainAddFunds.tsx | 11 ++--- frontend/components/Main/MainGasBalance.tsx | 5 ++- .../Main/MainHeader/CannotStartAgent.tsx | 5 ++- .../components/Main/MainHeader/constants.tsx | 2 +- .../MainHeader/{MainHeader.tsx => index.tsx} | 16 +++---- frontend/components/Main/MainNeedsFunds.tsx | 8 ++-- frontend/components/Main/MainOlasBalance.tsx | 8 ++-- frontend/components/Main/MainRewards.tsx | 6 +-- .../components/Main/{Main.tsx => index.tsx} | 8 ++-- .../components/Settings/DebugInfoCard.tsx | 15 ++++--- .../Settings/SettingsAddBackupWallet.tsx | 8 ++-- .../Settings/{Settings.tsx => index.tsx} | 13 +++--- .../Setup/Create/SetupBackupSigner.tsx | 6 +-- .../Setup/Create/SetupCreateHeader.tsx | 4 +- .../Setup/Create/SetupCreateSafe.tsx | 9 ++-- .../Setup/Create/SetupEoaFunding.tsx | 17 ++++---- .../components/Setup/Create/SetupPassword.tsx | 4 +- .../Setup/Create/SetupSeedPhrase.tsx | 8 ++-- frontend/components/Setup/SetupRestore.tsx | 4 +- frontend/components/Setup/SetupWelcome.tsx | 31 +++++++++---- .../components/Setup/{Setup.tsx => index.tsx} | 4 +- frontend/components/index.ts | 3 -- frontend/components/styled/CardSection.tsx | 2 +- 31 files changed, 199 insertions(+), 99 deletions(-) create mode 100644 frontend/components/Alert/index.tsx create mode 100644 frontend/components/Card/CardTitle.tsx create mode 100644 frontend/components/Confetti/ConfettiAnimation.jsx rename frontend/components/HelpAndSupport/{HelpAndSupport.tsx => index.tsx} (91%) delete mode 100644 frontend/components/Layout/index.ts rename frontend/components/Layout/{Layout.tsx => index.tsx} (96%) rename frontend/components/Main/MainHeader/{MainHeader.tsx => index.tsx} (95%) rename frontend/components/Main/{Main.tsx => index.tsx} (86%) rename frontend/components/Settings/{Settings.tsx => index.tsx} (90%) rename frontend/components/Setup/{Setup.tsx => index.tsx} (94%) delete mode 100644 frontend/components/index.ts diff --git a/frontend/components/Alert/index.tsx b/frontend/components/Alert/index.tsx new file mode 100644 index 000000000..3cadd98b7 --- /dev/null +++ b/frontend/components/Alert/index.tsx @@ -0,0 +1,28 @@ +import { + ExclamationCircleOutlined, + InfoCircleOutlined, + WarningOutlined, +} from '@ant-design/icons'; +import { Alert as AlertAntd, AlertProps } from 'antd'; + +type AlertType = 'primary' | 'info' | 'warning' | 'error'; + +const icons = { + primary: , + info: , + warning: , + error: , +}; + +export const Alert = ({ + type, + fullWidth, + ...rest +}: { type: AlertType; fullWidth?: boolean } & Omit) => ( + +); diff --git a/frontend/components/Card/CardTitle.tsx b/frontend/components/Card/CardTitle.tsx new file mode 100644 index 000000000..41b35c231 --- /dev/null +++ b/frontend/components/Card/CardTitle.tsx @@ -0,0 +1,10 @@ +import { Flex, Typography } from 'antd'; +import { ReactNode } from 'react'; + +export const CardTitle = ({ title }: { title: string | ReactNode }) => ( + + + {title} + + +); diff --git a/frontend/components/Confetti/ConfettiAnimation.jsx b/frontend/components/Confetti/ConfettiAnimation.jsx new file mode 100644 index 000000000..9e02463ff --- /dev/null +++ b/frontend/components/Confetti/ConfettiAnimation.jsx @@ -0,0 +1,43 @@ +import { useCallback, useRef } from 'react'; +import ReactCanvasConfetti from 'react-canvas-confetti'; +import { useInterval } from 'usehooks-ts'; + +const canvasStyles = { + position: 'fixed', + pointerEvents: 'none', + width: '100%', + height: '100%', + top: 0, + left: 0, +}; + +export const ConfettiAnimation = () => { + const animationInstance = useRef(null); + + const makeShot = useCallback((particleRatio, opts) => { + if (!animationInstance.current) return; + + animationInstance.current({ + ...opts, + origin: { y: 0.45 }, + particleCount: Math.floor(200 * particleRatio), + }); + }, []); + + const fire = useCallback(() => { + makeShot(0.25, { spread: 26, startVelocity: 55 }); + makeShot(0.2, { spread: 60 }); + makeShot(0.35, { spread: 80, decay: 0.91, scalar: 0.8 }); + makeShot(0.1, { spread: 100, startVelocity: 25, decay: 0.92, scalar: 1.2 }); + makeShot(0.1, { spread: 100, startVelocity: 45 }); + }, [makeShot]); + + const getInstance = useCallback((instance) => { + animationInstance.current = instance; + }, []); + + // Fire confetti every 2.5 seconds + useInterval(() => fire(), 2500); + + return ; +}; diff --git a/frontend/components/HelpAndSupport/HelpAndSupport.tsx b/frontend/components/HelpAndSupport/index.tsx similarity index 91% rename from frontend/components/HelpAndSupport/HelpAndSupport.tsx rename to frontend/components/HelpAndSupport/index.tsx index 431d1994e..278246e9e 100644 --- a/frontend/components/HelpAndSupport/HelpAndSupport.tsx +++ b/frontend/components/HelpAndSupport/index.tsx @@ -2,13 +2,14 @@ import { CloseOutlined, QuestionCircleOutlined } from '@ant-design/icons'; import { Button, Card, Flex, message, Typography } from 'antd'; import { useCallback, useEffect, useState } from 'react'; -import { FAQ_URL, SUPPORT_URL } from '@/constants'; -import { UNICODE_SYMBOLS } from '@/constants/unicode'; -import { PageState } from '@/enums'; -import { useLogs, usePageState } from '@/hooks'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { FAQ_URL, SUPPORT_URL } from '@/constants/urls'; +import { PageState } from '@/enums/PageState'; import { useElectronApi } from '@/hooks/useElectronApi'; +import { useLogs } from '@/hooks/useLogs'; +import { usePageState } from '@/hooks/usePageState'; -import { CardTitle } from '../common/CardTitle'; +import { CardTitle } from '../Card/CardTitle'; import { CardSection } from '../styled/CardSection'; const { Title, Paragraph } = Typography; diff --git a/frontend/components/Layout/TopBar.tsx b/frontend/components/Layout/TopBar.tsx index c36f3054f..ddaf17016 100644 --- a/frontend/components/Layout/TopBar.tsx +++ b/frontend/components/Layout/TopBar.tsx @@ -1,7 +1,7 @@ import { Typography } from 'antd'; import styled from 'styled-components'; -import { COLOR } from '@/constants'; +import { COLOR } from '@/constants/colors'; import { useElectronApi } from '@/hooks/useElectronApi'; import { useStore } from '@/hooks/useStore'; diff --git a/frontend/components/Layout/index.ts b/frontend/components/Layout/index.ts deleted file mode 100644 index 9fc685e2a..000000000 --- a/frontend/components/Layout/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Layout } from './Layout'; diff --git a/frontend/components/Layout/Layout.tsx b/frontend/components/Layout/index.tsx similarity index 96% rename from frontend/components/Layout/Layout.tsx rename to frontend/components/Layout/index.tsx index 62f88eea4..42d6f1fdf 100644 --- a/frontend/components/Layout/Layout.tsx +++ b/frontend/components/Layout/index.tsx @@ -3,7 +3,7 @@ import { message } from 'antd'; import { PropsWithChildren, useContext, useEffect } from 'react'; import styled, { css } from 'styled-components'; -import { COLOR } from '@/constants'; +import { COLOR } from '@/constants/colors'; import { OnlineStatusContext } from '@/context/OnlineStatusProvider'; import { TopBar } from './TopBar'; diff --git a/frontend/components/Main/KeepAgentRunning.tsx b/frontend/components/Main/KeepAgentRunning.tsx index c44b4bb44..1cc98b333 100644 --- a/frontend/components/Main/KeepAgentRunning.tsx +++ b/frontend/components/Main/KeepAgentRunning.tsx @@ -1,10 +1,10 @@ import { Flex, Typography } from 'antd'; import { DeploymentStatus } from '@/client'; -import { useServices } from '@/hooks'; +import { useServices } from '@/hooks/useServices'; import { useStore } from '@/hooks/useStore'; -import { Alert } from '../common/Alert'; +import { Alert } from '../Alert'; import { CardSection } from '../styled/CardSection'; const { Text } = Typography; diff --git a/frontend/components/Main/MainAddFunds.tsx b/frontend/components/Main/MainAddFunds.tsx index e7c245724..06fd3d4dc 100644 --- a/frontend/components/Main/MainAddFunds.tsx +++ b/frontend/components/Main/MainAddFunds.tsx @@ -15,13 +15,14 @@ import Link from 'next/link'; import { useCallback, useMemo, useState } from 'react'; import styled from 'styled-components'; -import { copyToClipboard, truncateAddress } from '@/common-util'; -import { COW_SWAP_GNOSIS_XDAI_OLAS_URL } from '@/constants'; -import { UNICODE_SYMBOLS } from '@/constants/unicode'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { COW_SWAP_GNOSIS_XDAI_OLAS_URL } from '@/constants/urls'; import { useWallet } from '@/hooks/useWallet'; -import { Address } from '@/types'; +import { Address } from '@/types/Address'; +import { copyToClipboard } from '@/utils/copyToClipboard'; +import { truncateAddress } from '@/utils/truncate'; -import { Alert } from '../common/Alert'; +import { Alert } from '../Alert'; import { CardSection } from '../styled/CardSection'; const { Text } = Typography; diff --git a/frontend/components/Main/MainGasBalance.tsx b/frontend/components/Main/MainGasBalance.tsx index a4b3c9282..3f8e77487 100644 --- a/frontend/components/Main/MainGasBalance.tsx +++ b/frontend/components/Main/MainGasBalance.tsx @@ -3,8 +3,9 @@ import { Skeleton, Tooltip, Typography } from 'antd'; import { useMemo } from 'react'; import styled from 'styled-components'; -import { COLOR, LOW_BALANCE } from '@/constants'; -import { useBalance } from '@/hooks'; +import { COLOR } from '@/constants/colors'; +import { LOW_BALANCE } from '@/constants/thresholds'; +import { useBalance } from '@/hooks/useBalance'; import { useWallet } from '@/hooks/useWallet'; import { CardSection } from '../styled/CardSection'; diff --git a/frontend/components/Main/MainHeader/CannotStartAgent.tsx b/frontend/components/Main/MainHeader/CannotStartAgent.tsx index 4e37f4227..72921d94f 100644 --- a/frontend/components/Main/MainHeader/CannotStartAgent.tsx +++ b/frontend/components/Main/MainHeader/CannotStartAgent.tsx @@ -1,8 +1,9 @@ import { InfoCircleOutlined } from '@ant-design/icons'; import { Popover, PopoverProps, Typography } from 'antd'; -import { COLOR, SUPPORT_URL } from '@/constants'; -import { UNICODE_SYMBOLS } from '@/constants/unicode'; +import { COLOR } from '@/constants/colors'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { SUPPORT_URL } from '@/constants/urls'; import { useStakingContractInfo } from '@/hooks/useStakingContractInfo'; const { Paragraph, Text } = Typography; diff --git a/frontend/components/Main/MainHeader/constants.tsx b/frontend/components/Main/MainHeader/constants.tsx index 70ca0a431..1487211ce 100644 --- a/frontend/components/Main/MainHeader/constants.tsx +++ b/frontend/components/Main/MainHeader/constants.tsx @@ -1,6 +1,6 @@ import { formatUnits } from 'ethers/lib/utils'; -import { SERVICE_TEMPLATES } from '@/constants'; +import { SERVICE_TEMPLATES } from '@/constants/serviceTemplates'; const olasCostOfBond = Number( formatUnits(`${SERVICE_TEMPLATES[0].configuration.olas_cost_of_bond}`, 18), diff --git a/frontend/components/Main/MainHeader/MainHeader.tsx b/frontend/components/Main/MainHeader/index.tsx similarity index 95% rename from frontend/components/Main/MainHeader/MainHeader.tsx rename to frontend/components/Main/MainHeader/index.tsx index 24c971486..8fd800ecd 100644 --- a/frontend/components/Main/MainHeader/MainHeader.tsx +++ b/frontend/components/Main/MainHeader/index.tsx @@ -4,18 +4,19 @@ import Image from 'next/image'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { Chain, DeploymentStatus } from '@/client'; -import { COLOR, LOW_BALANCE } from '@/constants'; -import { useBalance, useServiceTemplates } from '@/hooks'; +import { COLOR } from '@/constants/colors'; +import { LOW_BALANCE } from '@/constants/thresholds'; +import { useBalance } from '@/hooks/useBalance'; import { useElectronApi } from '@/hooks/useElectronApi'; import { useReward } from '@/hooks/useReward'; import { useServices } from '@/hooks/useServices'; +import { useServiceTemplates } from '@/hooks/useServiceTemplates'; import { useStakingContractInfo } from '@/hooks/useStakingContractInfo'; import { useStore } from '@/hooks/useStore'; import { useWallet } from '@/hooks/useWallet'; -import { ServicesService } from '@/service'; +import { ServicesService } from '@/service/Services'; import { WalletService } from '@/service/Wallet'; -import { CannotStartAgent } from './CannotStartAgent'; import { requiredGas, requiredOlas } from './constants'; import { FirstRunModal } from './FirstRunModal'; @@ -86,8 +87,7 @@ export const MainHeader = () => { const { minimumStakedAmountRequired } = useReward(); - const { isStakingContractInfoLoading, canStartAgent } = - useStakingContractInfo(); + const { canStartAgent } = useStakingContractInfo(); // hook to setup tray icon useSetupTrayIcon(); @@ -299,9 +299,7 @@ export const MainHeader = () => { return ( {agentHead} - {isStakingContractInfoLoading ? null : ( - <>{canStartAgent ? serviceToggleButton : } - )} + {serviceToggleButton} ); diff --git a/frontend/components/Main/MainNeedsFunds.tsx b/frontend/components/Main/MainNeedsFunds.tsx index 6891b4bad..404014d87 100644 --- a/frontend/components/Main/MainNeedsFunds.tsx +++ b/frontend/components/Main/MainNeedsFunds.tsx @@ -2,13 +2,13 @@ import { Flex, Typography } from 'antd'; import { formatUnits } from 'ethers/lib/utils'; import { ReactNode, useEffect, useMemo } from 'react'; -import { SERVICE_TEMPLATES } from '@/constants'; -import { UNICODE_SYMBOLS } from '@/constants/unicode'; -import { useBalance } from '@/hooks'; +import { SERVICE_TEMPLATES } from '@/constants/serviceTemplates'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { useBalance } from '@/hooks/useBalance'; import { useElectronApi } from '@/hooks/useElectronApi'; import { useStore } from '@/hooks/useStore'; -import { Alert } from '../common/Alert'; +import { Alert } from '../Alert'; import { CardSection } from '../styled/CardSection'; const { Text, Paragraph } = Typography; diff --git a/frontend/components/Main/MainOlasBalance.tsx b/frontend/components/Main/MainOlasBalance.tsx index d9960e862..f51cf2ef9 100644 --- a/frontend/components/Main/MainOlasBalance.tsx +++ b/frontend/components/Main/MainOlasBalance.tsx @@ -3,11 +3,11 @@ import { Flex, Skeleton, Tooltip, Typography } from 'antd'; import { useMemo } from 'react'; import styled from 'styled-components'; -import { balanceFormat } from '@/common-util/numberFormatters'; -import { COLOR } from '@/constants'; -import { UNICODE_SYMBOLS } from '@/constants/unicode'; -import { useBalance } from '@/hooks'; +import { COLOR } from '@/constants/colors'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { useBalance } from '@/hooks/useBalance'; import { useReward } from '@/hooks/useReward'; +import { balanceFormat } from '@/utils/numberFormatters'; import { CardSection } from '../styled/CardSection'; diff --git a/frontend/components/Main/MainRewards.tsx b/frontend/components/Main/MainRewards.tsx index d94dbaf16..9162029de 100644 --- a/frontend/components/Main/MainRewards.tsx +++ b/frontend/components/Main/MainRewards.tsx @@ -3,13 +3,13 @@ import { Button, Flex, Modal, Skeleton, Tag, Tooltip, Typography } from 'antd'; import Image from 'next/image'; import { useCallback, useEffect, useState } from 'react'; -import { balanceFormat } from '@/common-util'; -import { useBalance } from '@/hooks'; +import { useBalance } from '@/hooks/useBalance'; import { useElectronApi } from '@/hooks/useElectronApi'; import { useReward } from '@/hooks/useReward'; import { useStore } from '@/hooks/useStore'; +import { balanceFormat } from '@/utils/numberFormatters'; -import { ConfettiAnimation } from '../common/ConfettiAnimation'; +import { ConfettiAnimation } from '../Confetti/ConfettiAnimation'; import { CardSection } from '../styled/CardSection'; const { Text, Title, Paragraph } = Typography; diff --git a/frontend/components/Main/Main.tsx b/frontend/components/Main/index.tsx similarity index 86% rename from frontend/components/Main/Main.tsx rename to frontend/components/Main/index.tsx index 81864ae22..1d2c4a5d3 100644 --- a/frontend/components/Main/Main.tsx +++ b/frontend/components/Main/index.tsx @@ -2,13 +2,15 @@ import { QuestionCircleOutlined, SettingOutlined } from '@ant-design/icons'; import { Button, Card, Flex } from 'antd'; import { useEffect } from 'react'; -import { PageState } from '@/enums'; -import { useBalance, usePageState, useServices } from '@/hooks'; +import { PageState } from '@/enums/PageState'; +import { useBalance } from '@/hooks/useBalance'; +import { usePageState } from '@/hooks/usePageState'; +import { useServices } from '@/hooks/useServices'; import { KeepAgentRunning } from './KeepAgentRunning'; import { MainAddFunds } from './MainAddFunds'; import { MainGasBalance } from './MainGasBalance'; -import { MainHeader } from './MainHeader/MainHeader'; +import { MainHeader } from './MainHeader'; import { MainNeedsFunds } from './MainNeedsFunds'; import { MainOlasBalance } from './MainOlasBalance'; import { MainRewards } from './MainRewards'; diff --git a/frontend/components/Settings/DebugInfoCard.tsx b/frontend/components/Settings/DebugInfoCard.tsx index 0998907c8..07d60943f 100644 --- a/frontend/components/Settings/DebugInfoCard.tsx +++ b/frontend/components/Settings/DebugInfoCard.tsx @@ -13,13 +13,16 @@ import { import { useCallback, useMemo, useState } from 'react'; import styled from 'styled-components'; -import { balanceFormat, copyToClipboard, truncateAddress } from '@/common-util'; -import { COLOR } from '@/constants'; -import { UNICODE_SYMBOLS } from '@/constants/unicode'; -import { Token } from '@/enums'; -import { useBalance, useServices } from '@/hooks'; +import { COLOR } from '@/constants/colors'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { Token } from '@/enums/Token'; +import { useBalance } from '@/hooks/useBalance'; +import { useServices } from '@/hooks/useServices'; import { useWallet } from '@/hooks/useWallet'; -import { WalletAddressNumberRecord } from '@/types'; +import { WalletAddressNumberRecord } from '@/types/Records'; +import { copyToClipboard } from '@/utils/copyToClipboard'; +import { balanceFormat } from '@/utils/numberFormatters'; +import { truncateAddress } from '@/utils/truncate'; import { CardSection } from '../styled/CardSection'; diff --git a/frontend/components/Settings/SettingsAddBackupWallet.tsx b/frontend/components/Settings/SettingsAddBackupWallet.tsx index 2555b8f0f..ac67149ff 100644 --- a/frontend/components/Settings/SettingsAddBackupWallet.tsx +++ b/frontend/components/Settings/SettingsAddBackupWallet.tsx @@ -3,12 +3,12 @@ import { Button, Form, Input, Typography } from 'antd'; import { useMemo } from 'react'; import { Chain } from '@/client'; -import { MIN_ETH_BALANCE_THRESHOLDS } from '@/constants'; -import { SettingsScreen } from '@/enums'; -import { useBalance } from '@/hooks'; +import { MIN_ETH_BALANCE_THRESHOLDS } from '@/constants/thresholds'; +import { SettingsScreen } from '@/enums/SettingsScreen'; +import { useBalance } from '@/hooks/useBalance'; import { useSettings } from '@/hooks/useSettings'; -import { CardTitle } from '../common/CardTitle'; +import { CardTitle } from '../Card/CardTitle'; import { CardFlex } from '../styled/CardFlex'; export const SettingsAddBackupWallet = () => { diff --git a/frontend/components/Settings/Settings.tsx b/frontend/components/Settings/index.tsx similarity index 90% rename from frontend/components/Settings/Settings.tsx rename to frontend/components/Settings/index.tsx index c92c4da82..81a0a0160 100644 --- a/frontend/components/Settings/Settings.tsx +++ b/frontend/components/Settings/index.tsx @@ -3,15 +3,16 @@ import { Button, Card, Flex, Typography } from 'antd'; import Link from 'next/link'; import { useMemo } from 'react'; -import { truncateAddress } from '@/common-util'; -import { UNICODE_SYMBOLS } from '@/constants/unicode'; -import { PageState, SettingsScreen } from '@/enums'; -import { usePageState } from '@/hooks'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { PageState } from '@/enums/PageState'; +import { SettingsScreen } from '@/enums/SettingsScreen'; import { useMasterSafe } from '@/hooks/useMasterSafe'; +import { usePageState } from '@/hooks/usePageState'; import { useSettings } from '@/hooks/useSettings'; +import { truncateAddress } from '@/utils/truncate'; -import { Alert } from '../common/Alert'; -import { CardTitle } from '../common/CardTitle'; +import { Alert } from '../Alert'; +import { CardTitle } from '../Card/CardTitle'; import { CardSection } from '../styled/CardSection'; import { DebugInfoCard } from './DebugInfoCard'; import { SettingsAddBackupWallet } from './SettingsAddBackupWallet'; diff --git a/frontend/components/Setup/Create/SetupBackupSigner.tsx b/frontend/components/Setup/Create/SetupBackupSigner.tsx index 5afe3dfcc..4862a9b45 100644 --- a/frontend/components/Setup/Create/SetupBackupSigner.tsx +++ b/frontend/components/Setup/Create/SetupBackupSigner.tsx @@ -2,9 +2,9 @@ import { Button, Flex, Form, Input, Typography } from 'antd'; import { CardFlex } from '@/components/styled/CardFlex'; import { FormFlex } from '@/components/styled/FormFlex'; -import { SetupScreen } from '@/enums'; -import { useSetup } from '@/hooks'; -import { Address } from '@/types'; +import { SetupScreen } from '@/enums/SetupScreen'; +import { useSetup } from '@/hooks/useSetup'; +import { Address } from '@/types/Address'; import { SetupCreateHeader } from './SetupCreateHeader'; diff --git a/frontend/components/Setup/Create/SetupCreateHeader.tsx b/frontend/components/Setup/Create/SetupCreateHeader.tsx index f077e684a..d4f7bc670 100644 --- a/frontend/components/Setup/Create/SetupCreateHeader.tsx +++ b/frontend/components/Setup/Create/SetupCreateHeader.tsx @@ -3,8 +3,8 @@ import { Button, Col, Flex, Row } from 'antd'; import Image from 'next/image'; import { memo } from 'react'; -import { SetupScreen } from '@/enums'; -import { useSetup } from '@/hooks'; +import { SetupScreen } from '@/enums/SetupScreen'; +import { useSetup } from '@/hooks/useSetup'; export const SetupCreateHeader = memo(function SetupCreateHeader({ prev, diff --git a/frontend/components/Setup/Create/SetupCreateSafe.tsx b/frontend/components/Setup/Create/SetupCreateSafe.tsx index 05fbc752a..05a0fbebf 100644 --- a/frontend/components/Setup/Create/SetupCreateSafe.tsx +++ b/frontend/components/Setup/Create/SetupCreateSafe.tsx @@ -4,10 +4,11 @@ import { useEffect, useState } from 'react'; import { Chain } from '@/client'; import { CardSection } from '@/components/styled/CardSection'; -import { SUPPORT_URL } from '@/constants'; -import { UNICODE_SYMBOLS } from '@/constants/unicode'; -import { PageState } from '@/enums'; -import { usePageState, useSetup } from '@/hooks'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { SUPPORT_URL } from '@/constants/urls'; +import { PageState } from '@/enums/PageState'; +import { usePageState } from '@/hooks/usePageState'; +import { useSetup } from '@/hooks/useSetup'; import { useWallet } from '@/hooks/useWallet'; import { WalletService } from '@/service/Wallet'; diff --git a/frontend/components/Setup/Create/SetupEoaFunding.tsx b/frontend/components/Setup/Create/SetupEoaFunding.tsx index dca8a6c31..c5486e66b 100644 --- a/frontend/components/Setup/Create/SetupEoaFunding.tsx +++ b/frontend/components/Setup/Create/SetupEoaFunding.tsx @@ -15,18 +15,17 @@ import { useEffect, useMemo } from 'react'; import styled from 'styled-components'; import { Chain } from '@/client'; -import { copyToClipboard } from '@/common-util'; -import { Alert } from '@/components/common/Alert'; +import { Alert } from '@/components/Alert'; import { CardFlex } from '@/components/styled/CardFlex'; import { CardSection } from '@/components/styled/CardSection'; -import { - COW_SWAP_GNOSIS_XDAI_OLAS_URL, - MIN_ETH_BALANCE_THRESHOLDS, -} from '@/constants'; -import { UNICODE_SYMBOLS } from '@/constants/unicode'; -import { SetupScreen } from '@/enums'; -import { useBalance, useSetup } from '@/hooks'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { MIN_ETH_BALANCE_THRESHOLDS } from '@/constants/thresholds'; +import { COW_SWAP_GNOSIS_XDAI_OLAS_URL } from '@/constants/urls'; +import { SetupScreen } from '@/enums/SetupScreen'; +import { useBalance } from '@/hooks/useBalance'; +import { useSetup } from '@/hooks/useSetup'; import { useWallet } from '@/hooks/useWallet'; +import { copyToClipboard } from '@/utils/copyToClipboard'; import { SetupCreateHeader } from './SetupCreateHeader'; diff --git a/frontend/components/Setup/Create/SetupPassword.tsx b/frontend/components/Setup/Create/SetupPassword.tsx index f7b08c067..4907724af 100644 --- a/frontend/components/Setup/Create/SetupPassword.tsx +++ b/frontend/components/Setup/Create/SetupPassword.tsx @@ -2,8 +2,8 @@ import { Button, Checkbox, Form, Input, message, Typography } from 'antd'; import { useState } from 'react'; import { Chain } from '@/client'; -import { SetupScreen } from '@/enums'; -import { useSetup } from '@/hooks'; +import { SetupScreen } from '@/enums/SetupScreen'; +import { useSetup } from '@/hooks/useSetup'; import { AccountService } from '@/service/Account'; import { WalletService } from '@/service/Wallet'; diff --git a/frontend/components/Setup/Create/SetupSeedPhrase.tsx b/frontend/components/Setup/Create/SetupSeedPhrase.tsx index 48b8d804a..5b32a4cdb 100644 --- a/frontend/components/Setup/Create/SetupSeedPhrase.tsx +++ b/frontend/components/Setup/Create/SetupSeedPhrase.tsx @@ -1,9 +1,9 @@ import { CopyOutlined } from '@ant-design/icons'; import { Button, Flex, message, Tag, Typography } from 'antd'; -import { copyToClipboard } from '@/common-util'; -import { SetupScreen } from '@/enums'; -import { useSetup } from '@/hooks'; +import { SetupScreen } from '@/enums/SetupScreen'; +import { useSetup } from '@/hooks/useSetup'; +import { copyToClipboard } from '@/utils/copyToClipboard'; import { CardFlex } from '../../styled/CardFlex'; import { SetupCreateHeader } from './SetupCreateHeader'; @@ -24,7 +24,7 @@ export const SetupSeedPhrase = () => { password. - {mnemonic.map((word) => ( + {mnemonic.map((word: string) => ( {word} ))} diff --git a/frontend/components/Setup/SetupRestore.tsx b/frontend/components/Setup/SetupRestore.tsx index a84ca6f8e..99f57d61d 100644 --- a/frontend/components/Setup/SetupRestore.tsx +++ b/frontend/components/Setup/SetupRestore.tsx @@ -5,8 +5,8 @@ import { memo, useMemo, useState } from 'react'; import { CardFlex } from '@/components/styled/CardFlex'; import { CardSection } from '@/components/styled/CardSection'; -import { SetupScreen } from '@/enums'; -import { useSetup } from '@/hooks'; +import { SetupScreen } from '@/enums/SetupScreen'; +import { useSetup } from '@/hooks/useSetup'; const ExitButton = memo(function ExitButton() { const { goto } = useSetup(); diff --git a/frontend/components/Setup/SetupWelcome.tsx b/frontend/components/Setup/SetupWelcome.tsx index 37d518626..943ae59b8 100644 --- a/frontend/components/Setup/SetupWelcome.tsx +++ b/frontend/components/Setup/SetupWelcome.tsx @@ -12,9 +12,12 @@ import Image from 'next/image'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { AccountIsSetup } from '@/client'; -import { PageState, SetupScreen } from '@/enums'; -import { useBalance, usePageState, useSetup } from '@/hooks'; +import { PageState } from '@/enums/PageState'; +import { SetupScreen } from '@/enums/SetupScreen'; +import { useBalance } from '@/hooks/useBalance'; import { useElectronApi } from '@/hooks/useElectronApi'; +import { usePageState } from '@/hooks/usePageState'; +import { useSetup } from '@/hooks/useSetup'; import { useWallet } from '@/hooks/useWallet'; import { AccountService } from '@/service/Account'; @@ -24,17 +27,17 @@ const { Title } = Typography; export const SetupWelcome = () => { const electronApi = useElectronApi(); - const [isSetup, setIsSetup] = useState( - AccountIsSetup.Loading, - ); + const [isSetup, setIsSetup] = useState(null); useEffect(() => { + if (isSetup !== null) return; + setIsSetup(AccountIsSetup.Loading); + AccountService.getAccount() .then((res) => { switch (res.is_setup) { case true: setIsSetup(AccountIsSetup.True); - break; case false: // Reset persistent state @@ -51,7 +54,7 @@ export const SetupWelcome = () => { console.error(e); setIsSetup(AccountIsSetup.Error); }); - }, []); + }, [electronApi.store, isSetup]); const welcomeScreen = useMemo(() => { switch (isSetup) { @@ -59,8 +62,20 @@ export const SetupWelcome = () => { return ; case AccountIsSetup.False: return ; + case AccountIsSetup.Loading: + return ( + + + + ); default: - return ; + return ( + + + Error determining account setup state. + + + ); } }, [isSetup]); diff --git a/frontend/components/Setup/Setup.tsx b/frontend/components/Setup/index.tsx similarity index 94% rename from frontend/components/Setup/Setup.tsx rename to frontend/components/Setup/index.tsx index 9e302585c..598ff10ac 100644 --- a/frontend/components/Setup/Setup.tsx +++ b/frontend/components/Setup/index.tsx @@ -1,7 +1,7 @@ import { useContext, useMemo } from 'react'; -import { SetupContext } from '@/context'; -import { SetupScreen } from '@/enums'; +import { SetupContext } from '@/context/SetupProvider'; +import { SetupScreen } from '@/enums/SetupScreen'; import { SetupBackupSigner } from './Create/SetupBackupSigner'; import { SetupCreateSafe } from './Create/SetupCreateSafe'; diff --git a/frontend/components/index.ts b/frontend/components/index.ts deleted file mode 100644 index cf1f1f091..000000000 --- a/frontend/components/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './HelpAndSupport/HelpAndSupport'; -export * from './Settings/Settings'; -export * from './Setup/Setup'; diff --git a/frontend/components/styled/CardSection.tsx b/frontend/components/styled/CardSection.tsx index 3c38139b5..0a1b653a0 100644 --- a/frontend/components/styled/CardSection.tsx +++ b/frontend/components/styled/CardSection.tsx @@ -1,7 +1,7 @@ import { Flex, FlexProps } from 'antd'; import styled from 'styled-components'; -import { COLOR } from '@/constants'; +import { COLOR } from '@/constants/colors'; type CardSectionProps = FlexProps & { bordertop?: 'true' | 'false'; From 87671e5ed7bdf92b6a543618c9d039f08923455e Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:25:16 +0100 Subject: [PATCH 09/17] chore: remove provider barrel, update types, add interval to StakingContractInfo provider --- frontend/context/BalanceProvider.tsx | 13 +++++++------ frontend/context/ElectronApiProvider.tsx | 2 +- frontend/context/MasterSafeProvider.tsx | 9 +++------ frontend/context/PageStateProvider.tsx | 2 +- frontend/context/RewardProvider.tsx | 6 +++++- frontend/context/ServicesProvider.tsx | 7 ++++--- frontend/context/SettingsProvider.tsx | 2 +- frontend/context/SetupProvider.tsx | 2 +- frontend/context/StakingContractInfoProvider.tsx | 3 ++- frontend/context/StoreProvider.tsx | 4 ++-- frontend/context/WalletProvider.tsx | 5 +++-- 11 files changed, 30 insertions(+), 25 deletions(-) diff --git a/frontend/context/BalanceProvider.tsx b/frontend/context/BalanceProvider.tsx index bc539cedb..12c5400ec 100644 --- a/frontend/context/BalanceProvider.tsx +++ b/frontend/context/BalanceProvider.tsx @@ -15,21 +15,22 @@ import { import { useInterval } from 'usehooks-ts'; import { Wallet } from '@/client'; +import { FIVE_SECONDS_INTERVAL } from '@/constants/intervals'; import { TOKENS } from '@/constants/tokens'; import { ServiceRegistryL2ServiceState } from '@/enums/ServiceRegistryL2ServiceState'; import { Token } from '@/enums/Token'; -import { EthersService } from '@/service'; import { AutonolasService } from '@/service/Autonolas'; +import { EthersService } from '@/service/Ethers'; import MulticallService from '@/service/Multicall'; +import { Address } from '@/types/Address'; import { - Address, AddressNumberRecord, WalletAddressNumberRecord, -} from '@/types'; +} from '@/types/Records'; -import { ServicesContext } from '.'; import { OnlineStatusContext } from './OnlineStatusProvider'; import { RewardContext } from './RewardProvider'; +import { ServicesContext } from './ServicesProvider'; import { WalletContext } from './WalletProvider'; export const BalanceContext = createContext<{ @@ -199,7 +200,7 @@ export const BalanceProvider = ({ children }: PropsWithChildren) => { () => { updateBalances(); }, - isPaused || !isOnline ? null : 5000, + isPaused || !isOnline ? null : FIVE_SECONDS_INTERVAL, ); return ( @@ -268,7 +269,7 @@ export const getWalletAddresses = ( } for (const serviceAddress of serviceAddresses) { - if (serviceAddress && isAddress(serviceAddress)) { + if (serviceAddress && isAddress(`${serviceAddress}`)) { walletsToCheck.push(serviceAddress); } } diff --git a/frontend/context/ElectronApiProvider.tsx b/frontend/context/ElectronApiProvider.tsx index 032551c99..01f85bdf9 100644 --- a/frontend/context/ElectronApiProvider.tsx +++ b/frontend/context/ElectronApiProvider.tsx @@ -1,7 +1,7 @@ import { get } from 'lodash'; import { createContext, PropsWithChildren } from 'react'; -import { ElectronStore, ElectronTrayIconStatus } from '@/types'; +import { ElectronStore, ElectronTrayIconStatus } from '@/types/ElectronApi'; type ElectronApiContextProps = { closeApp?: () => void; diff --git a/frontend/context/MasterSafeProvider.tsx b/frontend/context/MasterSafeProvider.tsx index 484646eb0..46daeaba1 100644 --- a/frontend/context/MasterSafeProvider.tsx +++ b/frontend/context/MasterSafeProvider.tsx @@ -1,7 +1,3 @@ -/** - * placeholder incase required, currently not used - */ - import { createContext, PropsWithChildren, @@ -11,8 +7,9 @@ import { } from 'react'; import { useInterval } from 'usehooks-ts'; +import { FIVE_SECONDS_INTERVAL } from '@/constants/intervals'; import { GnosisSafeService } from '@/service/GnosisSafe'; -import { Address } from '@/types'; +import { Address } from '@/types/Address'; import { OnlineStatusContext } from './OnlineStatusProvider'; import { WalletContext } from './WalletProvider'; @@ -70,7 +67,7 @@ export const MasterSafeProvider = ({ children }: PropsWithChildren) => { updateMasterSafeOwners, (masterSafeOwners && masterSafeOwners.length >= 2) || !isOnline ? null - : 5000, + : FIVE_SECONDS_INTERVAL, ); return ( diff --git a/frontend/context/PageStateProvider.tsx b/frontend/context/PageStateProvider.tsx index 07b7f5364..e176a246f 100644 --- a/frontend/context/PageStateProvider.tsx +++ b/frontend/context/PageStateProvider.tsx @@ -6,7 +6,7 @@ import { useState, } from 'react'; -import { PageState } from '@/enums'; +import { PageState } from '@/enums/PageState'; type PageStateContextType = { pageState: PageState; diff --git a/frontend/context/RewardProvider.tsx b/frontend/context/RewardProvider.tsx index 831e2b420..c645226ae 100644 --- a/frontend/context/RewardProvider.tsx +++ b/frontend/context/RewardProvider.tsx @@ -10,6 +10,7 @@ import { } from 'react'; import { useInterval } from 'usehooks-ts'; +import { FIVE_SECONDS_INTERVAL } from '@/constants/intervals'; import { useElectronApi } from '@/hooks/useElectronApi'; import { useStore } from '@/hooks/useStore'; import { AutonolasService } from '@/service/Autonolas'; @@ -100,7 +101,10 @@ export const RewardProvider = ({ children }: PropsWithChildren) => { storeState?.firstStakingRewardAchieved, ]); - useInterval(async () => updateRewards(), isOnline ? 5000 : null); + useInterval( + async () => updateRewards(), + isOnline ? FIVE_SECONDS_INTERVAL : null, + ); return ( { updateServicesState() .then(() => updateServiceStatus()) .catch((e) => message.error(e.message)), - isOnline ? 5000 : null, + isOnline ? FIVE_SECONDS_INTERVAL : null, ); return ( diff --git a/frontend/context/SettingsProvider.tsx b/frontend/context/SettingsProvider.tsx index b9752a386..6bdb43a15 100644 --- a/frontend/context/SettingsProvider.tsx +++ b/frontend/context/SettingsProvider.tsx @@ -1,6 +1,6 @@ import { createContext, PropsWithChildren, useState } from 'react'; -import { SettingsScreen } from '@/enums'; +import { SettingsScreen } from '@/enums/SettingsScreen'; export const SettingsContext = createContext<{ screen: SettingsScreen; diff --git a/frontend/context/SetupProvider.tsx b/frontend/context/SetupProvider.tsx index 33f4445a3..d833bf2ee 100644 --- a/frontend/context/SetupProvider.tsx +++ b/frontend/context/SetupProvider.tsx @@ -7,7 +7,7 @@ import { } from 'react'; import { SetupScreen } from '@/enums/SetupScreen'; -import { Address } from '@/types'; +import { Address } from '@/types/Address'; type SetupObjectType = { state: SetupScreen; diff --git a/frontend/context/StakingContractInfoProvider.tsx b/frontend/context/StakingContractInfoProvider.tsx index 9509c560d..28d010921 100644 --- a/frontend/context/StakingContractInfoProvider.tsx +++ b/frontend/context/StakingContractInfoProvider.tsx @@ -1,6 +1,7 @@ import { createContext, PropsWithChildren, useCallback, useState } from 'react'; import { useInterval } from 'usehooks-ts'; +import { FIVE_SECONDS_INTERVAL } from '@/constants/intervals'; import { AutonolasService } from '@/service/Autonolas'; type StakingContractInfoContextProps = { @@ -54,7 +55,7 @@ export const StakingContractInfoProvider = ({ } }, []); - useInterval(updateStakingContractInfo, 5000); + useInterval(updateStakingContractInfo, FIVE_SECONDS_INTERVAL); return ( { const setupStore = useCallback(async () => { const tempStore = await store?.store?.(); - setStoreState(tempStore); + if (tempStore) setStoreState(tempStore); ipcRenderer?.on?.('store-changed', (_event: unknown, data: unknown) => { setStoreState(data as ElectronStore); }); diff --git a/frontend/context/WalletProvider.tsx b/frontend/context/WalletProvider.tsx index f175394b0..21c02606a 100644 --- a/frontend/context/WalletProvider.tsx +++ b/frontend/context/WalletProvider.tsx @@ -2,8 +2,9 @@ import { createContext, PropsWithChildren, useContext, useState } from 'react'; import { useInterval } from 'usehooks-ts'; import { Wallet } from '@/client'; +import { FIVE_SECONDS_INTERVAL } from '@/constants/intervals'; import { WalletService } from '@/service/Wallet'; -import { Address } from '@/types'; +import { Address } from '@/types/Address'; import { OnlineStatusContext } from './OnlineStatusProvider'; @@ -33,7 +34,7 @@ export const WalletProvider = ({ children }: PropsWithChildren) => { setWallets(wallets); }; - useInterval(updateWallets, isOnline ? 5000 : null); + useInterval(updateWallets, isOnline ? FIVE_SECONDS_INTERVAL : null); return ( Date: Tue, 9 Jul 2024 15:25:36 +0100 Subject: [PATCH 10/17] chore: move DEFAULT_HEIGHT constant out of PageState enum file --- frontend/enums/PageState.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/enums/PageState.ts b/frontend/enums/PageState.ts index 25cb8f307..7a670f683 100644 --- a/frontend/enums/PageState.ts +++ b/frontend/enums/PageState.ts @@ -6,5 +6,3 @@ export enum PageState { Receive, Send, } - -export const DEFAULT_HEIGHT = 700; From dafd9baaab137ebc0a8d04b38679bb1e43296dab Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:26:02 +0100 Subject: [PATCH 11/17] chore: refactor hooks that export useContext call, update types, remove barrel --- frontend/hooks/usePageState.ts | 4 ++-- frontend/hooks/useServiceTemplates.ts | 2 +- frontend/hooks/useServices.ts | 7 ++++--- frontend/hooks/useSettings.ts | 5 +---- frontend/hooks/useSetup.ts | 6 +++--- frontend/hooks/useStakingContractInfo.ts | 19 ++----------------- frontend/hooks/useStore.ts | 6 +----- frontend/hooks/useWallet.ts | 12 +----------- 8 files changed, 15 insertions(+), 46 deletions(-) diff --git a/frontend/hooks/usePageState.ts b/frontend/hooks/usePageState.ts index ff3f8bc65..45dd74d62 100644 --- a/frontend/hooks/usePageState.ts +++ b/frontend/hooks/usePageState.ts @@ -1,7 +1,7 @@ import { useContext } from 'react'; -import { PageStateContext } from '@/context'; -import { PageState } from '@/enums'; +import { PageStateContext } from '@/context/PageStateProvider'; +import { PageState } from '@/enums/PageState'; export const usePageState = () => { const { pageState, setPageState } = useContext(PageStateContext); diff --git a/frontend/hooks/useServiceTemplates.ts b/frontend/hooks/useServiceTemplates.ts index 503adcc13..0eb803f94 100644 --- a/frontend/hooks/useServiceTemplates.ts +++ b/frontend/hooks/useServiceTemplates.ts @@ -1,5 +1,5 @@ import { ServiceTemplate } from '@/client/types'; -import { SERVICE_TEMPLATES } from '@/constants'; +import { SERVICE_TEMPLATES } from '@/constants/serviceTemplates'; export const useServiceTemplates = () => { const getServiceTemplates = (): ServiceTemplate[] => SERVICE_TEMPLATES; diff --git a/frontend/hooks/useServices.ts b/frontend/hooks/useServices.ts index 634af8a97..d78a563fc 100644 --- a/frontend/hooks/useServices.ts +++ b/frontend/hooks/useServices.ts @@ -1,10 +1,11 @@ import { useContext } from 'react'; import { Service, ServiceHash, ServiceTemplate } from '@/client'; -import { ServicesContext } from '@/context'; -import { ServicesService } from '@/service'; +import { ServicesContext } from '@/context/ServicesProvider'; import MulticallService from '@/service/Multicall'; -import { Address, AddressBooleanRecord } from '@/types'; +import { ServicesService } from '@/service/Services'; +import { Address } from '@/types/Address'; +import { AddressBooleanRecord } from '@/types/Records'; const checkServiceIsFunded = async ( service: Service, diff --git a/frontend/hooks/useSettings.ts b/frontend/hooks/useSettings.ts index e6b3b5b46..9b5ba28fe 100644 --- a/frontend/hooks/useSettings.ts +++ b/frontend/hooks/useSettings.ts @@ -2,7 +2,4 @@ import { useContext } from 'react'; import { SettingsContext } from '@/context/SettingsProvider'; -export const useSettings = () => { - const { screen, goto } = useContext(SettingsContext); - return { screen, goto }; -}; +export const useSettings = () => useContext(SettingsContext); diff --git a/frontend/hooks/useSetup.ts b/frontend/hooks/useSetup.ts index 3af169b93..cbde83cc3 100644 --- a/frontend/hooks/useSetup.ts +++ b/frontend/hooks/useSetup.ts @@ -1,8 +1,8 @@ import { useContext } from 'react'; -import { SetupContext } from '@/context'; -import { SetupScreen } from '@/enums'; -import { Address } from '@/types'; +import { SetupContext } from '@/context/SetupProvider'; +import { SetupScreen } from '@/enums/SetupScreen'; +import { Address } from '@/types/Address'; export const useSetup = () => { const { setupObject, setSetupObject } = useContext(SetupContext); diff --git a/frontend/hooks/useStakingContractInfo.ts b/frontend/hooks/useStakingContractInfo.ts index 69301068e..e3fc10c91 100644 --- a/frontend/hooks/useStakingContractInfo.ts +++ b/frontend/hooks/useStakingContractInfo.ts @@ -2,20 +2,5 @@ import { useContext } from 'react'; import { StakingContractInfoContext } from '@/context/StakingContractInfoProvider'; -export const useStakingContractInfo = () => { - const { - canStartAgent, - hasEnoughServiceSlots, - isAgentEvicted, - isRewardsAvailable, - isStakingContractInfoLoading, - } = useContext(StakingContractInfoContext); - - return { - canStartAgent, - hasEnoughServiceSlots, - isAgentEvicted, - isRewardsAvailable, - isStakingContractInfoLoading, - }; -}; +export const useStakingContractInfo = () => + useContext(StakingContractInfoContext); diff --git a/frontend/hooks/useStore.ts b/frontend/hooks/useStore.ts index 44fb0d881..ddc4a66b8 100644 --- a/frontend/hooks/useStore.ts +++ b/frontend/hooks/useStore.ts @@ -2,8 +2,4 @@ import { useContext } from 'react'; import { StoreContext } from '@/context/StoreProvider'; -export const useStore = () => { - const { storeState } = useContext(StoreContext); - - return { storeState }; -}; +export const useStore = () => useContext(StoreContext); diff --git a/frontend/hooks/useWallet.ts b/frontend/hooks/useWallet.ts index be2b58b88..3ac343b60 100644 --- a/frontend/hooks/useWallet.ts +++ b/frontend/hooks/useWallet.ts @@ -2,14 +2,4 @@ import { useContext } from 'react'; import { WalletContext } from '@/context/WalletProvider'; -export const useWallet = () => { - const { wallets, masterEoaAddress, masterSafeAddress, updateWallets } = - useContext(WalletContext); - - return { - wallets, - masterEoaAddress, - masterSafeAddress, - updateWallets, - }; -}; +export const useWallet = () => useContext(WalletContext); From 46bd77a4c992f7b4e48ce3a97035183cf8cd8726 Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:26:19 +0100 Subject: [PATCH 12/17] chore: update provider imports --- frontend/pages/_app.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/pages/_app.tsx b/frontend/pages/_app.tsx index 4cbfa6f85..7a6c2efe8 100644 --- a/frontend/pages/_app.tsx +++ b/frontend/pages/_app.tsx @@ -5,13 +5,15 @@ import type { AppProps } from 'next/app'; import { useEffect, useRef } from 'react'; import { Layout } from '@/components/Layout'; -import { PageStateProvider, ServicesProvider, SetupProvider } from '@/context'; import { BalanceProvider } from '@/context/BalanceProvider'; import { ElectronApiProvider } from '@/context/ElectronApiProvider'; import { MasterSafeProvider } from '@/context/MasterSafeProvider'; import { OnlineStatusProvider } from '@/context/OnlineStatusProvider'; +import { PageStateProvider } from '@/context/PageStateProvider'; import { RewardProvider } from '@/context/RewardProvider'; +import { ServicesProvider } from '@/context/ServicesProvider'; import { SettingsProvider } from '@/context/SettingsProvider'; +import { SetupProvider } from '@/context/SetupProvider'; import { StakingContractInfoProvider } from '@/context/StakingContractInfoProvider'; import { StoreProvider } from '@/context/StoreProvider'; import { WalletProvider } from '@/context/WalletProvider'; From daa5febfe1f98df569917173b01a5a8b207279dd Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:26:32 +0100 Subject: [PATCH 13/17] chore: update imports --- frontend/pages/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index e772571e9..e4976d2eb 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -1,10 +1,14 @@ import { useEffect, useMemo } from 'react'; -import { HelpAndSupport, Settings, Setup } from '@/components'; -import { Main } from '@/components/Main/Main'; -import { DEFAULT_HEIGHT, PageState } from '@/enums'; -import { usePageState } from '@/hooks'; +import { HelpAndSupport } from '@/components/HelpAndSupport'; +import { Main } from '@/components/Main'; +import { Settings } from '@/components/Settings'; +import { Setup } from '@/components/Setup'; +import { PageState } from '@/enums/PageState'; import { useElectronApi } from '@/hooks/useElectronApi'; +import { usePageState } from '@/hooks/usePageState'; + +const DEFAULT_APP_HEIGHT = 700; export default function Home() { const { pageState } = usePageState(); @@ -15,7 +19,7 @@ export default function Home() { const bodyElement = document.querySelector('body'); if (bodyElement) { const scrollHeight = bodyElement.scrollHeight; - electronApi?.setAppHeight?.(Math.min(DEFAULT_HEIGHT, scrollHeight)); + electronApi?.setAppHeight?.(Math.min(DEFAULT_APP_HEIGHT, scrollHeight)); } } From 119aad48fdb586da7843d007d40fcbeee2af7a46 Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:26:57 +0100 Subject: [PATCH 14/17] chore: update service imports and remove barrel --- frontend/service/Account.ts | 2 +- frontend/service/Autonolas.ts | 19 +++++++++---------- frontend/service/Ethers.ts | 2 +- frontend/service/GnosisSafe.ts | 4 ++-- frontend/service/Multicall.ts | 9 +++++---- frontend/service/Services.ts | 2 +- frontend/service/Wallet.ts | 2 +- frontend/service/index.ts | 3 --- 8 files changed, 20 insertions(+), 23 deletions(-) delete mode 100644 frontend/service/index.ts diff --git a/frontend/service/Account.ts b/frontend/service/Account.ts index 56c91b4e9..49a61c29a 100644 --- a/frontend/service/Account.ts +++ b/frontend/service/Account.ts @@ -1,4 +1,4 @@ -import { BACKEND_URL } from '@/constants'; +import { BACKEND_URL } from '@/constants/urls'; /** * Gets account status "is_setup" diff --git a/frontend/service/Autonolas.ts b/frontend/service/Autonolas.ts index a20fd9c96..670b84f94 100644 --- a/frontend/service/Autonolas.ts +++ b/frontend/service/Autonolas.ts @@ -1,13 +1,11 @@ import { BigNumber, ethers } from 'ethers'; import { Contract as MulticallContract } from 'ethers-multicall'; -import { - AGENT_MECH_ABI, - MECH_ACTIVITY_CHECKER_ABI, - SERVICE_REGISTRY_L2_ABI, - SERVICE_REGISTRY_TOKEN_UTILITY_ABI, - SERVICE_STAKING_TOKEN_MECH_USAGE_ABI, -} from '@/abi'; +import { AGENT_MECH_ABI } from '@/abis/agentMech'; +import { MECH_ACTIVITY_CHECKER_ABI } from '@/abis/mechActivityChecker'; +import { SERVICE_REGISTRY_L2_ABI } from '@/abis/serviceRegistryL2'; +import { SERVICE_REGISTRY_TOKEN_UTILITY_ABI } from '@/abis/serviceRegistryTokenUtility'; +import { SERVICE_STAKING_TOKEN_MECH_USAGE_ABI } from '@/abis/serviceStakingTokenMechUsage'; import { Chain } from '@/client'; import { AGENT_MECH_CONTRACT_ADDRESS, @@ -15,10 +13,11 @@ import { SERVICE_REGISTRY_L2_CONTRACT_ADDRESS, SERVICE_REGISTRY_TOKEN_UTILITY_CONTRACT_ADDRESS, SERVICE_STAKING_TOKEN_MECH_USAGE_CONTRACT_ADDRESS, -} from '@/constants'; +} from '@/constants/contractAddresses'; import { gnosisMulticallProvider } from '@/constants/providers'; -import { ServiceRegistryL2ServiceState } from '@/enums'; -import { Address, StakingContractInfo, StakingRewardsInfo } from '@/types'; +import { ServiceRegistryL2ServiceState } from '@/enums/ServiceRegistryL2ServiceState'; +import { Address } from '@/types/Address'; +import { StakingContractInfo, StakingRewardsInfo } from '@/types/Autonolas'; const REQUIRED_MECH_REQUESTS_SAFETY_MARGIN = 1; diff --git a/frontend/service/Ethers.ts b/frontend/service/Ethers.ts index 287206a3e..20ad4cc70 100644 --- a/frontend/service/Ethers.ts +++ b/frontend/service/Ethers.ts @@ -1,7 +1,7 @@ import { ContractInterface, ethers, providers, utils } from 'ethers'; import { gnosisProvider } from '@/constants/providers'; -import { Address } from '@/types'; +import { Address } from '@/types/Address'; /** * Returns native balance of the given address diff --git a/frontend/service/GnosisSafe.ts b/frontend/service/GnosisSafe.ts index 0ecf80456..5c2879499 100644 --- a/frontend/service/GnosisSafe.ts +++ b/frontend/service/GnosisSafe.ts @@ -1,8 +1,8 @@ import { ethers } from 'ethers'; -import { GNOSIS_SAFE_ABI } from '@/abi/gnosisSafe'; +import { GNOSIS_SAFE_ABI } from '@/abis/gnosisSafe'; import { gnosisProvider } from '@/constants/providers'; -import { Address } from '@/types'; +import { Address } from '@/types/Address'; const getOwners = async ({ address, diff --git a/frontend/service/Multicall.ts b/frontend/service/Multicall.ts index 972a64b42..390274f14 100644 --- a/frontend/service/Multicall.ts +++ b/frontend/service/Multicall.ts @@ -1,11 +1,12 @@ import { BigNumber, ethers } from 'ethers'; import { Contract as MulticallContract, ContractCall } from 'ethers-multicall'; -import { MULTICALL3_ABI } from '@/abi'; -import { ERC20_BALANCEOF_FRAGMENT } from '@/abi/erc20'; -import { MULTICALL_CONTRACT_ADDRESS } from '@/constants'; +import { ERC20_BALANCEOF_FRAGMENT } from '@/abis/erc20'; +import { MULTICALL3_ABI } from '@/abis/multicall3'; +import { MULTICALL_CONTRACT_ADDRESS } from '@/constants/contractAddresses'; import { gnosisMulticallProvider } from '@/constants/providers'; -import { Address, AddressNumberRecord } from '@/types'; +import { Address } from '@/types/Address'; +import { AddressNumberRecord } from '@/types/Records'; const multicallContract = new MulticallContract( MULTICALL_CONTRACT_ADDRESS, diff --git a/frontend/service/Services.ts b/frontend/service/Services.ts index fe2182217..a12591909 100644 --- a/frontend/service/Services.ts +++ b/frontend/service/Services.ts @@ -1,5 +1,5 @@ import { Deployment, Service, ServiceHash, ServiceTemplate } from '@/client'; -import { BACKEND_URL } from '@/constants'; +import { BACKEND_URL } from '@/constants/urls'; /** * Get a single service from the backend diff --git a/frontend/service/Wallet.ts b/frontend/service/Wallet.ts index d6dec31a6..b09a8e95c 100644 --- a/frontend/service/Wallet.ts +++ b/frontend/service/Wallet.ts @@ -1,5 +1,5 @@ import { Chain } from '@/client'; -import { BACKEND_URL } from '@/constants'; +import { BACKEND_URL } from '@/constants/urls'; /** * Returns a list of available wallets diff --git a/frontend/service/index.ts b/frontend/service/index.ts deleted file mode 100644 index 6ad783a74..000000000 --- a/frontend/service/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './Ethers'; -export * from './Multicall'; -export * from './Services'; From 3208b40093edf846194b77d96a31f871db5aef8a Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:27:17 +0100 Subject: [PATCH 15/17] chore: theme only exports mainTheme, removed useless barrel --- frontend/theme/index.ts | 44 ++++++++++++++++++++++++++++++++++++- frontend/theme/mainTheme.ts | 43 ------------------------------------ 2 files changed, 43 insertions(+), 44 deletions(-) delete mode 100644 frontend/theme/mainTheme.ts diff --git a/frontend/theme/index.ts b/frontend/theme/index.ts index fdeaac41b..e42767da3 100644 --- a/frontend/theme/index.ts +++ b/frontend/theme/index.ts @@ -1 +1,43 @@ -export * from './mainTheme'; +import { ThemeConfig } from 'antd'; + +export const mainTheme: ThemeConfig = { + token: { + colorLink: '#7E22CE', + colorPrimary: '#7E22CE', + colorWarning: '#FF9C27', + colorInfoText: '#36075F', + colorText: '#0F172A', + colorTextSecondary: '#4D596A', + colorFillSecondary: '#E4E4E4', + fontSize: 16, + fontFamily: 'Inter', + colorBgContainer: '#FFFFFF', + }, + components: { + Alert: { + fontSize: 16, + }, + Button: { + fontSize: 16, + fontSizeLG: 16, + }, + Card: { + colorBgContainer: '#FFFFFF', + padding: 20, + fontWeightStrong: 400, + }, + Input: { + fontSize: 20, + colorTextDisabled: '#334155', + }, + Tooltip: { + fontSize: 16, + colorText: 'black', + colorTextLightSolid: 'black', + colorBgSpotlight: 'white', + }, + Typography: { + colorTextDescription: '#4D596A', + }, + }, +}; diff --git a/frontend/theme/mainTheme.ts b/frontend/theme/mainTheme.ts deleted file mode 100644 index e42767da3..000000000 --- a/frontend/theme/mainTheme.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { ThemeConfig } from 'antd'; - -export const mainTheme: ThemeConfig = { - token: { - colorLink: '#7E22CE', - colorPrimary: '#7E22CE', - colorWarning: '#FF9C27', - colorInfoText: '#36075F', - colorText: '#0F172A', - colorTextSecondary: '#4D596A', - colorFillSecondary: '#E4E4E4', - fontSize: 16, - fontFamily: 'Inter', - colorBgContainer: '#FFFFFF', - }, - components: { - Alert: { - fontSize: 16, - }, - Button: { - fontSize: 16, - fontSizeLG: 16, - }, - Card: { - colorBgContainer: '#FFFFFF', - padding: 20, - fontWeightStrong: 400, - }, - Input: { - fontSize: 20, - colorTextDisabled: '#334155', - }, - Tooltip: { - fontSize: 16, - colorText: 'black', - colorTextLightSolid: 'black', - colorBgSpotlight: 'white', - }, - Typography: { - colorTextDescription: '#4D596A', - }, - }, -}; From c588189c2e1c4f574bbfc39f272d270715f83f86 Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 9 Jul 2024 15:27:31 +0100 Subject: [PATCH 16/17] chore: update record type's imports --- frontend/types/Records.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/types/Records.ts b/frontend/types/Records.ts index 616119e0d..20a8611a9 100644 --- a/frontend/types/Records.ts +++ b/frontend/types/Records.ts @@ -1,6 +1,6 @@ -import { Token } from '@/enums'; +import { Token } from '@/enums/Token'; -import { Address } from '.'; +import { Address } from './Address'; export type AddressNumberRecord = Record; export type AddressBooleanRecord = Record; From 3808b40916e8b375efef30ddf0616558e5fc18eb Mon Sep 17 00:00:00 2001 From: Josh Miller <31908788+truemiller@users.noreply.github.com> Date: Wed, 10 Jul 2024 09:55:21 +0100 Subject: [PATCH 17/17] Update frontend/context/StoreProvider.tsx --- frontend/context/StoreProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/context/StoreProvider.tsx b/frontend/context/StoreProvider.tsx index 4c3249ee1..63ce0ed88 100644 --- a/frontend/context/StoreProvider.tsx +++ b/frontend/context/StoreProvider.tsx @@ -21,7 +21,7 @@ export const StoreProvider = ({ children }: PropsWithChildren) => { const setupStore = useCallback(async () => { const tempStore = await store?.store?.(); - if (tempStore) setStoreState(tempStore); + setStoreState(tempStore); ipcRenderer?.on?.('store-changed', (_event: unknown, data: unknown) => { setStoreState(data as ElectronStore); });