diff --git a/src/renderer/components/Wallet.tsx b/src/renderer/components/Wallet.tsx index 8b2640e..e251890 100644 --- a/src/renderer/components/Wallet.tsx +++ b/src/renderer/components/Wallet.tsx @@ -35,8 +35,6 @@ function Wallet() { const { disconnect: wagmiDisconnect } = useDisconnect(); const { nativeTokenBalance, flockTokenBalance } = useContext(WalletContext); const [privateKey, setPrivateKey] = useState(''); - const [userEmail, setUserEmail] = useState(''); - const [showEmailImport, setShowEmailImport] = useState(false); const handleConnect = async () => { setIsWalletOpen(false); @@ -53,66 +51,9 @@ function Wallet() { await connectAsync({ connector: connectors[1], }); - } catch (error) { - toast.error('Invalid private key'); - } - }; - - const loadEmail = async () => { - try { - const res = await fetch( - `https://us-central1-flock-demo-design.cloudfunctions.net/getEmailFromDB?wallet=${address}`, - { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - } - ); - - const { email } = await res.json(); - if (email) { - setUserEmail(email); - setShowWalletImport(false); - } else { - setShowWalletImport(false); - setShowEmailImport(true); - } - } catch (error) { setShowWalletImport(false); - } - }; - - const importEmail = async () => { - try { - const response = await fetch( - 'https://us-central1-flock-demo-design.cloudfunctions.net/postEmailToDB', - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - email: userEmail, - wallet: address, - }), - } - ); - if (response.ok) { - setShowEmailImport(false); - } else { - const data = await response.json(); - console.log(data); - if ( - data.error.includes( - 'Unique constraint failed on the fields: (`email`)' - ) - ) { - toast.error('Email already exists'); - } - } } catch (error) { - console.error('Error importing email:', error); + toast.error('Invalid private key'); } }; @@ -135,31 +76,6 @@ function Wallet() { oAuthAccessToken?: string; } - const loadUserInfo = async () => { - try { - if (pendingConnector?.id === 'web3auth') { - const user = await web3AuthInstance.getUserInfo(); - - await fetch( - 'https://us-central1-flock-demo-design.cloudfunctions.net/postEmailToDB', - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${user.idToken}`, - }, - body: JSON.stringify({ - email: user.email, - wallet: address, - }), - } - ); - } - } catch (error) { - console.error('Error loading user info:', error); - } - }; - const { data: dataTransfer, writeAsync: writeAsyncApprove } = useContractWrite({ address: FLOCK_ADDRESS as `0x${string}`, @@ -193,13 +109,6 @@ function Wallet() { } }, [isSuccessTransfer]); - useEffect(() => { - if (address) { - loadEmail(); - loadUserInfo(); - } - }, [address, isSuccess]); - if (showWalletSettings) { return ( setShowWalletSettings(false)} full> @@ -335,48 +244,6 @@ function Wallet() { ); } - if (showEmailImport) { - return ( - setShowEmailImport(false)} full> - - Enter your email - This email will be used for claiming OAT - setUserEmail(event.target.value)} - /> - -