diff --git a/website/src/tabs/account/NewAccount.jsx b/website/src/tabs/account/NewAccount.jsx index ed18f9570..e7100762a 100644 --- a/website/src/tabs/account/NewAccount.jsx +++ b/website/src/tabs/account/NewAccount.jsx @@ -5,91 +5,85 @@ import { useAleoWASM } from "../../aleo-wasm-hook"; export const NewAccount = () => { const [account, setAccount] = useState(null); - const [loading, setLoading] = useState(false); - const [aleo] = useAleoWASM(); + const [aleo, loading] = useAleoWASM(); + const isExistAccount = account !== null; + const privateKey = isExistAccount ? account.to_string() : ""; + const viewKey = isExistAccount ? account.to_view_key().to_string() : ""; + const address = isExistAccount ? account.to_address().to_string() : ""; - const generateAccount = async () => { - setLoading(true); - setTimeout(() => { - setAccount(new aleo.PrivateKey()); - setLoading(false); - }, 25); + const layout = { labelCol: { span: 3 }, wrapperCol: { span: 21 } }; + + const generateAccount = () => { + // when user are able to see button, it means aleo is already loaded + setAccount(new aleo.PrivateKey()); }; const clear = () => { setAccount(null); }; - const privateKey = () => (account !== null ? account.to_string() : ""); - const viewKey = () => - account !== null ? account.to_view_key().to_string() : ""; - const address = () => - account !== null ? account.to_address().to_string() : ""; - - const layout = { labelCol: { span: 3 }, wrapperCol: { span: 21 } }; - - if (aleo !== null) { - return ( - - - - - - - - - - {account && ( -
- - - } - disabled - /> - - - } - disabled - /> - - - } - disabled - /> - - - )} -
- ); - } else { + if (loading) { return (

Loading...

); } + + return ( + + + + + + + + + + {account && ( +
+ + + } + disabled + /> + + + } + disabled + /> + + + } + disabled + /> + + + )} +
+ ); };