From fa3ea3ec9b14aa569952534a20564ff8507e6e35 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Wed, 4 Oct 2017 11:01:28 +0200 Subject: [PATCH] WIP balance data --- app/browser/api/ledger.js | 75 +- app/browser/reducers/ledgerReducer.js | 2 +- app/browser/tabs.js | 4 +- app/common/lib/ledgerUtil.js | 2 +- app/extensions.js | 2 +- js/actions/appActions.js | 5 +- package-lock.json | 694 ++++++++++-------- package.json | 2 +- .../app/browser/reducers/ledgerReducerTest.js | 12 +- 9 files changed, 432 insertions(+), 366 deletions(-) diff --git a/app/browser/api/ledger.js b/app/browser/api/ledger.js index 13f0415bf49..e9f43ba2820 100644 --- a/app/browser/api/ledger.js +++ b/app/browser/api/ledger.js @@ -1005,7 +1005,7 @@ const onWalletRecovery = (state, error, result) => { // we reset ledgerInfo.error to what it was before (likely null) // if ledgerInfo.error is not null, the wallet info will not display in UI // logError sets ledgerInfo.error, so we must we clear it or UI will show an error - state = logError(error, 'recoveryWallet') + state = logError(state, error, 'recoveryWallet') state = ledgerState.setInfoProp(state, 'error', existingLedgerError) state = ledgerState.setRecoveryStatus(state, false) } else { @@ -1526,6 +1526,8 @@ const generatePaymentData = (state) => { case 'LTC': url = `litecoin:${address}` break + default: + return } try { @@ -1539,7 +1541,7 @@ const generatePaymentData = (state) => { appActions.onLedgerQRGenerated(index, paymentIMG) }) } catch (ex) { - console.error('qr.imageSync error: ' + ex.toString()) + console.error('qr.imageSync (for url ' + url + ') error: ' + ex.toString()) } }) @@ -1563,7 +1565,6 @@ const getPaymentInfo = (state) => { client.getWalletProperties(amount, currency, function (err, body) { if (err) { - logError(err, 'getWalletProperties') return } @@ -1579,30 +1580,7 @@ const getPaymentInfo = (state) => { } const onWalletProperties = (state, body) => { - let newInfo = { - probi: body.get('probi'), - addresses: body.get('addresses') - } - - state = ledgerState.mergeInfoProp(state, newInfo) - - const info = ledgerState.getInfoProps(state) - - const amount = info.get('balance') - const currency = info.getIn(['bravery', 'fee', 'currency']) - - if (currency) { - const rate = body.getIn(['rates', currency]) - state = ledgerState.setInfoProp(state, 'currentRate', rate) - - if (amount) { - if (rate) { - const converted = new BigNumber(newInfo.probi.toString()).times(new BigNumber(rate.toString())).toFixed(2) - state = ledgerState.setInfoProp(state, 'converted', converted) - } - } - } - + state = ledgerState.setInfoProp(state, 'addresses', body.get('addresses')) state = generatePaymentData(state) return state @@ -1654,6 +1632,7 @@ const onBraveryProperties = (state, error, result) => { } const getBalance = (state) => { + console.log('getBalance') if (!client) return const addresses = ledgerState.getInfoProp(state, 'addresses') @@ -1670,13 +1649,47 @@ const getBalance = (state) => { if (err) { return console.warn('ledger balance warning: ' + JSON.stringify(err, null, 2)) } - appActions.onLedgerBalanceReceived(result.balance, result.unconfirmed) + appActions.onLedgerBalanceReceived(result) }) } -const balanceReceived = (state, balance, unconfirmed) => { - state = ledgerState.setInfoProp(state, 'balance', balance) +// TODO we are still not getting this data from bat-client +const balanceReceived = (state, result) => { + // Balance + const balance = parseFloat(result.get('balance')) + if (balance > 0) { + state = ledgerState.setInfoProp(state, 'balance', balance) + } + + // Rates + const rates = result.get('rates') + if (rates != null) { + state = ledgerState.setInfoProp(state, 'rates', rates) + } + + // Probi + const probi = parseFloat(result.get('probi')) + if (probi > 0) { + state = ledgerState.setInfoProp(state, 'probi', probi) + + const info = ledgerState.getInfoProps(state) + const amount = info.get('balance') + const infoRates = info.get('rates') + const currency = info.getIn(['bravery', 'fee', 'currency']) + + if (currency) { + const rate = infoRates.get(currency) + state = ledgerState.setInfoProp(state, 'currentRate', rate) + + if (amount && rate) { + const converted = new BigNumber(probi.toString()).times(new BigNumber(rate.toString())).toFixed(2) + state = ledgerState.setInfoProp(state, 'converted', converted) + } + } + } + // unconfirmed amount + const unconfirmed = parseFloat(result.get('unconfirmed')) if (unconfirmed > 0) { const result = (unconfirmed / 1e8).toFixed(4) if (ledgerState.getInfoProp(state, 'unconfirmed') === result) { @@ -1917,7 +1930,7 @@ const onInitRead = (state, parsedData) => { } const onTimeUntilReconcile = (state, stateResult) => { - state = getStateInfo(stateResult) + state = getStateInfo(state, stateResult.toJS()) // TODO optimize muonWriter(stateResult) return state diff --git a/app/browser/reducers/ledgerReducer.js b/app/browser/reducers/ledgerReducer.js index 529ce8b67c8..fda35906d43 100644 --- a/app/browser/reducers/ledgerReducer.js +++ b/app/browser/reducers/ledgerReducer.js @@ -249,7 +249,7 @@ const ledgerReducer = (state, action, immutableAction) => { } case appConstants.APP_ON_LEDGER_BALANCE_RECEIVED: { - state = ledgerApi.balanceReceived(state, action.get('balance'), action.get('unconfirmed')) + state = ledgerApi.balanceReceived(state, action.get('result')) break } case appConstants.APP_ON_WALLET_PROPERTIES: diff --git a/app/browser/tabs.js b/app/browser/tabs.js index d88651670e4..87ab493c740 100644 --- a/app/browser/tabs.js +++ b/app/browser/tabs.js @@ -182,14 +182,16 @@ const updateAboutDetails = (tab, tabValue) => { // TODO save this into values into the sate so that we don't call this app action on every state change // this should be saved in app state when windows will be refactored #11151 + /* if (url === 'about:preferences#payments') { tab.on('destroyed', () => { appActions.ledgerPaymentsPresent(tabValue.get('tabId'), false) }) - appActions.ledgerPaymentsPresent(tabValue.get('tabId'), false) + appActions.ledgerPaymentsPresent(tabValue.get('tabId'), true) } else { appActions.ledgerPaymentsPresent(tabValue.get('tabId'), false) } + */ if (location === 'about:preferences' || location === 'about:contributions' || location === aboutUrls.get('about:contributions')) { const ledgerData = ledgerInfo diff --git a/app/common/lib/ledgerUtil.js b/app/common/lib/ledgerUtil.js index a7dcd194eb8..0ccb2b213ba 100644 --- a/app/common/lib/ledgerUtil.js +++ b/app/common/lib/ledgerUtil.js @@ -87,7 +87,7 @@ const formatCurrentBalance = (ledgerData) => { converted = Number.parseFloat(ledgerData.get('converted')) || 0 } - balance = Math.floor(balance) + balance = balance.toFixed(2) converted = converted.toFixed(2) return `${balance} BAT (${converted} ${currency})` diff --git a/app/extensions.js b/app/extensions.js index 43251873f62..08ffb271108 100644 --- a/app/extensions.js +++ b/app/extensions.js @@ -170,7 +170,7 @@ let generateBraveManifest = () => { 'form-action': '\'none\'', 'style-src': '\'self\' \'unsafe-inline\'', 'img-src': '* data: file://*', - 'frame-src': '\'self\' https://buy.coinbase.com https://brave.com' + 'frame-src': '\'self\' https://brave.com' } if (process.env.NODE_ENV === 'development') { diff --git a/js/actions/appActions.js b/js/actions/appActions.js index 34826e637a0..3f71e941a82 100644 --- a/js/actions/appActions.js +++ b/js/actions/appActions.js @@ -1606,11 +1606,10 @@ const appActions = { }) }, - onLedgerBalanceReceived: function (balance, unconfirmed) { + onLedgerBalanceReceived: function (result) { dispatch({ actionType: appConstants.APP_ON_LEDGER_BALANCE_RECEIVED, - balance, - unconfirmed + result }) }, diff --git a/package-lock.json b/package-lock.json index a0d53e1aad4..b1c70030816 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1441,12 +1441,13 @@ } }, "bat-client": { - "version": "0.9.12", - "resolved": "https://registry.npmjs.org/bat-client/-/bat-client-0.9.12.tgz", - "integrity": "sha1-hUICQ0JhdwoENKKgPFV8snjfdAM=", + "version": "0.9.14", + "resolved": "https://registry.npmjs.org/bat-client/-/bat-client-0.9.14.tgz", + "integrity": "sha1-4avXQ8KaChL5QKmlimP9loEb0PM=", "requires": { + "bat-balance": "0.9.6", "bat-publisher": "0.9.4", - "bitgo": "4.6.0", + "bitgo": "4.7.0", "http-request-signature": "github:uphold/http-request-signature#fcbc1b4ff5c8c9e38553c86051d9ce61e6b00aea", "joi": "11.1.1", "json-stable-stringify": "1.0.1", @@ -1458,61 +1459,113 @@ "uuid": "3.1.0" }, "dependencies": { - "big.js": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz", - "integrity": "sha1-TK2iGTZS6zyp7I5VyQFWacmAaXg=" + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" }, - "bitgo": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/bitgo/-/bitgo-4.6.0.tgz", - "integrity": "sha1-o9yXie9gsciecf8n5/oyeAQo2ck=", - "requires": { - "argparse": "0.1.16", - "assert": "0.4.9", - "bcashjs-lib": "git+https://github.com/BitGo/bcashjs-lib.git#a49702b12f06729ab80756d1c6dba880f0c64295", - "big.js": "3.1.3", - "bigi": "1.4.0", - "bignumber.js": "4.0.4", - "bitcoinjs-lib": "2.1.4", - "bluebird": "3.5.0", - "body-parser": "1.17.2", - "bs58": "2.0.1", - "bs58check": "1.0.4", - "create-hmac": "1.1.6", - "ecurve": "1.0.5", - "eol": "0.5.0", - "ethereumjs-abi": "0.6.4", - "ethereumjs-util": "4.4.1", - "express": "4.15.5", - "http-proxy": "1.11.1", - "lodash": "4.13.1", - "minimist": "0.2.0", - "moment": "2.18.1", - "morgan": "1.5.3", - "prova-lib": "0.2.8", - "ripple-lib": "0.17.7", - "sanitize-html": "1.13.0", - "secp256k1": "3.2.5", - "superagent": "3.5.2", - "superagent-proxy": "1.0.2", - "underscore.string": "2.4.0" + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "requires": { + "color-convert": "1.9.0" } }, - "form-data": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", - "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", + "chalk": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", + "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.4.0" } }, - "formidable": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.1.1.tgz", - "integrity": "sha1-lriIb3w8NQi5Mta9cMTTqI818ak=" + "color-convert": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", + "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "requires": { + "color-name": "1.1.3" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "doctrine": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", + "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", + "requires": { + "esutils": "2.0.2", + "isarray": "1.0.0" + } + }, + "eslint": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.8.0.tgz", + "integrity": "sha1-Ip7w41Tg5h2DfHqA/fuoJeGZgV4=", + "requires": { + "ajv": "5.2.3", + "babel-code-frame": "6.26.0", + "chalk": "2.1.0", + "concat-stream": "1.6.0", + "cross-spawn": "5.1.0", + "debug": "3.1.0", + "doctrine": "2.0.0", + "eslint-scope": "3.7.1", + "espree": "3.5.1", + "esquery": "1.0.0", + "estraverse": "4.2.0", + "esutils": "2.0.2", + "file-entry-cache": "2.0.0", + "functional-red-black-tree": "1.0.1", + "glob": "7.1.2", + "globals": "9.18.0", + "ignore": "3.3.5", + "imurmurhash": "0.1.4", + "inquirer": "3.0.6", + "is-resolvable": "1.0.0", + "js-yaml": "3.10.0", + "json-stable-stringify": "1.0.1", + "levn": "0.3.0", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "natural-compare": "1.4.0", + "optionator": "0.8.2", + "path-is-inside": "1.0.2", + "pluralize": "7.0.0", + "progress": "2.0.0", + "require-uncached": "1.0.3", + "semver": "5.4.1", + "strip-ansi": "4.0.0", + "strip-json-comments": "2.0.1", + "table": "4.0.2", + "text-table": "0.2.0" + } + }, + "http-request-signature": { + "version": "github:uphold/http-request-signature#fcbc1b4ff5c8c9e38553c86051d9ce61e6b00aea", + "requires": { + "debugnyan": "2.0.1", + "eslint": "4.8.0", + "lodash": "4.17.4", + "standard-http-error": "2.0.1", + "validator.js": "2.0.3", + "validator.js-asserts": "3.1.0" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" }, "isarray": { "version": "1.0.0", @@ -1529,58 +1582,60 @@ "topo": "2.0.2" } }, - "lodash": { - "version": "4.13.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz", - "integrity": "sha1-g+SxCRP0hJbU0W/sSlYK8u50S2g=" + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" }, - "minimist": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.0.tgz", - "integrity": "sha1-Tf/lJdriuGTGbC4jxicdev3s784=" + "progress": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=" }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "requires": { + "is-fullwidth-code-point": "2.0.0" + } }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "requires": { - "safe-buffer": "5.1.1" + "ansi-regex": "3.0.0" } }, - "superagent": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.5.2.tgz", - "integrity": "sha1-M2GjlxVnUEw1EGOr6q4PqiPb8/g=", + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", "requires": { - "component-emitter": "1.2.1", - "cookiejar": "2.0.6", - "debug": "2.6.9", - "extend": "3.0.0", - "form-data": "2.3.1", - "formidable": "1.1.1", - "methods": "1.1.2", - "mime": "1.3.4", - "qs": "6.5.1", - "readable-stream": "2.3.3" + "has-flag": "2.0.0" + } + }, + "table": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "requires": { + "ajv": "5.2.3", + "ajv-keywords": "2.1.0", + "chalk": "2.1.0", + "lodash": "4.17.4", + "slice-ansi": "1.0.0", + "string-width": "2.1.1" } }, "tweetnacl": { @@ -1822,6 +1877,123 @@ "resolved": "https://registry.npmjs.org/bitfield/-/bitfield-1.1.2.tgz", "integrity": "sha1-pUd/AOM/Knbtwgmq8mvwk5SjeM8=" }, + "bitgo": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/bitgo/-/bitgo-4.7.0.tgz", + "integrity": "sha512-ibPNges48EnIvjGBR7GSTxq9wh5oaBJSAnC9kmbgG4V8V1QmHwue9cGp0VENA5oqZSvaO9bZZ+o3DVAB6T7pfg==", + "requires": { + "argparse": "0.1.16", + "assert": "0.4.9", + "bcashjs-lib": "git+https://github.com/BitGo/bcashjs-lib.git#a49702b12f06729ab80756d1c6dba880f0c64295", + "big.js": "3.1.3", + "bigi": "1.4.0", + "bignumber.js": "4.0.4", + "bitcoinjs-lib": "2.1.4", + "bluebird": "3.5.0", + "body-parser": "1.17.2", + "bs58": "2.0.1", + "bs58check": "1.0.4", + "create-hmac": "1.1.6", + "ecurve": "1.0.5", + "eol": "0.5.0", + "ethereumjs-abi": "0.6.4", + "ethereumjs-util": "4.4.1", + "express": "4.15.5", + "http-proxy": "1.11.1", + "lodash": "4.13.1", + "minimist": "0.2.0", + "moment": "2.18.1", + "morgan": "1.5.3", + "prova-lib": "0.2.8", + "ripple-lib": "0.17.7", + "sanitize-html": "1.13.0", + "secp256k1": "3.2.5", + "superagent": "3.5.2", + "superagent-proxy": "1.0.2", + "underscore.string": "2.4.0" + }, + "dependencies": { + "big.js": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz", + "integrity": "sha1-TK2iGTZS6zyp7I5VyQFWacmAaXg=" + }, + "form-data": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", + "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + } + }, + "formidable": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.1.1.tgz", + "integrity": "sha1-lriIb3w8NQi5Mta9cMTTqI818ak=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "lodash": { + "version": "4.13.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz", + "integrity": "sha1-g+SxCRP0hJbU0W/sSlYK8u50S2g=" + }, + "minimist": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.0.tgz", + "integrity": "sha1-Tf/lJdriuGTGbC4jxicdev3s784=" + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "superagent": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.5.2.tgz", + "integrity": "sha1-M2GjlxVnUEw1EGOr6q4PqiPb8/g=", + "requires": { + "component-emitter": "1.2.1", + "cookiejar": "2.0.6", + "debug": "2.6.9", + "extend": "3.0.0", + "form-data": "2.3.1", + "formidable": "1.1.1", + "methods": "1.1.2", + "mime": "1.3.4", + "qs": "6.5.1", + "readable-stream": "2.3.3" + } + } + } + }, "bittorrent-dht": { "version": "7.6.0", "resolved": "https://registry.npmjs.org/bittorrent-dht/-/bittorrent-dht-7.6.0.tgz", @@ -5135,63 +5307,8 @@ }, "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } - } - }, - "electron-download": { - "version": "github:brave/electron-download#409b65caff14edeef1daa36a7445ba6334658d7c", - "dev": true, - "requires": { - "debug": "2.6.9", - "home-path": "1.0.5", - "minimist": "1.2.0", - "mkdirp": "0.5.1", - "mv": "2.1.1", - "nugget": "1.6.2", - "path-exists": "1.0.0", - "rc": "1.2.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "nugget": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/nugget/-/nugget-1.6.2.tgz", - "integrity": "sha1-iMpuA7pXBqmRc/XaCQJZPWvK4Qc=", - "dev": true, - "requires": { - "debug": "2.6.9", - "minimist": "1.2.0", - "pretty-bytes": "1.0.4", - "progress-stream": "1.2.0", - "request": "2.82.0", - "single-line-log": "0.4.1", - "throttleit": "0.0.2" - } - }, - "path-exists": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-1.0.0.tgz", - "integrity": "sha1-1aiZjrce83p0w06w2eum6HjuoIE=", - "dev": true - }, - "single-line-log": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/single-line-log/-/single-line-log-0.4.1.tgz", - "integrity": "sha1-h6VWSfdJ14PsDc2AToFA2Yc8fO4=", - "dev": true - }, - "throttleit": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz", - "integrity": "sha1-z+34jmDADdlpe2H90qg0OptoDq8=", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true } } @@ -5381,6 +5498,20 @@ "integrity": "sha1-HUixB9ghJqLz4hHC6iX4A7pVGyE=", "dev": true }, + "electron-download": { + "version": "github:brave/electron-download#409b65caff14edeef1daa36a7445ba6334658d7c", + "dev": true, + "requires": { + "debug": "2.6.9", + "home-path": "1.0.5", + "minimist": "1.2.0", + "mkdirp": "0.5.1", + "mv": "2.1.1", + "nugget": "1.6.2", + "path-exists": "1.0.0", + "rc": "1.2.1" + } + }, "electron-osx-sign": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/electron-osx-sign/-/electron-osx-sign-0.3.2.tgz", @@ -5430,6 +5561,27 @@ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, + "nugget": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/nugget/-/nugget-1.6.2.tgz", + "integrity": "sha1-iMpuA7pXBqmRc/XaCQJZPWvK4Qc=", + "dev": true, + "requires": { + "debug": "2.6.9", + "minimist": "1.2.0", + "pretty-bytes": "1.0.4", + "progress-stream": "1.2.0", + "request": "2.82.0", + "single-line-log": "0.4.1", + "throttleit": "0.0.2" + } + }, + "path-exists": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-1.0.0.tgz", + "integrity": "sha1-1aiZjrce83p0w06w2eum6HjuoIE=", + "dev": true + }, "plist": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/plist/-/plist-1.2.0.tgz", @@ -5442,6 +5594,18 @@ "xmldom": "0.1.27" } }, + "single-line-log": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/single-line-log/-/single-line-log-0.4.1.tgz", + "integrity": "sha1-h6VWSfdJ14PsDc2AToFA2Yc8fO4=", + "dev": true + }, + "throttleit": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz", + "integrity": "sha1-z+34jmDADdlpe2H90qg0OptoDq8=", + "dev": true + }, "xmlbuilder": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.0.0.tgz", @@ -5459,6 +5623,61 @@ "requires": { "electron-download": "github:brave/electron-download#409b65caff14edeef1daa36a7445ba6334658d7c", "extract-zip": "1.6.5" + }, + "dependencies": { + "electron-download": { + "version": "github:brave/electron-download#409b65caff14edeef1daa36a7445ba6334658d7c", + "dev": true, + "requires": { + "debug": "2.6.9", + "home-path": "1.0.5", + "minimist": "1.2.0", + "mkdirp": "0.5.1", + "mv": "2.1.1", + "nugget": "1.6.2", + "path-exists": "1.0.0", + "rc": "1.2.1" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "nugget": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/nugget/-/nugget-1.6.2.tgz", + "integrity": "sha1-iMpuA7pXBqmRc/XaCQJZPWvK4Qc=", + "dev": true, + "requires": { + "debug": "2.6.9", + "minimist": "1.2.0", + "pretty-bytes": "1.0.4", + "progress-stream": "1.2.0", + "request": "2.82.0", + "single-line-log": "0.4.1", + "throttleit": "0.0.2" + } + }, + "path-exists": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-1.0.0.tgz", + "integrity": "sha1-1aiZjrce83p0w06w2eum6HjuoIE=", + "dev": true + }, + "single-line-log": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/single-line-log/-/single-line-log-0.4.1.tgz", + "integrity": "sha1-h6VWSfdJ14PsDc2AToFA2Yc8fO4=", + "dev": true + }, + "throttleit": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz", + "integrity": "sha1-z+34jmDADdlpe2H90qg0OptoDq8=", + "dev": true + } } }, "electron-publish": { @@ -8749,177 +8968,6 @@ } } }, - "http-request-signature": { - "version": "github:uphold/http-request-signature#fcbc1b4ff5c8c9e38553c86051d9ce61e6b00aea", - "requires": { - "debugnyan": "2.0.1", - "eslint": "4.8.0", - "lodash": "4.17.4", - "standard-http-error": "2.0.1", - "validator.js": "2.0.3", - "validator.js-asserts": "3.1.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" - }, - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "requires": { - "color-convert": "1.9.0" - } - }, - "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", - "requires": { - "ansi-styles": "3.2.0", - "escape-string-regexp": "1.0.5", - "supports-color": "4.4.0" - } - }, - "color-convert": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", - "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", - "requires": { - "color-name": "1.1.3" - } - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } - }, - "doctrine": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", - "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", - "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" - } - }, - "eslint": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.8.0.tgz", - "integrity": "sha1-Ip7w41Tg5h2DfHqA/fuoJeGZgV4=", - "requires": { - "ajv": "5.2.3", - "babel-code-frame": "6.26.0", - "chalk": "2.1.0", - "concat-stream": "1.6.0", - "cross-spawn": "5.1.0", - "debug": "3.1.0", - "doctrine": "2.0.0", - "eslint-scope": "3.7.1", - "espree": "3.5.1", - "esquery": "1.0.0", - "estraverse": "4.2.0", - "esutils": "2.0.2", - "file-entry-cache": "2.0.0", - "functional-red-black-tree": "1.0.1", - "glob": "7.1.2", - "globals": "9.18.0", - "ignore": "3.3.5", - "imurmurhash": "0.1.4", - "inquirer": "3.0.6", - "is-resolvable": "1.0.0", - "js-yaml": "3.10.0", - "json-stable-stringify": "1.0.1", - "levn": "0.3.0", - "lodash": "4.17.4", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "natural-compare": "1.4.0", - "optionator": "0.8.2", - "path-is-inside": "1.0.2", - "pluralize": "7.0.0", - "progress": "2.0.0", - "require-uncached": "1.0.3", - "semver": "5.4.1", - "strip-ansi": "4.0.0", - "strip-json-comments": "2.0.1", - "table": "4.0.2", - "text-table": "0.2.0" - } - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "pluralize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", - "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==" - }, - "progress": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", - "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=" - }, - "slice-ansi": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", - "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", - "requires": { - "is-fullwidth-code-point": "2.0.0" - } - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "requires": { - "ansi-regex": "3.0.0" - } - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "requires": { - "has-flag": "2.0.0" - } - }, - "table": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", - "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", - "requires": { - "ajv": "5.2.3", - "ajv-keywords": "2.1.0", - "chalk": "2.1.0", - "lodash": "4.17.4", - "slice-ansi": "1.0.0", - "string-width": "2.1.1" - } - } - } - }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", diff --git a/package.json b/package.json index 5d3f114dad4..39661ebfd1b 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "aphrodite": "1.1.0", "async": "^2.0.1", "bat-balance": "^0.9.6", - "bat-client": "^0.9.0", + "bat-client": "^0.9.14", "bat-publisher": "^0.9.0", "bignumber.js": "^4.0.4", "bloodhound-js": "brave/bloodhound", diff --git a/test/unit/app/browser/reducers/ledgerReducerTest.js b/test/unit/app/browser/reducers/ledgerReducerTest.js index f697fd776a3..c7c6491d34d 100644 --- a/test/unit/app/browser/reducers/ledgerReducerTest.js +++ b/test/unit/app/browser/reducers/ledgerReducerTest.js @@ -282,20 +282,24 @@ describe('ledgerReducer unit tests', function () { }) describe('APP_ON_LEDGER_BALANCE_RECEIVED', function () { - let balanceReceivedSpy + let balanceReceivedSpy, result before(function () { + result = { + balance: 10, + unconfirmed: 20, + probi: 10.0000000000 + } balanceReceivedSpy = sinon.spy(fakeLedgerApi, 'balanceReceived') returnedState = ledgerReducer(appState, Immutable.fromJS({ actionType: appConstants.APP_ON_LEDGER_BALANCE_RECEIVED, - balance: 10, - unconfirmed: 20 + result: result })) }) after(function () { balanceReceivedSpy.restore() }) it('calls ledgerApi.balanceReceived', function () { - assert(balanceReceivedSpy.withArgs(appState, 10, 20).calledOnce) + assert(balanceReceivedSpy.withArgs(appState, Immutable.fromJS(result)).calledOnce) }) it('returns a modified state', function () { assert.notDeepEqual(returnedState, appState)