From 355e698744dcba2d4c0e74c57c6a8282fae41125 Mon Sep 17 00:00:00 2001 From: francocarballar Date: Thu, 27 Jul 2023 13:03:38 -0300 Subject: [PATCH 1/7] Update .gitignore file --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5248935..aee1339 100644 --- a/.gitignore +++ b/.gitignore @@ -116,4 +116,7 @@ yarn.lock public/sw.js public/sw.js.map public/workbox-*.js -public/workbox-*.js.map \ No newline at end of file +public/workbox-*.js.map + +# Wallet +test-seed-phrase.txt \ No newline at end of file From be2444d294d52443f7a4c44c259283dbd672f275 Mon Sep 17 00:00:00 2001 From: francocarballar Date: Thu, 27 Jul 2023 13:05:04 -0300 Subject: [PATCH 2/7] Bug: update the logic of the input that takes the address to which the cryptocurrency is to be sent --- src/components/FullModal/Send/index.tsx | 35 +++++++++++++-- src/components/InputWithButton/index.jsx | 55 +++++++++++++++--------- 2 files changed, 67 insertions(+), 23 deletions(-) diff --git a/src/components/FullModal/Send/index.tsx b/src/components/FullModal/Send/index.tsx index 18db9d5..038617d 100644 --- a/src/components/FullModal/Send/index.tsx +++ b/src/components/FullModal/Send/index.tsx @@ -50,6 +50,7 @@ const Component = ({ onClose }) => { // Price const [price, setPrice] = useState({ eth: 0, dai: 0 }); const [gasPrice, setGasPrice] = useState(); + const [addressIsValid, setAddressIsValid] = useState(false); useEffect(() => { // setLoading(true); @@ -81,6 +82,11 @@ const Component = ({ onClose }) => { !gasPrice && !price.eth && !price.dai && init(); }, [gasPrice, totalTokensUSD]); + useEffect(() => { + setToAddress(null) + setAddressIsValid(false) + }, []); + // Send transaction const handleSendTransaction = async () => { setLoading(true); @@ -167,6 +173,28 @@ const Component = ({ onClose }) => { setMount(null); }; + const continueToken = () => { + if (toAddress === null || toAddress === '') { + toast({ + description: 'El campo de texto está vacío', + status: 'warning', + position: 'top', + duration: '1500' + }); + } + + if (!addressIsValid && toAddress !== null && toAddress !== '') { + toast({ + description: 'No existe la dirección de esta wallet', + status: 'error', + position: 'top', + duration: '1500' + }); + } + + if (toAddress && addressIsValid) setStep('token') + } + return ( <> @@ -181,7 +209,8 @@ const Component = ({ onClose }) => { value={toAddress} onChange={setToAddress} onClick={setToAddress} - // autoFocus + addressIsValid={addressIsValid} + setAddressIsValid={setAddressIsValid} /> @@ -324,7 +353,7 @@ const Component = ({ onClose }) => { Cancelar {step === 'address' && ( - )} @@ -336,7 +365,7 @@ const Component = ({ onClose }) => { {step === 'amount' && ( diff --git a/src/components/InputWithButton/index.jsx b/src/components/InputWithButton/index.jsx index 1c83471..ae23090 100644 --- a/src/components/InputWithButton/index.jsx +++ b/src/components/InputWithButton/index.jsx @@ -7,7 +7,7 @@ import Input from 'src/components/Shared/Input'; import useTruncatedAddress from 'src/hooks/useTruncatedAddress'; const Component = (props) => { - const { placeholder, value, onChange, onClick } = props; + const { placeholder, value, onChange, onClick, addressIsValid, setAddressIsValid } = props; // Chakra const toast = useToast(); @@ -15,14 +15,23 @@ const Component = (props) => { const handlePasteAddress = async () => { try { const text = await navigator.clipboard.readText(); - const addressIsValid = ethers.utils.isAddress(text); + const isValid = ethers.utils.isAddress(text); + setAddressIsValid(isValid); - if (addressIsValid) { + if (isValid) { onClick(text); + toast({ + description: 'Perfecto', + status: 'success', + position: 'top', + duration: '1500' + }); } else { toast({ - description: 'La address parece ser incorrecta.', - status: 'warning', + description: 'No existe la dirección de esta wallet', + status: 'error', + position: 'top', + duration: '1500' }); } } catch (err) { @@ -30,19 +39,15 @@ const Component = (props) => { } }; - const handleValidateAddress = (value) => { - const addressIsValid = ethers.utils.isAddress(value); - if (addressIsValid) { - onChange(value); - } - // else { - // toast({ - // description: 'La address parece ser incorrecta.', - // status: 'warning', - // }); - // } + const handleValidateAddress = ({ target: { value } }) => { + const isValid = ethers.utils.isAddress(value); + setAddressIsValid(isValid); + onChange(value); }; + const truncated = addressIsValid && value !== null && value !== '' + const inputValue = truncated ? useTruncatedAddress(value) : value + const style = { position: 'relative', display: 'flex', @@ -52,21 +57,31 @@ const Component = (props) => { const buttonBoxStyle = { position: 'absolute', zIndex: 1, - right: '20px', - top: 0, + right: '2px', + top: '2px', display: 'flex', height: '100%', alignItems: 'center', + + padding: '5px 20px', + + minWidth: 'fit-content', + width: '80px', + maxHeight: '56px', + + backgroundColor: '#1B1B1B', + borderRadius: '0px 10px 10px 0px' }; return ( handleValidateAddress(e.target.value)} + value={inputValue} + onChange={handleValidateAddress} autoFocus={!value} + style={{ paddingRight: '100px' }} />