From 59e70dacd781176f57c4966ca5cef65693a204dd Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 12:25:45 -0300 Subject: [PATCH 01/19] progress --- .../Views/AccountBackupStep4/index.js | 46 +++-- .../Views/AccountBackupStep5/index.js | 159 +++++++----------- app/components/Views/BrowserTab/index.js | 4 +- scripts/build.sh | 2 +- 4 files changed, 92 insertions(+), 119 deletions(-) diff --git a/app/components/Views/AccountBackupStep4/index.js b/app/components/Views/AccountBackupStep4/index.js index c64a5071141..80cfe1ed845 100644 --- a/app/components/Views/AccountBackupStep4/index.js +++ b/app/components/Views/AccountBackupStep4/index.js @@ -16,7 +16,7 @@ import { colors, fontStyles } from '../../../styles/common'; import StyledButton from '../../UI/StyledButton'; import { strings } from '../../../../locales/i18n'; import Engine from '../../../core/Engine'; -import SecureKeychain from '../../../core/SecureKeychain'; +// import SecureKeychain from '../../../core/SecureKeychain'; const styles = StyleSheet.create({ mainWrapper: { @@ -132,7 +132,7 @@ const styles = StyleSheet.create({ const WRONG_PASSWORD_ERROR = 'Error: Decrypt failed'; const SEED_PHRASE = 'seed_phrase'; -const CONFIRM_PASSWORD = 'confirm_password'; +// const CONFIRM_PASSWORD = 'confirm_password'; /** * View that's shown during the fourth step of * the backup seed phrase flow @@ -165,20 +165,34 @@ export default class AccountBackupStep4 extends PureComponent { }; async componentDidMount() { - this.words = this.props.navigation.getParam('words', []); - // If the user is going to the backup seed flow directly - if (!this.words.length) { - try { - const credentials = await SecureKeychain.getGenericPassword(); - if (credentials) { - this.words = await this.tryExportSeedPhrase(credentials.password); - } else { - this.setState({ view: CONFIRM_PASSWORD }); - } - } catch (e) { - this.setState({ view: CONFIRM_PASSWORD }); - } - } + // this.words = this.props.navigation.getParam('words', []); + // // If the user is going to the backup seed flow directly + // if (!this.words.length) { + // try { + // const credentials = await SecureKeychain.getGenericPassword(); + // if (credentials) { + // this.words = await this.tryExportSeedPhrase(credentials.password); + // } else { + // this.setState({ view: CONFIRM_PASSWORD }); + // } + // } catch (e) { + // this.setState({ view: CONFIRM_PASSWORD }); + // } + // } + this.words = [ + 'outdoor', + 'group', + 'glove', + 'unhappy', + 'speed', + 'pattern', + 'fix', + 'devote', + 'renew', + 'lyrics', + 'wool', + 'speed' + ]; this.setState({ ready: true }); } diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 2cc88ea478f..3c33e8e431c 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -165,18 +165,60 @@ class AccountBackupStep5 extends PureComponent { constructor(props) { super(props); - const words = props.navigation.getParam('words', []); - if (process.env.JEST_WORKER_ID === undefined) { - this.words = [...words].sort(() => 0.5 - Math.random()); - } else { - this.words = words; - } + // const words = props.navigation.getParam('words', []); + // if (process.env.JEST_WORKER_ID === undefined) { + // this.words = [...words].sort(() => 0.5 - Math.random()); + // } else { + // this.words = words; + // } + this.words = [ + 'outdoor', + 'group', + 'glove', + 'unhappy', + 'speed', + 'pattern', + 'fix', + 'devote', + 'renew', + 'lyrics', + 'wool', + 'speed' + ]; } state = { confirmedWords: Array(12).fill(), - currentIndex: 0, - showSuccessModal: false + showSuccessModal: false, + wordsDict: {}, + currentIndex: 0 + }; + + componentDidMount = () => { + this.createWordsDictionary(); + }; + + createWordsDictionary = () => { + const dict = {}; + this.words.forEach((word, i) => { + dict[[word, i]] = { currentPosition: undefined }; + }); + this.setState({ wordsDict: dict }); + }; + + selectWord = (word, i) => { + const { wordsDict, confirmedWords } = this.state; + let currentIndex = this.state.currentIndex; + if (wordsDict[[word, i]].currentPosition) { + currentIndex--; + wordsDict[[word, i]].currentPosition = undefined; + confirmedWords[currentIndex] = undefined; + } else { + wordsDict[[word, i]].currentPosition = currentIndex; + confirmedWords[currentIndex] = word; + currentIndex++; + } + this.setState({ currentIndex, wordsDict }); }; goBack = () => { @@ -206,85 +248,9 @@ class AccountBackupStep5 extends PureComponent { }); }; - getIndexOfWord(word, index, words) { - const confirmedWordsOcurrences = this.getNumberOfOcurrences(word, words); - if (confirmedWordsOcurrences === 1) { - return words.indexOf(word); - } - - let currentOccurence = 0; - - for (let i = 0; i < words.length; i++) { - if (words[i] === word) { - currentOccurence++; - if (i === index && currentOccurence <= confirmedWordsOcurrences) { - return i; - } - } - } - return words.indexOf(word); - } + render = () => { + const { confirmedWords, wordsDict, currentIndex } = this.state; - selectWord = (word, i) => { - const newConfirmedWords = this.state.confirmedWords.slice(); - let newIndex; - if (this.isSelectedWord(word, i)) { - const matchIndex = this.getIndexOfWord(word, i, this.state.confirmedWords); - newConfirmedWords[matchIndex] = undefined; - newIndex = matchIndex; - } else { - // Find next empty cell - newConfirmedWords[this.state.currentIndex] = word; - newIndex = 11; - for (i = this.state.currentIndex; i < 12; i++) { - if (newConfirmedWords[i] === undefined) { - newIndex = i; - break; - } - } - } - this.setState({ confirmedWords: newConfirmedWords, currentIndex: newIndex }); - }; - - updateWordAtIndex = index => { - const newConfirmedWords = this.state.confirmedWords.slice(); - const newIndex = index; - newConfirmedWords[index] = undefined; - this.setState({ confirmedWords: newConfirmedWords, currentIndex: newIndex }); - }; - - getNumberOfOcurrences(word, words) { - let ocurrences = 0; - for (let i = 0; i < words.length; i++) { - words[i] === word && ocurrences++; - } - return ocurrences; - } - - isSelectedWord(word, index) { - if (!this.state.confirmedWords.includes(word)) { - return false; - } - const totalOcurrences = this.getNumberOfOcurrences(word, this.words); - const confirmedWordsOcurrences = this.getNumberOfOcurrences(word, this.state.confirmedWords); - if (totalOcurrences === confirmedWordsOcurrences) { - return true; - } - - let currentOccurence = 0; - - for (let i = 0; i < this.words.length; i++) { - if (this.words[i] === word) { - currentOccurence++; - if (i === index && currentOccurence <= confirmedWordsOcurrences) { - return true; - } - } - } - return false; - } - - render() { return ( @@ -301,25 +267,20 @@ class AccountBackupStep5 extends PureComponent { - {this.state.confirmedWords.slice(0, 6).map((word, i) => ( + {confirmedWords.slice(0, 6).map((word, i) => ( this.updateWordAtIndex(i)} > - + {(word && `${i + 1}. ${word}`) || ' '} ))} - {this.state.confirmedWords.slice(-6).map((word, i) => ( + {confirmedWords.slice(-6).map((word, i) => ( this.updateWordAtIndex(i + 6)} @@ -328,7 +289,7 @@ class AccountBackupStep5 extends PureComponent { {(word && `${i + 7}. ${word}`) || ' '} @@ -339,8 +300,9 @@ class AccountBackupStep5 extends PureComponent { - {this.words.map((word, i) => { - const selected = this.isSelectedWord(word, i) ? styles.selectedWord : null; + {Object.keys(wordsDict).map((key, i) => { + const [word] = key.split(','); + const selected = wordsDict[key].currentPosition ? styles.selectedWord : null; const selectedText = selected ? styles.selectedWordText : null; return ( word === undefined).length === 0)} > {strings('account_backup_step_5.cta_text')} @@ -380,7 +341,7 @@ class AccountBackupStep5 extends PureComponent { ); - } + }; } const mapDispatchToProps = dispatch => ({ diff --git a/app/components/Views/BrowserTab/index.js b/app/components/Views/BrowserTab/index.js index 92539e6560e..0d44f2899df 100644 --- a/app/components/Views/BrowserTab/index.js +++ b/app/components/Views/BrowserTab/index.js @@ -1872,9 +1872,7 @@ export class BrowserTab extends PureComponent { {!isHidden && this.renderOptions()} {!isHidden && this.renderBottomBar()} {!isHidden && this.renderOnboardingWizard()} - {!isHidden && this.props.passwordSet && !this.props.seedphraseBackedUp && ( - - )} + ); } diff --git a/scripts/build.sh b/scripts/build.sh index 41eedbd21f7..d6c9fb5d0b1 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -175,7 +175,7 @@ buildIosRelease(){ if [ ! -f "ios/release.xcconfig" ] ; then echo "$IOS_ENV" | tr "|" "\n" > ios/release.xcconfig fi - ./node_modules/.bin/react-native run-ios --configuration Release --simulator "iPhone 11 Pro (13.2)" + ./node_modules/.bin/react-native run-ios --configuration Release --simulator "iPhone 11 Pro" fi } From 73891b6e8c3f3d79e3170ce40a5f594b9fdcda72 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 12:35:55 -0300 Subject: [PATCH 02/19] cleaner code --- .../Views/AccountBackupStep5/index.js | 42 +++++++------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 3c33e8e431c..01fe0ce05d7 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -248,8 +248,19 @@ class AccountBackupStep5 extends PureComponent { }); }; + renderWordBox = (word, i) => { + const { currentIndex } = this.state; + let wordText = ''; + if (word) wordText = `${i + 1}. ${word}`; + return ( + + {wordText} + + ); + }; + render = () => { - const { confirmedWords, wordsDict, currentIndex } = this.state; + const { confirmedWords, wordsDict } = this.state; return ( @@ -267,35 +278,10 @@ class AccountBackupStep5 extends PureComponent { - {confirmedWords.slice(0, 6).map((word, i) => ( - this.updateWordAtIndex(i)} - > - - {(word && `${i + 1}. ${word}`) || ' '} - - - ))} + {confirmedWords.slice(0, 6).map((word, i) => this.renderWordBox(word, i))} - {confirmedWords.slice(-6).map((word, i) => ( - this.updateWordAtIndex(i + 6)} - key={`word_${i}`} - > - - {(word && `${i + 7}. ${word}`) || ' '} - - - ))} + {confirmedWords.slice(-6).map((word, i) => this.renderWordBox(word, i + 6))} From 0ab4196ace8659551cf38ae9647c173a394b2f1d Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 12:55:55 -0300 Subject: [PATCH 03/19] fix check --- app/components/Views/AccountBackupStep5/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 01fe0ce05d7..8521dcad6f3 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -209,7 +209,7 @@ class AccountBackupStep5 extends PureComponent { selectWord = (word, i) => { const { wordsDict, confirmedWords } = this.state; let currentIndex = this.state.currentIndex; - if (wordsDict[[word, i]].currentPosition) { + if (wordsDict[[word, i]].currentPosition !== undefined) { currentIndex--; wordsDict[[word, i]].currentPosition = undefined; confirmedWords[currentIndex] = undefined; @@ -218,7 +218,7 @@ class AccountBackupStep5 extends PureComponent { confirmedWords[currentIndex] = word; currentIndex++; } - this.setState({ currentIndex, wordsDict }); + this.setState({ currentIndex, wordsDict, confirmedWords }); }; goBack = () => { @@ -288,7 +288,8 @@ class AccountBackupStep5 extends PureComponent { {Object.keys(wordsDict).map((key, i) => { const [word] = key.split(','); - const selected = wordsDict[key].currentPosition ? styles.selectedWord : null; + const selected = + wordsDict[key].currentPosition !== undefined ? styles.selectedWord : null; const selectedText = selected ? styles.selectedWordText : null; return ( Date: Tue, 11 Feb 2020 13:09:20 -0300 Subject: [PATCH 04/19] works --- app/components/Views/AccountBackupStep5/index.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 8521dcad6f3..f694bbb3226 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -206,17 +206,25 @@ class AccountBackupStep5 extends PureComponent { this.setState({ wordsDict: dict }); }; + findNextAvailableIndex = () => { + const { currentIndex, confirmedWords } = this.state; + for (let i = 0; i < 12; i++) { + if (!confirmedWords[i]) return i; + } + return currentIndex + 1; + }; + selectWord = (word, i) => { const { wordsDict, confirmedWords } = this.state; let currentIndex = this.state.currentIndex; if (wordsDict[[word, i]].currentPosition !== undefined) { - currentIndex--; + currentIndex = wordsDict[[word, i]].currentPosition; wordsDict[[word, i]].currentPosition = undefined; confirmedWords[currentIndex] = undefined; } else { - wordsDict[[word, i]].currentPosition = currentIndex; + wordsDict[[word, i]].currentPosition = this.findNextAvailableIndex(); confirmedWords[currentIndex] = word; - currentIndex++; + currentIndex = this.findNextAvailableIndex(); } this.setState({ currentIndex, wordsDict, confirmedWords }); }; From 74ffecf0eaaa73785f3d975cbefd36342ff94d73 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 13:18:56 -0300 Subject: [PATCH 05/19] almost there --- .../Views/AccountBackupStep5/index.js | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index f694bbb3226..dd63d7727b2 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -188,7 +188,7 @@ class AccountBackupStep5 extends PureComponent { } state = { - confirmedWords: Array(12).fill(), + confirmedWords: Array(12).fill({ word: undefined, originalPosition: undefined }), showSuccessModal: false, wordsDict: {}, currentIndex: 0 @@ -209,7 +209,7 @@ class AccountBackupStep5 extends PureComponent { findNextAvailableIndex = () => { const { currentIndex, confirmedWords } = this.state; for (let i = 0; i < 12; i++) { - if (!confirmedWords[i]) return i; + if (!confirmedWords[i].word) return i; } return currentIndex + 1; }; @@ -220,15 +220,24 @@ class AccountBackupStep5 extends PureComponent { if (wordsDict[[word, i]].currentPosition !== undefined) { currentIndex = wordsDict[[word, i]].currentPosition; wordsDict[[word, i]].currentPosition = undefined; - confirmedWords[currentIndex] = undefined; + confirmedWords[currentIndex] = { word: undefined, originalPosition: undefined }; } else { wordsDict[[word, i]].currentPosition = this.findNextAvailableIndex(); - confirmedWords[currentIndex] = word; + confirmedWords[currentIndex] = { word, originalPosition: i }; currentIndex = this.findNextAvailableIndex(); } this.setState({ currentIndex, wordsDict, confirmedWords }); }; + clearConfirmedWordAt = i => { + const { confirmedWords, wordsDict } = this.state; + const { word, originalPosition } = confirmedWords[i]; + const currentIndex = i; + wordsDict[[word, originalPosition]].currentPosition = undefined; + confirmedWords[i] = { word: undefined, originalPosition: undefined }; + this.setState({ currentIndex, wordsDict, confirmedWords }); + }; + goBack = () => { this.props.navigation.goBack(); }; @@ -261,7 +270,12 @@ class AccountBackupStep5 extends PureComponent { let wordText = ''; if (word) wordText = `${i + 1}. ${word}`; return ( - + { + this.clearConfirmedWordAt(i); + }} + > {wordText} ); @@ -286,10 +300,10 @@ class AccountBackupStep5 extends PureComponent { - {confirmedWords.slice(0, 6).map((word, i) => this.renderWordBox(word, i))} + {confirmedWords.slice(0, 6).map(({ word }, i) => this.renderWordBox(word, i))} - {confirmedWords.slice(-6).map((word, i) => this.renderWordBox(word, i + 6))} + {confirmedWords.slice(-6).map(({ word }, i) => this.renderWordBox(word, i + 6))} From c240a39dc4260f61a54cae091173df4a7696d8a9 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 16:17:36 -0300 Subject: [PATCH 06/19] fix some bugs --- app/components/Views/AccountBackupStep5/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index dd63d7727b2..81c6f7c3747 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -208,9 +208,7 @@ class AccountBackupStep5 extends PureComponent { findNextAvailableIndex = () => { const { currentIndex, confirmedWords } = this.state; - for (let i = 0; i < 12; i++) { - if (!confirmedWords[i].word) return i; - } + for (let i = 0; i < 12; i++) if (!confirmedWords[i].word) return i; return currentIndex + 1; }; @@ -232,6 +230,7 @@ class AccountBackupStep5 extends PureComponent { clearConfirmedWordAt = i => { const { confirmedWords, wordsDict } = this.state; const { word, originalPosition } = confirmedWords[i]; + if (!word || originalPosition === undefined) return; const currentIndex = i; wordsDict[[word, originalPosition]].currentPosition = undefined; confirmedWords[i] = { word: undefined, originalPosition: undefined }; From 19735b845d944315b3b3998cc083860e829092f4 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 16:22:55 -0300 Subject: [PATCH 07/19] cleaner --- .../Views/AccountBackupStep5/index.js | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 81c6f7c3747..7ba0c047211 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -271,6 +271,7 @@ class AccountBackupStep5 extends PureComponent { return ( { this.clearConfirmedWordAt(i); }} @@ -280,6 +281,22 @@ class AccountBackupStep5 extends PureComponent { ); }; + renderWordSelectableBox = (key, i) => { + const { wordsDict } = this.state; + const [word] = key.split(','); + const selected = wordsDict[key].currentPosition !== undefined; + return ( + this.selectWord(word, i)} + style={[styles.selectableWord, selected && styles.selectedWord]} + key={`selectableWord_${i}`} + > + {word} + + ); + }; + render = () => { const { confirmedWords, wordsDict } = this.state; @@ -307,22 +324,7 @@ class AccountBackupStep5 extends PureComponent { - {Object.keys(wordsDict).map((key, i) => { - const [word] = key.split(','); - const selected = - wordsDict[key].currentPosition !== undefined ? styles.selectedWord : null; - const selectedText = selected ? styles.selectedWordText : null; - return ( - this.selectWord(word, i)} - style={[styles.selectableWord, selected]} - key={`selectableWord_${i}`} - > - {word} - - ); - })} + {Object.keys(wordsDict).map((key, i) => this.renderWordSelectableBox(key, i))} From 4c1001974d579233f4b6a7d2eaecb801867ff3d5 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 16:39:02 -0300 Subject: [PATCH 08/19] select empty box --- .../Views/AccountBackupStep5/index.js | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 7ba0c047211..3e7f33f8e4e 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -191,7 +191,8 @@ class AccountBackupStep5 extends PureComponent { confirmedWords: Array(12).fill({ word: undefined, originalPosition: undefined }), showSuccessModal: false, wordsDict: {}, - currentIndex: 0 + currentIndex: 0, + seedPhraseReady: false }; componentDidMount = () => { @@ -207,9 +208,9 @@ class AccountBackupStep5 extends PureComponent { }; findNextAvailableIndex = () => { - const { currentIndex, confirmedWords } = this.state; + const { confirmedWords } = this.state; for (let i = 0; i < 12; i++) if (!confirmedWords[i].word) return i; - return currentIndex + 1; + return 12; }; selectWord = (word, i) => { @@ -224,16 +225,22 @@ class AccountBackupStep5 extends PureComponent { confirmedWords[currentIndex] = { word, originalPosition: i }; currentIndex = this.findNextAvailableIndex(); } - this.setState({ currentIndex, wordsDict, confirmedWords }); + this.setState({ + currentIndex, + wordsDict, + confirmedWords, + seedPhraseReady: this.findNextAvailableIndex() === 12 + }); }; clearConfirmedWordAt = i => { const { confirmedWords, wordsDict } = this.state; const { word, originalPosition } = confirmedWords[i]; - if (!word || originalPosition === undefined) return; const currentIndex = i; - wordsDict[[word, originalPosition]].currentPosition = undefined; - confirmedWords[i] = { word: undefined, originalPosition: undefined }; + if (word && (originalPosition || originalPosition === 0)) { + wordsDict[[word, originalPosition]].currentPosition = undefined; + confirmedWords[i] = { word: undefined, originalPosition: undefined }; + } this.setState({ currentIndex, wordsDict, confirmedWords }); }; @@ -298,8 +305,7 @@ class AccountBackupStep5 extends PureComponent { }; render = () => { - const { confirmedWords, wordsDict } = this.state; - + const { confirmedWords, wordsDict, seedPhraseReady } = this.state; return ( @@ -333,6 +339,7 @@ class AccountBackupStep5 extends PureComponent { type={'confirm'} onPress={this.goNext} testID={'submit-button'} + disabled={!seedPhraseReady} > {strings('account_backup_step_5.cta_text')} From b733d887a23148d3761d5b2772e78bcb8c0122fe Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 16:56:44 -0300 Subject: [PATCH 09/19] done --- app/components/Views/AccountBackupStep5/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 3e7f33f8e4e..1c544088774 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -250,7 +250,8 @@ class AccountBackupStep5 extends PureComponent { goNext = () => { const words = this.props.navigation.getParam('words', []); - if (words.join('') === this.state.confirmedWords.join('')) { + const confirmedWords = this.state.confirmedWords.map(confirmedWord => confirmedWord.word); + if (words.join('') === confirmedWords.join('')) { this.props.seedphraseBackedUp(); this.setState({ showSuccessModal: true }); } else { From 774113ef89657ece9e51bb80be28de015d363ca4 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 17:05:10 -0300 Subject: [PATCH 10/19] undo custom changes --- .../Views/AccountBackupStep4/index.js | 46 +++++++------------ .../Views/AccountBackupStep5/index.js | 26 +++-------- app/components/Views/BrowserTab/index.js | 4 +- 3 files changed, 25 insertions(+), 51 deletions(-) diff --git a/app/components/Views/AccountBackupStep4/index.js b/app/components/Views/AccountBackupStep4/index.js index 80cfe1ed845..c64a5071141 100644 --- a/app/components/Views/AccountBackupStep4/index.js +++ b/app/components/Views/AccountBackupStep4/index.js @@ -16,7 +16,7 @@ import { colors, fontStyles } from '../../../styles/common'; import StyledButton from '../../UI/StyledButton'; import { strings } from '../../../../locales/i18n'; import Engine from '../../../core/Engine'; -// import SecureKeychain from '../../../core/SecureKeychain'; +import SecureKeychain from '../../../core/SecureKeychain'; const styles = StyleSheet.create({ mainWrapper: { @@ -132,7 +132,7 @@ const styles = StyleSheet.create({ const WRONG_PASSWORD_ERROR = 'Error: Decrypt failed'; const SEED_PHRASE = 'seed_phrase'; -// const CONFIRM_PASSWORD = 'confirm_password'; +const CONFIRM_PASSWORD = 'confirm_password'; /** * View that's shown during the fourth step of * the backup seed phrase flow @@ -165,34 +165,20 @@ export default class AccountBackupStep4 extends PureComponent { }; async componentDidMount() { - // this.words = this.props.navigation.getParam('words', []); - // // If the user is going to the backup seed flow directly - // if (!this.words.length) { - // try { - // const credentials = await SecureKeychain.getGenericPassword(); - // if (credentials) { - // this.words = await this.tryExportSeedPhrase(credentials.password); - // } else { - // this.setState({ view: CONFIRM_PASSWORD }); - // } - // } catch (e) { - // this.setState({ view: CONFIRM_PASSWORD }); - // } - // } - this.words = [ - 'outdoor', - 'group', - 'glove', - 'unhappy', - 'speed', - 'pattern', - 'fix', - 'devote', - 'renew', - 'lyrics', - 'wool', - 'speed' - ]; + this.words = this.props.navigation.getParam('words', []); + // If the user is going to the backup seed flow directly + if (!this.words.length) { + try { + const credentials = await SecureKeychain.getGenericPassword(); + if (credentials) { + this.words = await this.tryExportSeedPhrase(credentials.password); + } else { + this.setState({ view: CONFIRM_PASSWORD }); + } + } catch (e) { + this.setState({ view: CONFIRM_PASSWORD }); + } + } this.setState({ ready: true }); } diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 1c544088774..46e00521b3d 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -165,26 +165,12 @@ class AccountBackupStep5 extends PureComponent { constructor(props) { super(props); - // const words = props.navigation.getParam('words', []); - // if (process.env.JEST_WORKER_ID === undefined) { - // this.words = [...words].sort(() => 0.5 - Math.random()); - // } else { - // this.words = words; - // } - this.words = [ - 'outdoor', - 'group', - 'glove', - 'unhappy', - 'speed', - 'pattern', - 'fix', - 'devote', - 'renew', - 'lyrics', - 'wool', - 'speed' - ]; + const words = props.navigation.getParam('words', []); + if (process.env.JEST_WORKER_ID === undefined) { + this.words = [...words].sort(() => 0.5 - Math.random()); + } else { + this.words = words; + } } state = { diff --git a/app/components/Views/BrowserTab/index.js b/app/components/Views/BrowserTab/index.js index 0d44f2899df..92539e6560e 100644 --- a/app/components/Views/BrowserTab/index.js +++ b/app/components/Views/BrowserTab/index.js @@ -1872,7 +1872,9 @@ export class BrowserTab extends PureComponent { {!isHidden && this.renderOptions()} {!isHidden && this.renderBottomBar()} {!isHidden && this.renderOnboardingWizard()} - + {!isHidden && this.props.passwordSet && !this.props.seedphraseBackedUp && ( + + )} ); } From 468ae85fe63dfca254ca99b5ad71a40e9d5838c8 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 17:13:20 -0300 Subject: [PATCH 11/19] Revert "undo custom changes" This reverts commit 774113ef89657ece9e51bb80be28de015d363ca4. --- .../Views/AccountBackupStep4/index.js | 46 ++++++++++++------- .../Views/AccountBackupStep5/index.js | 26 ++++++++--- app/components/Views/BrowserTab/index.js | 4 +- 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/app/components/Views/AccountBackupStep4/index.js b/app/components/Views/AccountBackupStep4/index.js index c64a5071141..80cfe1ed845 100644 --- a/app/components/Views/AccountBackupStep4/index.js +++ b/app/components/Views/AccountBackupStep4/index.js @@ -16,7 +16,7 @@ import { colors, fontStyles } from '../../../styles/common'; import StyledButton from '../../UI/StyledButton'; import { strings } from '../../../../locales/i18n'; import Engine from '../../../core/Engine'; -import SecureKeychain from '../../../core/SecureKeychain'; +// import SecureKeychain from '../../../core/SecureKeychain'; const styles = StyleSheet.create({ mainWrapper: { @@ -132,7 +132,7 @@ const styles = StyleSheet.create({ const WRONG_PASSWORD_ERROR = 'Error: Decrypt failed'; const SEED_PHRASE = 'seed_phrase'; -const CONFIRM_PASSWORD = 'confirm_password'; +// const CONFIRM_PASSWORD = 'confirm_password'; /** * View that's shown during the fourth step of * the backup seed phrase flow @@ -165,20 +165,34 @@ export default class AccountBackupStep4 extends PureComponent { }; async componentDidMount() { - this.words = this.props.navigation.getParam('words', []); - // If the user is going to the backup seed flow directly - if (!this.words.length) { - try { - const credentials = await SecureKeychain.getGenericPassword(); - if (credentials) { - this.words = await this.tryExportSeedPhrase(credentials.password); - } else { - this.setState({ view: CONFIRM_PASSWORD }); - } - } catch (e) { - this.setState({ view: CONFIRM_PASSWORD }); - } - } + // this.words = this.props.navigation.getParam('words', []); + // // If the user is going to the backup seed flow directly + // if (!this.words.length) { + // try { + // const credentials = await SecureKeychain.getGenericPassword(); + // if (credentials) { + // this.words = await this.tryExportSeedPhrase(credentials.password); + // } else { + // this.setState({ view: CONFIRM_PASSWORD }); + // } + // } catch (e) { + // this.setState({ view: CONFIRM_PASSWORD }); + // } + // } + this.words = [ + 'outdoor', + 'group', + 'glove', + 'unhappy', + 'speed', + 'pattern', + 'fix', + 'devote', + 'renew', + 'lyrics', + 'wool', + 'speed' + ]; this.setState({ ready: true }); } diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 46e00521b3d..1c544088774 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -165,12 +165,26 @@ class AccountBackupStep5 extends PureComponent { constructor(props) { super(props); - const words = props.navigation.getParam('words', []); - if (process.env.JEST_WORKER_ID === undefined) { - this.words = [...words].sort(() => 0.5 - Math.random()); - } else { - this.words = words; - } + // const words = props.navigation.getParam('words', []); + // if (process.env.JEST_WORKER_ID === undefined) { + // this.words = [...words].sort(() => 0.5 - Math.random()); + // } else { + // this.words = words; + // } + this.words = [ + 'outdoor', + 'group', + 'glove', + 'unhappy', + 'speed', + 'pattern', + 'fix', + 'devote', + 'renew', + 'lyrics', + 'wool', + 'speed' + ]; } state = { diff --git a/app/components/Views/BrowserTab/index.js b/app/components/Views/BrowserTab/index.js index 92539e6560e..0d44f2899df 100644 --- a/app/components/Views/BrowserTab/index.js +++ b/app/components/Views/BrowserTab/index.js @@ -1872,9 +1872,7 @@ export class BrowserTab extends PureComponent { {!isHidden && this.renderOptions()} {!isHidden && this.renderBottomBar()} {!isHidden && this.renderOnboardingWizard()} - {!isHidden && this.props.passwordSet && !this.props.seedphraseBackedUp && ( - - )} + ); } From cb039dd5a8fc86a113bcad27683c3043a619a78e Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 17:49:59 -0300 Subject: [PATCH 12/19] Revert "Revert "undo custom changes"" This reverts commit 468ae85fe63dfca254ca99b5ad71a40e9d5838c8. --- .../Views/AccountBackupStep4/index.js | 46 +++++++------------ .../Views/AccountBackupStep5/index.js | 26 +++-------- app/components/Views/BrowserTab/index.js | 4 +- 3 files changed, 25 insertions(+), 51 deletions(-) diff --git a/app/components/Views/AccountBackupStep4/index.js b/app/components/Views/AccountBackupStep4/index.js index 80cfe1ed845..c64a5071141 100644 --- a/app/components/Views/AccountBackupStep4/index.js +++ b/app/components/Views/AccountBackupStep4/index.js @@ -16,7 +16,7 @@ import { colors, fontStyles } from '../../../styles/common'; import StyledButton from '../../UI/StyledButton'; import { strings } from '../../../../locales/i18n'; import Engine from '../../../core/Engine'; -// import SecureKeychain from '../../../core/SecureKeychain'; +import SecureKeychain from '../../../core/SecureKeychain'; const styles = StyleSheet.create({ mainWrapper: { @@ -132,7 +132,7 @@ const styles = StyleSheet.create({ const WRONG_PASSWORD_ERROR = 'Error: Decrypt failed'; const SEED_PHRASE = 'seed_phrase'; -// const CONFIRM_PASSWORD = 'confirm_password'; +const CONFIRM_PASSWORD = 'confirm_password'; /** * View that's shown during the fourth step of * the backup seed phrase flow @@ -165,34 +165,20 @@ export default class AccountBackupStep4 extends PureComponent { }; async componentDidMount() { - // this.words = this.props.navigation.getParam('words', []); - // // If the user is going to the backup seed flow directly - // if (!this.words.length) { - // try { - // const credentials = await SecureKeychain.getGenericPassword(); - // if (credentials) { - // this.words = await this.tryExportSeedPhrase(credentials.password); - // } else { - // this.setState({ view: CONFIRM_PASSWORD }); - // } - // } catch (e) { - // this.setState({ view: CONFIRM_PASSWORD }); - // } - // } - this.words = [ - 'outdoor', - 'group', - 'glove', - 'unhappy', - 'speed', - 'pattern', - 'fix', - 'devote', - 'renew', - 'lyrics', - 'wool', - 'speed' - ]; + this.words = this.props.navigation.getParam('words', []); + // If the user is going to the backup seed flow directly + if (!this.words.length) { + try { + const credentials = await SecureKeychain.getGenericPassword(); + if (credentials) { + this.words = await this.tryExportSeedPhrase(credentials.password); + } else { + this.setState({ view: CONFIRM_PASSWORD }); + } + } catch (e) { + this.setState({ view: CONFIRM_PASSWORD }); + } + } this.setState({ ready: true }); } diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 1c544088774..46e00521b3d 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -165,26 +165,12 @@ class AccountBackupStep5 extends PureComponent { constructor(props) { super(props); - // const words = props.navigation.getParam('words', []); - // if (process.env.JEST_WORKER_ID === undefined) { - // this.words = [...words].sort(() => 0.5 - Math.random()); - // } else { - // this.words = words; - // } - this.words = [ - 'outdoor', - 'group', - 'glove', - 'unhappy', - 'speed', - 'pattern', - 'fix', - 'devote', - 'renew', - 'lyrics', - 'wool', - 'speed' - ]; + const words = props.navigation.getParam('words', []); + if (process.env.JEST_WORKER_ID === undefined) { + this.words = [...words].sort(() => 0.5 - Math.random()); + } else { + this.words = words; + } } state = { diff --git a/app/components/Views/BrowserTab/index.js b/app/components/Views/BrowserTab/index.js index 0d44f2899df..92539e6560e 100644 --- a/app/components/Views/BrowserTab/index.js +++ b/app/components/Views/BrowserTab/index.js @@ -1872,7 +1872,9 @@ export class BrowserTab extends PureComponent { {!isHidden && this.renderOptions()} {!isHidden && this.renderBottomBar()} {!isHidden && this.renderOnboardingWizard()} - + {!isHidden && this.props.passwordSet && !this.props.seedphraseBackedUp && ( + + )} ); } From 7ee04a64b49212076bc0575cf53b337bbc74a4a6 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 17:50:21 -0300 Subject: [PATCH 13/19] fix bug --- app/components/Views/AccountBackupStep5/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 46e00521b3d..3eb51a34752 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -207,7 +207,7 @@ class AccountBackupStep5 extends PureComponent { wordsDict[[word, i]].currentPosition = undefined; confirmedWords[currentIndex] = { word: undefined, originalPosition: undefined }; } else { - wordsDict[[word, i]].currentPosition = this.findNextAvailableIndex(); + wordsDict[[word, i]].currentPosition = currentIndex; confirmedWords[currentIndex] = { word, originalPosition: i }; currentIndex = this.findNextAvailableIndex(); } From c8ec89e69141e3ac6d42d715f00fee0f3f459038 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 11 Feb 2020 17:59:52 -0300 Subject: [PATCH 14/19] snaps --- .../__snapshots__/index.test.js.snap | 108 +++++++----------- 1 file changed, 42 insertions(+), 66 deletions(-) diff --git a/app/components/Views/AccountBackupStep5/__snapshots__/index.test.js.snap b/app/components/Views/AccountBackupStep5/__snapshots__/index.test.js.snap index ddf90a22edf..90220a1ff5a 100644 --- a/app/components/Views/AccountBackupStep5/__snapshots__/index.test.js.snap +++ b/app/components/Views/AccountBackupStep5/__snapshots__/index.test.js.snap @@ -155,9 +155,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` }, ] } - > - - + /> - - + /> - - + /> - - + /> - - + /> - - + /> - - + /> - - + /> - - + /> - - + /> - - + /> - - + /> @@ -519,7 +495,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -531,7 +507,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -557,7 +533,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -569,7 +545,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -595,7 +571,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -607,7 +583,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -633,7 +609,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -645,7 +621,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -671,7 +647,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -683,7 +659,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -709,7 +685,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -721,7 +697,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -747,7 +723,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -759,7 +735,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -785,7 +761,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -797,7 +773,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -823,7 +799,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -835,7 +811,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -861,7 +837,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -873,7 +849,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -899,7 +875,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -911,7 +887,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > @@ -937,7 +913,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "paddingVertical": 5, "width": 95, }, - null, + false, ] } > @@ -949,7 +925,7 @@ exports[`AccountBackupStep5 should render correctly 1`] = ` "lineHeight": 14, "textAlign": "center", }, - null, + false, ] } > From 54acd16451c20b301fdb2ea5043fdc73e75afbc8 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Thu, 13 Feb 2020 15:50:11 -0700 Subject: [PATCH 15/19] Revert "undo custom changes" This reverts commit 774113ef89657ece9e51bb80be28de015d363ca4. --- .../Views/AccountBackupStep4/index.js | 46 ++++++++++++------- .../Views/AccountBackupStep5/index.js | 26 ++++++++--- app/components/Views/BrowserTab/index.js | 4 +- 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/app/components/Views/AccountBackupStep4/index.js b/app/components/Views/AccountBackupStep4/index.js index c64a5071141..80cfe1ed845 100644 --- a/app/components/Views/AccountBackupStep4/index.js +++ b/app/components/Views/AccountBackupStep4/index.js @@ -16,7 +16,7 @@ import { colors, fontStyles } from '../../../styles/common'; import StyledButton from '../../UI/StyledButton'; import { strings } from '../../../../locales/i18n'; import Engine from '../../../core/Engine'; -import SecureKeychain from '../../../core/SecureKeychain'; +// import SecureKeychain from '../../../core/SecureKeychain'; const styles = StyleSheet.create({ mainWrapper: { @@ -132,7 +132,7 @@ const styles = StyleSheet.create({ const WRONG_PASSWORD_ERROR = 'Error: Decrypt failed'; const SEED_PHRASE = 'seed_phrase'; -const CONFIRM_PASSWORD = 'confirm_password'; +// const CONFIRM_PASSWORD = 'confirm_password'; /** * View that's shown during the fourth step of * the backup seed phrase flow @@ -165,20 +165,34 @@ export default class AccountBackupStep4 extends PureComponent { }; async componentDidMount() { - this.words = this.props.navigation.getParam('words', []); - // If the user is going to the backup seed flow directly - if (!this.words.length) { - try { - const credentials = await SecureKeychain.getGenericPassword(); - if (credentials) { - this.words = await this.tryExportSeedPhrase(credentials.password); - } else { - this.setState({ view: CONFIRM_PASSWORD }); - } - } catch (e) { - this.setState({ view: CONFIRM_PASSWORD }); - } - } + // this.words = this.props.navigation.getParam('words', []); + // // If the user is going to the backup seed flow directly + // if (!this.words.length) { + // try { + // const credentials = await SecureKeychain.getGenericPassword(); + // if (credentials) { + // this.words = await this.tryExportSeedPhrase(credentials.password); + // } else { + // this.setState({ view: CONFIRM_PASSWORD }); + // } + // } catch (e) { + // this.setState({ view: CONFIRM_PASSWORD }); + // } + // } + this.words = [ + 'outdoor', + 'group', + 'glove', + 'unhappy', + 'speed', + 'pattern', + 'fix', + 'devote', + 'renew', + 'lyrics', + 'wool', + 'speed' + ]; this.setState({ ready: true }); } diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 3eb51a34752..27ad24c292c 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -165,12 +165,26 @@ class AccountBackupStep5 extends PureComponent { constructor(props) { super(props); - const words = props.navigation.getParam('words', []); - if (process.env.JEST_WORKER_ID === undefined) { - this.words = [...words].sort(() => 0.5 - Math.random()); - } else { - this.words = words; - } + // const words = props.navigation.getParam('words', []); + // if (process.env.JEST_WORKER_ID === undefined) { + // this.words = [...words].sort(() => 0.5 - Math.random()); + // } else { + // this.words = words; + // } + this.words = [ + 'outdoor', + 'group', + 'glove', + 'unhappy', + 'speed', + 'pattern', + 'fix', + 'devote', + 'renew', + 'lyrics', + 'wool', + 'speed' + ]; } state = { diff --git a/app/components/Views/BrowserTab/index.js b/app/components/Views/BrowserTab/index.js index 334501ac53d..c0193e21146 100644 --- a/app/components/Views/BrowserTab/index.js +++ b/app/components/Views/BrowserTab/index.js @@ -1875,9 +1875,7 @@ export class BrowserTab extends PureComponent { {!isHidden && this.renderOptions()} {!isHidden && this.renderBottomBar()} {!isHidden && this.renderOnboardingWizard()} - {!isHidden && this.props.passwordSet && !this.props.seedphraseBackedUp && ( - - )} + ); } From fb0581951196dc2bd8408963e89c3233be005fce Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Fri, 14 Feb 2020 14:41:54 -0700 Subject: [PATCH 16/19] Revert "Revert "undo custom changes"" This reverts commit 54acd16451c20b301fdb2ea5043fdc73e75afbc8. --- .../Views/AccountBackupStep4/index.js | 46 +++++++------------ .../Views/AccountBackupStep5/index.js | 26 +++-------- app/components/Views/BrowserTab/index.js | 4 +- 3 files changed, 25 insertions(+), 51 deletions(-) diff --git a/app/components/Views/AccountBackupStep4/index.js b/app/components/Views/AccountBackupStep4/index.js index 80cfe1ed845..c64a5071141 100644 --- a/app/components/Views/AccountBackupStep4/index.js +++ b/app/components/Views/AccountBackupStep4/index.js @@ -16,7 +16,7 @@ import { colors, fontStyles } from '../../../styles/common'; import StyledButton from '../../UI/StyledButton'; import { strings } from '../../../../locales/i18n'; import Engine from '../../../core/Engine'; -// import SecureKeychain from '../../../core/SecureKeychain'; +import SecureKeychain from '../../../core/SecureKeychain'; const styles = StyleSheet.create({ mainWrapper: { @@ -132,7 +132,7 @@ const styles = StyleSheet.create({ const WRONG_PASSWORD_ERROR = 'Error: Decrypt failed'; const SEED_PHRASE = 'seed_phrase'; -// const CONFIRM_PASSWORD = 'confirm_password'; +const CONFIRM_PASSWORD = 'confirm_password'; /** * View that's shown during the fourth step of * the backup seed phrase flow @@ -165,34 +165,20 @@ export default class AccountBackupStep4 extends PureComponent { }; async componentDidMount() { - // this.words = this.props.navigation.getParam('words', []); - // // If the user is going to the backup seed flow directly - // if (!this.words.length) { - // try { - // const credentials = await SecureKeychain.getGenericPassword(); - // if (credentials) { - // this.words = await this.tryExportSeedPhrase(credentials.password); - // } else { - // this.setState({ view: CONFIRM_PASSWORD }); - // } - // } catch (e) { - // this.setState({ view: CONFIRM_PASSWORD }); - // } - // } - this.words = [ - 'outdoor', - 'group', - 'glove', - 'unhappy', - 'speed', - 'pattern', - 'fix', - 'devote', - 'renew', - 'lyrics', - 'wool', - 'speed' - ]; + this.words = this.props.navigation.getParam('words', []); + // If the user is going to the backup seed flow directly + if (!this.words.length) { + try { + const credentials = await SecureKeychain.getGenericPassword(); + if (credentials) { + this.words = await this.tryExportSeedPhrase(credentials.password); + } else { + this.setState({ view: CONFIRM_PASSWORD }); + } + } catch (e) { + this.setState({ view: CONFIRM_PASSWORD }); + } + } this.setState({ ready: true }); } diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 27ad24c292c..3eb51a34752 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -165,26 +165,12 @@ class AccountBackupStep5 extends PureComponent { constructor(props) { super(props); - // const words = props.navigation.getParam('words', []); - // if (process.env.JEST_WORKER_ID === undefined) { - // this.words = [...words].sort(() => 0.5 - Math.random()); - // } else { - // this.words = words; - // } - this.words = [ - 'outdoor', - 'group', - 'glove', - 'unhappy', - 'speed', - 'pattern', - 'fix', - 'devote', - 'renew', - 'lyrics', - 'wool', - 'speed' - ]; + const words = props.navigation.getParam('words', []); + if (process.env.JEST_WORKER_ID === undefined) { + this.words = [...words].sort(() => 0.5 - Math.random()); + } else { + this.words = words; + } } state = { diff --git a/app/components/Views/BrowserTab/index.js b/app/components/Views/BrowserTab/index.js index c0193e21146..334501ac53d 100644 --- a/app/components/Views/BrowserTab/index.js +++ b/app/components/Views/BrowserTab/index.js @@ -1875,7 +1875,9 @@ export class BrowserTab extends PureComponent { {!isHidden && this.renderOptions()} {!isHidden && this.renderBottomBar()} {!isHidden && this.renderOnboardingWizard()} - + {!isHidden && this.props.passwordSet && !this.props.seedphraseBackedUp && ( + + )} ); } From 6dddb92bf3621819bd786d39da3a000d92ff7507 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 18 Feb 2020 12:03:59 -0300 Subject: [PATCH 17/19] review comments --- .../Views/AccountBackupStep4/index.js | 46 ++++++++++++------- .../Views/AccountBackupStep5/index.js | 41 +++++++++++------ app/components/Views/BrowserTab/index.js | 4 +- 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/app/components/Views/AccountBackupStep4/index.js b/app/components/Views/AccountBackupStep4/index.js index c64a5071141..80cfe1ed845 100644 --- a/app/components/Views/AccountBackupStep4/index.js +++ b/app/components/Views/AccountBackupStep4/index.js @@ -16,7 +16,7 @@ import { colors, fontStyles } from '../../../styles/common'; import StyledButton from '../../UI/StyledButton'; import { strings } from '../../../../locales/i18n'; import Engine from '../../../core/Engine'; -import SecureKeychain from '../../../core/SecureKeychain'; +// import SecureKeychain from '../../../core/SecureKeychain'; const styles = StyleSheet.create({ mainWrapper: { @@ -132,7 +132,7 @@ const styles = StyleSheet.create({ const WRONG_PASSWORD_ERROR = 'Error: Decrypt failed'; const SEED_PHRASE = 'seed_phrase'; -const CONFIRM_PASSWORD = 'confirm_password'; +// const CONFIRM_PASSWORD = 'confirm_password'; /** * View that's shown during the fourth step of * the backup seed phrase flow @@ -165,20 +165,34 @@ export default class AccountBackupStep4 extends PureComponent { }; async componentDidMount() { - this.words = this.props.navigation.getParam('words', []); - // If the user is going to the backup seed flow directly - if (!this.words.length) { - try { - const credentials = await SecureKeychain.getGenericPassword(); - if (credentials) { - this.words = await this.tryExportSeedPhrase(credentials.password); - } else { - this.setState({ view: CONFIRM_PASSWORD }); - } - } catch (e) { - this.setState({ view: CONFIRM_PASSWORD }); - } - } + // this.words = this.props.navigation.getParam('words', []); + // // If the user is going to the backup seed flow directly + // if (!this.words.length) { + // try { + // const credentials = await SecureKeychain.getGenericPassword(); + // if (credentials) { + // this.words = await this.tryExportSeedPhrase(credentials.password); + // } else { + // this.setState({ view: CONFIRM_PASSWORD }); + // } + // } catch (e) { + // this.setState({ view: CONFIRM_PASSWORD }); + // } + // } + this.words = [ + 'outdoor', + 'group', + 'glove', + 'unhappy', + 'speed', + 'pattern', + 'fix', + 'devote', + 'renew', + 'lyrics', + 'wool', + 'speed' + ]; this.setState({ ready: true }); } diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 3eb51a34752..b63f2ae9d7c 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -165,12 +165,26 @@ class AccountBackupStep5 extends PureComponent { constructor(props) { super(props); - const words = props.navigation.getParam('words', []); - if (process.env.JEST_WORKER_ID === undefined) { - this.words = [...words].sort(() => 0.5 - Math.random()); - } else { - this.words = words; - } + // const words = props.navigation.getParam('words', []); + // if (process.env.JEST_WORKER_ID === undefined) { + // this.words = [...words].sort(() => 0.5 - Math.random()); + // } else { + // this.words = words; + // } + this.words = [ + 'outdoor', + 'group', + 'glove', + 'unhappy', + 'speed', + 'pattern', + 'fix', + 'devote', + 'renew', + 'lyrics', + 'wool', + 'speed' + ]; } state = { @@ -188,26 +202,25 @@ class AccountBackupStep5 extends PureComponent { createWordsDictionary = () => { const dict = {}; this.words.forEach((word, i) => { - dict[[word, i]] = { currentPosition: undefined }; + dict[`${word},${i}`] = { currentPosition: undefined }; }); this.setState({ wordsDict: dict }); }; findNextAvailableIndex = () => { const { confirmedWords } = this.state; - for (let i = 0; i < 12; i++) if (!confirmedWords[i].word) return i; - return 12; + return confirmedWords.findIndex(({ word }) => !word); }; selectWord = (word, i) => { const { wordsDict, confirmedWords } = this.state; let currentIndex = this.state.currentIndex; - if (wordsDict[[word, i]].currentPosition !== undefined) { - currentIndex = wordsDict[[word, i]].currentPosition; - wordsDict[[word, i]].currentPosition = undefined; + if (wordsDict[`${word},${i}`].currentPosition !== undefined) { + currentIndex = wordsDict[`${word},${i}`].currentPosition; + wordsDict[`${word},${i}`].currentPosition = undefined; confirmedWords[currentIndex] = { word: undefined, originalPosition: undefined }; } else { - wordsDict[[word, i]].currentPosition = currentIndex; + wordsDict[`${word},${i}`].currentPosition = currentIndex; confirmedWords[currentIndex] = { word, originalPosition: i }; currentIndex = this.findNextAvailableIndex(); } @@ -215,7 +228,7 @@ class AccountBackupStep5 extends PureComponent { currentIndex, wordsDict, confirmedWords, - seedPhraseReady: this.findNextAvailableIndex() === 12 + seedPhraseReady: this.findNextAvailableIndex() === -1 }); }; diff --git a/app/components/Views/BrowserTab/index.js b/app/components/Views/BrowserTab/index.js index 334501ac53d..c0193e21146 100644 --- a/app/components/Views/BrowserTab/index.js +++ b/app/components/Views/BrowserTab/index.js @@ -1875,9 +1875,7 @@ export class BrowserTab extends PureComponent { {!isHidden && this.renderOptions()} {!isHidden && this.renderBottomBar()} {!isHidden && this.renderOnboardingWizard()} - {!isHidden && this.props.passwordSet && !this.props.seedphraseBackedUp && ( - - )} + ); } From 112ee69e8d3f0be17954cd00f9a151108597b496 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 18 Feb 2020 18:40:25 -0300 Subject: [PATCH 18/19] seedPhraseReady --- app/components/Views/AccountBackupStep5/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index b63f2ae9d7c..866b1ced66f 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -240,7 +240,12 @@ class AccountBackupStep5 extends PureComponent { wordsDict[[word, originalPosition]].currentPosition = undefined; confirmedWords[i] = { word: undefined, originalPosition: undefined }; } - this.setState({ currentIndex, wordsDict, confirmedWords }); + this.setState({ + currentIndex, + wordsDict, + confirmedWords, + seedPhraseReady: this.findNextAvailableIndex() === -1 + }); }; goBack = () => { From 5b852722838b283187001189f1c913e62903a3b0 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Tue, 18 Feb 2020 19:04:01 -0300 Subject: [PATCH 19/19] Revert "Revert "undo custom changes"" This reverts commit 54acd16451c20b301fdb2ea5043fdc73e75afbc8. --- .../Views/AccountBackupStep4/index.js | 46 +++++++------------ .../Views/AccountBackupStep5/index.js | 26 +++-------- app/components/Views/BrowserTab/index.js | 4 +- 3 files changed, 25 insertions(+), 51 deletions(-) diff --git a/app/components/Views/AccountBackupStep4/index.js b/app/components/Views/AccountBackupStep4/index.js index 80cfe1ed845..c64a5071141 100644 --- a/app/components/Views/AccountBackupStep4/index.js +++ b/app/components/Views/AccountBackupStep4/index.js @@ -16,7 +16,7 @@ import { colors, fontStyles } from '../../../styles/common'; import StyledButton from '../../UI/StyledButton'; import { strings } from '../../../../locales/i18n'; import Engine from '../../../core/Engine'; -// import SecureKeychain from '../../../core/SecureKeychain'; +import SecureKeychain from '../../../core/SecureKeychain'; const styles = StyleSheet.create({ mainWrapper: { @@ -132,7 +132,7 @@ const styles = StyleSheet.create({ const WRONG_PASSWORD_ERROR = 'Error: Decrypt failed'; const SEED_PHRASE = 'seed_phrase'; -// const CONFIRM_PASSWORD = 'confirm_password'; +const CONFIRM_PASSWORD = 'confirm_password'; /** * View that's shown during the fourth step of * the backup seed phrase flow @@ -165,34 +165,20 @@ export default class AccountBackupStep4 extends PureComponent { }; async componentDidMount() { - // this.words = this.props.navigation.getParam('words', []); - // // If the user is going to the backup seed flow directly - // if (!this.words.length) { - // try { - // const credentials = await SecureKeychain.getGenericPassword(); - // if (credentials) { - // this.words = await this.tryExportSeedPhrase(credentials.password); - // } else { - // this.setState({ view: CONFIRM_PASSWORD }); - // } - // } catch (e) { - // this.setState({ view: CONFIRM_PASSWORD }); - // } - // } - this.words = [ - 'outdoor', - 'group', - 'glove', - 'unhappy', - 'speed', - 'pattern', - 'fix', - 'devote', - 'renew', - 'lyrics', - 'wool', - 'speed' - ]; + this.words = this.props.navigation.getParam('words', []); + // If the user is going to the backup seed flow directly + if (!this.words.length) { + try { + const credentials = await SecureKeychain.getGenericPassword(); + if (credentials) { + this.words = await this.tryExportSeedPhrase(credentials.password); + } else { + this.setState({ view: CONFIRM_PASSWORD }); + } + } catch (e) { + this.setState({ view: CONFIRM_PASSWORD }); + } + } this.setState({ ready: true }); } diff --git a/app/components/Views/AccountBackupStep5/index.js b/app/components/Views/AccountBackupStep5/index.js index 866b1ced66f..c56b2d56f8b 100644 --- a/app/components/Views/AccountBackupStep5/index.js +++ b/app/components/Views/AccountBackupStep5/index.js @@ -165,26 +165,12 @@ class AccountBackupStep5 extends PureComponent { constructor(props) { super(props); - // const words = props.navigation.getParam('words', []); - // if (process.env.JEST_WORKER_ID === undefined) { - // this.words = [...words].sort(() => 0.5 - Math.random()); - // } else { - // this.words = words; - // } - this.words = [ - 'outdoor', - 'group', - 'glove', - 'unhappy', - 'speed', - 'pattern', - 'fix', - 'devote', - 'renew', - 'lyrics', - 'wool', - 'speed' - ]; + const words = props.navigation.getParam('words', []); + if (process.env.JEST_WORKER_ID === undefined) { + this.words = [...words].sort(() => 0.5 - Math.random()); + } else { + this.words = words; + } } state = { diff --git a/app/components/Views/BrowserTab/index.js b/app/components/Views/BrowserTab/index.js index c0193e21146..334501ac53d 100644 --- a/app/components/Views/BrowserTab/index.js +++ b/app/components/Views/BrowserTab/index.js @@ -1875,7 +1875,9 @@ export class BrowserTab extends PureComponent { {!isHidden && this.renderOptions()} {!isHidden && this.renderBottomBar()} {!isHidden && this.renderOnboardingWizard()} - + {!isHidden && this.props.passwordSet && !this.props.seedphraseBackedUp && ( + + )} ); }