Skip to content

Commit

Permalink
Merge pull request #1936 from argentlabs/hotfix/BLO-922-2fa-undeployed
Browse files Browse the repository at this point in the history
BLO-922 fix: 2fa check
  • Loading branch information
simonheys authored Mar 23, 2023
2 parents 4c5abb3 + 47d0699 commit 6ecb5d6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 31 deletions.
20 changes: 0 additions & 20 deletions packages/extension/src/shared/account/details/getImplementation.ts
Original file line number Diff line number Diff line change
@@ -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"

/**
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -74,9 +73,6 @@ export const AccountEditScreen: FC = () => {

const argentShieldEnabled = useArgentShieldEnabled()

const canEnableArgentShieldForAccount =
useCanEnableArgentShieldForAccount(account)

const experimentalAllowChooseAccount = useKeyValueStorage(
settingsStore,
"experimentalAllowChooseAccount",
Expand Down Expand Up @@ -181,7 +177,7 @@ export const AccountEditScreen: FC = () => {
</Center>
</Flex>
<SpacerCell />
{argentShieldEnabled && canEnableArgentShieldForAccount && (
{argentShieldEnabled && (
<>
<ButtonCell
as={Link}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import { FC } from "react"

import { ShieldHeader } from "./ui/ShieldHeader"

export const ShieldAccountNotDeployed: FC = () => {
interface ShieldAccountNotReadyProps {
needsUpgrade?: boolean
}

export const ShieldAccountNotReady: FC<ShieldAccountNotReadyProps> = ({
needsUpgrade = false,
}) => {
const action = needsUpgrade ? "upgrade" : "deploy"
return (
<ShieldHeader
title={"Add Argent Shield"}
subtitle={
"You must deploy this account before Argent Shield can be added"
}
subtitle={`You must ${action} this account before Argent Shield can be added`}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down Expand Up @@ -80,7 +82,9 @@ export const ShieldAccountStartScreen: FC = () => {
<NavigationContainer leftButton={<BarBackButton />} title={"Argent Shield"}>
{isAvailable ? (
account?.needsDeploy ? (
<ShieldAccountNotDeployed />
<ShieldAccountNotReady />
) : needsUpgrade ? (
<ShieldAccountNotReady needsUpgrade />
) : (
<Flex flexDirection={"column"} flex={1} px={4} pb={4}>
{account?.guardian ? (
Expand Down

0 comments on commit 6ecb5d6

Please sign in to comment.