Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLO-922 fix: 2fa check #1936

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ? (
simonheys marked this conversation as resolved.
Show resolved Hide resolved
<ShieldAccountNotReady needsUpgrade />
) : (
<Flex flexDirection={"column"} flex={1} px={4} pb={4}>
{account?.guardian ? (
Expand Down