Skip to content

Commit

Permalink
chore: ethereum address flow changes (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-orion authored Dec 1, 2023
1 parent 8591b30 commit 8d9ac70
Show file tree
Hide file tree
Showing 53 changed files with 198 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import {COLORS} from '@constants/colors';
import {InfoIcon} from '@svg/InfoIcon';
import {t} from '@translations/i18n';
import {replaceString, t, tagRegex} from '@translations/i18n';
import {font} from '@utils/styles';
import React from 'react';
import {StyleProp, StyleSheet, Text, View, ViewStyle} from 'react-native';
Expand All @@ -23,7 +23,15 @@ export const EthereumAddressWarning = ({style}: Props) => {
secondaryColor={COLORS.attention}
/>
<Text style={styles.warningText}>
{t('ethereum_address.enter_address_warning')}
{replaceString(
t('ethereum_address.self_custodial_addr_warning_text'),
tagRegex('bold', false),
(match, index) => (
<Text key={match + index} style={styles.boldStyle}>
{match}
</Text>
),
)}
</Text>
</View>
</View>
Expand All @@ -46,4 +54,7 @@ const styles = StyleSheet.create({
marginStart: rem(12),
flex: 1,
},
boldStyle: {
...font(13, 18, 'bold'),
},
});
35 changes: 25 additions & 10 deletions src/screens/HomeFlow/EthereumAddress/hooks/useGoBackIfAddressSet.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
// SPDX-License-Identifier: ice License 1.0

import {MainNavigationParams} from '@navigation/Main';
import {removeScreenByName} from '@navigation/utils';
import {useNavigation} from '@react-navigation/native';
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
import {unsafeUserSelector} from '@store/modules/Account/selectors';
import {AccountActions} from '@store/modules/Account/actions';
import {
actionPayloadSelector,
isSuccessSelector,
} from '@store/modules/UtilityProcessStatuses/selectors';
import {checkProp} from '@utils/guards';
import {useEffect} from 'react';
import {useSelector} from 'react-redux';

export const useGoBackIfAddressSet = () => {
const user = useSelector(unsafeUserSelector);
const navigation =
useNavigation<NativeStackNavigationProp<MainNavigationParams>>();
export const useGoBackIfAddressSet = ({
isFormSubmitted,
}: {
isFormSubmitted: boolean;
}) => {
const isSuccessUpdate = useSelector(
isSuccessSelector.bind(null, AccountActions.UPDATE_ACCOUNT),
);

const updatePayload = useSelector(
actionPayloadSelector.bind(null, AccountActions.UPDATE_ACCOUNT),
);

useEffect(() => {
if (user.miningBlockchainAccountAddress) {
if (
isFormSubmitted &&
isSuccessUpdate &&
checkProp(updatePayload, 'userInfo') &&
checkProp(updatePayload.userInfo, 'miningBlockchainAccountAddress')
) {
removeScreenByName('EthereumAddress');
}
}, [user.miningBlockchainAccountAddress, navigation]);
}, [isFormSubmitted, isSuccessUpdate, updatePayload]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import {MainNavigationParams} from '@navigation/Main';
import {useNavigation} from '@react-navigation/native';
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
import {useGoBackIfAddressSet} from '@screens/HomeFlow/EthereumAddress/hooks/useGoBackIfAddressSet';
import {AccountActions} from '@store/modules/Account/actions';
import {unsafeUserSelector} from '@store/modules/Account/selectors';
import {
failedReasonSelector,
isLoadingSelector,
Expand All @@ -19,9 +21,14 @@ export const useSetEthereumAddress = () => {
const navigation =
useNavigation<NativeStackNavigationProp<MainNavigationParams>>();
const dispatch = useDispatch();
const [address, setAddress] = useState('');
const user = useSelector(unsafeUserSelector);
const [address, setAddress] = useState(
user.miningBlockchainAccountAddress ?? '',
);
const submittedRef = useRef(false);

useGoBackIfAddressSet({isFormSubmitted: submittedRef.current});

const error = useSelector(
failedReasonSelector.bind(null, AccountActions.UPDATE_ACCOUNT),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ import {MainNavigationParams} from '@navigation/Main';
import {useNavigation} from '@react-navigation/native';
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
import {AccountActions} from '@store/modules/Account/actions';
import {ethereumWarningConfirmedSelector} from '@store/modules/Account/selectors';
import {
ethereumWarningConfirmedSelector,
unsafeUserSelector,
} from '@store/modules/Account/selectors';
import {t} from '@translations/i18n';
import {useDispatch, useSelector} from 'react-redux';

export const useValidatorsWarning = () => {
const navigation =
useNavigation<NativeStackNavigationProp<MainNavigationParams>>();
const dispatch = useDispatch();
const user = useSelector(unsafeUserSelector);
const warningConfirmed = useSelector(ethereumWarningConfirmedSelector);
const needToShowWarning =
!user.miningBlockchainAccountAddress && !warningConfirmed;

const showWarning = () => {
navigation.navigate('PopUp', {
Expand All @@ -35,5 +41,5 @@ export const useValidatorsWarning = () => {
});
};

return {showWarning, warningConfirmed};
return {showWarning, needToShowWarning};
};
7 changes: 2 additions & 5 deletions src/screens/HomeFlow/EthereumAddress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {useFocusStatusBar} from '@navigation/hooks/useFocusStatusBar';
import {ConfirmAddressButton} from '@screens/HomeFlow/EthereumAddress/components/ConfirmAddressButton';
import {EthereumAddressWarning} from '@screens/HomeFlow/EthereumAddress/components/EthereumAddressWarning';
import {FramedEthereumIcon} from '@screens/HomeFlow/EthereumAddress/components/FramedEthereumIcon';
import {useGoBackIfAddressSet} from '@screens/HomeFlow/EthereumAddress/hooks/useGoBackIfAddressSet';
import {useSetEthereumAddress} from '@screens/HomeFlow/EthereumAddress/hooks/useSetEthereumAddress';
import {useValidatorsWarning} from '@screens/HomeFlow/EthereumAddress/hooks/useValidatorsWarning';
import {EthereumBookIcon} from '@svg/EthereumBookIcon';
Expand All @@ -26,13 +25,11 @@ export const EthereumAddress = memo(() => {
const {bottom: bottomInset} = useSafeAreaInsets();
const {scrollRef} = useScrollEndOnKeyboardShown();
const isKeyboardShown = useIsKeyboardShown();
const {showWarning, warningConfirmed} = useValidatorsWarning();
const {showWarning, needToShowWarning} = useValidatorsWarning();

const {address, loading, error, onAddressChange, onSubmit} =
useSetEthereumAddress();

useGoBackIfAddressSet();

return (
<KeyboardAvoider>
<Header title={t('ethereum_address.title')} />
Expand All @@ -59,7 +56,7 @@ export const EthereumAddress = memo(() => {
containerStyle={styles.input}
editable={!loading}
errorText={error}
onChange={!warningConfirmed ? showWarning : undefined}
onChange={needToShowWarning ? showWarning : undefined}
showChangeLabel={false}
/>
{!isKeyboardShown && <EthereumAddressWarning style={styles.warning} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const EthereumAddress = memo(() => {
<SectionHeader title={t('home.ethereum_address.title')} />
<ActionListItem
onPress={onPress}
disabled={!!user.miningBlockchainAccountAddress}
containerStyle={styles.container}
LeadingIcon={<EthereumIcon color={COLORS.primaryLight} />}
title={t('home.ethereum_address.title')}
Expand All @@ -48,9 +47,7 @@ export const EthereumAddress = memo(() => {
)
}
TrailingIcon={
user.miningBlockchainAccountAddress ? null : (
<ChevronSmallIcon style={styles.chevron} color={COLORS.white} />
)
<ChevronSmallIcon style={styles.chevron} color={COLORS.white} />
}
backgroundImageSource={Images.backgrounds.darkListItem}
leadingIconContainerStyle={styles.leadingIconContainer}
Expand All @@ -76,7 +73,7 @@ const styles = StyleSheet.create({
color: COLORS.white,
},
subtitleText: {
width: '80%',
width: '90%',
marginTop: rem(4),
...font(12, 14.4, 'medium', 'white'),
},
Expand Down
6 changes: 3 additions & 3 deletions src/translations/locales/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -1155,9 +1155,9 @@
"title": "Ethereum Adres",
"enter_address_title": "Voer jou\nERC-20-adres in",
"enter_address_description": "Tydens Fase Een sal die ICE-tokens op die Ethereum-blokchain vrygestel word. Sodra die Hoofnet begin het, sal die tokens oorgeruil kan word van Ethereum na die Ice Open Network (ION) blokchain.",
"enter_address_warning": "Maak asseblief seker dat die ERC-20-adres hierbo korrek is en dat jy daarvolgens vir die hele Fase Een periode toegang het. Dit is nie moontlik om dit te verander nadat jy dit bevestig het nie.",
"enter_address_confirmation": "Is jy seker dat die ERC-20-adres korrek is? Dit is nie moontlik om dit te verander nadat jy dit bevestig het nie.",
"enter_address_confirmation": "Is jy seker dat die ERC-20-adres korrek is?",
"validators_warning_title": "Bevestig Adres",
"validators_warning_text": "Let daarop dat individue wat 'n Ethereum-adres aan hul rekening bygevoeg het, nie in aanmerking kom om een van die top 300-validatorse te word volgens ons witboek vir die hoofnetlansering nie."
"validators_warning_text": "Let daarop dat individue wat 'n Ethereum-adres aan hul rekening bygevoeg het, nie in aanmerking kom om een van die top 300-validatorse te word volgens ons witboek vir die hoofnetlansering nie.",
"self_custodial_addr_warning_text": "Ons adviseer om 'n selfbewaringsbeurs soos Metamask of Trust Wallet te gebruik. Moet nie enige exchange-adres gebruik nie, want Ice sal aanvanklik net op Uniswap gelys word, of jy kan jou munte [[:bold]]verloor[[/:bold]]."
}
}
5 changes: 3 additions & 2 deletions src/translations/locales/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,9 @@
"title": "Ethereum አድራሻ",
"enter_address_title": "የእርስዎን\nERC-20 አድራሻ ያስገቡ",
"enter_address_description": "በደረጃ አንድ ወቅት የ ICE ቶከኖች በ Ethereum blockchain ላይ ይለቀቃሉ። ሜንኔት አንዴ ከተጀመረ ቶከኖቹ ከEthereum ወደ Ice Open Network (ION) blockchain ይቀየራሉ።",
"enter_address_warning": "እባክዎ ከላይ ያለው የ ERC-20 አድራሻ ትክክል መሆኑን እና ለክፍል አንድ ጊዜ በሙሉ መዳረሻ እንደሚኖርዎት ያረጋግጡ። ካረጋገጡ በኋላ መቀየር አይቻልም።",
"validators_warning_title": "አድራሻ አረጋግጥ",
"validators_warning_text": "እባክዎን የኢቴሬም አድራሻን ወደ መለያቸው ያከሉ ግለሰቦች ለዋና ኔትዎርክ ማስጀመሪያ በነጭ ወረቀታችን መሰረት ከከፍተኛ 300 አረጋጋጮች ውስጥ አንዱ ለመሆን ብቁ እንዳልሆኑ ልብ ይበሉ።"
"validators_warning_text": "እባክዎን የኢቴሬም አድራሻን ወደ መለያቸው ያከሉ ግለሰቦች ለዋና ኔትዎርክ ማስጀመሪያ በነጭ ወረቀታችን መሰረት ከከፍተኛ 300 አረጋጋጮች ውስጥ አንዱ ለመሆን ብቁ እንዳልሆኑ ልብ ይበሉ።",
"self_custodial_addr_warning_text": "እንደ Metamask ወይም Trust Wallet ያሉ እራስን የሚጠብቅ የኪስ ቦርሳ እንዲጠቀሙ እንመክራለን። አይስ መጀመሪያ ላይ Uniswap ላይ ብቻ ስለሚዘረዘር ማንኛውንም የመለዋወጫ አድራሻ አይጠቀሙ ወይም ሳንቲሞችዎን ሊያጡ ይችላሉ።",
"enter_address_confirmation": "የ ERC-20 አድራሻ ትክክል መሆኑን እርግጠኛ ነዎት?"
}
}
6 changes: 3 additions & 3 deletions src/translations/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,9 @@
"title": "عنوان إيثيريوم",
"enter_address_title": "أدخل\nعنوان ERC-20 الخاص بك",
"enter_address_description": "خلال المرحلة الأولى، ستتم إصدار عملات ICE على سلسلة الكتل Ethereum. بمجرد أن يتم إطلاق الشبكة الرئيسية، سيمكن تبادل العملات من Ethereum إلى شبكة Ice Open (ION) Blockchain.",
"enter_address_warning": "تأكد من أن عنوان ERC-20 أعلاه صحيح وأن لديك وصول إليه طوال فترة المرحلة الأولى بالكامل. لا يمكن تغييره بعد تأكيده.",
"enter_address_confirmation": "هل أنت متأكد من أن عنوان ERC-20 صحيح؟ لا يمكن تغييره بعد تأكيده.",
"enter_address_confirmation": "هل أنت متأكد من أن عنوان ERC-20 صحيح؟",
"validators_warning_title": "تأكيد العنوان",
"validators_warning_text": "يرجى ملاحظة أن الأفراد الذين أضافوا عنوان Ethereum إلى حسابهم ليس لديهم الحق في أن يصبحوا واحدًا من أفضل 300 مُحقق وفقًا لورقتنا البيضاء لإطلاق الشبكة الرئيسية."
"validators_warning_text": "يرجى ملاحظة أن الأفراد الذين أضافوا عنوان Ethereum إلى حسابهم ليس لديهم الحق في أن يصبحوا واحدًا من أفضل 300 مُحقق وفقًا لورقتنا البيضاء لإطلاق الشبكة الرئيسية.",
"self_custodial_addr_warning_text": "ننصح باستخدام محفظة ذاتية التخزين مثل Metamask أو Trust Wallet. لا تستخدم أي عنوان تبادل exchange كـ Ice سيتم إدراجه فقط على Uniswap في البداية ، أو يمكن أن تخاطر في فقدان عملاتك."
}
}
6 changes: 3 additions & 3 deletions src/translations/locales/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,9 @@
"title": "Ethereum Ünvanı",
"enter_address_title": "ERC-20 ünvanınızı daxil edin",
"enter_address_description": "Fəzə Bir zamanı ICE tokenləri Ethereum blokçeyndə buraxılacaq. Əsas şəbəkə başladıqdan sonra, tokenlərin Ethereumdan Ice Open Network (ION) blokçeynə dəyişdirilməsi mümkün olacaq.",
"enter_address_warning": "Xahiş edirəm yuxarıdakı ERC-20 ünvanının düzgün olduğunu və Fəzə Bir müddəti boyunca buna tam əksərlikdə giriş hüququnuzun olduğunu təsdiq edin. Təsdiq etdikdən sonra dəyişdirmək mümkün deyil.",
"enter_address_confirmation": "Əminsinizmi ki, ERC-20 ünvanı düzgündür? Təsdiq etdikdən sonra dəyişdirmək mümkün deyil.",
"enter_address_confirmation": "ERC-20 ünvanının düzgün olduğundan əminsinizmi?",
"validators_warning_title": "Ünvanı Təsdiq Et",
"validators_warning_text": "Xahiş edirəm diqqət edin ki, Ethereum ünvanını hesabına əlavə edənlər, əsas şəbəkənin istehsalı üçün bizim ağlaşdırmamıza əsasən ən yaxşı 300 doğrulayıcının biri olmaq üçün əhəmiyyət daşımırlar."
"validators_warning_text": "Xahiş edirəm diqqət edin ki, Ethereum ünvanını hesabına əlavə edənlər, əsas şəbəkənin istehsalı üçün bizim ağlaşdırmamıza əsasən ən yaxşı 300 doğrulayıcının biri olmaq üçün əhəmiyyət daşımırlar.",
"self_custodial_addr_warning_text": "Metamask və ya Trust Wallet kimi öz-əmanəti qoruyan bir cüzdan istifadə etməyin tövsiyə edirik. İlk başta yalnız Uniswap-da siyahılanacaq Ice kimi heç bir exchange ünvanı istifadə etməyin, yoxsa siklərinizi itirə bilərsiniz."
}
}
6 changes: 3 additions & 3 deletions src/translations/locales/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -1152,9 +1152,9 @@
"title": "Адрес на Ethereum",
"enter_address_title": "Въведете\nвашия ERC-20 адрес",
"enter_address_description": "През Фаза Едно, токените ICE ще бъдат пуснати на блокчейн Ethereum. След като бъде стартирана главната мрежа, токените ще бъдат заменяеми от Ethereum към блокчейна Ice Open Network (ION).",
"enter_address_warning": "Моля, уверете се, че горният ERC-20 адрес е правилен и че имате достъп до него през целия период на Фаза Едно. Не е възможно да го промените след като го потвърдите.",
"enter_address_confirmation": "Сигурни ли сте, че ERC-20 адресът е правилен? Не е възможно да го промените след като го потвърдите.",
"enter_address_confirmation": "Сигурни ли сте, че ERC-20 адресът е правилен?",
"validators_warning_title": "Потвърдете адреса",
"validators_warning_text": "Моля, обърнете внимание, че лицата, които са добавили Ethereum адрес към своя акаунт, нямат право да станат един от най-добрите 300 потвърждаващи лица според нашата бяла книга за пускането на основната мрежа."
"validators_warning_text": "Моля, обърнете внимание, че лицата, които са добавили Ethereum адрес към своя акаунт, нямат право да станат един от най-добрите 300 потвърждаващи лица според нашата бяла книга за пускането на основната мрежа.",
"self_custodial_addr_warning_text": "Препоръчваме използването на самоуправляваща се портфейл като Metamask или Trust Wallet. Не използвайте адрес на никаква борса, тъй като Ice ще бъде списан само в Uniswap в началото, или рискувате [[:bold]]загубата на монетите си[[/:bold]]."
}
}
Loading

0 comments on commit 8d9ac70

Please sign in to comment.