From 222e62d7f10ffe22dd606aea9c15e1547986c4ab Mon Sep 17 00:00:00 2001 From: Howard Braham Date: Mon, 17 Sep 2018 20:04:10 -0700 Subject: [PATCH 01/52] Bug Fix: #1789 and #4525 eth.getCode() with no contract --- CHANGELOG.md | 1 + app/_locales/en/messages.json | 3 +++ .../controllers/transactions/tx-gas-utils.js | 23 +++++++++++++------ old-ui/app/components/pending-tx.js | 2 +- .../confirm-transaction-base.component.js | 2 +- ui/app/components/send/send.utils.js | 2 +- ui/app/constants/error-keys.js | 1 + ui/app/helpers/transactions.util.js | 2 +- 8 files changed, 25 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aef455127..6adb6f64b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Update transaction statuses when switching networks. - [#5470](https://github.com/MetaMask/metamask-extension/pull/5470) 100% coverage in French locale, fixed the procedure to verify proposed locale. +- [#5283](https://github.com/MetaMask/metamask-extension/pull/5283): Fix bug when eth.getCode() called with no contract ## 4.12.0 Thursday September 27 2018 diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 66f378ab8..94716a7ad 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -1154,6 +1154,9 @@ "transactionError": { "message": "Transaction Error. Exception thrown in contract code." }, + "transactionErrorNoContract": { + "message": "Trying to call a contract function at an address that is not a contract address." + }, "transactionMemo": { "message": "Transaction memo (optional)" }, diff --git a/app/scripts/controllers/transactions/tx-gas-utils.js b/app/scripts/controllers/transactions/tx-gas-utils.js index 3dd45507f..5ec728085 100644 --- a/app/scripts/controllers/transactions/tx-gas-utils.js +++ b/app/scripts/controllers/transactions/tx-gas-utils.js @@ -7,6 +7,8 @@ const { const { addHexPrefix } = require('ethereumjs-util') const SIMPLE_GAS_COST = '0x5208' // Hex for 21000, cost of a simple send. +import { TRANSACTION_NO_CONTRACT_ERROR_KEY } from '../../../../ui/app/constants/error-keys' + /** tx-gas-utils are gas utility methods for Transaction manager its passed ethquery @@ -32,6 +34,7 @@ class TxGasUtil { } catch (err) { txMeta.simulationFails = { reason: err.message, + errorKey: err.errorKey, } return txMeta } @@ -56,16 +59,22 @@ class TxGasUtil { return txParams.gas } - // if recipient has no code, gas is 21k max: const recipient = txParams.to const hasRecipient = Boolean(recipient) - let code - if (recipient) code = await this.query.getCode(recipient) - if (hasRecipient && (!code || code === '0x')) { - txParams.gas = SIMPLE_GAS_COST - txMeta.simpleSend = true // Prevents buffer addition - return SIMPLE_GAS_COST + if (hasRecipient) { + let code = await this.query.getCode(recipient) + + // If there's data in the params, but there's no code, it's not a valid contract + // For no code, Infura will return '0x', and Ganache will return '0x0' + if (txParams.data && (!code || code === '0x' || code === '0x0')) { + throw {errorKey: TRANSACTION_NO_CONTRACT_ERROR_KEY} + } + else if (!code) { + txParams.gas = SIMPLE_GAS_COST // For a standard ETH send, gas is 21k max + txMeta.simpleSend = true // Prevents buffer addition + return SIMPLE_GAS_COST + } } // if not, fall back to block gasLimit diff --git a/old-ui/app/components/pending-tx.js b/old-ui/app/components/pending-tx.js index c8132539c..7d8c94699 100644 --- a/old-ui/app/components/pending-tx.js +++ b/old-ui/app/components/pending-tx.js @@ -489,7 +489,7 @@ PendingTx.prototype.verifyGasParams = function () { } PendingTx.prototype._notZeroOrEmptyString = function (obj) { - return obj !== '' && obj !== '0x0' + return obj !== '' && obj !== '0x0' && obj !== '0x' // The '0x' case might not ever happen, but it seems safest to protect against it } PendingTx.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) { diff --git a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js index 707dad62d..9e6341722 100644 --- a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -131,7 +131,7 @@ export default class ConfirmTransactionBase extends Component { if (simulationFails) { return { valid: true, - errorKey: TRANSACTION_ERROR_KEY, + errorKey: simulationFails.errorKey ? simulationFails.errorKey : TRANSACTION_ERROR_KEY, } } diff --git a/ui/app/components/send/send.utils.js b/ui/app/components/send/send.utils.js index a18a9e4b3..05ba6b88f 100644 --- a/ui/app/components/send/send.utils.js +++ b/ui/app/components/send/send.utils.js @@ -215,7 +215,7 @@ async function estimateGas ({ // if recipient has no code, gas is 21k max: if (!selectedToken && !data) { const code = Boolean(to) && await global.eth.getCode(to) - if (!code || code === '0x') { + if (!code || code === '0x' || code === '0x0') { // Infura will return '0x', and Ganache will return '0x0' return SIMPLE_GAS_COST } } else if (selectedToken && !to) { diff --git a/ui/app/constants/error-keys.js b/ui/app/constants/error-keys.js index f70ed3b19..704064c96 100644 --- a/ui/app/constants/error-keys.js +++ b/ui/app/constants/error-keys.js @@ -1,3 +1,4 @@ export const INSUFFICIENT_FUNDS_ERROR_KEY = 'insufficientFunds' export const GAS_LIMIT_TOO_LOW_ERROR_KEY = 'gasLimitTooLow' export const TRANSACTION_ERROR_KEY = 'transactionError' +export const TRANSACTION_NO_CONTRACT_ERROR_KEY = 'transactionErrorNoContract' diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js index f7d249e63..0eb7972d6 100644 --- a/ui/app/helpers/transactions.util.js +++ b/ui/app/helpers/transactions.util.js @@ -114,7 +114,7 @@ export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0') export async function isSmartContractAddress (address) { const code = await global.eth.getCode(address) - return code && code !== '0x' + return code && code !== '0x' && code !== '0x0'; // Infura will return '0x', and Ganache will return '0x0' } export function sumHexes (...args) { From 4cc0b1ef01573e1541d18bdcd89650e1db32ae9a Mon Sep 17 00:00:00 2001 From: Howard Braham Date: Fri, 28 Sep 2018 11:01:34 -0700 Subject: [PATCH 02/52] ganache-core merged my PR, so I changed some comments to clarify that ganache-core v2.2.1 and below will return the non-standard '0x0' --- app/scripts/controllers/transactions/tx-gas-utils.js | 11 ++++++----- old-ui/app/components/pending-tx.js | 2 +- ui/app/components/send/send.utils.js | 2 +- ui/app/helpers/transactions.util.js | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/scripts/controllers/transactions/tx-gas-utils.js b/app/scripts/controllers/transactions/tx-gas-utils.js index 5ec728085..ac57dfe1d 100644 --- a/app/scripts/controllers/transactions/tx-gas-utils.js +++ b/app/scripts/controllers/transactions/tx-gas-utils.js @@ -63,14 +63,15 @@ class TxGasUtil { const hasRecipient = Boolean(recipient) if (hasRecipient) { - let code = await this.query.getCode(recipient) + const code = await this.query.getCode(recipient) // If there's data in the params, but there's no code, it's not a valid contract - // For no code, Infura will return '0x', and Ganache will return '0x0' + // For no code, Infura will return '0x', and ganache-core v2.2.1 will return '0x0' if (txParams.data && (!code || code === '0x' || code === '0x0')) { - throw {errorKey: TRANSACTION_NO_CONTRACT_ERROR_KEY} - } - else if (!code) { + const err = new Error() + err.errorKey = TRANSACTION_NO_CONTRACT_ERROR_KEY + throw err + } else if (!code) { txParams.gas = SIMPLE_GAS_COST // For a standard ETH send, gas is 21k max txMeta.simpleSend = true // Prevents buffer addition return SIMPLE_GAS_COST diff --git a/old-ui/app/components/pending-tx.js b/old-ui/app/components/pending-tx.js index 7d8c94699..d8d2334a4 100644 --- a/old-ui/app/components/pending-tx.js +++ b/old-ui/app/components/pending-tx.js @@ -489,7 +489,7 @@ PendingTx.prototype.verifyGasParams = function () { } PendingTx.prototype._notZeroOrEmptyString = function (obj) { - return obj !== '' && obj !== '0x0' && obj !== '0x' // The '0x' case might not ever happen, but it seems safest to protect against it + return obj !== '' && obj !== '0x0' && obj !== '0x' // '0x' means null } PendingTx.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) { diff --git a/ui/app/components/send/send.utils.js b/ui/app/components/send/send.utils.js index 05ba6b88f..af7b3823f 100644 --- a/ui/app/components/send/send.utils.js +++ b/ui/app/components/send/send.utils.js @@ -215,7 +215,7 @@ async function estimateGas ({ // if recipient has no code, gas is 21k max: if (!selectedToken && !data) { const code = Boolean(to) && await global.eth.getCode(to) - if (!code || code === '0x' || code === '0x0') { // Infura will return '0x', and Ganache will return '0x0' + if (!code || code === '0x' || code === '0x0') { // Infura will return '0x', and ganache-core v2.2.1 will return '0x0' return SIMPLE_GAS_COST } } else if (selectedToken && !to) { diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js index 0eb7972d6..b2c617384 100644 --- a/ui/app/helpers/transactions.util.js +++ b/ui/app/helpers/transactions.util.js @@ -114,7 +114,7 @@ export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0') export async function isSmartContractAddress (address) { const code = await global.eth.getCode(address) - return code && code !== '0x' && code !== '0x0'; // Infura will return '0x', and Ganache will return '0x0' + return code && code !== '0x' && code !== '0x0' // Infura will return '0x', and ganache-core v2.2.1 will return '0x0' } export function sumHexes (...args) { From 600f755dbf8d4cfdc152e3d521b537ee9a046a35 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 9 Oct 2018 23:17:05 -0400 Subject: [PATCH 03/52] tx-gas-utils - improve format + comments --- .../controllers/transactions/tx-gas-utils.js | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/app/scripts/controllers/transactions/tx-gas-utils.js b/app/scripts/controllers/transactions/tx-gas-utils.js index ac57dfe1d..436900715 100644 --- a/app/scripts/controllers/transactions/tx-gas-utils.js +++ b/app/scripts/controllers/transactions/tx-gas-utils.js @@ -62,28 +62,34 @@ class TxGasUtil { const recipient = txParams.to const hasRecipient = Boolean(recipient) + // see if we can set the gas based on the recipient if (hasRecipient) { const code = await this.query.getCode(recipient) - - // If there's data in the params, but there's no code, it's not a valid contract - // For no code, Infura will return '0x', and ganache-core v2.2.1 will return '0x0' - if (txParams.data && (!code || code === '0x' || code === '0x0')) { - const err = new Error() - err.errorKey = TRANSACTION_NO_CONTRACT_ERROR_KEY - throw err - } else if (!code) { - txParams.gas = SIMPLE_GAS_COST // For a standard ETH send, gas is 21k max - txMeta.simpleSend = true // Prevents buffer addition + // For an address with no code, geth will return '0x', and ganache-core v2.2.1 will return '0x0' + const codeIsEmpty = !code || code === '0x' || code === '0x0' + + if (codeIsEmpty) { + // if there's data in the params, but there's no contract code, it's not a valid transaction + if (txParams.data) { + const err = new Error() + err.errorKey = TRANSACTION_NO_CONTRACT_ERROR_KEY + throw err + } + + // This is a standard ether simple send, gas requirement is exactly 21k + txParams.gas = SIMPLE_GAS_COST + // prevents buffer addition + txMeta.simpleSend = true return SIMPLE_GAS_COST } } - // if not, fall back to block gasLimit + // fallback to block gasLimit const blockGasLimitBN = hexToBn(blockGasLimitHex) const saferGasLimitBN = BnMultiplyByFraction(blockGasLimitBN, 19, 20) txParams.gas = bnToHex(saferGasLimitBN) - // run tx + // estimate tx gas requirements return await this.query.estimateGas(txParams) } From 4d1d4a11595b7024a8233761bd034d6ff579eb71 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 17 Oct 2018 20:40:09 -0700 Subject: [PATCH 04/52] Update Shapeshift logo url and adjust list item contents --- ui/app/components/shift-list-item.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/app/components/shift-list-item.js b/ui/app/components/shift-list-item.js index b87bf959e..0461b615a 100644 --- a/ui/app/components/shift-list-item.js +++ b/ui/app/components/shift-list-item.js @@ -52,12 +52,12 @@ ShiftListItem.prototype.render = function () { }, }, [ h('img', { - src: 'https://info.shapeshift.io/sites/default/files/logo.png', + src: 'https://shapeshift.io/logo.png', style: { height: '35px', width: '132px', position: 'absolute', - clip: 'rect(0px,23px,34px,0px)', + clip: 'rect(0px,30px,34px,0px)', }, }), ]), @@ -132,7 +132,6 @@ ShiftListItem.prototype.renderInfo = function () { case 'no_deposits': return h('.flex-column', { style: { - width: '200px', overflow: 'hidden', }, }, [ From ea214945cf88cef457147bd33a3017c8ea97956a Mon Sep 17 00:00:00 2001 From: William Chong Date: Fri, 19 Oct 2018 00:50:56 +0800 Subject: [PATCH 05/52] Set `NODE_ENV` when generating bundler (#4983) --- gulpfile.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 5a468d2f3..0a0e3b3d5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -462,7 +462,9 @@ function generateBundler (opts, performBundle) { bundler.transform(envify({ METAMASK_DEBUG: opts.devMode, NODE_ENV: opts.devMode ? 'development' : 'production', - })) + }), { + global: true, + }) if (opts.watch) { bundler = watchify(bundler) From 26b30a031dacb23cc0a8ec742ece972acdd48594 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 19 Oct 2018 04:36:36 -0400 Subject: [PATCH 06/52] sentry - move isBrave decoration to insides of try-catch --- app/scripts/lib/setupRaven.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js index e6e511640..e1dc4bb8b 100644 --- a/app/scripts/lib/setupRaven.js +++ b/app/scripts/lib/setupRaven.js @@ -24,10 +24,11 @@ function setupRaven (opts) { const client = Raven.config(ravenTarget, { release, transport: function (opts) { - opts.data.extra.isBrave = isBrave const report = opts.data try { + // mark browser as brave or not + report.extra.isBrave = isBrave // handle error-like non-error exceptions rewriteErrorLikeExceptions(report) // simplify certain complex error messages (e.g. Ethjs) From fb1b8d42ac09982b0844ebfd5d4e0169383c983f Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 19 Oct 2018 04:40:23 -0400 Subject: [PATCH 07/52] sentry - update raven-js --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 09b66d261..7be0ccbce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10390,7 +10390,7 @@ "dependencies": { "babelify": { "version": "7.3.0", - "resolved": "http://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz", + "resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz", "integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=", "requires": { "babel-core": "^6.0.14", @@ -27091,9 +27091,9 @@ } }, "raven-js": { - "version": "3.24.2", - "resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.24.2.tgz", - "integrity": "sha512-Dy/FHDxuo5pXywVf8Nrs5utB2juMATpkxWGqHjVbpFD3m8CaWYLvkB5SEXjWFUZ5GvUsrBVVQ+Dfcp0x6Z7SOg==" + "version": "3.27.0", + "resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.27.0.tgz", + "integrity": "sha512-vChdOL+yzecfnGA+B5EhEZkJ3kY3KlMzxEhShKh6Vdtooyl0yZfYNFQfYzgMf2v4pyQa+OTZ5esTxxgOOZDHqw==" }, "raw-body": { "version": "2.3.2", diff --git a/package.json b/package.json index c994acc2f..6c2773623 100644 --- a/package.json +++ b/package.json @@ -186,7 +186,7 @@ "pumpify": "^1.3.4", "qrcode-npm": "0.0.3", "ramda": "^0.24.1", - "raven-js": "^3.24.2", + "raven-js": "^3.27.0", "react": "^15.6.2", "react-addons-css-transition-group": "^15.6.0", "react-dom": "^15.6.2", From 65aa0a1d14b0b18d77b537b216d03ce5d9fca725 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 19 Oct 2018 04:51:03 -0400 Subject: [PATCH 08/52] blacklist - throw errors on request/parse failure --- app/scripts/controllers/blacklist.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js index 89c7cc888..5a5ec1c31 100644 --- a/app/scripts/controllers/blacklist.js +++ b/app/scripts/controllers/blacklist.js @@ -83,8 +83,23 @@ class BlacklistController { * */ async updatePhishingList () { - const response = await fetch('https://api.infura.io/v2/blacklist') - const phishing = await response.json() + // make request + let response + try { + response = await fetch('https://api.infura.io/v2/blacklist') + } catch (err) { + throw new Error(`BlacklistController - failed to fetch blacklist:\n${err.stack}`) + } + // parse response + let rawResponse + let phishing + try { + const rawResponse = await response.text() + phishing = JSON.parse(rawResponse) + } catch (err) { + throw new Error(`BlacklistController - failed to parse blacklist:\n${rawResponse}`) + } + // update current blacklist this.store.updateState({ phishing }) this._setupPhishingDetector(phishing) return phishing @@ -97,9 +112,9 @@ class BlacklistController { */ scheduleUpdates () { if (this._phishingUpdateIntervalRef) return - this.updatePhishingList().catch(log.warn) + this.updatePhishingList() this._phishingUpdateIntervalRef = setInterval(() => { - this.updatePhishingList().catch(log.warn) + this.updatePhishingList() }, POLLING_INTERVAL) } From 2394881511928e414ca99cac2a46f30a7703ae91 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 19 Oct 2018 04:58:19 -0400 Subject: [PATCH 09/52] currency - throw errors on failure --- app/scripts/controllers/currency.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index d5bc5fe2b..619c515fa 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -107,14 +107,28 @@ class CurrencyController { let currentCurrency try { currentCurrency = this.getCurrentCurrency() - const response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) - const parsedResponse = await response.json() + let response + try { + response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) + } catch (err) { + throw new Error(`CurrencyController - Failed to request currency from Infura:\n${err.stack}`) + } + let rawResponse + let parsedResponse + try { + rawResponse = await response.text() + parsedResponse = JSON.parse(rawResponse) + } catch () { + throw new Error(`CurrencyController - Failed to parse response "${rawResponse}"`) + } this.setConversionRate(Number(parsedResponse.bid)) this.setConversionDate(Number(parsedResponse.timestamp)) } catch (err) { - log.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err) + // reset current conversion rate this.setConversionRate(0) this.setConversionDate('N/A') + // throw error + throw new Error(`CurrencyController - Failed to query rate for currency "${currentCurrency}":\n${err.stack}`) } } From 0b12c4efb197dafce24eed8ae25fb93c0571bce0 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 19 Oct 2018 05:18:47 -0400 Subject: [PATCH 10/52] deps - bump eth-json-rpc-middleware for bugfix --- package-lock.json | 48 +++++++++++++++++++++++++++++++++++++---------- package.json | 2 +- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7be0ccbce..b754db4b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9899,29 +9899,26 @@ } }, "eth-json-rpc-middleware": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/eth-json-rpc-middleware/-/eth-json-rpc-middleware-3.1.3.tgz", - "integrity": "sha512-glp/mCefhsqrgVOTTuYlHYiTL+9mMPfaZsuQv4vnRg3kqNigblS1nqARaMeVW9WOM8ssh9TqIFpuUr7JDgNmKQ==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/eth-json-rpc-middleware/-/eth-json-rpc-middleware-3.1.5.tgz", + "integrity": "sha512-68POkWUj0zYvxincExjRWXE49cxKDUSrSZn4oDVER5O5mWm0q/xcsLxlcurNFdHPov9APVqCXqzK6n2jUCDfRQ==", "dev": true, "requires": { - "async": "^2.5.0", "btoa": "^1.2.1", "clone": "^2.1.1", "eth-query": "^2.1.2", "eth-sig-util": "^1.4.2", - "eth-tx-summary": "^3.1.2", + "eth-tx-summary": "^3.2.3", "ethereumjs-block": "^1.6.0", "ethereumjs-tx": "^1.3.3", "ethereumjs-util": "^5.1.2", - "ethereumjs-vm": "^2.1.0", + "ethereumjs-vm": "^2.4.0", "fetch-ponyfill": "^4.0.0", - "json-rpc-engine": "^3.6.3", + "json-rpc-engine": "^3.8.0", "json-rpc-error": "^2.0.0", "json-stable-stringify": "^1.0.1", "pify": "^3.0.0", - "promise-to-callback": "^1.0.0", - "safe-event-emitter": "^1.0.1", - "tape": "^4.6.3" + "safe-event-emitter": "^1.0.1" }, "dependencies": { "eth-sig-util": { @@ -9957,6 +9954,31 @@ "safe-buffer": "^5.1.1", "secp256k1": "^3.0.1" } + }, + "ethereumjs-vm": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/ethereumjs-vm/-/ethereumjs-vm-2.4.0.tgz", + "integrity": "sha512-MJ4lCWa5c6LhahhhvoDKW+YGjK00ZQn0RHHLh4L+WaH1k6Qv7/q3uTluew6sJGNCZdlO0yYMDXYW9qyxLHKlgQ==", + "dev": true, + "requires": { + "async": "^2.1.2", + "async-eventemitter": "^0.2.2", + "ethereumjs-account": "^2.0.3", + "ethereumjs-block": "~1.7.0", + "ethereumjs-common": "~0.4.0", + "ethereumjs-util": "^5.2.0", + "fake-merkle-patricia-tree": "^1.0.1", + "functional-red-black-tree": "^1.0.1", + "merkle-patricia-tree": "^2.1.2", + "rustbn.js": "~0.2.0", + "safe-buffer": "^5.1.1" + } + }, + "rustbn.js": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/rustbn.js/-/rustbn.js-0.2.0.tgz", + "integrity": "sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA==", + "dev": true } } }, @@ -10907,6 +10929,12 @@ } } }, + "ethereumjs-common": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-0.4.1.tgz", + "integrity": "sha512-ywYGsOeGCsMNWso5Y4GhjWI24FJv9FK7+VyVKiQgXg8ZRDPXJ7F/kJ1CnjtkjTvDF4e0yqU+FWswlqR3bmZQ9Q==", + "dev": true + }, "ethereumjs-tx": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-1.3.3.tgz", diff --git a/package.json b/package.json index 6c2773623..3b35c6cff 100644 --- a/package.json +++ b/package.json @@ -261,7 +261,7 @@ "eslint-plugin-json": "^1.2.0", "eslint-plugin-mocha": "^5.0.0", "eslint-plugin-react": "^7.4.0", - "eth-json-rpc-middleware": "^3.1.3", + "eth-json-rpc-middleware": "^3.1.5", "eth-keyring-controller": "^3.3.1", "fetch-mock": "^6.5.2", "file-loader": "^1.1.11", From 3e3d4b9ddef032fe81419a516e65eb62ed664cb9 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 19 Oct 2018 05:30:21 -0400 Subject: [PATCH 11/52] sentry - failed txs - namespace txMeta for better readability --- app/scripts/lib/reportFailedTxToSentry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/lib/reportFailedTxToSentry.js b/app/scripts/lib/reportFailedTxToSentry.js index df5661e59..fc6fbac24 100644 --- a/app/scripts/lib/reportFailedTxToSentry.js +++ b/app/scripts/lib/reportFailedTxToSentry.js @@ -11,6 +11,6 @@ function reportFailedTxToSentry ({ raven, txMeta }) { const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message) raven.captureMessage(errorMessage, { // "extra" key is required by Sentry - extra: txMeta, + extra: { txMeta }, }) } From b85ae55cd59b4f8fe52ec75e1b7c6efe52a02e3f Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 19 Oct 2018 06:42:53 -0400 Subject: [PATCH 12/52] fetch debugger - only append source stack if no stack is present --- app/scripts/lib/setupFetchDebugging.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/scripts/lib/setupFetchDebugging.js b/app/scripts/lib/setupFetchDebugging.js index dd87b65a6..c1ef22d21 100644 --- a/app/scripts/lib/setupFetchDebugging.js +++ b/app/scripts/lib/setupFetchDebugging.js @@ -2,7 +2,7 @@ module.exports = setupFetchDebugging // // This is a utility to help resolve cases where `window.fetch` throws a -// `TypeError: Failed to Fetch` without any stack or context for the request +// `TypeError: Failed to Fetch` without any stack or context for the request // https://github.com/getsentry/sentry-javascript/pull/1293 // @@ -17,9 +17,11 @@ function setupFetchDebugging() { try { return await originalFetch.call(window, ...args) } catch (err) { - console.warn('FetchDebugger - fetch encountered an Error', err) - console.warn('FetchDebugger - overriding stack to point of original call') - err.stack = initialStack + if (!err.stack) { + console.warn('FetchDebugger - fetch encountered an Error without a stack', err) + console.warn('FetchDebugger - overriding stack to point of original call') + err.stack = initialStack + } throw err } } From a57d267dcbfa1a75a5ce3295e51825561e42c58d Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 19 Oct 2018 07:08:04 -0400 Subject: [PATCH 13/52] lint fix --- app/scripts/controllers/blacklist.js | 1 - app/scripts/controllers/currency.js | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js index 5a5ec1c31..6ee89259c 100644 --- a/app/scripts/controllers/blacklist.js +++ b/app/scripts/controllers/blacklist.js @@ -1,7 +1,6 @@ const ObservableStore = require('obs-store') const extend = require('xtend') const PhishingDetector = require('eth-phishing-detect/src/detector') -const log = require('loglevel') // compute phishing lists const PHISHING_DETECTION_CONFIG = require('eth-phishing-detect/src/config.json') diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index 619c515fa..6cb39d39a 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -1,6 +1,5 @@ const ObservableStore = require('obs-store') const extend = require('xtend') -const log = require('loglevel') // every ten minutes const POLLING_INTERVAL = 600000 @@ -118,7 +117,7 @@ class CurrencyController { try { rawResponse = await response.text() parsedResponse = JSON.parse(rawResponse) - } catch () { + } catch (err) { throw new Error(`CurrencyController - Failed to parse response "${rawResponse}"`) } this.setConversionRate(Number(parsedResponse.bid)) From 31175dcb24d836650469775a50289bfc131bcd18 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 19 Oct 2018 07:18:16 -0400 Subject: [PATCH 14/52] blacklist + currency - report error via log instead of throw --- app/scripts/controllers/blacklist.js | 7 +++++-- app/scripts/controllers/currency.js | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js index 6ee89259c..e55b09d03 100644 --- a/app/scripts/controllers/blacklist.js +++ b/app/scripts/controllers/blacklist.js @@ -1,6 +1,7 @@ const ObservableStore = require('obs-store') const extend = require('xtend') const PhishingDetector = require('eth-phishing-detect/src/detector') +const log = require('loglevel') // compute phishing lists const PHISHING_DETECTION_CONFIG = require('eth-phishing-detect/src/config.json') @@ -87,7 +88,8 @@ class BlacklistController { try { response = await fetch('https://api.infura.io/v2/blacklist') } catch (err) { - throw new Error(`BlacklistController - failed to fetch blacklist:\n${err.stack}`) + log.error(new Error(`BlacklistController - failed to fetch blacklist:\n${err.stack}`)) + return } // parse response let rawResponse @@ -96,7 +98,8 @@ class BlacklistController { const rawResponse = await response.text() phishing = JSON.parse(rawResponse) } catch (err) { - throw new Error(`BlacklistController - failed to parse blacklist:\n${rawResponse}`) + log.error(new Error(`BlacklistController - failed to parse blacklist:\n${rawResponse}`)) + return } // update current blacklist this.store.updateState({ phishing }) diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index 6cb39d39a..6b82265f6 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -1,5 +1,6 @@ const ObservableStore = require('obs-store') const extend = require('xtend') +const log = require('loglevel') // every ten minutes const POLLING_INTERVAL = 600000 @@ -110,7 +111,8 @@ class CurrencyController { try { response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) } catch (err) { - throw new Error(`CurrencyController - Failed to request currency from Infura:\n${err.stack}`) + log.error(new Error(`CurrencyController - Failed to request currency from Infura:\n${err.stack}`)) + return } let rawResponse let parsedResponse @@ -118,7 +120,8 @@ class CurrencyController { rawResponse = await response.text() parsedResponse = JSON.parse(rawResponse) } catch (err) { - throw new Error(`CurrencyController - Failed to parse response "${rawResponse}"`) + log.error(new Error(`CurrencyController - Failed to parse response "${rawResponse}"`)) + return } this.setConversionRate(Number(parsedResponse.bid)) this.setConversionDate(Number(parsedResponse.timestamp)) @@ -127,7 +130,8 @@ class CurrencyController { this.setConversionRate(0) this.setConversionDate('N/A') // throw error - throw new Error(`CurrencyController - Failed to query rate for currency "${currentCurrency}":\n${err.stack}`) + log.error(new Error(`CurrencyController - Failed to query rate for currency "${currentCurrency}":\n${err.stack}`)) + return } } From 2f6530a4948743fe156dc3519f04bd44f7c6e2ae Mon Sep 17 00:00:00 2001 From: hackyminer Date: Sat, 20 Oct 2018 00:45:59 +0900 Subject: [PATCH 15/52] support both eth_chainId and net_version get the real chainId using eth_chainId and use net_version as a fallback --- app/scripts/controllers/network/network.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index c1667d9a6..b386161da 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -86,10 +86,17 @@ module.exports = class NetworkController extends EventEmitter { return log.warn('NetworkController - lookupNetwork aborted due to missing provider') } const ethQuery = new EthQuery(this._provider) - ethQuery.sendAsync({ method: 'net_version' }, (err, network) => { - if (err) return this.setNetworkState('loading') - log.info('web3.getNetwork returned ' + network) - this.setNetworkState(network) + ethQuery.sendAsync({ method: 'eth_chainId' }, (err, chainId) => { + if (err) { + ethQuery.sendAsync({ method: 'net_version' }, (err, network) => { + if (err) return this.setNetworkState('loading') + log.info('web3.getNetwork returned net_version = ' + network) + this.setNetworkState(network) + }) + return + } + log.info('web3.getNetwork returned chainId = ' + parseInt(chainId)) + this.setNetworkState(parseInt(chainId)) }) } From 75661673e5b2573ee9ab3a378130e4383c4c034f Mon Sep 17 00:00:00 2001 From: Esteban MIno Date: Fri, 19 Oct 2018 13:57:11 -0300 Subject: [PATCH 16/52] add support for wallet_watchAsset --- app/scripts/controllers/preferences.js | 2 +- test/unit/app/controllers/preferences-controller-test.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 8eb2bce0c..16620ca96 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -104,7 +104,7 @@ class PreferencesController { * @param {Function} - end */ async requestWatchAsset (req, res, next, end) { - if (req.method === 'metamask_watchAsset') { + if (req.method === 'metamask_watchAsset' || req.method === 'wallet_watchAsset') { const { type, options } = req.params switch (type) { case 'ERC20': diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index b5ccf3fb5..e81b072d5 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -375,6 +375,11 @@ describe('preferences controller', function () { await preferencesController.requestWatchAsset(req, res, asy.next, asy.end) sandbox.assert.called(stubEnd) sandbox.assert.notCalled(stubNext) + req.method = 'wallet_watchAsset' + req.params.type = 'someasset' + await preferencesController.requestWatchAsset(req, res, asy.next, asy.end) + sandbox.assert.calledTwice(stubEnd) + sandbox.assert.notCalled(stubNext) }) it('should through error if method is supported but asset type is not', async function () { req.method = 'metamask_watchAsset' From 7c4f98ffd6f5d7237d86cb7e1277ec44dec2db22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20Mi=C3=B1o?= Date: Fri, 19 Oct 2018 17:20:54 -0300 Subject: [PATCH 17/52] specific add and remove methods for frequentRpcList (#5554) --- app/scripts/controllers/preferences.js | 51 +++++++++---------- app/scripts/metamask-controller.js | 4 +- .../preferences-controller-test.js | 19 +++++++ 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 8eb2bce0c..689506a7a 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -374,22 +374,6 @@ class PreferencesController { return Promise.resolve(label) } - /** - * Gets an updated rpc list from this.addToFrequentRpcList() and sets the `frequentRpcList` to this update list. - * - * @param {string} _url The the new rpc url to add to the updated list - * @param {bool} remove Remove selected url - * @returns {Promise} Promise resolves with undefined - * - */ - updateFrequentRpcList (_url, remove = false) { - return this.addToFrequentRpcList(_url, remove) - .then((rpcList) => { - this.store.updateState({ frequentRpcList: rpcList }) - return Promise.resolve() - }) - } - /** * Setter for the `currentAccountTab` property * @@ -405,24 +389,39 @@ class PreferencesController { } /** - * Returns an updated rpcList based on the passed url and the current list. - * The returned list will have a max length of 3. If the _url currently exists it the list, it will be moved to the - * end of the list. The current list is modified and returned as a promise. + * Adds custom RPC url to state. * - * @param {string} _url The rpc url to add to the frequentRpcList. - * @param {bool} remove Remove selected url - * @returns {Promise} The updated frequentRpcList. + * @param {string} url The RPC url to add to frequentRpcList. + * @returns {Promise} Promise resolving to updated frequentRpcList. * */ - addToFrequentRpcList (_url, remove = false) { + addToFrequentRpcList (url) { const rpcList = this.getFrequentRpcList() - const index = rpcList.findIndex((element) => { return element === _url }) + const index = rpcList.findIndex((element) => { return element === url }) if (index !== -1) { rpcList.splice(index, 1) } - if (!remove && _url !== 'http://localhost:8545') { - rpcList.push(_url) + if (url !== 'http://localhost:8545') { + rpcList.push(url) + } + this.store.updateState({ frequentRpcList: rpcList }) + return Promise.resolve(rpcList) + } + + /** + * Removes custom RPC url from state. + * + * @param {string} url The RPC url to remove from frequentRpcList. + * @returns {Promise} Promise resolving to updated frequentRpcList. + * + */ + removeFromFrequentRpcList (url) { + const rpcList = this.getFrequentRpcList() + const index = rpcList.findIndex((element) => { return element === url }) + if (index !== -1) { + rpcList.splice(index, 1) } + this.store.updateState({ frequentRpcList: rpcList }) return Promise.resolve(rpcList) } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 32ceb6790..7913662d4 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1458,7 +1458,7 @@ module.exports = class MetamaskController extends EventEmitter { */ async setCustomRpc (rpcTarget) { this.networkController.setRpcTarget(rpcTarget) - await this.preferencesController.updateFrequentRpcList(rpcTarget) + await this.preferencesController.addToFrequentRpcList(rpcTarget) return rpcTarget } @@ -1467,7 +1467,7 @@ module.exports = class MetamaskController extends EventEmitter { * @param {string} rpcTarget - A RPC URL to delete. */ async delCustomRpc (rpcTarget) { - await this.preferencesController.updateFrequentRpcList(rpcTarget, true) + await this.preferencesController.removeFromFrequentRpcList(rpcTarget) } /** diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index b5ccf3fb5..02f421de2 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -479,5 +479,24 @@ describe('preferences controller', function () { assert.equal(preferencesController.store.getState().seedWords, 'foo bar baz') }) }) + + describe('on updateFrequentRpcList', function () { + it('should add custom RPC url to state', function () { + preferencesController.addToFrequentRpcList('rpc_url') + preferencesController.addToFrequentRpcList('http://localhost:8545') + assert.deepEqual(preferencesController.store.getState().frequentRpcList, ['rpc_url']) + preferencesController.addToFrequentRpcList('rpc_url') + assert.deepEqual(preferencesController.store.getState().frequentRpcList, ['rpc_url']) + }) + + it('should remove custom RPC url from state', function () { + preferencesController.addToFrequentRpcList('rpc_url') + assert.deepEqual(preferencesController.store.getState().frequentRpcList, ['rpc_url']) + preferencesController.removeFromFrequentRpcList('other_rpc_url') + preferencesController.removeFromFrequentRpcList('http://localhost:8545') + preferencesController.removeFromFrequentRpcList('rpc_url') + assert.deepEqual(preferencesController.store.getState().frequentRpcList, []) + }) + }) }) From e3fda83ab209af7836ba93bfaba215c271d73e8a Mon Sep 17 00:00:00 2001 From: kumavis Date: Sat, 20 Oct 2018 02:22:50 -0400 Subject: [PATCH 18/52] sentry - replace raven-js with sentry/browser --- app/scripts/background.js | 12 ++-- app/scripts/lib/reportFailedTxToSentry.js | 4 +- .../lib/{setupRaven.js => setupSentry.js} | 68 ++++++++----------- app/scripts/ui.js | 4 +- package-lock.json | 57 ++++++++++++++-- package.json | 2 +- 6 files changed, 92 insertions(+), 55 deletions(-) rename app/scripts/lib/{setupRaven.js => setupSentry.js} (52%) diff --git a/app/scripts/background.js b/app/scripts/background.js index 509a0001d..2455608aa 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -23,7 +23,7 @@ const createStreamSink = require('./lib/createStreamSink') const NotificationManager = require('./lib/notification-manager.js') const MetamaskController = require('./metamask-controller') const rawFirstTimeState = require('./first-time-state') -const setupRaven = require('./lib/setupRaven') +const setupSentry = require('./lib/setupSentry') const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry') const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics') const EdgeEncryptor = require('./edge-encryptor') @@ -50,7 +50,7 @@ global.METAMASK_NOTIFIER = notificationManager // setup sentry error reporting const release = platform.getVersion() -const raven = setupRaven({ release }) +const sentry = setupSentry({ release }) // browser check if it is Edge - https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser // Internet Explorer 6-11 @@ -197,14 +197,14 @@ async function loadStateFromPersistence () { // we were able to recover (though it might be old) versionedData = diskStoreState const vaultStructure = getObjStructure(versionedData) - raven.captureMessage('MetaMask - Empty vault found - recovered from diskStore', { + sentry.captureMessage('MetaMask - Empty vault found - recovered from diskStore', { // "extra" key is required by Sentry extra: { vaultStructure }, }) } else { // unable to recover, clear state versionedData = migrator.generateInitialState(firstTimeState) - raven.captureMessage('MetaMask - Empty vault found - unable to recover') + sentry.captureMessage('MetaMask - Empty vault found - unable to recover') } } @@ -212,7 +212,7 @@ async function loadStateFromPersistence () { migrator.on('error', (err) => { // get vault structure without secrets const vaultStructure = getObjStructure(versionedData) - raven.captureException(err, { + sentry.captureException(err, { // "extra" key is required by Sentry extra: { vaultStructure }, }) @@ -279,7 +279,7 @@ function setupController (initState, initLangCode) { if (status !== 'failed') return const txMeta = controller.txController.txStateManager.getTx(txId) try { - reportFailedTxToSentry({ raven, txMeta }) + reportFailedTxToSentry({ sentry, txMeta }) } catch (e) { console.error(e) } diff --git a/app/scripts/lib/reportFailedTxToSentry.js b/app/scripts/lib/reportFailedTxToSentry.js index fc6fbac24..de4d57145 100644 --- a/app/scripts/lib/reportFailedTxToSentry.js +++ b/app/scripts/lib/reportFailedTxToSentry.js @@ -7,9 +7,9 @@ module.exports = reportFailedTxToSentry // for sending to sentry // -function reportFailedTxToSentry ({ raven, txMeta }) { +function reportFailedTxToSentry ({ sentry, txMeta }) { const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message) - raven.captureMessage(errorMessage, { + sentry.captureMessage(errorMessage, { // "extra" key is required by Sentry extra: { txMeta }, }) diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupSentry.js similarity index 52% rename from app/scripts/lib/setupRaven.js rename to app/scripts/lib/setupSentry.js index e1dc4bb8b..aa8d72194 100644 --- a/app/scripts/lib/setupRaven.js +++ b/app/scripts/lib/setupSentry.js @@ -1,59 +1,49 @@ -const Raven = require('raven-js') +const Sentry = require('@sentry/browser') const METAMASK_DEBUG = process.env.METAMASK_DEBUG const extractEthjsErrorMessage = require('./extractEthjsErrorMessage') -const PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505' -const DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496' +const SENTRY_DSN_PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505' +const SENTRY_DSN_DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496' -module.exports = setupRaven +module.exports = setupSentry -// Setup raven / sentry remote error reporting -function setupRaven (opts) { +// Setup sentry remote error reporting +function setupSentry (opts) { const { release } = opts - let ravenTarget + let sentryTarget // detect brave const isBrave = Boolean(window.chrome.ipcRenderer) if (METAMASK_DEBUG) { - console.log('Setting up Sentry Remote Error Reporting: DEV') - ravenTarget = DEV + console.log('Setting up Sentry Remote Error Reporting: SENTRY_DSN_DEV') + sentryTarget = SENTRY_DSN_DEV } else { - console.log('Setting up Sentry Remote Error Reporting: PROD') - ravenTarget = PROD + console.log('Setting up Sentry Remote Error Reporting: SENTRY_DSN_PROD') + sentryTarget = SENTRY_DSN_PROD } - const client = Raven.config(ravenTarget, { + Sentry.init({ + dsn: sentryTarget, + debug: METAMASK_DEBUG, release, - transport: function (opts) { - const report = opts.data + beforeSend: (report) => rewriteReport(report), + }) - try { - // mark browser as brave or not - report.extra.isBrave = isBrave - // handle error-like non-error exceptions - rewriteErrorLikeExceptions(report) - // simplify certain complex error messages (e.g. Ethjs) - simplifyErrorMessages(report) - // modify report urls - rewriteReportUrls(report) - } catch (err) { - console.warn(err) - } - // make request normally - client._makeRequest(opts) - }, + Sentry.configureScope(scope => { + scope.setExtra('isBrave', isBrave) }) - client.install() - return Raven -} + function rewriteReport(report) { + try { + // simplify certain complex error messages (e.g. Ethjs) + simplifyErrorMessages(report) + // modify report urls + rewriteReportUrls(report) + } catch (err) { + console.warn(err) + } + } -function rewriteErrorLikeExceptions (report) { - // handle errors that lost their error-ness in serialization (e.g. dnode) - rewriteErrorMessages(report, (errorMessage) => { - if (!errorMessage.includes('Non-Error exception captured with keys:')) return errorMessage - if (!(report.extra && report.extra.__serialized__ && report.extra.__serialized__.message)) return errorMessage - return `Non-Error Exception: ${report.extra.__serialized__.message}` - }) + return Sentry } function simplifyErrorMessages (report) { diff --git a/app/scripts/ui.js b/app/scripts/ui.js index 98a036338..8893ceaad 100644 --- a/app/scripts/ui.js +++ b/app/scripts/ui.js @@ -9,7 +9,7 @@ const extension = require('extensionizer') const ExtensionPlatform = require('./platforms/extension') const NotificationManager = require('./lib/notification-manager') const notificationManager = new NotificationManager() -const setupRaven = require('./lib/setupRaven') +const setupSentry = require('./lib/setupSentry') const log = require('loglevel') start().catch(log.error) @@ -21,7 +21,7 @@ async function start () { // setup sentry error reporting const release = global.platform.getVersion() - setupRaven({ release }) + setupSentry({ release }) // inject css // const css = MetaMaskUiCss() diff --git a/package-lock.json b/package-lock.json index b754db4b8..dc63d8b91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -489,6 +489,16 @@ } } }, + "@sentry/browser": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-4.1.1.tgz", + "integrity": "sha512-rmkGlTh0AL3Jf0DvF3BluChIyzPkkYpNgIwEHjxTUiLp6BQdgwakZuzBqSPJrEs+jMsKMoesOuJ/fAAG0K7+Ew==", + "requires": { + "@sentry/core": "4.1.1", + "@sentry/types": "4.1.0", + "@sentry/utils": "4.1.1" + } + }, "@sentry/cli": { "version": "1.30.3", "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-1.30.3.tgz", @@ -531,6 +541,48 @@ } } }, + "@sentry/core": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-4.1.1.tgz", + "integrity": "sha512-QJExTxZ1ZA5P/To5gOwd3sowukXW0N/Q9nfu8biRDNa+YURn6ElLjO0fD6eIBqX1f3npo/kTiWZwFBc7LXEzSg==", + "requires": { + "@sentry/hub": "4.1.1", + "@sentry/minimal": "4.1.1", + "@sentry/types": "4.1.0", + "@sentry/utils": "4.1.1" + } + }, + "@sentry/hub": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-4.1.1.tgz", + "integrity": "sha512-VmcZOgcbFjJzK1oQNwcFP/wgfoWQr24dFv1C0uwdXldNXx3mwyUVkomvklBHz90HwiahsI/gCc+ZmbC3ECQk2Q==", + "requires": { + "@sentry/types": "4.1.0", + "@sentry/utils": "4.1.1" + } + }, + "@sentry/minimal": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-4.1.1.tgz", + "integrity": "sha512-xRKWA46OGnZinJyTljDUel53emPP9mb/XNi/kF6SBaVDOUXl7HAB8kP7Bn7eLBwOanxN8PbYoAzh/lIQXWTmDg==", + "requires": { + "@sentry/hub": "4.1.1", + "@sentry/types": "4.1.0" + } + }, + "@sentry/types": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-4.1.0.tgz", + "integrity": "sha512-KY7B9wYs1NACHlYzG4OuP6k4uQJkyDPJppftjj3NJYShfwdDTO1I2Swkhhb5dJMEMMMpBJGxXmiqZ2mX5ErISQ==" + }, + "@sentry/utils": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-4.1.1.tgz", + "integrity": "sha512-XMvGqAWATBrRkOF0lkt0Ij8of2mRmp4WeFTUAgiKzCekxfUBLBaTb4wTaFXz1cnnnjVTwcAq72qBRMhHwQ0IIg==", + "requires": { + "@sentry/types": "4.1.0" + } + }, "@sinonjs/formatio": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz", @@ -27118,11 +27170,6 @@ "eve-raphael": "0.5.0" } }, - "raven-js": { - "version": "3.27.0", - "resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.27.0.tgz", - "integrity": "sha512-vChdOL+yzecfnGA+B5EhEZkJ3kY3KlMzxEhShKh6Vdtooyl0yZfYNFQfYzgMf2v4pyQa+OTZ5esTxxgOOZDHqw==" - }, "raw-body": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", diff --git a/package.json b/package.json index 3b35c6cff..ebac62d7f 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ }, "dependencies": { "@material-ui/core": "1.0.0", + "@sentry/browser": "^4.1.1", "@zxing/library": "^0.8.0", "abi-decoder": "^1.0.9", "asmcrypto.js": "0.22.0", @@ -186,7 +187,6 @@ "pumpify": "^1.3.4", "qrcode-npm": "0.0.3", "ramda": "^0.24.1", - "raven-js": "^3.27.0", "react": "^15.6.2", "react-addons-css-transition-group": "^15.6.0", "react-dom": "^15.6.2", From 73ec4e66cb7a476d01371a61692b0d8d9224da04 Mon Sep 17 00:00:00 2001 From: kumavis Date: Sat, 20 Oct 2018 03:14:59 -0400 Subject: [PATCH 19/52] sentry - include app state in ui errors --- app/scripts/lib/setupSentry.js | 8 +++++++- app/scripts/ui.js | 12 +++++++++++- package-lock.json | 6 +++--- package.json | 2 +- ui/app/reducers.js | 26 ++++++++++++++++---------- 5 files changed, 38 insertions(+), 16 deletions(-) diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index aa8d72194..69042bc19 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -8,7 +8,7 @@ module.exports = setupSentry // Setup sentry remote error reporting function setupSentry (opts) { - const { release } = opts + const { release, getState } = opts let sentryTarget // detect brave const isBrave = Boolean(window.chrome.ipcRenderer) @@ -38,9 +38,15 @@ function setupSentry (opts) { simplifyErrorMessages(report) // modify report urls rewriteReportUrls(report) + // append app state + if (getState) { + const appState = getState() + report.extra.appState = appState + } } catch (err) { console.warn(err) } + return report } return Sentry diff --git a/app/scripts/ui.js b/app/scripts/ui.js index 8893ceaad..c4f6615db 100644 --- a/app/scripts/ui.js +++ b/app/scripts/ui.js @@ -21,7 +21,17 @@ async function start () { // setup sentry error reporting const release = global.platform.getVersion() - setupSentry({ release }) + setupSentry({ release, getState }) + // provide app state to append to error logs + function getState() { + // get app state + const state = window.getCleanAppState() + // remove unnecessary data + delete state.localeMessages + delete state.metamask.recentBlocks + // return state to be added to request + return state + } // inject css // const css = MetaMaskUiCss() diff --git a/package-lock.json b/package-lock.json index dc63d8b91..04c2b7014 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6183,9 +6183,9 @@ } }, "clone": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz", - "integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs=" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=" }, "clone-buffer": { "version": "1.0.0", diff --git a/package.json b/package.json index ebac62d7f..9f56e726a 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "browserify-derequire": "^0.9.4", "browserify-unibabel": "^3.0.0", "classnames": "^2.2.5", - "clone": "^2.1.1", + "clone": "^2.1.2", "copy-to-clipboard": "^3.0.8", "css-loader": "^0.28.11", "currency-formatter": "^1.4.2", diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 80e76d570..e1a982f93 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -1,3 +1,4 @@ +const clone = require('clone') const extend = require('xtend') const copyToClipboard = require('copy-to-clipboard') @@ -52,19 +53,24 @@ function rootReducer (state, action) { return state } +window.getCleanAppState = function () { + const state = clone(window.METAMASK_CACHED_LOG_STATE) + // append additional information + state.version = global.platform.getVersion() + state.browser = window.navigator.userAgent + // ensure seedWords are not included + if (state.metamask) delete state.metamask.seedWords + if (state.appState.currentView) delete state.appState.currentView.seedWords + return state +} + window.logStateString = function (cb) { - const state = window.METAMASK_CACHED_LOG_STATE - const version = global.platform.getVersion() - const browser = window.navigator.userAgent - return global.platform.getPlatformInfo((err, platform) => { - if (err) { - return cb(err) - } - state.version = version + const state = window.getCleanAppState() + global.platform.getPlatformInfo((err, platform) => { + if (err) return cb(err) state.platform = platform - state.browser = browser const stateString = JSON.stringify(state, removeSeedWords, 2) - return cb(null, stateString) + cb(null, stateString) }) } From 539597cb13e43ef0479091e17dce48b70833bce0 Mon Sep 17 00:00:00 2001 From: kumavis Date: Sat, 20 Oct 2018 04:01:50 -0400 Subject: [PATCH 20/52] deps - fix gulp ref to gulp#v4.0.0 --- package-lock.json | 407 +++++++++++++++++++++++++++++++++++++++++++--- package.json | 2 +- 2 files changed, 384 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 09b66d261..e3322d21d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9932,12 +9932,22 @@ "requires": { "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7", "ethereumjs-util": "^5.1.1" + }, + "dependencies": { + "ethereumjs-abi": { + "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7", + "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7", + "dev": true, + "requires": { + "bn.js": "^4.10.0", + "ethereumjs-util": "^5.0.0" + } + } } }, "ethereumjs-abi": { "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7", "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git", - "dev": true, "requires": { "bn.js": "^4.10.0", "ethereumjs-util": "^5.0.0" @@ -9947,7 +9957,6 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, "requires": { "bn.js": "^4.11.0", "create-hash": "^1.1.2", @@ -10390,7 +10399,7 @@ "dependencies": { "babelify": { "version": "7.3.0", - "resolved": "http://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz", + "resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz", "integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=", "requires": { "babel-core": "^6.0.14", @@ -12779,7 +12788,8 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", @@ -12787,7 +12797,8 @@ }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -12890,7 +12901,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -12900,6 +12912,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -13017,7 +13030,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -13027,6 +13041,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -13132,6 +13147,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -14249,14 +14265,354 @@ "dev": true }, "glob-watcher": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-4.0.0.tgz", - "integrity": "sha1-nmOo/25h6TLebMLK7OUHGm1zcyk=", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-5.0.1.tgz", + "integrity": "sha512-fK92r2COMC199WCyGUblrZKhjra3cyVMDiypDdqg1vsSDmexnbYivK1kNR4QItiNXLKmGlqan469ks67RtNa2g==", "requires": { "async-done": "^1.2.0", - "chokidar": "^1.4.3", + "chokidar": "^2.0.0", "just-debounce": "^1.0.0", "object.defaults": "^1.1.0" + }, + "dependencies": { + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=" + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=" + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "chokidar": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz", + "integrity": "sha512-z9n7yt9rOvIJrMhvDtDictKrkFHeihkNl6uWMmZlmL6tJtX9Cs+87oK+teBx+JIgzvbX3yZHT3eF8vpbDxHJXQ==", + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.0", + "braces": "^2.3.0", + "fsevents": "^1.2.2", + "glob-parent": "^3.1.0", + "inherits": "^2.0.1", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "lodash.debounce": "^4.0.8", + "normalize-path": "^2.1.1", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.0.0", + "upath": "^1.0.5" + } + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + } + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + } + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==" + } + } + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-glob": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", + "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + }, + "dependencies": { + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + } + } + }, + "upath": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.0.tgz", + "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==" + } } }, "glob2base": { @@ -14381,10 +14737,10 @@ "dev": true }, "gulp": { - "version": "github:gulpjs/gulp#71c094a51c7972d26f557899ddecab0210ef3776", - "from": "github:gulpjs/gulp#4.0", + "version": "github:gulpjs/gulp#55eb23a268dcc7340bb40808600fd4802848c06f", + "from": "github:gulpjs/gulp#v4.0.0", "requires": { - "glob-watcher": "^4.0.0", + "glob-watcher": "^5.0.0", "gulp-cli": "^2.0.0", "undertaker": "^1.0.0", "vinyl-fs": "^3.0.0" @@ -21494,9 +21850,9 @@ "dev": true }, "mute-stdout": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.0.tgz", - "integrity": "sha1-WzLqB+tDyd7WEwQ0z5JvRrKn/U0=" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.1.tgz", + "integrity": "sha512-kDcwXR4PS7caBpuRYYBUz9iVixUk3anO3f5OYFiIPwK/20vCzKCHyKoulbiDY1S53zD2bxUpxN/IJ+TnXjfvxg==" }, "mute-stream": { "version": "0.0.7", @@ -26412,7 +26768,7 @@ }, "pretty-hrtime": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", + "resolved": "http://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=" }, "printf": { @@ -33471,9 +33827,9 @@ "optional": true }, "v8flags": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.0.tgz", - "integrity": "sha512-0m69VIK2dudEf2Ub0xwLQhZkDZu85OmiOpTw+UGDt56ibviYICHziM/3aE+oVg7IjGPp0c83w3eSVqa+lYZ9UQ==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.1.1.tgz", + "integrity": "sha512-iw/1ViSEaff8NJ3HLyEjawk/8hjJib3E7pvG4pddVXfUg1983s3VGsiClDjhK64MQVDGqc1Q8r18S4VKQZS9EQ==", "requires": { "homedir-polyfill": "^1.0.1" } @@ -33700,9 +34056,12 @@ }, "dependencies": { "convert-source-map": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", - "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=" + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", + "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", + "requires": { + "safe-buffer": "~5.1.1" + } } } }, diff --git a/package.json b/package.json index c994acc2f..ef72d7bfb 100644 --- a/package.json +++ b/package.json @@ -143,7 +143,7 @@ "fast-levenshtein": "^2.0.6", "file-loader": "^1.1.11", "fuse.js": "^3.2.0", - "gulp": "github:gulpjs/gulp#4.0", + "gulp": "github:gulpjs/gulp#v4.0.0", "gulp-autoprefixer": "^5.0.0", "gulp-debug": "^3.2.0", "gulp-eslint": "^4.0.0", From b53a1f492c3339ef6fe070ac7d02b63a4393669c Mon Sep 17 00:00:00 2001 From: Brandon Wissmann Date: Sat, 20 Oct 2018 23:55:37 -0400 Subject: [PATCH 21/52] i18n - use localized names in language selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4250 (#5559) * Added localized names for languages * Capital letter for Čeština * capital letter Русский * i18n - use localized names in language selection * fix build * package-lock.json build fix --- app/_locales/index.json | 42 ++++++++++++++++++++--------------------- package-lock.json | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/_locales/index.json b/app/_locales/index.json index 46933dc3f..234215e39 100644 --- a/app/_locales/index.json +++ b/app/_locales/index.json @@ -1,24 +1,24 @@ [ - { "code": "cs", "name": "Czech" }, - { "code": "de", "name": "German" }, + { "code": "cs", "name": "Čeština" }, + { "code": "de", "name": "Deutsche" }, { "code": "en", "name": "English" }, - { "code": "es", "name": "Spanish" }, - { "code": "fr", "name": "French" }, - { "code": "ht", "name": "Haitian Creole" }, - { "code": "hn", "name": "Hindi" }, - { "code": "it", "name": "Italian" }, - { "code": "ja", "name": "Japanese" }, - { "code": "ko", "name": "Korean" }, - { "code": "nl", "name": "Dutch" }, - { "code": "ph", "name": "Tagalog" }, - { "code": "pl", "name": "Polish" }, - { "code": "pt", "name": "Portuguese" }, - { "code": "ru", "name": "Russian" }, - { "code": "sl", "name": "Slovenian" }, - { "code": "th", "name": "Thai" }, - { "code": "tml", "name": "Tamil" }, - { "code": "tr", "name": "Turkish" }, - { "code": "vi", "name": "Vietnamese" }, - { "code": "zh_CN", "name": "Chinese (Simplified)" }, - { "code": "zh_TW", "name": "Chinese (Traditional)" } + { "code": "es", "name": "Español" }, + { "code": "fr", "name": "Français" }, + { "code": "ht", "name": "Kreyòl ayisyen" }, + { "code": "hn", "name": "हिन्दी" }, + { "code": "it", "name": "Italiano" }, + { "code": "ja", "name": "日本語" }, + { "code": "ko", "name": "한국어" }, + { "code": "nl", "name": "Nederlands" }, + { "code": "ph", "name": "Pilipino" }, + { "code": "pl", "name": "Polskie" }, + { "code": "pt", "name": "Português" }, + { "code": "ru", "name": "Русский" }, + { "code": "sl", "name": "Slovenščina" }, + { "code": "th", "name": "ไทย" }, + { "code": "tml", "name": "தமிழ்" }, + { "code": "tr", "name": "Türkçe" }, + { "code": "vi", "name": "Tiếng Việt" }, + { "code": "zh_CN", "name": "中文(简体)" }, + { "code": "zh_TW", "name": "中文(繁體)" } ] diff --git a/package-lock.json b/package-lock.json index e3322d21d..22f0f3ab9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35267,4 +35267,4 @@ "dev": true } } -} +} \ No newline at end of file From fda101912bbb99f7f1adbac9856d34105390c408 Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 21 Oct 2018 00:52:41 -0400 Subject: [PATCH 22/52] ui - use variable to clarify result of emptiness check --- old-ui/app/components/pending-tx.js | 6 ++++-- ui/app/components/send/send.utils.js | 4 +++- ui/app/helpers/transactions.util.js | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/old-ui/app/components/pending-tx.js b/old-ui/app/components/pending-tx.js index d8d2334a4..b02476f46 100644 --- a/old-ui/app/components/pending-tx.js +++ b/old-ui/app/components/pending-tx.js @@ -488,8 +488,10 @@ PendingTx.prototype.verifyGasParams = function () { ) } -PendingTx.prototype._notZeroOrEmptyString = function (obj) { - return obj !== '' && obj !== '0x0' && obj !== '0x' // '0x' means null +PendingTx.prototype._notZeroOrEmptyString = function (value) { + // Geth will return '0x', and ganache-core v2.2.1 will return '0x0' + const valueIsEmpty = !value || value === '0x' || value === '0x0' + return !valueIsEmpty } PendingTx.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) { diff --git a/ui/app/components/send/send.utils.js b/ui/app/components/send/send.utils.js index af7b3823f..eb1667c63 100644 --- a/ui/app/components/send/send.utils.js +++ b/ui/app/components/send/send.utils.js @@ -215,7 +215,9 @@ async function estimateGas ({ // if recipient has no code, gas is 21k max: if (!selectedToken && !data) { const code = Boolean(to) && await global.eth.getCode(to) - if (!code || code === '0x' || code === '0x0') { // Infura will return '0x', and ganache-core v2.2.1 will return '0x0' + // Geth will return '0x', and ganache-core v2.2.1 will return '0x0' + const codeIsEmpty = !code || code === '0x' || code === '0x0' + if (codeIsEmpty) { return SIMPLE_GAS_COST } } else if (selectedToken && !to) { diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js index 9be77e14f..cfe2c4229 100644 --- a/ui/app/helpers/transactions.util.js +++ b/ui/app/helpers/transactions.util.js @@ -114,7 +114,9 @@ export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0') export async function isSmartContractAddress (address) { const code = await global.eth.getCode(address) - return code && code !== '0x' && code !== '0x0' // Infura will return '0x', and ganache-core v2.2.1 will return '0x0' + // Geth will return '0x', and ganache-core v2.2.1 will return '0x0' + const codeIsEmpty = !code || code === '0x' || code === '0x0' + return !codeIsEmpty } export function sumHexes (...args) { From 17a856cfd35a0e419524cf00e852be6c797b1e0b Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 21 Oct 2018 00:57:45 -0400 Subject: [PATCH 23/52] send tx - validate - simplify error message for attempting to call function on non-contract address --- app/_locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 4cdf6b8dc..e2fb3fc13 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -1176,7 +1176,7 @@ "message": "Transaction Error. Exception thrown in contract code." }, "transactionErrorNoContract": { - "message": "Trying to call a contract function at an address that is not a contract address." + "message": "Trying to call a function on a non-contract address." }, "transactionMemo": { "message": "Transaction memo (optional)" From 31e5cad1e34c1b07079c430bb1903f7914021111 Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 21 Oct 2018 01:01:21 -0400 Subject: [PATCH 24/52] tx-gas-util - set error message when invalidating tx based on tx data but no contract code --- app/scripts/controllers/transactions/tx-gas-utils.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/scripts/controllers/transactions/tx-gas-utils.js b/app/scripts/controllers/transactions/tx-gas-utils.js index 436900715..def67c2c3 100644 --- a/app/scripts/controllers/transactions/tx-gas-utils.js +++ b/app/scripts/controllers/transactions/tx-gas-utils.js @@ -62,20 +62,21 @@ class TxGasUtil { const recipient = txParams.to const hasRecipient = Boolean(recipient) - // see if we can set the gas based on the recipient + // see if we can set the gas based on the recipient if (hasRecipient) { const code = await this.query.getCode(recipient) // For an address with no code, geth will return '0x', and ganache-core v2.2.1 will return '0x0' const codeIsEmpty = !code || code === '0x' || code === '0x0' - + if (codeIsEmpty) { // if there's data in the params, but there's no contract code, it's not a valid transaction if (txParams.data) { - const err = new Error() + const err = new Error('TxGasUtil - Trying to call a function on a non-contract address') + // set error key so ui can display localized error message err.errorKey = TRANSACTION_NO_CONTRACT_ERROR_KEY throw err } - + // This is a standard ether simple send, gas requirement is exactly 21k txParams.gas = SIMPLE_GAS_COST // prevents buffer addition From 61c7bbb1c1f0c216d5f8cd0d0753c78bc635624e Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 21 Oct 2018 01:20:08 -0400 Subject: [PATCH 25/52] network - improve logging and type conversion --- app/scripts/controllers/network/network.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index b386161da..904c20cff 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -86,17 +86,19 @@ module.exports = class NetworkController extends EventEmitter { return log.warn('NetworkController - lookupNetwork aborted due to missing provider') } const ethQuery = new EthQuery(this._provider) - ethQuery.sendAsync({ method: 'eth_chainId' }, (err, chainId) => { + ethQuery.sendAsync({ method: 'eth_chainId' }, (err, chainIdHex) => { if (err) { + // if eth_chainId is not supported, fallback to net_verion ethQuery.sendAsync({ method: 'net_version' }, (err, network) => { if (err) return this.setNetworkState('loading') - log.info('web3.getNetwork returned net_version = ' + network) + log.info(`net_version returned ${network}`) this.setNetworkState(network) }) return } - log.info('web3.getNetwork returned chainId = ' + parseInt(chainId)) - this.setNetworkState(parseInt(chainId)) + const chainId = Number.parseInt(chainIdHex, 16) + log.info(`net_version returned ${chainId}`) + this.setNetworkState(chainId) }) } From b62d07f3a5bdfde7e295f17b7f601c6f2d5314ef Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 21 Oct 2018 04:32:07 -0400 Subject: [PATCH 26/52] Update network.js --- app/scripts/controllers/network/network.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index 904c20cff..6a5369f06 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -86,6 +86,7 @@ module.exports = class NetworkController extends EventEmitter { return log.warn('NetworkController - lookupNetwork aborted due to missing provider') } const ethQuery = new EthQuery(this._provider) + // first attempt to perform lookup via eth_chainId ethQuery.sendAsync({ method: 'eth_chainId' }, (err, chainIdHex) => { if (err) { // if eth_chainId is not supported, fallback to net_verion From baa3af46f375f46a3516ee7dec4e83795cbcfb66 Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Sun, 21 Oct 2018 05:35:37 -0400 Subject: [PATCH 27/52] install truffle globally --- test/e2e/beta/run-drizzle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/beta/run-drizzle.sh b/test/e2e/beta/run-drizzle.sh index 7bfffd7e6..bfb7e6fdb 100755 --- a/test/e2e/beta/run-drizzle.sh +++ b/test/e2e/beta/run-drizzle.sh @@ -11,7 +11,7 @@ sleep 5 cd test/e2e/beta/ rm -rf drizzle-test mkdir drizzle-test && cd drizzle-test -npm install truffle +sudo npm install -g truffle truffle unbox drizzle echo "Deploying contracts for Drizzle test..." truffle compile && truffle migrate From 6d09f60bbfe5ee737ff7a138260cc33e3db5ca46 Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 21 Oct 2018 05:48:15 -0400 Subject: [PATCH 28/52] ens-ipfs - refactor for readability (#5568) * ens-ipfs - refactor for readability * ens-ipfs - use official ipfs gateway for better performance * lint - remove unused code * ens-ipfs - support path and search * lint - gotta love that linter * ens-ipfs - improve loading page formatting * ens-ipfs - loading - redirect to 404 after 1 min timeout * ens-ipfs - destructure for cleaner code --- app/loading.html | 12 +++- app/scripts/background.js | 10 +-- .../lib/{ => ens-ipfs}/contracts/registrar.js | 0 .../lib/{ => ens-ipfs}/contracts/resolver.js | 0 app/scripts/lib/ens-ipfs/resolver.js | 54 ++++++++++++++ app/scripts/lib/ens-ipfs/setup.js | 63 ++++++++++++++++ app/scripts/lib/ipfsContent.js | 46 ------------ app/scripts/lib/resolver.js | 71 ------------------- 8 files changed, 131 insertions(+), 125 deletions(-) rename app/scripts/lib/{ => ens-ipfs}/contracts/registrar.js (100%) rename app/scripts/lib/{ => ens-ipfs}/contracts/resolver.js (100%) create mode 100644 app/scripts/lib/ens-ipfs/resolver.js create mode 100644 app/scripts/lib/ens-ipfs/setup.js delete mode 100644 app/scripts/lib/ipfsContent.js delete mode 100644 app/scripts/lib/resolver.js diff --git a/app/loading.html b/app/loading.html index aef5d9607..71403a5ac 100644 --- a/app/loading.html +++ b/app/loading.html @@ -1,5 +1,9 @@ - + + + + + MetaMask Loading