Skip to content

Commit

Permalink
fix: rework 2fa check for undeployed + upgradable accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
simonheys committed Mar 22, 2023
2 parents 4449139 + 5d8feae commit 01a5066
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 57 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*"],
"version": "5.3.11",
"version": "5.3.12",
"npmClient": "yarn",
"useWorkspaces": true
}
6 changes: 3 additions & 3 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent-x/dapp",
"version": "5.3.11",
"version": "5.3.12",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -10,8 +10,8 @@
"lint": "next lint"
},
"dependencies": {
"@argent/get-starknet": "^5.3.11",
"@argent/x-sessions": "^5.3.11",
"@argent/get-starknet": "^5.3.12",
"@argent/x-sessions": "^5.3.12",
"ethers": "^5.5.1",
"next": "^13.0.0",
"react": "^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/manifest/v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/chrome-manifest.json",
"name": "Argent X",
"description": "The security of Ethereum with the scale of StarkNet",
"version": "5.3.11",
"version": "5.3.12",
"manifest_version": 2,
"browser_action": {
"default_icon": {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/manifest/v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/chrome-manifest.json",
"name": "Argent X",
"description": "The security of Ethereum with the scale of StarkNet",
"version": "5.3.11",
"version": "5.3.12",
"manifest_version": 3,
"action": {
"default_icon": {
Expand Down
16 changes: 8 additions & 8 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent-x/extension",
"version": "5.3.11",
"version": "5.3.12",
"main": "index.js",
"license": "MIT",
"devDependencies": {
Expand Down Expand Up @@ -74,13 +74,13 @@
"push-release-branch": "git push --set-upstream origin release/v$npm_package_version --follow-tags"
},
"dependencies": {
"@argent/guardian": "^5.3.11",
"@argent/stack-router": "^5.3.11",
"@argent/ui": "^5.3.11",
"@argent/x-multicall": "^5.3.11",
"@argent/x-sessions": "^5.3.11",
"@argent/x-swap": "^5.3.11",
"@argent/x-window": "^5.3.11",
"@argent/guardian": "^5.3.12",
"@argent/stack-router": "^5.3.12",
"@argent/ui": "^5.3.12",
"@argent/x-multicall": "^5.3.12",
"@argent/x-sessions": "^5.3.12",
"@argent/x-swap": "^5.3.12",
"@argent/x-window": "^5.3.12",
"@chakra-ui/icons": "^2.0.15",
"@chakra-ui/react": "2.5.1",
"@extend-chrome/messages": "^1.2.2",
Expand Down
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
2 changes: 1 addition & 1 deletion packages/get-starknet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent/get-starknet",
"version": "5.3.11",
"version": "5.3.12",
"repository": "github:argentlabs/argent-x",
"private": false,
"main": "dist/",
Expand Down
2 changes: 1 addition & 1 deletion packages/guardian/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent/guardian",
"version": "5.3.11",
"version": "5.3.12",
"license": "MIT",
"private": false,
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/multicall/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent/x-multicall",
"version": "5.3.11",
"version": "5.3.12",
"description": "A library for batched calls to Starknet smart contracts",
"keywords": [
"starknet",
Expand Down
2 changes: 1 addition & 1 deletion packages/sessions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent/x-sessions",
"version": "5.3.11",
"version": "5.3.12",
"description": "Manage sessions for Argent X wallets",
"keywords": [
"starknet",
Expand Down
4 changes: 2 additions & 2 deletions packages/stack-router/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent/stack-router",
"version": "5.3.11",
"version": "5.3.12",
"license": "MIT",
"private": true,
"files": [
Expand Down Expand Up @@ -32,7 +32,7 @@
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@argent/ui": "^5.3.11",
"@argent/ui": "^5.3.12",
"@types/lodash-es": "^4.17.6",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@argent-x/storybook",
"version": "5.3.11",
"version": "5.3.12",
"private": true,
"devDependencies": {
"@argent-x/extension": "^5.3.11",
"@argent/ui": "^5.3.11",
"@argent-x/extension": "^5.3.12",
"@argent/ui": "^5.3.12",
"@babel/core": "^7.18.5",
"@chakra-ui/storybook-addon": "^4.0.12",
"@storybook/addon-actions": "^6.5.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/swap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent/x-swap",
"version": "5.3.11",
"version": "5.3.12",
"license": "MIT",
"private": true,
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent/ui",
"version": "5.3.11",
"version": "5.3.12",
"license": "MIT",
"private": true,
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/window/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@argent/x-window",
"version": "5.3.11",
"version": "5.3.12",
"license": "MIT",
"files": [
"dist"
Expand Down

0 comments on commit 01a5066

Please sign in to comment.