diff --git a/packages/extension/src/shared/account/details/getImplementation.ts b/packages/extension/src/shared/account/details/getImplementation.ts index ebfc84977..a9dace710 100644 --- a/packages/extension/src/shared/account/details/getImplementation.ts +++ b/packages/extension/src/shared/account/details/getImplementation.ts @@ -1,11 +1,8 @@ import { Call, number } from "starknet" -import useSWR from "swr" -import { useArgentShieldEnabled } from "../../../ui/features/shield/useArgentShieldEnabled" import { getMulticallForNetwork } from "../../multicall" import { getNetwork } from "../../network" import { BaseWalletAccount } from "../../wallet.model" -import { getAccountIdentifier } from "../../wallet.service" import { uint256ToHexString } from "./util" /** @@ -41,20 +38,3 @@ export const getIsCurrentImplementation = async ( ) return isCurrentImplementation } - -/** - * Returns result of `getIsCurrentImplementation` if shield is enabled and account is defined - */ - -export const useCanEnableArgentShieldForAccount = ( - account?: BaseWalletAccount, -) => { - const argentShieldEnabled = useArgentShieldEnabled() - const { data: canEnableGuardianForAccount } = useSWR( - argentShieldEnabled && account - ? [getAccountIdentifier(account), "canEnableGuardianForAccount"] - : null, - () => account && getIsCurrentImplementation(account), - ) - return canEnableGuardianForAccount -} diff --git a/packages/extension/src/ui/features/accountEdit/AccountEditScreen.tsx b/packages/extension/src/ui/features/accountEdit/AccountEditScreen.tsx index 15fdc3df6..a42caa06e 100644 --- a/packages/extension/src/ui/features/accountEdit/AccountEditScreen.tsx +++ b/packages/extension/src/ui/features/accountEdit/AccountEditScreen.tsx @@ -12,7 +12,6 @@ import { Center, Flex, Image, Spinner } from "@chakra-ui/react" import { FC, useCallback, useMemo, useState } from "react" import { Link, useNavigate, useParams } from "react-router-dom" -import { useCanEnableArgentShieldForAccount } from "../../../shared/account/details/getImplementation" import { settingsStore } from "../../../shared/settings" import { useKeyValueStorage } from "../../../shared/storage/hooks" import { parseAmount } from "../../../shared/token/amount" @@ -74,9 +73,6 @@ export const AccountEditScreen: FC = () => { const argentShieldEnabled = useArgentShieldEnabled() - const canEnableArgentShieldForAccount = - useCanEnableArgentShieldForAccount(account) - const experimentalAllowChooseAccount = useKeyValueStorage( settingsStore, "experimentalAllowChooseAccount", @@ -181,7 +177,7 @@ export const AccountEditScreen: FC = () => { - {argentShieldEnabled && canEnableArgentShieldForAccount && ( + {argentShieldEnabled && ( <> { +interface ShieldAccountNotReadyProps { + needsUpgrade?: boolean +} + +export const ShieldAccountNotReady: FC = ({ + needsUpgrade = false, +}) => { + const action = needsUpgrade ? "upgrade" : "deploy" return ( ) } diff --git a/packages/extension/src/ui/features/shield/ShieldAccountStartScreen.tsx b/packages/extension/src/ui/features/shield/ShieldAccountStartScreen.tsx index 30dafec09..2e6685163 100644 --- a/packages/extension/src/ui/features/shield/ShieldAccountStartScreen.tsx +++ b/packages/extension/src/ui/features/shield/ShieldAccountStartScreen.tsx @@ -17,10 +17,11 @@ import { } from "../../../shared/shield/register" import { getVerifiedEmailIsExpiredForRemoval } from "../../../shared/shield/verifiedEmail" import { routes } from "../../routes" +import { useCheckUpgradeAvailable } from "../accounts/upgrade.service" import { useCurrentNetwork } from "../networks/useNetworks" import { ShieldAccountActivate } from "./ShieldAccountActivate" import { ShieldAccountDeactivate } from "./ShieldAccountDeactivate" -import { ShieldAccountNotDeployed } from "./ShieldAccountNotDeployed" +import { ShieldAccountNotReady } from "./ShieldAccountNotDeployed" import { useRouteAccount } from "./useRouteAccount" import { useShieldOnboardingTracking } from "./useShieldTracking" import { useShieldVerifiedEmail } from "./useShieldVerifiedEmail" @@ -34,6 +35,7 @@ export const ShieldAccountStartScreen: FC = () => { const [isLoading, setIsLoading] = useState(false) const toast = useToast() const network = useCurrentNetwork() + const { needsUpgrade = false } = useCheckUpgradeAvailable(account) const { trackSuccess } = useShieldOnboardingTracking({ stepId: "welcome", @@ -80,7 +82,9 @@ export const ShieldAccountStartScreen: FC = () => { } title={"Argent Shield"}> {isAvailable ? ( account?.needsDeploy ? ( - + + ) : needsUpgrade ? ( + ) : ( {account?.guardian ? (