Skip to content

Commit

Permalink
Merge pull request #1382 from Giveth/hotfix/verification_duplicate_ad…
Browse files Browse the repository at this point in the history
…dress_check

Hotfix verification duplicate address check
  • Loading branch information
MohammadPCh authored Aug 16, 2022
2 parents 3a9b871 + dfdabdf commit 1e7ce4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/components/views/verification/manageFunds/AddAddressModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,23 @@ const AddAddressModal: FC<IProps> = ({
};

const validateAddress = async (address: string) => {
let actualAddress = address;
if (!library) return 'Web3 is not initialized';
if (isAddressENS(address)) {
if (chainId !== 1) {
return 'Please switch to Mainnet to handle ENS addresses';
}
const actualAddress = await getAddressFromENS(address, library);
const isDuplicate = addresses.some(
item =>
item.address === actualAddress &&
item.networkId === getValues('network')?.value,
);
if (isDuplicate) return 'Address already exists';
return actualAddress ? true : 'Invalid ENS address';
actualAddress = await getAddressFromENS(address, library);
if (!actualAddress) return 'Invalid ENS address';
} else {
return utils.isAddress(address) ? true : 'Invalid address';
if (!utils.isAddress(address)) return 'Invalid address';
}
const isDuplicate = addresses.some(
item =>
item.address.toLowerCase() === actualAddress.toLowerCase() &&
item.networkId === getValues('network')?.value,
);
return isDuplicate ? 'Address already exists' : true;
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const RowContainer = styled.div`
`;

const OptionContainer = styled.div`
cursor: pointer;
display: flex;
align-items: center;
justify-content: space-between;
Expand Down

0 comments on commit 1e7ce4e

Please sign in to comment.