From deb0ad8501cc098d05401295a08a60d9f702259b Mon Sep 17 00:00:00 2001 From: Mati Dastugue Date: Mon, 31 Aug 2020 18:07:12 -0300 Subject: [PATCH 1/9] Bump new onboard.js version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bcb633ca9e..8ed9be47b7 100644 --- a/package.json +++ b/package.json @@ -176,7 +176,7 @@ "async-sema": "^3.1.0", "axios": "0.19.2", "bignumber.js": "9.0.0", - "bnc-onboard": "1.11.1", + "bnc-onboard": "1.12.0", "classnames": "^2.2.6", "concurrently": "^5.2.0", "connected-react-router": "6.8.0", From fe975086c72cd94995aed2003dc1f40119300a45 Mon Sep 17 00:00:00 2001 From: Mati Dastugue Date: Wed, 16 Sep 2020 21:15:20 -0300 Subject: [PATCH 2/9] Fix ENS names --- .../SendModal/screens/AddressBookInput/index.tsx | 10 +++++++--- .../SendModal/screens/SendCollectible/index.tsx | 2 ++ .../Balances/SendModal/screens/SendFunds/index.tsx | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx index 6079daefc4..b69c082e64 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -22,7 +22,9 @@ export interface AddressBookProps { pristine: boolean recipientAddress?: string setSelectedEntry: ( - entry: { address?: string; name?: string } | React.SetStateAction<{ address: string; name: string }>, + entry: + | { address?: string; name?: string; ensToAddress?: string } + | React.SetStateAction<{ address: string; name: string; ensToAddress: string }>, ) => void setIsValidAddress: (valid?: boolean) => void } @@ -84,6 +86,7 @@ const AddressBookInput = ({ const onAddressInputChanged = async (value: string): Promise => { const normalizedAddress = trimSpaces(value) + const isENSDomain = isValidEnsName(normalizedAddress) setInputAddValue(normalizedAddress) let resolvedAddress = normalizedAddress let isValidText @@ -94,10 +97,11 @@ const AddressBookInput = ({ return } if (normalizedAddress) { - if (isValidEnsName(normalizedAddress)) { + if (isENSDomain) { resolvedAddress = await getAddressFromENS(normalizedAddress) setInputAddValue(resolvedAddress) } + isValidText = mustBeEthereumAddress(resolvedAddress) if (isCustomTx && isValidText === undefined) { isValidText = await mustBeEthereumContractAddress(resolvedAddress) @@ -115,7 +119,7 @@ const AddressBookInput = ({ }) setADBKList(filteredADBK) if (!isValidText) { - setSelectedEntry({ address: normalizedAddress }) + setSelectedEntry({ address: normalizedAddress, ensToAddress: isENSDomain ? resolvedAddress : '' }) } } setIsValidForm(isValidText === undefined) diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx index 637085a707..dfcc27ea59 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx @@ -51,6 +51,7 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel const [selectedEntry, setSelectedEntry] = useState({ address: recipientAddress || initialValues.recipientAddress, name: '', + ensToAddress: '', }) const [pristine, setPristine] = useState(true) const [isValidAddress, setIsValidAddress] = useState(true) @@ -102,6 +103,7 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel setSelectedEntry({ name: scannedName, address: scannedAddress, + ensToAddress: '', }) closeQrModal() } diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx index 8b78fc79b4..5955bd3d45 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx @@ -55,6 +55,7 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT const [selectedEntry, setSelectedEntry] = useState({ address: recipientAddress || initialValues.recipientAddress, name: '', + ensToAddress: '', }) const [pristine, setPristine] = useState(true) @@ -105,6 +106,7 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT setSelectedEntry({ name: scannedName, address: scannedAddress, + ensToAddress: '', }) closeQrModal() } @@ -165,8 +167,8 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT {selectedEntry.address} - - + + @@ -238,6 +240,7 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT setSelectedEntry({ name: selectedEntry?.name, address: selectedEntry?.address, + ensToAddress: selectedEntry?.ensToAddress, }) mutators.onTokenChange() }} From 9a8a12c7e08998118cfec0a22bacddf8db732673 Mon Sep 17 00:00:00 2001 From: Mati Dastugue Date: Wed, 16 Sep 2020 21:26:13 -0300 Subject: [PATCH 3/9] Fix types --- .../Balances/SendModal/screens/SendFunds/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx index bfe116e36d..98b9716eac 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx @@ -150,7 +150,7 @@ const SendFunds = ({
{ if (e.keyCode !== 9) { - setSelectedEntry({ address: '', name: 'string' }) + setSelectedEntry({ address: '', name: 'string', ensToAddress: '' }) } }} role="listbox" @@ -171,7 +171,7 @@ const SendFunds = ({ setSelectedEntry({ address: '', name: 'string' })} + onClick={() => setSelectedEntry({ address: '', name: 'string', ensToAddress: '' })} weight="bolder" > {selectedEntry.name} @@ -179,7 +179,7 @@ const SendFunds = ({ setSelectedEntry({ address: '', name: 'string' })} + onClick={() => setSelectedEntry({ address: '', name: 'string', ensToAddress: '' })} weight="bolder" > {selectedEntry.address} From d8d91f317e3776bfa23365a70dc416173680bffc Mon Sep 17 00:00:00 2001 From: Mati Dastugue Date: Wed, 16 Sep 2020 21:30:15 -0300 Subject: [PATCH 4/9] Update types on sendcollectible screen --- .../Balances/SendModal/screens/SendCollectible/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx index 969527e31b..6c23f54007 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx @@ -131,7 +131,7 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel
{ if (e.keyCode !== 9) { - setSelectedEntry({ address: '', name: 'string' }) + setSelectedEntry({ address: '', name: 'string', ensToAddress: '' }) } }} role="listbox" @@ -152,7 +152,7 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel setSelectedEntry({ address: '', name: 'string' })} + onClick={() => setSelectedEntry({ address: '', name: 'string', ensToAddress: '' })} weight="bolder" > {selectedEntry.name} @@ -160,7 +160,7 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel setSelectedEntry({ address: '', name: 'string' })} + onClick={() => setSelectedEntry({ address: '', name: 'string', ensToAddress: '' })} weight="bolder" > {selectedEntry.address} From 7c6206e7d1893cecf31f36ccb78a377d7fc8ab2e Mon Sep 17 00:00:00 2001 From: Mati Dastugue Date: Wed, 16 Sep 2020 21:56:24 -0300 Subject: [PATCH 5/9] Fix merge types --- .../Balances/SendModal/screens/AddressBookInput/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx index 1b4d08cc71..fa148c2c17 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -24,7 +24,7 @@ export interface AddressBookProps { setSelectedEntry: ( entry: | { address?: string; name?: string; ensToAddress?: string } - | React.SetStateAction<{ address: string; name: string; ensToAddress: string }> + | React.SetStateAction<{ address?: string; name?: string; ensToAddress?: string }> | null, ) => void setIsValidAddress: (valid: boolean) => void From 15a196c95344fcd033686bcd6c748e9260ea3fd8 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Thu, 17 Sep 2020 15:52:56 +0200 Subject: [PATCH 6/9] Add typo to AddressBookInput component --- .../Balances/SendModal/screens/AddressBookInput/index.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx index fa148c2c17..6cec24dc1d 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -1,5 +1,4 @@ import MuiTextField from '@material-ui/core/TextField' -import { withStyles } from '@material-ui/core/styles' import makeStyles from '@material-ui/core/styles/makeStyles' import Autocomplete from '@material-ui/lab/Autocomplete' import { List } from 'immutable' @@ -74,7 +73,7 @@ const AddressBookInput = ({ recipientAddress, setIsValidAddress, setSelectedEntry, -}: AddressBookProps) => { +}: AddressBookProps): React.ReactElement => { const classes = useStyles() const addressBook = useSelector(getAddressBook) const [isValidForm, setIsValidForm] = useState(true) @@ -242,4 +241,4 @@ const AddressBookInput = ({ ) } -export default withStyles(styles as any)(AddressBookInput) +export default AddressBookInput From 3d98601e4284731325816be4ee0f0ab375d96546 Mon Sep 17 00:00:00 2001 From: Mati Dastugue Date: Thu, 17 Sep 2020 13:43:26 -0300 Subject: [PATCH 7/9] Remove ensToAddress field --- .../SendModal/screens/AddressBookInput/index.tsx | 10 +++++----- .../SendModal/screens/SendCollectible/index.tsx | 8 +++----- .../Balances/SendModal/screens/SendFunds/index.tsx | 13 +++++-------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx index fa148c2c17..f94bd31b0a 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -22,10 +22,7 @@ export interface AddressBookProps { pristine: boolean recipientAddress?: string setSelectedEntry: ( - entry: - | { address?: string; name?: string; ensToAddress?: string } - | React.SetStateAction<{ address?: string; name?: string; ensToAddress?: string }> - | null, + entry: { address?: string; name?: string } | React.SetStateAction<{ address?: string; name? }> | null, ) => void setIsValidAddress: (valid: boolean) => void } @@ -120,7 +117,10 @@ const AddressBookInput = ({ }) setADBKList(filteredADBK) if (!isValidText) { - setSelectedEntry({ address: normalizedAddress, ensToAddress: isENSDomain ? resolvedAddress : '' }) + setSelectedEntry({ + name: isENSDomain ? normalizedAddress : undefined, + address: isENSDomain ? resolvedAddress : '', + }) } } setIsValidForm(isValidText === undefined) diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx index 6c23f54007..55fab95ba5 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendCollectible/index.tsx @@ -51,7 +51,6 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel const [selectedEntry, setSelectedEntry] = useState({ address: recipientAddress || initialValues.recipientAddress, name: '', - ensToAddress: '', }) const [pristine, setPristine] = useState(true) const [isValidAddress, setIsValidAddress] = useState(false) @@ -103,7 +102,6 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel setSelectedEntry({ name: scannedName || '', address: scannedAddress, - ensToAddress: '', }) closeQrModal() } @@ -131,7 +129,7 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel
{ if (e.keyCode !== 9) { - setSelectedEntry({ address: '', name: 'string', ensToAddress: '' }) + setSelectedEntry({ address: '', name: 'string' }) } }} role="listbox" @@ -152,7 +150,7 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel setSelectedEntry({ address: '', name: 'string', ensToAddress: '' })} + onClick={() => setSelectedEntry({ address: '', name: 'string' })} weight="bolder" > {selectedEntry.name} @@ -160,7 +158,7 @@ const SendCollectible = ({ initialValues, onClose, onNext, recipientAddress, sel setSelectedEntry({ address: '', name: 'string', ensToAddress: '' })} + onClick={() => setSelectedEntry({ address: '', name: 'string' })} weight="bolder" > {selectedEntry.address} diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx index 98b9716eac..11b293d8d1 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.tsx @@ -73,7 +73,6 @@ const SendFunds = ({ const [selectedEntry, setSelectedEntry] = useState({ address: recipientAddress || initialValues.recipientAddress, name: '', - ensToAddress: '', }) const [pristine, setPristine] = useState(true) @@ -124,7 +123,6 @@ const SendFunds = ({ setSelectedEntry({ name: scannedName || '', address: scannedAddress, - ensToAddress: '', }) closeQrModal() } @@ -150,7 +148,7 @@ const SendFunds = ({
{ if (e.keyCode !== 9) { - setSelectedEntry({ address: '', name: 'string', ensToAddress: '' }) + setSelectedEntry({ address: '', name: 'string' }) } }} role="listbox" @@ -171,7 +169,7 @@ const SendFunds = ({ setSelectedEntry({ address: '', name: 'string', ensToAddress: '' })} + onClick={() => setSelectedEntry({ address: '', name: 'string' })} weight="bolder" > {selectedEntry.name} @@ -179,14 +177,14 @@ const SendFunds = ({ setSelectedEntry({ address: '', name: 'string', ensToAddress: '' })} + onClick={() => setSelectedEntry({ address: '', name: 'string' })} weight="bolder" > {selectedEntry.address} - - + + @@ -258,7 +256,6 @@ const SendFunds = ({ setSelectedEntry({ name: selectedEntry?.name, address: selectedEntry?.address, - ensToAddress: selectedEntry?.ensToAddress, }) mutators.onTokenChange() }} From 235783e09445ae9594da664ca11f95e883924c33 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 21 Sep 2020 14:35:09 +0200 Subject: [PATCH 8/9] Simplify If logic --- .../SendModal/screens/AddressBookInput/index.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx index 088b63a72a..5faa66b167 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -97,6 +97,10 @@ const AddressBookInput = ({ if (isENSDomain) { resolvedAddress = await getAddressFromENS(normalizedAddress) setInputAddValue(resolvedAddress) + setSelectedEntry({ + name: normalizedAddress, + address: resolvedAddress, + }) } isValidText = mustBeEthereumAddress(resolvedAddress) @@ -115,10 +119,10 @@ const AddressBookInput = ({ ) }) setADBKList(filteredADBK) - if (!isValidText) { + if (!isValidText && !isENSDomain) { setSelectedEntry({ - name: isENSDomain ? normalizedAddress : undefined, - address: isENSDomain ? resolvedAddress : '', + name: undefined, + address: '', }) } } From 474768baf6b8df4bdd5cb617b6f0e6038cfbe84e Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Mon, 21 Sep 2020 14:43:12 +0200 Subject: [PATCH 9/9] Fix error message variable name --- .../screens/AddressBookInput/index.tsx | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx index 5faa66b167..ddd0791daa 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -86,7 +86,7 @@ const AddressBookInput = ({ const isENSDomain = isValidEnsName(normalizedAddress) setInputAddValue(normalizedAddress) let resolvedAddress = normalizedAddress - let isValidText + let addressErrorMessage if (inputTouched && !normalizedAddress) { setIsValidForm(false) setValidationText('Required') @@ -97,15 +97,11 @@ const AddressBookInput = ({ if (isENSDomain) { resolvedAddress = await getAddressFromENS(normalizedAddress) setInputAddValue(resolvedAddress) - setSelectedEntry({ - name: normalizedAddress, - address: resolvedAddress, - }) } - isValidText = mustBeEthereumAddress(resolvedAddress) - if (isCustomTx && isValidText === undefined) { - isValidText = await mustBeEthereumContractAddress(resolvedAddress) + addressErrorMessage = mustBeEthereumAddress(resolvedAddress) + if (isCustomTx && addressErrorMessage === undefined) { + addressErrorMessage = await mustBeEthereumContractAddress(resolvedAddress) } // First removes the entries that are not contracts if the operation is custom tx @@ -119,17 +115,17 @@ const AddressBookInput = ({ ) }) setADBKList(filteredADBK) - if (!isValidText && !isENSDomain) { + if (!addressErrorMessage) { setSelectedEntry({ - name: undefined, - address: '', + name: normalizedAddress, + address: resolvedAddress, }) } } - setIsValidForm(isValidText === undefined) - setValidationText(isValidText) + setIsValidForm(addressErrorMessage === undefined) + setValidationText(addressErrorMessage) fieldMutator(resolvedAddress) - setIsValidAddress(isValidText === undefined) + setIsValidAddress(addressErrorMessage === undefined) } useEffect(() => {