diff --git a/app/browser/api/ledger.js b/app/browser/api/ledger.js index 407e39f68da..65618971977 100644 --- a/app/browser/api/ledger.js +++ b/app/browser/api/ledger.js @@ -31,6 +31,7 @@ const updateState = require('../../common/state/updateState') // Constants const settings = require('../../../js/constants/settings') const messages = require('../../../js/constants/messages') +const ledgerStatuses = require('../../common/constants/ledgerStatuses') // Utils const config = require('../../../js/constants/buildConfig') @@ -179,11 +180,25 @@ const paymentPresent = (state, tabId, present) => { } appActions.onPromotionGet() + + state = checkSeed(state) getPublisherTimestamp(true) } else if (balanceTimeoutId) { clearTimeout(balanceTimeoutId) balanceTimeoutId = false } + + return state +} + +const checkSeed = (state) => { + const seed = ledgerState.getInfoProp(state, 'passphrase') + + if (seed && !client.isValidPassPhrase(seed)) { + state = ledgerState.setAboutProp(state, 'status', ledgerStatuses.CORRUPTED) + } + + return state } const getPublisherTimestamp = (updateList) => { @@ -1629,7 +1644,7 @@ const getStateInfo = (state, parsedData) => { const oldReconcileStamp = ledgerState.getInfoProp(state, 'reconcileStamp') if (oldReconcileStamp && newInfo.reconcileStamp > oldReconcileStamp) { - state = ledgerState.setAboutProp(state, 'status', 'contributionInProgress') + state = ledgerState.setAboutProp(state, 'status', ledgerStatuses.IN_PROGRESS) } let passphrase = ledgerClient.prototype.getWalletPassphrase(parsedData) @@ -2963,7 +2978,8 @@ const getMethods = () => { onReferralInit, roundTripFromWindow, onReferralCodeRead, - onVerifiedPStatus + onVerifiedPStatus, + checkSeed } } diff --git a/app/browser/reducers/ledgerReducer.js b/app/browser/reducers/ledgerReducer.js index 9ff932db3b2..ca8d60e70e1 100644 --- a/app/browser/reducers/ledgerReducer.js +++ b/app/browser/reducers/ledgerReducer.js @@ -250,7 +250,7 @@ const ledgerReducer = (state, action, immutableAction) => { } case appConstants.APP_LEDGER_PAYMENTS_PRESENT: { - ledgerApi.paymentPresent(state, action.get('tabId'), action.get('present')) + state = ledgerApi.paymentPresent(state, action.get('tabId'), action.get('present')) break } case appConstants.APP_ON_ADD_FUNDS_CLOSED: diff --git a/app/browser/tabs.js b/app/browser/tabs.js index 2311a70a130..999064a4517 100644 --- a/app/browser/tabs.js +++ b/app/browser/tabs.js @@ -271,6 +271,7 @@ const updateAboutDetails = (tabId) => { .set('wizardData', wizardData) .set('migration', migration) .set('promotion', ledgerState.getAboutPromotion(appState)) + .set('tabId', tabId) sendAboutDetails(tabId, messages.LEDGER_UPDATED, ledgerData) } else if (url === 'about:preferences#sync' || location === 'about:contributions' || onPaymentsPage) { const sync = appState.get('sync', Immutable.Map()) diff --git a/app/common/constants/ledgerStatuses.js b/app/common/constants/ledgerStatuses.js new file mode 100644 index 00000000000..4c3c6500506 --- /dev/null +++ b/app/common/constants/ledgerStatuses.js @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const statuses = { + CORRUPTED: 'corruptedSeed', + IN_PROGRESS: 'contributionInProgress' +} + +module.exports = statuses diff --git a/app/extensions/brave/locales/en-US/preferences.properties b/app/extensions/brave/locales/en-US/preferences.properties index 3400bd1cdcd..e471306739d 100644 --- a/app/extensions/brave/locales/en-US/preferences.properties +++ b/app/extensions/brave/locales/en-US/preferences.properties @@ -90,6 +90,11 @@ contributionTime=Contribution Time copied=Copied! copy=Copy copyToClipboard.title=Copy to clipboard +corruptedOverlayTitle=Hello! +corruptedOverlayMessage=Unfortunately your active wallet has been corrupted. +corruptedOverlayText=You must recover your backup wallet with your recovery keys before any transactions can be processed. We apologize for the inconvenience. +corruptedOverlayFAQ=View the Brave Payments FAQ… +corruptedOverlayButton=Recover your Brave Wallet createdWalletStatus=Your wallet is ready! createWallet=create wallet createWalletStatus=Click the Create Wallet button to get started. diff --git a/app/locale.js b/app/locale.js index b4fd3f151b3..47b2636fcf7 100644 --- a/app/locale.js +++ b/app/locale.js @@ -281,7 +281,10 @@ var rendererIdentifiers = function () { 'promotionGeneralErrorText', 'promotionClaimedErrorMessage', 'promotionClaimedErrorText', - 'promotionClaimedErrorTitle' + 'promotionClaimedErrorTitle', + 'corruptedOverlayTitle', + 'corruptedOverlayMessage', + 'corruptedOverlayText' ].concat(countryCodes).concat(availableLanguages) } diff --git a/app/renderer/components/preferences/payment/enabledContent.js b/app/renderer/components/preferences/payment/enabledContent.js index 0a878627cd0..0f770e103b4 100644 --- a/app/renderer/components/preferences/payment/enabledContent.js +++ b/app/renderer/components/preferences/payment/enabledContent.js @@ -7,41 +7,49 @@ const {StyleSheet, css} = require('aphrodite/no-important') const addMonths = require('date-fns/add_months') const Immutable = require('immutable') -// util -const {batToCurrencyString, formatCurrentBalance, formattedDateFromTimestamp, walletStatus} = require('../../../../common/lib/ledgerUtil') -const {l10nErrorText} = require('../../../../common/lib/httpUtil') -const ledgerUtil = require('../../../../common/lib/ledgerUtil') -const {changeSetting} = require('../../../lib/settingsUtil') -const settings = require('../../../../../js/constants/settings') -const locale = require('../../../../../js/l10n') - -// State -const ledgerState = require('../../../../common/state/ledgerState') - -// components +// Components const ImmutableComponent = require('../../immutableComponent') const BrowserButton = require('../../common/browserButton') const {FormTextbox} = require('../../common/textbox') const {FormDropdown} = require('../../common/dropdown') const LedgerTable = require('./ledgerTable') -// style -const globalStyles = require('../../styles/global') -const {paymentStylesVariables} = require('../../styles/payment') -const closeButton = require('../../../../../img/toolbar/stoploading_btn.svg') -const cx = require('../../../../../js/lib/classSet') +// State +const ledgerState = require('../../../../common/state/ledgerState') // Actions const appActions = require('../../../../../js/actions/appActions') +// Constants +const ledgerStatuses = require('../../../../common/constants/ledgerStatuses') +const settings = require('../../../../../js/constants/settings') + +// Utils +const { + batToCurrencyString, + formatCurrentBalance, + formattedDateFromTimestamp, + walletStatus +} = require('../../../../common/lib/ledgerUtil') +const {l10nErrorText} = require('../../../../common/lib/httpUtil') +const ledgerUtil = require('../../../../common/lib/ledgerUtil') +const {changeSetting} = require('../../../lib/settingsUtil') +const locale = require('../../../../../js/l10n') + +// Styles +const globalStyles = require('../../styles/global') +const cx = require('../../../../../js/lib/classSet') +const {paymentStylesVariables} = require('../../styles/payment') +const closeButton = require('../../../../../img/toolbar/stoploading_btn.svg') + // TODO: report when funds are too low -// TODO: support non-USD currency class EnabledContent extends ImmutableComponent { constructor (props) { super(props) this.claimButton = this.claimButton.bind(this) this.onClaimClick = this.onClaimClick.bind(this) - this.closeClick = this.closeClick.bind(this) + this.closePromotionClick = this.closePromotionClick.bind(this) + this.recoverStatusClick = this.recoverStatusClick.bind(this) } walletButton () { @@ -139,7 +147,7 @@ class EnabledContent extends ImmutableComponent { let prevReconcileDateValue let text - if (ledgerData.get('status') === 'contributionInProgress') { + if (ledgerData.get('status') === ledgerStatuses.IN_PROGRESS) { text = 'paymentInProgress' } else if (!walletCreated || !walletHasReconcile || !walletHasTransactions) { text = 'noPaymentHistory' @@ -201,7 +209,7 @@ class EnabledContent extends ImmutableComponent { } - closeClick () { + closePromotionClick () { const promo = this.props.ledgerData.get('promotion') || Immutable.Map() const status = promo.get('promotionStatus') if (status && !promo.has('claimedTimestamp')) { @@ -215,55 +223,105 @@ class EnabledContent extends ImmutableComponent { } } + recoverStatusClick () { + appActions.loadURLInActiveTabRequested( + this.props.ledgerData.get('tabId'), + 'about:preferences#payments?ledgerRecoveryOverlayVisible' + ) + } + statusMessage () { const promo = this.props.ledgerData.get('promotion') || Immutable.Map() + const status = this.props.ledgerData.get('status') || '' const successText = promo.getIn(['panel', 'successText']) - let status = promo.get('promotionStatus') + const promotionStatus = promo.get('promotionStatus') + let isPromotion = true - if ((!successText || !promo.has('claimedTimestamp')) && !status) { - return + if ((!successText || !promo.has('claimedTimestamp')) && !promotionStatus) { + isPromotion = false + if (status.length === 0) { + return + } } - let title = successText.get('title') - let message = successText.get('message') - let text = promo.getIn(['panel', 'disclaimer']) + let title, message, text, rightButton, leftButton, showClose - if (status) { + if (isPromotion) { + showClose = true + title = successText.get('title') + message = successText.get('message') + text = promo.getIn(['panel', 'disclaimer']) + rightButton = + + if (promotionStatus) { + switch (promotionStatus) { + case 'generalError': + { + title = locale.translation('promotionGeneralErrorTitle') + message = locale.translation('promotionGeneralErrorMessage') + text = locale.translation('promotionGeneralErrorText') + break + } + case 'expiredError': + { + title = locale.translation('promotionClaimedErrorTitle') + message = locale.translation('promotionClaimedErrorMessage') + text = locale.translation('promotionClaimedErrorText') + break + } + } + } + } else { switch (status) { - case 'generalError': + case ledgerStatuses.CORRUPTED: { - title = locale.translation('promotionGeneralErrorTitle') - message = locale.translation('promotionGeneralErrorMessage') - text = locale.translation('promotionGeneralErrorText') + showClose = false + title = locale.translation('corruptedOverlayTitle') + message = locale.translation('corruptedOverlayMessage') + text = locale.translation('corruptedOverlayText') + leftButton = + rightButton = break } - case 'expiredError': + default: { - title = locale.translation('promotionClaimedErrorTitle') - message = locale.translation('promotionClaimedErrorMessage') - text = locale.translation('promotionClaimedErrorText') - break + return } } } - return
-
-

- {title} {message} + return

+ { + showClose ?
: null + } +

+ {title} {message}

-

+

{text}

- +
+
{leftButton}
+
{rightButton}
+
} @@ -465,7 +523,7 @@ const styles = StyleSheet.create({ padding: '0 10px' }, - enabledContent__grant: { + enabledContent__overlay: { position: 'absolute', zIndex: 3, top: 0, @@ -474,12 +532,12 @@ const styles = StyleSheet.create({ minHeight: '159px', background: '#f3f3f3', borderRadius: '8px', - padding: '30px 50px 20px', + padding: '27px 50px 17px', boxSizing: 'border-box', boxShadow: '4px 6px 3px #dadada' }, - enabledContent__grant_close: { + enabledContent__overlay_close: { position: 'absolute', right: '15px', top: '15px', @@ -495,29 +553,52 @@ const styles = StyleSheet.create({ } }, - enabledContent__grant_title: { + enabledContent__overlay_title: { color: '#5f5f5f', fontSize: '20px', display: 'block', marginBottom: '10px' }, - enabledContent__grant_bold: { + enabledContent__overlay_bold: { color: '#ff5500' }, - enabledContent__grant_text: { + enabledContent__overlay_text: { fontSize: '16px', color: '#828282', maxWidth: '700px', lineHeight: '25px', - padding: '5px' + padding: '5px 5px 5px 0' }, - enabledContent__grant_button: { + enabledContent__overlay_buttons: { + display: 'grid', + gridTemplateColumns: '1fr 1fr' + }, + + enabledContent__overlay_buttons_left: { + marginLeft: 0 + }, + + enabledContent__overlay_buttons_right: { + marginRight: 0 + }, + + enabledContent__overlay_button: { float: 'right' }, + enabledContent__overlay_link: { + color: '#5f5f5f', + fontSize: '16px', + textDecoration: 'none', + + ':hover': { + textDecoration: 'underline' + } + }, + enabledContent__walletBar: { display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', diff --git a/package-lock.json b/package-lock.json index f7feeab575a..0deaff765e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -124,7 +124,8 @@ "ajv-keywords": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.1.0.tgz", - "integrity": "sha1-rCsnk5xUPpXSwG5/f1wnvkqlQ74=" + "integrity": "sha1-rCsnk5xUPpXSwG5/f1wnvkqlQ74=", + "dev": true }, "align-text": { "version": "0.1.4", @@ -528,9 +529,9 @@ "dev": true }, "ast-types": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.11.2.tgz", - "integrity": "sha512-aL+pcOQ+6dpWd0xrUe+Obo2CgdkFvsntkXEmzZKqEN4cR0PStF+1MBuc4V+YZsv4Q36luvyjG7F4lc+wH2bmag==" + "version": "0.11.3", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.11.3.tgz", + "integrity": "sha512-XA5o5dsNw8MhyW0Q7MWXJWc4oOzZKbdsEJq45h7c8q/d9DwWZ5F2ugUc1PuMLPGsUnphCt/cNDHu8JeBbxf1qA==" }, "async": { "version": "2.6.0", @@ -1564,14 +1565,14 @@ } }, "bat-client": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/bat-client/-/bat-client-2.0.11.tgz", - "integrity": "sha512-7ugu2PycE4BTQjQvlXhg19e1SgfCztaETG9lu742tZD8E5tfTGZg19AxNOBJHOCnOmMpvONleCIPJ3QP6W7Zag==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bat-client/-/bat-client-2.1.1.tgz", + "integrity": "sha512-ydlsnTUoMiOEcX9a8nccWvnRs+4XvO9OsQhBvtEI7fKl3oTzz4DSk+ypZfuIAFLRw72AmhaWTdR7rxDmdfah5w==", "requires": { "@ambassify/backoff-strategies": "1.0.0", "bat-balance": "1.0.7", "bat-publisher": "2.0.13", - "bitgo": "4.21.0", + "bitgo": "4.22.0", "brave-crypto": "0.0.1", "http-request-signature": "0.0.2", "joi": "13.1.2", @@ -1656,9 +1657,9 @@ } }, "bech32": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/bech32/-/bech32-0.0.3.tgz", - "integrity": "sha512-O+K1w8P/aAOLcYwwQ4sbiPYZ51ZIW95lnS4/6nE8Aib/z+OOddQIIPdu2qi94qGDp4HhYy/wJotttXKkak1lXg==" + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.3.tgz", + "integrity": "sha512-yuVFUvrNcoJi0sv5phmqc6P+Fl1HjRDRNOOkHY2X/3LBy2bIGNSFx4fZ95HMaXHupuS7cZR15AsvtmCIF4UEyg==" }, "beeper": { "version": "1.1.1", @@ -1766,6 +1767,47 @@ } } }, + "bitcoinjs-lib-zcash": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/bitcoinjs-lib-zcash/-/bitcoinjs-lib-zcash-3.3.2.tgz", + "integrity": "sha512-/wBR9faXIbXfM2gyvhzBSEpRUm0ePGqOQCDIZXGLSu2FlRX5nrPzfEAWM9weIw7PIorhpI3ztbPaJvxgLfQuuw==", + "requires": { + "bech32": "1.1.3", + "bigi": "1.4.0", + "bip66": "1.1.5", + "bitcoin-ops": "1.4.1", + "bs58check": "2.1.1", + "create-hash": "1.1.3", + "create-hmac": "1.1.6", + "ecurve": "1.0.6", + "merkle-lib": "2.0.10", + "pushdata-bitcoin": "1.0.1", + "randombytes": "2.0.6", + "safe-buffer": "5.1.1", + "typeforce": "1.12.0", + "varuint-bitcoin": "1.1.0", + "wif": "2.0.6" + }, + "dependencies": { + "bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", + "requires": { + "base-x": "3.0.4" + } + }, + "bs58check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.1.tgz", + "integrity": "sha512-okRQiWc5FJuA2VOwQ1hB7Sf0MyEFg/EwRN12h4b8HrJoGkZ3xq1CGjkaAfYloLcZyqixQnO5mhPpN6IcHSplVg==", + "requires": { + "bs58": "4.0.1", + "create-hash": "1.1.3" + } + } + } + }, "bitcoinjs-message": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/bitcoinjs-message/-/bitcoinjs-message-2.0.0.tgz", @@ -1803,15 +1845,16 @@ "integrity": "sha512-4xM4DYejOHQ/qWBfeqBXNA4mJ12PwcOibFYnH1kYh5U9BHciCqEJBqGNVnMJXUhm8mflujNRLSv7IiVQxovgjw==" }, "bitgo": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/bitgo/-/bitgo-4.21.0.tgz", - "integrity": "sha1-cA7IjJS2xsNQ3PyF3RM6GIDYwCc=", + "version": "4.22.0", + "resolved": "https://registry.npmjs.org/bitgo/-/bitgo-4.22.0.tgz", + "integrity": "sha1-6AXsMUWoTd/xe4HH1uSnuYI0+N4=", "requires": { "argparse": "0.1.16", "assert": "0.4.9", "big.js": "3.1.3", "bigi": "1.4.0", "bignumber.js": "4.0.4", + "bitcoinjs-lib-zcash": "3.3.2", "bitcoinjs-message": "2.0.0", "bitgo-bitcoinjs-lib": "git+https://github.com/BitGo/bitcoinjs-lib.git#54619798a2c4ec37bea8be3c68e50880ca7fbc15", "bluebird": "3.5.1", @@ -1882,6 +1925,11 @@ "wif": "2.0.6" }, "dependencies": { + "bech32": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/bech32/-/bech32-0.0.3.tgz", + "integrity": "sha512-O+K1w8P/aAOLcYwwQ4sbiPYZ51ZIW95lnS4/6nE8Aib/z+OOddQIIPdu2qi94qGDp4HhYy/wJotttXKkak1lXg==" + }, "bs58": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", @@ -2518,9 +2566,9 @@ }, "dependencies": { "clone": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", - "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "dev": true }, "uuid": { @@ -2535,7 +2583,7 @@ "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, "requires": { - "clone": "1.0.3", + "clone": "1.0.4", "clone-stats": "0.0.1", "replace-ext": "0.0.1" } @@ -4116,9 +4164,9 @@ } }, "clone": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", - "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "dev": true }, "expand-brackets": { @@ -4291,7 +4339,7 @@ "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, "requires": { - "clone": "1.0.3", + "clone": "1.0.4", "clone-stats": "0.0.1", "replace-ext": "0.0.1" } @@ -4462,9 +4510,9 @@ }, "dependencies": { "clone": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", - "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "dev": true }, "through2": { @@ -4483,7 +4531,7 @@ "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, "requires": { - "clone": "1.0.3", + "clone": "1.0.4", "clone-stats": "0.0.1", "replace-ext": "0.0.1" } @@ -4629,7 +4677,7 @@ "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-1.0.4.tgz", "integrity": "sha1-/PSQo37OJmRk2cxDGrmMWBnO0JU=", "requires": { - "ast-types": "0.11.2", + "ast-types": "0.11.3", "escodegen": "1.9.1", "esprima": "3.1.3" } @@ -5841,9 +5889,9 @@ } }, "eslint": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.18.1.tgz", - "integrity": "sha512-gPSfpSRCHre1GLxGmO68tZNxOlL2y7xBd95VcLD+Eo4S2js31YoMum3CAQIOaxY24hqYOMksMvW38xuuWKQTgw==", + "version": "4.19.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", + "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", "requires": { "ajv": "5.5.2", "babel-code-frame": "6.26.0", @@ -5854,7 +5902,7 @@ "doctrine": "2.1.0", "eslint-scope": "3.7.1", "eslint-visitor-keys": "1.0.0", - "espree": "3.5.3", + "espree": "3.5.4", "esquery": "1.0.0", "esutils": "2.0.2", "file-entry-cache": "2.0.0", @@ -5876,14 +5924,20 @@ "path-is-inside": "1.0.2", "pluralize": "7.0.0", "progress": "2.0.0", + "regexpp": "1.0.1", "require-uncached": "1.0.3", "semver": "5.5.0", "strip-ansi": "4.0.0", "strip-json-comments": "2.0.1", - "table": "4.0.3", + "table": "4.0.2", "text-table": "0.2.0" }, "dependencies": { + "acorn": { + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", + "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==" + }, "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", @@ -5897,6 +5951,15 @@ "ms": "2.0.0" } }, + "espree": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "requires": { + "acorn": "5.5.3", + "acorn-jsx": "3.0.1" + } + }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -6085,6 +6148,7 @@ "version": "3.5.3", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.3.tgz", "integrity": "sha512-Zy3tAJDORxQZLl2baguiRU1syPERAIg0L+JB2MWorORgTu/CplzvxS9WWA7Xh4+Q+eOQihNs/1o1Xep8cvCxWQ==", + "dev": true, "requires": { "acorn": "5.5.0", "acorn-jsx": "3.0.1" @@ -6093,7 +6157,8 @@ "acorn": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.0.tgz", - "integrity": "sha512-arn53F07VXmls4o4pUhSzBa4fvaagPRe7AVZ8l7NHxFWUie2DsuFSBMMNAkgzRlOhEhzAnxeKyaWVzOH4xqp/g==" + "integrity": "sha512-arn53F07VXmls4o4pUhSzBa4fvaagPRe7AVZ8l7NHxFWUie2DsuFSBMMNAkgzRlOhEhzAnxeKyaWVzOH4xqp/g==", + "dev": true } } }, @@ -7285,9 +7350,9 @@ } }, "formidable": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.1.1.tgz", - "integrity": "sha1-lriIb3w8NQi5Mta9cMTTqI818ak=" + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz", + "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg==" }, "forwarded": { "version": "0.1.2", @@ -8857,9 +8922,9 @@ }, "dependencies": { "clone": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", - "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "dev": true }, "through2": { @@ -8878,7 +8943,7 @@ "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, "requires": { - "clone": "1.0.3", + "clone": "1.0.4", "clone-stats": "0.0.1", "replace-ext": "0.0.1" } @@ -9386,7 +9451,7 @@ "integrity": "sha512-lyI0DUMqj211+xKIZX6cSSKNJTV30Q6IvWEb23S7Z3zt47P2p5AyYaaLGsFlBMGCOJAi8mxWMloFcM3RsiGNyg==", "requires": { "debugnyan": "2.0.1", - "eslint": "4.18.1", + "eslint": "4.19.1", "lodash": "4.17.5", "standard-http-error": "2.0.1", "validator.js": "2.0.3", @@ -15259,6 +15324,11 @@ "resolved": "https://registry.npmjs.org/regexp-quote/-/regexp-quote-0.0.0.tgz", "integrity": "sha1-Hg9GUMhi3L/tVP1CsUjpuxch/PI=" }, + "regexpp": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.0.1.tgz", + "integrity": "sha512-8Ph721maXiOYSLtaDGKVmDn5wdsNaF6Px85qFNeMPQq0r8K5Y10tgP6YuR65Ws35n4DvzFcCxEnRNBIXQunzLw==" + }, "regexpu-core": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", @@ -15609,7 +15679,7 @@ }, "elliptic": { "version": "5.2.1", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-5.2.1.tgz", + "resolved": "http://registry.npmjs.org/elliptic/-/elliptic-5.2.1.tgz", "integrity": "sha1-+ilLZWPG3bybo9yFlGh66ECFjxA=", "requires": { "bn.js": "3.3.0", @@ -17298,7 +17368,7 @@ "debug": "2.6.9", "extend": "3.0.1", "form-data": "2.3.2", - "formidable": "1.1.1", + "formidable": "1.2.1", "methods": "1.1.2", "mime": "1.6.0", "qs": "6.5.1", @@ -17395,27 +17465,22 @@ "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=" }, "table": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/table/-/table-4.0.3.tgz", - "integrity": "sha512-S7rnFITmBH1EnyKcvxBh1LjYeQMmnZtCXSEbHcH6S0NoKit24ZuFO/T1vDcLdYsLQkM188PVVhQmzKIuThNkKg==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", "requires": { - "ajv": "6.2.0", - "ajv-keywords": "3.1.0", + "ajv": "5.5.2", + "ajv-keywords": "2.1.1", "chalk": "2.3.1", "lodash": "4.17.5", "slice-ansi": "1.0.0", "string-width": "2.1.1" }, "dependencies": { - "ajv": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.2.0.tgz", - "integrity": "sha1-r6wpW7qgFSRJ5SJ0LkVHwa6TKNI=", - "requires": { - "fast-deep-equal": "1.1.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" - } + "ajv-keywords": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=" }, "ansi-regex": { "version": "3.0.0", diff --git a/package.json b/package.json index 70ca0eff977..0029e5bf100 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "aphrodite": "1.1.0", "async": "^2.0.1", "bat-balance": "^1.0.7", - "bat-client": "^2.0.11", + "bat-client": "^2.1.1", "bat-publisher": "^2.0.13", "bignumber.js": "^4.0.4", "bloodhound-js": "brave/bloodhound", diff --git a/test/unit/app/browser/api/ledgerTest.js b/test/unit/app/browser/api/ledgerTest.js index d715bec9e2f..c567473a669 100644 --- a/test/unit/app/browser/api/ledgerTest.js +++ b/test/unit/app/browser/api/ledgerTest.js @@ -2736,4 +2736,37 @@ describe('ledger api unit tests', function () { assert.equal(clientBallotsSpy.calledOnce, true) }) }) + + describe('checkSeed', function () { + let valid = false + + before(() => { + ledgerApi.setClient({ + isValidPassPhrase: () => valid + }) + }) + + it('seed is null', function () { + const result = ledgerApi.checkSeed(defaultAppState) + assert.deepEqual(result.toJS(), defaultAppState.toJS()) + }) + + it('seed is valid', function () { + valid = true + const state = defaultAppState + .setIn(['ledger', 'info', 'passphrase'], 'auten nobbling uncharitable decimation sayee unartful biter floodlight scholar cherubical fadable reconnoiter courtesan concussing asymmetrical test') + const result = ledgerApi.checkSeed(state) + assert.deepEqual(result.toJS(), state.toJS()) + valid = false + }) + + it('seed is invalid', function () { + const state = defaultAppState + .setIn(['ledger', 'info', 'passphrase'], 'a') + const exptedState = state + .setIn(['ledger', 'about', 'status'], 'corruptedSeed') + const result = ledgerApi.checkSeed(state) + assert.deepEqual(result.toJS(), exptedState.toJS()) + }) + }) }) diff --git a/test/unit/app/browser/reducers/ledgerReducerTest.js b/test/unit/app/browser/reducers/ledgerReducerTest.js index 7f7367bc7e0..0dbc7548d30 100644 --- a/test/unit/app/browser/reducers/ledgerReducerTest.js +++ b/test/unit/app/browser/reducers/ledgerReducerTest.js @@ -343,9 +343,6 @@ describe('ledgerReducer unit tests', function () { it('calls ledgerApi.paymentPresent', function () { assert(paymentPresentSpy.withArgs(appState, 123, true).calledOnce) }) - it('returns an ununmodified state', function () { - assert.deepEqual(returnedState, appState) - }) }) describe('APP_ON_ADD_FUNDS_CLOSED', function () {