diff --git a/.prettierignore b/.prettierignore index ec6d3cdd..2c4bd388 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ package.json +test-e2e/sync/data diff --git a/package.json b/package.json index ce335bac..6c84f1ac 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test": "jest src", "test-e2e": "jest test-e2e", "test-sync": "bash test-e2e/sync/launch.sh", - "prettier": "prettier --write \"{src,webpack,.storybook,test-e2e, test-e2e/sync/data}/**/*.{js,json}\"", + "prettier": "prettier --write \"{src,webpack,.storybook,test-e2e}/**/*.{js,json}\"", "ci": "yarn lint && yarn flow && yarn prettier && yarn test", "storybook": "NODE_ENV=development STORYBOOK_ENV=1 start-storybook -s ./static -p 4444", "publish-storybook": "bash ./scripts/legacy/publish-storybook.sh", @@ -40,7 +40,7 @@ "@ledgerhq/hw-transport": "^4.13.0", "@ledgerhq/hw-transport-node-hid": "4.22.0", "@ledgerhq/ledger-core": "2.0.0-rc.7", - "@ledgerhq/live-common": "^3.5.1", + "@ledgerhq/live-common": "^3.7.1", "animated": "^0.2.2", "async": "^2.6.1", "axios": "^0.18.0", diff --git a/src/bridge/EthereumJSBridge.js b/src/bridge/EthereumJSBridge.js index e68f70d2..2a48e6cf 100644 --- a/src/bridge/EthereumJSBridge.js +++ b/src/bridge/EthereumJSBridge.js @@ -420,15 +420,13 @@ const EthereumBridge: WalletBridge = { getTransactionRecipient: (a, t) => t.recipient, - isValidTransaction: (a, t) => (!t.amount.isZero() && t.recipient && true) || false, - EditFees, EditAdvancedOptions, - checkCanBeSpent: (a, t) => + checkValidTransaction: (a, t) => t.amount.isLessThanOrEqualTo(a.balance) - ? Promise.resolve() + ? Promise.resolve(true) : Promise.reject(new NotEnoughBalance()), getTotalSpent: (a, t) => diff --git a/src/bridge/LibcoreBridge.js b/src/bridge/LibcoreBridge.js index abfa5eae..355232e6 100644 --- a/src/bridge/LibcoreBridge.js +++ b/src/bridge/LibcoreBridge.js @@ -94,11 +94,11 @@ const getFees = async (a, transaction) => { return promise } -const checkCanBeSpent = (a, t) => +const checkValidTransaction = (a, t) => !t.amount - ? Promise.resolve() + ? Promise.resolve(true) : getFees(a, t) - .then(() => {}) + .then(() => true) .catch(e => { if (e.code === NOT_ENOUGH_FUNDS) { throw new NotEnoughBalance() @@ -191,9 +191,7 @@ const LibcoreBridge: WalletBridge = { // EditAdvancedOptions, - isValidTransaction: (a, t) => (!t.amount.isZero() && t.recipient && true) || false, - - checkCanBeSpent, + checkValidTransaction, getTotalSpent: (a, t) => t.amount.isZero() diff --git a/src/bridge/RippleJSBridge.js b/src/bridge/RippleJSBridge.js index f872eeb6..952fdaf9 100644 --- a/src/bridge/RippleJSBridge.js +++ b/src/bridge/RippleJSBridge.js @@ -463,10 +463,30 @@ const RippleJSBridge: WalletBridge = { getTransactionAmount: (a, t) => t.amount, - editTransactionRecipient: (account, t, recipient) => ({ - ...t, - recipient, - }), + editTransactionRecipient: (account, t, recipient) => { + const parts = recipient.split('?') + const params = new URLSearchParams(parts[1]) + recipient = parts[0] + + // Extract parameters we may need + for (const [key, value] of params.entries()) { + switch (key) { + case 'dt': + t.tag = parseInt(value, 10) || 0 + break + case 'amount': + t.amount = parseAPIValue(value || '0') + break + default: + // do nothing + } + } + + return { + ...t, + recipient, + } + }, EditFees, @@ -474,9 +494,7 @@ const RippleJSBridge: WalletBridge = { getTransactionRecipient: (a, t) => t.recipient, - isValidTransaction: (a, t) => (!t.amount.isZero() && t.recipient && true) || false, - - checkCanBeSpent: async (a, t) => { + checkValidTransaction: async (a, t) => { const r = await getServerInfo(a.endpointConfig) if ( t.amount @@ -484,7 +502,7 @@ const RippleJSBridge: WalletBridge = { .plus(parseAPIValue(r.validatedLedger.reserveBaseXRP)) .isLessThanOrEqualTo(a.balance) ) { - return + return true } throw new NotEnoughBalance() }, diff --git a/src/bridge/UnsupportedBridge.js b/src/bridge/UnsupportedBridge.js index 6f5d5c12..ebc768e5 100644 --- a/src/bridge/UnsupportedBridge.js +++ b/src/bridge/UnsupportedBridge.js @@ -27,13 +27,11 @@ const UnsupportedBridge: WalletBridge<*> = { getTransactionAmount: () => BigNumber(0), - isValidTransaction: () => false, - editTransactionRecipient: () => null, getTransactionRecipient: () => '', - checkCanBeSpent: () => Promise.resolve(), + checkValidTransaction: () => Promise.resolve(false), getTotalSpent: () => Promise.resolve(BigNumber(0)), diff --git a/src/bridge/makeMockBridge.js b/src/bridge/makeMockBridge.js index 909dfe91..d266c234 100644 --- a/src/bridge/makeMockBridge.js +++ b/src/bridge/makeMockBridge.js @@ -18,7 +18,7 @@ const defaultOpts = { scanAccountDeviceSuccessRate: 0.8, transactionsSizeTarget: 100, extraInitialTransactionProps: () => null, - checkCanBeSpent: () => Promise.resolve(), + checkValidTransaction: () => Promise.resolve(), getTotalSpent: (a, t) => Promise.resolve(t.amount), getMaxAmount: a => Promise.resolve(a.balance), } @@ -36,7 +36,7 @@ function makeMockBridge(opts?: Opts): WalletBridge<*> { extraInitialTransactionProps, getTotalSpent, getMaxAmount, - checkCanBeSpent, + checkValidTransaction, } = { ...defaultOpts, ...opts, @@ -155,9 +155,7 @@ function makeMockBridge(opts?: Opts): WalletBridge<*> { EditAdvancedOptions, - isValidTransaction: (a, t) => (t.amount > 0 && t.recipient && true) || false, - - checkCanBeSpent, + checkValidTransaction, getTotalSpent, diff --git a/src/bridge/types.js b/src/bridge/types.js index 53a28250..eea8cefa 100644 --- a/src/bridge/types.js +++ b/src/bridge/types.js @@ -76,15 +76,16 @@ export interface WalletBridge { getTransactionRecipient(account: Account, transaction: Transaction): string; - isValidTransaction(account: Account, transaction: Transaction): boolean; - // render the whole Fees section of the form EditFees?: *; // React$ComponentType>; // render the whole advanced part of the form EditAdvancedOptions?: *; // React$ComponentType>; - checkCanBeSpent(account: Account, transaction: Transaction): Promise; + // validate the transaction and all currency specific validations here, we can return false + // to disable the button without throwing an error if we are handling the error on a different + // input or throw an error that will highlight the issue on the amount field + checkValidTransaction(account: Account, transaction: Transaction): Promise; getTotalSpent(account: Account, transaction: Transaction): Promise; diff --git a/src/commands/index.js b/src/commands/index.js index 117a8b3f..fad516a6 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -15,6 +15,7 @@ import installFinalFirmware from 'commands/installFinalFirmware' import installMcu from 'commands/installMcu' import installOsuFirmware from 'commands/installOsuFirmware' import isDashboardOpen from 'commands/isDashboardOpen' +import killInternalProcess from 'commands/killInternalProcess' import libcoreGetFees from 'commands/libcoreGetFees' import libcoreGetVersion from 'commands/libcoreGetVersion' import libcoreScanAccounts from 'commands/libcoreScanAccounts' @@ -47,6 +48,7 @@ const all: Array> = [ installMcu, installOsuFirmware, isDashboardOpen, + killInternalProcess, libcoreGetFees, libcoreGetVersion, libcoreScanAccounts, diff --git a/src/commands/killInternalProcess.js b/src/commands/killInternalProcess.js new file mode 100644 index 00000000..428fecd4 --- /dev/null +++ b/src/commands/killInternalProcess.js @@ -0,0 +1,18 @@ +// @flow + +import { createCommand, Command } from 'helpers/ipc' +import { of } from 'rxjs' + +type Input = void +type Result = boolean + +const cmd: Command = createCommand('killInternalProcess', () => { + setTimeout(() => { + // we assume commands are run on the internal process + // special exit code for better identification + process.exit(42) + }) + return of(true) +}) + +export default cmd diff --git a/src/components/AdvancedOptions/RippleKind.js b/src/components/AdvancedOptions/RippleKind.js index 74b0b5a4..ff34faa7 100644 --- a/src/components/AdvancedOptions/RippleKind.js +++ b/src/components/AdvancedOptions/RippleKind.js @@ -6,7 +6,6 @@ import { translate } from 'react-i18next' import Box from 'components/base/Box' import Input from 'components/base/Input' import Label from 'components/base/Label' -import Spoiler from 'components/base/Spoiler' type Props = { tag: ?number, @@ -31,18 +30,14 @@ class RippleKind extends Component { render() { const { tag, t } = this.props return ( - - - - - - - - + + + + - + ) } } diff --git a/src/components/ExchangePage/index.js b/src/components/ExchangePage/index.js index 9e612a78..09f3502b 100644 --- a/src/components/ExchangePage/index.js +++ b/src/components/ExchangePage/index.js @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react' import { translate } from 'react-i18next' +import shuffle from 'lodash/shuffle' import type { T } from 'types/common' import { urls } from 'config/urls' @@ -21,7 +22,7 @@ type Props = { t: T, } -const cards = [ +const cards = shuffle([ { key: 'coinhouse', id: 'coinhouse', @@ -70,7 +71,7 @@ const cards = [ url: urls.genesis, logo: Genesis, }, -] +]) class ExchangePage extends PureComponent { render() { diff --git a/src/components/ManagerPage/AppsList.js b/src/components/ManagerPage/AppsList.js index f589ea7f..bf1fd550 100644 --- a/src/components/ManagerPage/AppsList.js +++ b/src/components/ManagerPage/AppsList.js @@ -7,15 +7,13 @@ import { translate } from 'react-i18next' import { connect } from 'react-redux' import { compose } from 'redux' import type { Device, T } from 'types/common' -import type { Application, ApplicationVersion, DeviceInfo } from 'helpers/types' +import type { ApplicationVersion, DeviceInfo } from 'helpers/types' +import { getFullListSortedCryptoCurrencies } from 'helpers/countervalues' import { developerModeSelector } from 'reducers/settings' - import listApps from 'commands/listApps' import listAppVersions from 'commands/listAppVersions' - import installApp from 'commands/installApp' import uninstallApp from 'commands/uninstallApp' - import Box from 'components/base/Box' import Space from 'components/base/Space' import Modal, { ModalBody, ModalFooter, ModalTitle, ModalContent } from 'components/base/Modal' @@ -26,13 +24,11 @@ import Spinner from 'components/base/Spinner' import Button from 'components/base/Button' import TranslatedError from 'components/TranslatedError' import TrackPage from 'analytics/TrackPage' - import IconInfoCircle from 'icons/InfoCircle' import ExclamationCircleThin from 'icons/ExclamationCircleThin' import Update from 'icons/Update' import Trash from 'icons/Trash' import CheckCircle from 'icons/CheckCircle' - import { FreezeDeviceChangeEvents } from './HookDeviceChange' import ManagerApp, { Container as FakeManagerAppContainer } from './ManagerApp' import AppSearchBar from './AppSearchBar' @@ -102,29 +98,53 @@ class AppsList extends PureComponent { _unmounted = false - filterAppVersions = (applicationsList, compatibleAppVersionsList) => { - if (!this.props.isDevMode) { - return compatibleAppVersionsList.filter(version => { - const app = applicationsList.find(e => e.id === version.app) - if (app) { - return app.category !== 2 - } + prepareAppList = ({ applicationsList, compatibleAppVersionsList, sortedCryptoCurrencies }) => { + const filtered = this.props.isDevMode + ? compatibleAppVersionsList.slice(0) + : compatibleAppVersionsList.filter(version => { + const app = applicationsList.find(e => e.id === version.app) + if (app) { + return app.category !== 2 + } - return false - }) - } - return compatibleAppVersionsList + return false + }) + + const sortedCryptoApps = [] + + // sort by crypto first + sortedCryptoCurrencies.forEach(crypto => { + const app = filtered.find( + item => item.name.toLowerCase() === crypto.managerAppName.toLowerCase(), + ) + if (app) { + filtered.splice(filtered.indexOf(app), 1) + sortedCryptoApps.push(app) + } + }) + + return sortedCryptoApps.concat(filtered) } async fetchAppList() { try { const { deviceInfo } = this.props - const applicationsList: Array = await listApps.send().toPromise() - const compatibleAppVersionsList = await listAppVersions.send(deviceInfo).toPromise() - const filteredAppVersionsList = this.filterAppVersions( + + const [ applicationsList, compatibleAppVersionsList, - ) + sortedCryptoCurrencies, + ] = await Promise.all([ + listApps.send().toPromise(), + listAppVersions.send(deviceInfo).toPromise(), + getFullListSortedCryptoCurrencies(), + ]) + + const filteredAppVersionsList = this.prepareAppList({ + applicationsList, + compatibleAppVersionsList, + sortedCryptoCurrencies, + }) if (!this._unmounted) { this.setState({ diff --git a/src/components/ManagerPage/index.js b/src/components/ManagerPage/index.js index 7c9631b2..24ee0407 100644 --- a/src/components/ManagerPage/index.js +++ b/src/components/ManagerPage/index.js @@ -4,12 +4,11 @@ import React, { PureComponent, Fragment } from 'react' import invariant from 'invariant' import { openURL } from 'helpers/linking' import { urls } from 'config/urls' - import type { Device } from 'types/common' import type { DeviceInfo } from 'helpers/types' +import { getFullListSortedCryptoCurrencies } from 'helpers/countervalues' import Dashboard from './Dashboard' - import ManagerGenuineCheck from './ManagerGenuineCheck' import HookDeviceChange from './HookDeviceChange' @@ -30,6 +29,10 @@ const INITIAL_STATE = { class ManagerPage extends PureComponent { state = INITIAL_STATE + componentDidMount() { + getFullListSortedCryptoCurrencies() // start fetching the crypto currencies ordering + } + // prettier-ignore handleSuccessGenuine = ({ device, deviceInfo }: { device: Device, deviceInfo: DeviceInfo }) => { // eslint-disable-line react/no-unused-prop-types this.setState({ isGenuine: true, device, deviceInfo }) diff --git a/src/components/Onboarding/steps/Analytics.js b/src/components/Onboarding/steps/Analytics.js index 360ce4ba..2ac8af4d 100644 --- a/src/components/Onboarding/steps/Analytics.js +++ b/src/components/Onboarding/steps/Analytics.js @@ -26,7 +26,7 @@ type State = { } const INITIAL_STATE = { - analyticsToggle: false, + analyticsToggle: true, sentryLogsToggle: true, } diff --git a/src/components/RequestAmount/index.js b/src/components/RequestAmount/index.js index 63528897..2e9c1778 100644 --- a/src/components/RequestAmount/index.js +++ b/src/components/RequestAmount/index.js @@ -48,7 +48,7 @@ type OwnProps = { // left value (always the one which is returned) value: BigNumber, - canBeSpentError: ?Error, + validTransactionError: ?Error, // max left value max: BigNumber, @@ -113,7 +113,7 @@ const mapStateToProps = (state: State, props: OwnProps) => { export class RequestAmount extends PureComponent { static defaultProps = { max: BigNumber(Infinity), - canBeSpent: true, + validTransaction: true, withMax: true, } @@ -139,14 +139,14 @@ export class RequestAmount extends PureComponent { renderInputs(containerProps: Object) { // TODO move this inlined into render() for less spaghetti - const { value, account, rightCurrency, getCounterValue, canBeSpentError } = this.props + const { value, account, rightCurrency, getCounterValue, validTransactionError } = this.props const right = getCounterValue(value) || BigNumber(0) const rightUnit = rightCurrency.units[0] // FIXME: no way InputCurrency pure can work here. inlined InputRight (should be static func?), inline containerProps object.. return ( { primary={!isDanger} danger={isDanger} isLoading={isLoading} + disabled={isLoading} > {realConfirmText} diff --git a/src/components/modals/Send/fields/AmountField.js b/src/components/modals/Send/fields/AmountField.js index 2fca8cef..5154e897 100644 --- a/src/components/modals/Send/fields/AmountField.js +++ b/src/components/modals/Send/fields/AmountField.js @@ -4,9 +4,9 @@ import Box from 'components/base/Box' import Label from 'components/base/Label' import RequestAmount from 'components/RequestAmount' -class AmountField extends Component<*, { canBeSpentError: ?Error }> { +class AmountField extends Component<*, { validTransactionError: ?Error }> { state = { - canBeSpentError: null, + validTransactionError: null, } componentDidMount() { this.resync() @@ -27,11 +27,11 @@ class AmountField extends Component<*, { canBeSpentError: ?Error }> { const { account, bridge, transaction } = this.props const syncId = ++this.syncId try { - await bridge.checkCanBeSpent(account, transaction) + await bridge.checkValidTransaction(account, transaction) if (this.syncId !== syncId) return - this.setState({ canBeSpentError: null }) - } catch (canBeSpentError) { - this.setState({ canBeSpentError }) + this.setState({ validTransactionError: null }) + } catch (validTransactionError) { + this.setState({ validTransactionError }) } } @@ -42,14 +42,14 @@ class AmountField extends Component<*, { canBeSpentError: ?Error }> { render() { const { bridge, account, transaction, t } = this.props - const { canBeSpentError } = this.state + const { validTransactionError } = this.state return ( diff --git a/src/components/modals/Send/steps/01-step-amount.js b/src/components/modals/Send/steps/01-step-amount.js index 959cd92e..a38f3db7 100644 --- a/src/components/modals/Send/steps/01-step-amount.js +++ b/src/components/modals/Send/steps/01-step-amount.js @@ -134,11 +134,13 @@ export class StepAmountFooter extends PureComponent< bridge.getTransactionRecipient(account, transaction), ) if (syncId !== this.syncId) return - const canBeSpent = await bridge - .checkCanBeSpent(account, transaction) - .then(() => true, () => false) + const isValidTransaction = await bridge + .checkValidTransaction(account, transaction) + .then(result => result, () => false) + if (syncId !== this.syncId) return - const canNext = isRecipientValid && canBeSpent && totalSpent.gt(0) + const canNext = + !transaction.amount.isZero() && isRecipientValid && isValidTransaction && totalSpent.gt(0) this.setState({ totalSpent, canNext, isSyncing: false }) } catch (err) { logger.critical(err) diff --git a/src/helpers/countervalues.js b/src/helpers/countervalues.js index 7f8801b1..1f45137c 100644 --- a/src/helpers/countervalues.js +++ b/src/helpers/countervalues.js @@ -12,6 +12,8 @@ import { intermediaryCurrency, } from 'reducers/settings' import logger from 'logger' +import { listCryptoCurrencies } from '@ledgerhq/live-common/lib/helpers/currencies' +import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types' const pairsSelector = createSelector( currenciesSelector, @@ -52,6 +54,7 @@ const addExtraPollingHooks = (schedulePoll, cancelPoll) => { } } +// TODO we should be able to pass-in our network() function const CounterValues = createCounterValues({ log: (...args) => logger.log('CounterValues:', ...args), getAPIBaseURL: () => LEDGER_COUNTERVALUES_API, @@ -61,4 +64,30 @@ const CounterValues = createCounterValues({ addExtraPollingHooks, }) +let sortCache +export const getFullListSortedCryptoCurrencies: () => Promise = () => { + if (!sortCache) { + sortCache = CounterValues.fetchTickersByMarketcap().then( + tickers => { + const list = listCryptoCurrencies().slice(0) + const prependList = [] + tickers.forEach(ticker => { + const item = list.find(c => c.ticker === ticker) + if (item) { + list.splice(list.indexOf(item), 1) + prependList.push(item) + } + }) + return prependList.concat(list) + }, + () => { + sortCache = null // reset the cache for the next time it comes here to "try again" + return listCryptoCurrencies() // fallback on default sort + }, + ) + } + + return sortCache +} + export default CounterValues diff --git a/src/helpers/reset.js b/src/helpers/reset.js index 198d354a..051d4240 100644 --- a/src/helpers/reset.js +++ b/src/helpers/reset.js @@ -6,8 +6,10 @@ import resolveUserDataDirectory from 'helpers/resolveUserDataDirectory' import { disable as disableDBMiddleware } from 'middlewares/db' import db from 'helpers/db' import { delay } from 'helpers/promise' +import killInternalProcess from 'commands/killInternalProcess' -function resetLibcoreDatabase() { +async function resetLibcoreDatabase() { + await killInternalProcess.send().toPromise() const dbpath = path.resolve(resolveUserDataDirectory(), 'sqlite/') rimraf.sync(dbpath, { glob: false }) } diff --git a/src/reducers/settings.js b/src/reducers/settings.js index 76e51bb7..2adfdd6f 100644 --- a/src/reducers/settings.js +++ b/src/reducers/settings.js @@ -70,7 +70,7 @@ const INITIAL_STATE: SettingsState = { currenciesSettings: {}, developerMode: !!process.env.__DEV__, loaded: false, - shareAnalytics: false, + shareAnalytics: true, sentryLogs: true, lastUsedVersion: __APP_VERSION__, } diff --git a/static/i18n/en/app.json b/static/i18n/en/app.json index b94db001..999829f3 100644 --- a/static/i18n/en/app.json +++ b/static/i18n/en/app.json @@ -167,7 +167,7 @@ "coinmama": "Coinmama is a financial service that makes it fast, safe and fun to buy digital assets, anywhere in the world.", "simplex": "Simplex is a EU licensed financial institution, providing a fraudless credit card payment solution.", "paybis": "it is safe and easy to Buy Bitcoin with credit card from PayBis. Service operates inĀ US, Canada, Germany, Russia and Saudi Arabia.", - "luno": "Luno makes it safe and easy to buy, store and learn about digital currencies like Bitcoin and Ethreum", + "luno": "Luno makes it safe and easy to buy, store and learn about cryptocurrencies like Bitcoin and Ethereum", "shapeshift": "ShapeShift is an online marketplace where users can buy and sell digital assets. It is a fast and secure way for the world to buy and sell digital assets, with no lengthy signup process, no counterparty risk, and no friction.", "genesis": "Genesis is an institutional trading firm offering liquidity and borrow for digital currencies, including bitcoin, bitcoin cash, ethereum, ethereum classic, litecoin, and XRP." }, diff --git a/test-e2e/password-lock-check.spec.js b/test-e2e/password-lock-check.spec.js index a5e9da19..912a4b27 100644 --- a/test-e2e/password-lock-check.spec.js +++ b/test-e2e/password-lock-check.spec.js @@ -2,30 +2,32 @@ import { Application } from 'spectron' import { waitForDisappear, waitForExpectedText } from './helpers' const os = require('os') +const path = require('path') +const fs = require('fs') const appVersion = require('../package.json') let app const TIMEOUT = 50 * 1000 -let app_path +let appPath let configPath const platform = os.platform() if (platform === 'darwin') { - app_path = `./dist/mac/Ledger Live.app/Contents/MacOS/Ledger Live` - configPath = `~/Library/Application Support/Ledger Live/` + appPath = `./dist/mac/Ledger Live.app/Contents/MacOS/Ledger Live` + configPath = `${os.homedir()}/Library/Application Support/Ledger Live/` } else if (platform === 'win32') { - app_path = `.\\dist\\win-unpacked\\Ledger Live.exe` + appPath = `.\\dist\\win-unpacked\\Ledger Live.exe` configPath = '%AppData\\Roaming\\Ledger Live' } else { - app_path = `./dist/ledger-live-desktop-${appVersion.version}-linux-x86_64.AppImage` + appPath = `./dist/ledger-live-desktop-${appVersion.version}-linux-x86_64.AppImage` configPath = '$HOME/apps/ledger-live-desktop-$ledgerLiveVersion-linux-x86_64.AppImage' } describe('Application launch', () => { beforeEach(async () => { app = new Application({ - path: app_path, + path: appPath, env: { SKIP_ONBOARDING: '1', }, @@ -49,7 +51,7 @@ describe('Application launch', () => { // Verify Account summary text // Count user's accounts const userAccountsList = await app.client.elements('[data-e2e=dashboard_AccountCardWrapper]') - const userAccountsCount = await Object.keys(userAccountsList.value).length + const userAccountsCount = Object.keys(userAccountsList.value).length // Check account number const accountSummary = await app.client.getText('[data-e2e=dashboard_accountsSummaryDesc]') const accountSummaryMessage = `Here's the summary of your ${userAccountsCount} accounts` @@ -66,18 +68,24 @@ describe('Application launch', () => { await app.client.setValue('[data-e2e=setPassword_ConfirmPassword]', 5) await app.client.keys('Enter') await waitForExpectedText(app, '[data-e2e=settings_title]', 'Settings') - + await app.client.pause(2000) // Verify in app.json that accounts data are encrypted - const tmpAppJSONPath = `${configPath} + "app.json"` - const accountsOperations = '"operations": [{' - expect(tmpAppJSONPath).not.toContain(accountsOperations) + const tmpAppJSONPath = path.resolve(configPath, 'app.json') + const LockedfileContent = fs.readFileSync(tmpAppJSONPath, 'utf-8') + const accountsOperations = '"operations":[{' + await expect(LockedfileContent).not.toContain(accountsOperations) - // Desable password lock + // Disable password lock await app.client.click('[data-e2e=passwordLock_button]') await waitForExpectedText(app, '[data-e2e=modal_title]', 'Disable password lock') await app.client.setValue('#password', 5) + await app.client.pause(500) await app.client.keys('Enter') await waitForExpectedText(app, '[data-e2e=settings_title]', 'Settings') + await app.client.pause(3000) + const UnlockedfileContent = fs.readFileSync(tmpAppJSONPath, 'utf-8') + // Verify in app.json that accounts data are not encrypted + await expect(UnlockedfileContent).toContain(accountsOperations) await app.client.pause(1000) }, TIMEOUT, diff --git a/yarn.lock b/yarn.lock index 71c73832..9e0fb6ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1549,9 +1549,9 @@ npm "^5.7.1" prebuild-install "^2.2.2" -"@ledgerhq/live-common@^3.5.1": - version "3.5.1" - resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-3.5.1.tgz#dab3eb061f361999a9e04ef564808831faac61ea" +"@ledgerhq/live-common@^3.7.1": + version "3.7.1" + resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-3.7.1.tgz#5ce1895920d2eae6c454c2c72612dc9afd11adec" dependencies: axios "^0.18.0" bignumber.js "^7.2.1"