diff --git a/packages/app-extension/src/components/Unlocked/Settings/AddConnectWallet/CreateMenu.tsx b/packages/app-extension/src/components/Unlocked/Settings/AddConnectWallet/CreateMenu.tsx index 172d78a39..4d2063cbd 100644 --- a/packages/app-extension/src/components/Unlocked/Settings/AddConnectWallet/CreateMenu.tsx +++ b/packages/app-extension/src/components/Unlocked/Settings/AddConnectWallet/CreateMenu.tsx @@ -2,42 +2,31 @@ import { useEffect, useState } from "react"; import type { Blockchain } from "@coral-xyz/common"; import { getAddMessage, - openConnectHardware, UI_RPC_METHOD_BLOCKCHAIN_KEYRINGS_ADD, UI_RPC_METHOD_FIND_WALLET_DESCRIPTOR, UI_RPC_METHOD_KEYRING_DERIVE_WALLET, UI_RPC_METHOD_KEYRING_IMPORT_WALLET, UI_RPC_METHOD_KEYRING_STORE_READ_ALL_PUBKEYS, } from "@coral-xyz/common"; -import { - HardwareIcon, - MnemonicIcon, - PushDetail, -} from "@coral-xyz/react-common"; import { useBackgroundClient, useEnabledBlockchains, useKeyringHasMnemonic, useRpcRequests, - useUser, } from "@coral-xyz/recoil"; -import { Box } from "@mui/material"; -import { Header, SubtextParagraph } from "../../../common"; import { useDrawerContext, WithMiniDrawer, } from "../../../common/Layout/Drawer"; import { useNavigation } from "../../../common/Layout/NavStack"; -import { SettingsList } from "../../../common/Settings/List"; import { ConfirmCreateWallet } from "./"; -export function CreateMenu({ blockchain }: { blockchain: Blockchain }) { +export function CreateMenuAction({ blockchain }: { blockchain: Blockchain }) { const nav = useNavigation(); const background = useBackgroundClient(); const hasMnemonic = useKeyringHasMnemonic(); - const user = useUser(); const enabledBlockchains = useEnabledBlockchains(); const keyringExists = enabledBlockchains.includes(blockchain); const { close: closeParentDrawer } = useDrawerContext(); @@ -51,7 +40,6 @@ export function CreateMenu({ blockchain }: { blockchain: Blockchain }) { // adding then additional logic is required to select the account index of // the first derivation path added const [hasHdPublicKeys, setHasHdPublicKeys] = useState(false); - const [hasLedgerPublicKeys, setHasLedgerPublicKeys] = useState(false); useEffect(() => { (async () => { @@ -62,21 +50,12 @@ export function CreateMenu({ blockchain }: { blockchain: Blockchain }) { const blockchainPublicKeys = publicKeys[blockchain]; if (blockchainPublicKeys) { setHasHdPublicKeys(blockchainPublicKeys.hdPublicKeys.length > 0); - setHasLedgerPublicKeys( - blockchainPublicKeys.ledgerPublicKeys.length > 0 - ); } + + createNewWithPhrase(); })(); }, [background, blockchain]); - useEffect(() => { - const prevTitle = nav.title; - nav.setOptions({ headerTitle: "" }); - return () => { - nav.setOptions({ headerTitle: prevTitle }); - }; - }, [nav]); - const createNewWithPhrase = async () => { // Mnemonic based keyring. This is the simple case because we don't // need to prompt for the user to open their Ledger app to get the @@ -146,65 +125,26 @@ export function CreateMenu({ blockchain }: { blockchain: Blockchain }) { } }; - const createMenu = { - "Secret recovery phrase": { - onClick: createNewWithPhrase, - icon: (props: any) => , - detailIcon: , - }, - "Hardware wallet": { - onClick: () => { - openConnectHardware( - blockchain, - // `create` gets a default account index for derivations - // where no wallets are used, `derive` just gets the next - // wallet in line given the existing derivation paths - keyringExists && hasLedgerPublicKeys ? "derive" : "create" - ); - window.close(); - }, - icon: (props: any) => , - detailIcon: , - }, - }; - return ( - <> -
- -
- - Add a new wallet for @{user.username} using one of the following: - - - -
- - { + { setOpenDrawer(false); closeParentDrawer(); }} - isLoading={loading} + isLoading={loading} /> - - + ); } diff --git a/packages/app-extension/src/components/Unlocked/Settings/AddConnectWallet/index.tsx b/packages/app-extension/src/components/Unlocked/Settings/AddConnectWallet/index.tsx index d4331d551..dcdd8c7e7 100644 --- a/packages/app-extension/src/components/Unlocked/Settings/AddConnectWallet/index.tsx +++ b/packages/app-extension/src/components/Unlocked/Settings/AddConnectWallet/index.tsx @@ -1,4 +1,4 @@ -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import type { Blockchain } from "@coral-xyz/common"; import { openAddUserAccount, openConnectHardware } from "@coral-xyz/common"; import { @@ -23,6 +23,8 @@ import { useNavigation } from "../../../common/Layout/NavStack"; import { SettingsList } from "../../../common/Settings/List"; import { WalletListItem } from "../YourAccount/EditWallets"; +import { CreateMenuAction } from "./CreateMenu"; + export function AddConnectPreview() { const nav = useNavigation(); const user = useUser(); @@ -144,10 +146,11 @@ export function AddConnectWalletMenu({ export function AddWalletMenu({ blockchain }: { blockchain: Blockchain }) { const navigation = useNavigation(); const user = useUser(); + const [showCreateMenuAction, setShowCreateMenuAction] = useState(false); const createOrImportMenu = { "Create a new wallet": { - onClick: () => navigation.push("create-wallet", { blockchain }), + onClick: () => setShowCreateMenuAction(true), icon: (props: any) => , detailIcon: , }, @@ -159,21 +162,24 @@ export function AddWalletMenu({ blockchain }: { blockchain: Blockchain }) { }; return ( -
- -
- - Add a new wallet for @{user.username} on Backpack. - - - -
+ <> +
+ +
+ + Add a new wallet for @{user.username} on Backpack. + + + +
+ {showCreateMenuAction ? : null} + ); } diff --git a/packages/app-extension/src/components/Unlocked/Settings/SettingsNavStackDrawer.tsx b/packages/app-extension/src/components/Unlocked/Settings/SettingsNavStackDrawer.tsx index 7b2808ec1..5766d4c1f 100644 --- a/packages/app-extension/src/components/Unlocked/Settings/SettingsNavStackDrawer.tsx +++ b/packages/app-extension/src/components/Unlocked/Settings/SettingsNavStackDrawer.tsx @@ -12,8 +12,7 @@ import { ResetWelcome } from "../../Locked/Reset/ResetWelcome"; import { ContactRequests, Contacts } from "../Messages/Contacts"; import { Requests } from "../Messages/Requests"; -import { CreateMenu } from "./AddConnectWallet/CreateMenu"; -import { CreateMnemonic } from "./AddConnectWallet/CreateMnemonic" +import { CreateMnemonic } from "./AddConnectWallet/CreateMnemonic"; import { ImportMenu } from "./AddConnectWallet/ImportMenu"; import { ImportMnemonic } from "./AddConnectWallet/ImportMnemonic"; import { ImportSecretKey } from "./AddConnectWallet/ImportSecretKey"; @@ -70,10 +69,6 @@ export function SettingsNavStackDrawer({ name="add-connect-wallet" component={(props: any) => } /> - } - /> } diff --git a/packages/app-extension/src/components/common/WalletList.tsx b/packages/app-extension/src/components/common/WalletList.tsx index f6929f547..c04b87d13 100644 --- a/packages/app-extension/src/components/common/WalletList.tsx +++ b/packages/app-extension/src/components/common/WalletList.tsx @@ -43,7 +43,6 @@ import { AddConnectPreview, AddConnectWalletMenu, } from "../Unlocked/Settings/AddConnectWallet"; -import { CreateMenu } from "../Unlocked/Settings/AddConnectWallet/CreateMenu"; import { CreateMnemonic } from "../Unlocked/Settings/AddConnectWallet/CreateMnemonic"; import { ImportMenu } from "../Unlocked/Settings/AddConnectWallet/ImportMenu"; import { ImportMnemonic } from "../Unlocked/Settings/AddConnectWallet/ImportMnemonic"; @@ -248,10 +247,6 @@ function WalletNavStack({ name="edit-wallets-blockchain-selector" component={(props: any) => } /> - } - /> }