Skip to content

Commit

Permalink
Feature/confusables (MetaMask#2464)
Browse files Browse the repository at this point in the history
* Add confusable warning to SendTo

* Highlight confusable characters

* Replace zeroWidthPoints characters with ?

* Add some notes

* Add confusable highlight to confirm screen

* Update checkZeroWidth function

* Add exclamation mark to Confirm

* Add handleConfusables method

* Move this into one spot

* Add hasZeroWidthPoints

* Rename T to Texts

* Use reduce

* Add homoglyphic tests

* Add Modal for confusable on confirm screen

* Update snapshot

* Use Swaps InfoModal

* Increase lineheight on modals

* Only display warning if address is not in addressBook

* Update snapshot

* Make texts lowercase

* Remove unused state

* Add patch

* Display as warning in yelllow when not zero width

* Only display confusables warnings if the user is not in addressbook

* Add optional chaining for addressBook

Co-authored-by: andrepimenta <andrepimenta7@gmail.com>
  • Loading branch information
rickycodes and andrepimenta authored Apr 29, 2021
1 parent 4bfc546 commit 2b571c5
Show file tree
Hide file tree
Showing 24 changed files with 407 additions and 34 deletions.
13 changes: 12 additions & 1 deletion app/components/Base/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ const style = StyleSheet.create({
right: {
textAlign: 'right'
},
bold: fontStyles.bold,
red: {
color: colors.red
},
black: {
color: colors.black
},
bold: fontStyles.bold,
blue: {
color: colors.blue
},
Expand Down Expand Up @@ -66,6 +69,7 @@ const Text = ({
green,
black,
blue,
red,
primary,
small,
upper,
Expand All @@ -87,6 +91,8 @@ const Text = ({
green && style.green,
black && style.black,
blue && style.blue,
red && style.red,
black && style.black,
primary && style.primary,
disclaimer && [style.small, style.disclaimer],
small && style.small,
Expand All @@ -110,6 +116,7 @@ Text.defaultProps = {
green: false,
black: false,
blue: false,
red: false,
primary: false,
disclaimer: false,
modal: false,
Expand Down Expand Up @@ -150,6 +157,10 @@ Text.propTypes = {
* Makes text blue
*/
blue: PropTypes.bool,
/**
* Makes text red
*/
red: PropTypes.bool,
/**
* Makes text fontPrimary color
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -55,6 +56,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -83,6 +85,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand All @@ -109,6 +112,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand All @@ -132,6 +136,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
noMargin={true}
onPress={[Function]}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -174,6 +179,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={false}
small={true}
Expand All @@ -199,6 +205,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={true}
small={false}
Expand Down Expand Up @@ -232,6 +239,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={false}
small={true}
Expand All @@ -257,6 +265,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={true}
small={false}
Expand Down Expand Up @@ -289,6 +298,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={false}
small={true}
Expand All @@ -314,6 +324,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={true}
red={false}
reset={false}
right={true}
small={false}
Expand Down Expand Up @@ -350,6 +361,7 @@ exports[`AddCustomNetwork should render correctly 1`] = `
modal={false}
noMargin={true}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ exports[`AssetActionButtons should render correctly 1`] = `
modal={false}
numberOfLines={1}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -97,6 +98,7 @@ exports[`AssetActionButtons should render type add correctly 1`] = `
modal={false}
numberOfLines={1}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -154,6 +156,7 @@ exports[`AssetActionButtons should render type information correctly 1`] = `
modal={false}
numberOfLines={1}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -211,6 +214,7 @@ exports[`AssetActionButtons should render type receive correctly 1`] = `
modal={false}
numberOfLines={1}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -268,6 +272,7 @@ exports[`AssetActionButtons should render type send correctly 1`] = `
modal={false}
numberOfLines={1}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -325,6 +330,7 @@ exports[`AssetActionButtons should render type swap correctly 1`] = `
modal={false}
numberOfLines={1}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ exports[`CustomNonceModal should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -150,6 +151,7 @@ exports[`CustomNonceModal should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand All @@ -176,6 +178,7 @@ exports[`CustomNonceModal should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -280,6 +283,7 @@ exports[`CustomNonceModal should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -309,6 +313,7 @@ exports[`CustomNonceModal should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -336,6 +341,7 @@ exports[`CustomNonceModal should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports[`ReceiveRequest should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -70,6 +71,7 @@ exports[`ReceiveRequest should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -104,6 +106,7 @@ exports[`ReceiveRequest should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand All @@ -126,6 +129,7 @@ exports[`ReceiveRequest should render correctly 1`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={true}
Expand Down
9 changes: 6 additions & 3 deletions app/components/UI/Swaps/QuotesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ const styles = StyleSheet.create({
termsButton: {
marginTop: 10,
marginBottom: 6
},
text: {
lineHeight: 20
}
});

Expand Down Expand Up @@ -1303,20 +1306,20 @@ function SwapsQuotesView({
isVisible={isUpdateModalVisible}
toggleModal={toggleUpdateModal}
title={strings('swaps.quotes_update_often')}
body={<Text>{strings('swaps.quotes_update_often_text')}</Text>}
body={<Text style={styles.text}>{strings('swaps.quotes_update_often_text')}</Text>}
/>
<InfoModal
isVisible={isPriceDifferenceModalVisible}
toggleModal={togglePriceDifferenceModal}
title={strings('swaps.price_difference_title')}
body={<Text>{strings('swaps.price_difference_body')}</Text>}
body={<Text style={styles.text}>{strings('swaps.price_difference_body')}</Text>}
/>
<InfoModal
isVisible={isFeeModalVisible}
toggleModal={toggleFeeModal}
title={strings('swaps.metamask_swap_fee')}
body={
<Text>
<Text style={styles.text}>
{strings('swaps.fee_text.get_the')} <Text bold>{strings('swaps.fee_text.best_price')}</Text>{' '}
{strings('swaps.fee_text.from_the')} <Text bold>{strings('swaps.fee_text.top_liquidity')}</Text>{' '}
{strings('swaps.fee_text.fee_is_applied', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ exports[`TokenIcon component should Render correctly 3`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -134,6 +135,7 @@ exports[`TokenIcon component should Render correctly 7`] = `
link={false}
modal={false}
primary={false}
red={false}
reset={false}
right={false}
small={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ exports[`TokenSelectButton component should Render correctly 1`] = `
link={false}
modal={false}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -96,6 +97,7 @@ exports[`TokenSelectButton component should Render correctly 2`] = `
link={false}
modal={false}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -158,6 +160,7 @@ exports[`TokenSelectButton component should Render correctly 3`] = `
link={false}
modal={false}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -221,6 +224,7 @@ exports[`TokenSelectButton component should Render correctly 4`] = `
link={false}
modal={false}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand Down Expand Up @@ -286,6 +290,7 @@ exports[`TokenSelectButton component should Render correctly 5`] = `
link={false}
modal={false}
primary={true}
red={false}
reset={false}
right={false}
small={false}
Expand Down
Loading

0 comments on commit 2b571c5

Please sign in to comment.