diff --git a/src/pages/CreateWallet.tsx b/src/pages/CreateWallet.tsx index efb2d29..ba41667 100644 --- a/src/pages/CreateWallet.tsx +++ b/src/pages/CreateWallet.tsx @@ -18,31 +18,36 @@ export enum Tabs { export default function CreateWallet () { const [ tab, setTab ] = useState(Tabs.Landing) - const [ mnemonic, setMnemonic ] = useState() + const [ sensitive, setSensitive ] = useState("") + const [ isImport, setIsImport ] = useState(false) const navigate = useNavigate() const kaspa = useKaspa() return ( { - [ Tabs.Landing ]: { setTab(tab) }} />, - [ Tabs.Intro ]: { setTab(Tabs.Password) }} />, - [ Tabs.Import ]: { - setMnemonic(mnemonic) - setTab(Tabs.Password) + [ Tabs.Landing ]: { + if (tab === Tabs.Password) setIsImport(true) + setTab(tab) }} />, + [ Tabs.Intro ]: { setTab(Tabs.Password) }} />, [ Tabs.Password ]: { - if (mnemonic) { - await kaspa.request('wallet:import', [ mnemonic, password ]) - navigate('/') + if (isImport) { + setSensitive(password) + setTab(Tabs.Import) } else { - const generatedMnemonic = await kaspa.request('wallet:create', [ password ]) - - setMnemonic(generatedMnemonic) + const mnemonic = await kaspa.request('wallet:create', [ password ]) + + setSensitive(mnemonic) setTab(Tabs.Create) } }} />, - [ Tabs.Create ]: { navigate('/') }} /> + [ Tabs.Import ]: { + await kaspa.request('wallet:import', [ mnemonic, sensitive ]) // TODO: in case of error, tell its an invalid mnemonics + + navigate('/wallet') + }} />, + [ Tabs.Create ]: { navigate('/wallet') }} /> }[tab] ) } diff --git a/src/pages/CreateWallet/Import.tsx b/src/pages/CreateWallet/Import.tsx index 213efdc..53dce42 100644 --- a/src/pages/CreateWallet/Import.tsx +++ b/src/pages/CreateWallet/Import.tsx @@ -29,7 +29,7 @@ export default function Import ({ onMnemonicsSubmit }: { onMnemonicsSubmit(mnemonic) }} > - {i18n.getMessage('importWallet')} + Import diff --git a/src/pages/CreateWallet/Landing.tsx b/src/pages/CreateWallet/Landing.tsx index e3da789..692acda 100644 --- a/src/pages/CreateWallet/Landing.tsx +++ b/src/pages/CreateWallet/Landing.tsx @@ -34,7 +34,7 @@ export default function Landing({ forward }: {