Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
armaniferrante committed Mar 29, 2023
1 parent e168e8e commit e29e586
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ export function CreateOrImportMnemonic({
},
"Import recovery phrase": {
onClick: () =>
nav.push("import-from-mnemonic", {
nav.push("set-and-sync-mnemonic", {
blockchain,
keyringExists,
forceSetMnemonic: true,
inputMnemonic: true,
}),
icon: (props: any) => <ImportedIcon {...props} />,
detailIcon: <PushDetail />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,42 @@ import { useNavigation } from "../../../common/Layout/NavStack";

import { ConfirmCreateWallet } from "./";

// WARNING: this will force set the mnemonic. Only use this if no mnemonic
// exists.
export function ImportMnemonicAutomatic({
blockchain,
keyringExists,
}: {
blockchain: Blockchain;
keyringExists: boolean;
}) {
const background = useBackgroundClient();
const dehydratedWallets = useDehydratedWallets();

const onSync = async (mnemonic: string) => {
await background.request({
method: UI_RPC_METHOD_KEYRING_SET_MNEMONIC,
params: [mnemonic],
});
if (dehydratedWallets.length > 0) {
await background.request({
method: UI_RPC_METHOD_KEYRING_STORE_MNEMONIC_SYNC,
params: [dehydratedWallets],
});
}
};

return (
<MnemonicInput
key="MnemonicInput"
buttonLabel="Next"
onNext={async (mnemonic) => {
onSync(mnemonic);
}}
/>
);
}

export function ImportMnemonic({
blockchain,
keyringExists,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import {
CreateOrImportMnemonic,
} from "./AddConnectWallet/CreateMnemonic";
import { ImportMenu } from "./AddConnectWallet/ImportMenu";
import { ImportMnemonic } from "./AddConnectWallet/ImportMnemonic";
import {
ImportMnemonic,
ImportMnemonicAutomatic,
} from "./AddConnectWallet/ImportMnemonic";
import { ImportSecretKey } from "./AddConnectWallet/ImportSecretKey";
import { PreferencesAutoLock } from "./Preferences/AutoLock";
import { PreferencesEthereum } from "./Preferences/Ethereum";
Expand Down Expand Up @@ -88,6 +91,10 @@ export function SettingsNavStackDrawer({
name="import-from-mnemonic"
component={(props: any) => <ImportMnemonic {...props} />}
/>
<NavStackScreen
name="set-and-sync-mnemonic"
component={(props: any) => <ImportMnemonicAutomatic {...props} />}
/>
<NavStackScreen
name="import-from-secret-key"
component={(props: any) => <ImportSecretKey {...props} />}
Expand Down

0 comments on commit e29e586

Please sign in to comment.