aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-03-29 05:12:20 +0800
committerkumavis <aaron@kumavis.me>2018-03-29 05:12:20 +0800
commitbedc1d1a477c94fe38c52d9d2b0b02405a399629 (patch)
treef80211eb2c307d9b52f40f3ff6923716473b0350
parent4f915cf2d817cf4dadea581c90a98841b81c156d (diff)
parent8766420f19251b95211dd99ff9a45e60cf0177ad (diff)
downloadtangerine-wallet-browser-bedc1d1a477c94fe38c52d9d2b0b02405a399629.tar.gz
tangerine-wallet-browser-bedc1d1a477c94fe38c52d9d2b0b02405a399629.tar.zst
tangerine-wallet-browser-bedc1d1a477c94fe38c52d9d2b0b02405a399629.zip
Merge branch 'master' of github.com:MetaMask/metamask-extension into ci-artifacts
-rw-r--r--app/scripts/controllers/currency.js2
-rw-r--r--app/scripts/controllers/transactions.js10
-rw-r--r--app/scripts/lib/setupRaven.js14
-rw-r--r--app/scripts/lib/tx-state-manager.js16
-rw-r--r--package-lock.json86
-rw-r--r--package.json4
6 files changed, 83 insertions, 49 deletions
diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js
index 25a7a942e..930fc52e8 100644
--- a/app/scripts/controllers/currency.js
+++ b/app/scripts/controllers/currency.js
@@ -52,7 +52,7 @@ class CurrencyController {
this.setConversionDate(Number(parsedResponse.timestamp))
}).catch((err) => {
if (err) {
- console.warn('MetaMask - Failed to query currency conversion.')
+ console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err)
this.setConversionRate(0)
this.setConversionDate('N/A')
}
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 3e3909361..7e2cc15da 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -250,7 +250,7 @@ module.exports = class TransactionController extends EventEmitter {
// wait for a nonce
nonceLock = await this.nonceTracker.getNonceLock(fromAddress)
// add nonce to txParams
- // if txMeta has lastGasPrice then it is a retry at same nonce with higher
+ // if txMeta has lastGasPrice then it is a retry at same nonce with higher
// gas price transaction and their for the nonce should not be calculated
const nonce = txMeta.lastGasPrice ? txMeta.txParams.nonce : nonceLock.nextNonce
txMeta.txParams.nonce = ethUtil.addHexPrefix(nonce.toString(16))
@@ -273,12 +273,14 @@ module.exports = class TransactionController extends EventEmitter {
async signTransaction (txId) {
const txMeta = this.txStateManager.getTx(txId)
- const txParams = txMeta.txParams
- const fromAddress = txParams.from
// add network/chain id
- txParams.chainId = ethUtil.addHexPrefix(this.getChainId().toString(16))
+ const chainId = this.getChainId()
+ const txParams = Object.assign({}, txMeta.txParams, { chainId })
+ // sign tx
+ const fromAddress = txParams.from
const ethTx = new Transaction(txParams)
await this.signEthTx(ethTx, fromAddress)
+ // set state to signed
this.txStateManager.setTxStatusSigned(txMeta.id)
const rawTx = ethUtil.bufferToHex(ethTx.serialize())
return rawTx
diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js
index a869588d0..b93591e65 100644
--- a/app/scripts/lib/setupRaven.js
+++ b/app/scripts/lib/setupRaven.js
@@ -23,10 +23,20 @@ function setupRaven(opts) {
release,
transport: function(opts) {
const report = opts.data
- // simplify ethjs error messages
+ // simplify certain complex error messages
report.exception.values.forEach(item => {
- item.value = extractEthjsErrorMessage(item.value)
+ let errorMessage = item.value
+ // simplify ethjs error messages
+ errorMessage = extractEthjsErrorMessage(errorMessage)
+ // simplify 'Transaction Failed: known transaction'
+ if (errorMessage.indexOf('Transaction Failed: known transaction') === 0) {
+ // cut the hash from the error message
+ errorMessage = 'Transaction Failed: known transaction'
+ }
+ // finalize
+ item.value = errorMessage
})
+
// modify report urls
rewriteReportUrls(report)
// make request normally
diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js
index ab344ae9b..23c915a61 100644
--- a/app/scripts/lib/tx-state-manager.js
+++ b/app/scripts/lib/tx-state-manager.js
@@ -106,12 +106,9 @@ module.exports = class TransactionStateManager extends EventEmitter {
}
updateTx (txMeta, note) {
+ // validate txParams
if (txMeta.txParams) {
- Object.keys(txMeta.txParams).forEach((key) => {
- const value = txMeta.txParams[key]
- if (typeof value !== 'string') console.error(`${key}: ${value} in txParams is not a string`)
- if (!ethUtil.isHexPrefixed(value)) console.error('is not hex prefixed, anything on txParams must be hex prefixed')
- })
+ this.validateTxParams(txMeta.txParams)
}
// create txMeta snapshot for history
@@ -139,6 +136,15 @@ module.exports = class TransactionStateManager extends EventEmitter {
this.updateTx(txMeta, `txStateManager#updateTxParams`)
}
+ // validates txParams members by type
+ validateTxParams(txParams) {
+ Object.keys(txParams).forEach((key) => {
+ const value = txParams[key]
+ if (typeof value !== 'string') throw new Error(`${key}: ${value} in txParams is not a string`)
+ if (!ethUtil.isHexPrefixed(value)) throw new Error('is not hex prefixed, everything on txParams must be hex prefixed')
+ })
+ }
+
/*
Takes an object of fields to search for eg:
let thingsToLookFor = {
diff --git a/package-lock.json b/package-lock.json
index 015828549..f0f76919a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -224,6 +224,15 @@
}
}
},
+ "@sinonjs/formatio": {
+ "version": "2.0.0",
+ "resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
+ "integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==",
+ "dev": true,
+ "requires": {
+ "samsam": "1.3.0"
+ }
+ },
"@types/node": {
"version": "8.5.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.5.5.tgz",
@@ -5202,12 +5211,20 @@
"dev": true
},
"eslint-plugin-mocha": {
- "version": "4.11.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-mocha/-/eslint-plugin-mocha-4.11.0.tgz",
- "integrity": "sha1-kRk6L1XiCl41l0BUoAidMBmO5Xg=",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-mocha/-/eslint-plugin-mocha-5.0.0.tgz",
+ "integrity": "sha512-mpRWWsjxRco2bY4qE5DL8SmGoVF0Onb6DZrbgOjFoNo1YNN299K2voIozd8Kce3qC/neWNr2XF27E1ZDMl1yZg==",
"dev": true,
"requires": {
- "ramda": "0.24.1"
+ "ramda": "0.25.0"
+ },
+ "dependencies": {
+ "ramda": {
+ "version": "0.25.0",
+ "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.25.0.tgz",
+ "integrity": "sha512-GXpfrYVPwx3K7RQ6aYT8KPS8XViSXUVJT1ONhoKPE9VAleW42YE+U+8VEyGWt41EnEQW7gwecYJriTI0pKoecQ==",
+ "dev": true
+ }
}
},
"eslint-plugin-react": {
@@ -6090,12 +6107,12 @@
}
},
"ethjs-query": {
- "version": "0.3.2",
- "resolved": "https://registry.npmjs.org/ethjs-query/-/ethjs-query-0.3.2.tgz",
- "integrity": "sha1-9IikjOGZTNTHfsy3tSkCxvKc/YU=",
+ "version": "0.3.4",
+ "resolved": "https://registry.npmjs.org/ethjs-query/-/ethjs-query-0.3.4.tgz",
+ "integrity": "sha512-RkeLtBwuXJkBIf/U+Az0GOT203UiBLmN7WA6WZIwSTbmhH2yNicggwaWKvN3TOtpErOsXnzYTZp82mElHdORUQ==",
"requires": {
- "ethjs-format": "0.2.4",
- "ethjs-rpc": "0.1.8"
+ "ethjs-format": "0.2.5",
+ "ethjs-rpc": "0.1.9"
},
"dependencies": {
"bn.js": {
@@ -6104,12 +6121,12 @@
"integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU="
},
"ethjs-format": {
- "version": "0.2.4",
- "resolved": "https://registry.npmjs.org/ethjs-format/-/ethjs-format-0.2.4.tgz",
- "integrity": "sha1-W7vESlrSTmirOTMS/5A5pztlv4E=",
+ "version": "0.2.5",
+ "resolved": "https://registry.npmjs.org/ethjs-format/-/ethjs-format-0.2.5.tgz",
+ "integrity": "sha1-RPMKvuF7B01xYtLIhqv/0GWCiSU=",
"requires": {
"bn.js": "4.11.6",
- "ethjs-schema": "0.1.9",
+ "ethjs-schema": "0.2.0",
"ethjs-util": "0.1.3",
"is-hex-prefixed": "1.0.0",
"number-to-bn": "1.7.0",
@@ -6117,9 +6134,14 @@
}
},
"ethjs-rpc": {
- "version": "0.1.8",
- "resolved": "https://registry.npmjs.org/ethjs-rpc/-/ethjs-rpc-0.1.8.tgz",
- "integrity": "sha1-FnZ0DkHHIoGWpxGJ0z8VychbWZ0="
+ "version": "0.1.9",
+ "resolved": "https://registry.npmjs.org/ethjs-rpc/-/ethjs-rpc-0.1.9.tgz",
+ "integrity": "sha512-KJqT7cgTeCJQ2RY1AlVmTZVnKIUXMPg+niPN5VJKwRSzpjgfr3LTVHlGbkRCqZtOMDi0ogB2vHZaRQiZBXZTUg=="
+ },
+ "ethjs-schema": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/ethjs-schema/-/ethjs-schema-0.2.0.tgz",
+ "integrity": "sha1-B7RtT1W3kqhGyQp58zDTHREsyjg="
},
"ethjs-util": {
"version": "0.1.3",
@@ -12459,9 +12481,9 @@
"integrity": "sha1-rgyqVhERSYxboTcj1vtjHSQAOTQ="
},
"lolex": {
- "version": "2.3.1",
- "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.1.tgz",
- "integrity": "sha512-mQuW55GhduF3ppo+ZRUTz1PRjEh1hS5BbqU7d8D0ez2OKxHDod7StPPeAVKisZR5aLkHZjdGWSL42LSONUJsZw==",
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz",
+ "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==",
"dev": true
},
"longest": {
@@ -13646,14 +13668,14 @@
"dev": true
},
"nise": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/nise/-/nise-1.2.0.tgz",
- "integrity": "sha512-q9jXh3UNsMV28KeqI43ILz5+c3l+RiNW8mhurEwCKckuHQbL+hTJIKKTiUlCPKlgQ/OukFvSnKB/Jk3+sFbkGA==",
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/nise/-/nise-1.3.2.tgz",
+ "integrity": "sha512-KPKb+wvETBiwb4eTwtR/OsA2+iijXP+VnlSFYJo3EHjm2yjek1NWxHOUQat3i7xNLm1Bm18UA5j5Wor0yO2GtA==",
"dev": true,
"requires": {
- "formatio": "1.2.0",
+ "@sinonjs/formatio": "2.0.0",
"just-extend": "1.1.27",
- "lolex": "1.6.0",
+ "lolex": "2.3.2",
"path-to-regexp": "1.7.0",
"text-encoding": "0.6.4"
},
@@ -13664,12 +13686,6 @@
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"dev": true
},
- "lolex": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.6.0.tgz",
- "integrity": "sha1-OpoCg0UqR9dDnnJzG54H1zhuSfY=",
- "dev": true
- },
"path-to-regexp": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz",
@@ -18695,16 +18711,16 @@
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
},
"sinon": {
- "version": "4.1.3",
- "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.1.3.tgz",
- "integrity": "sha512-c7u0ZuvBRX1eXuB4jN3BRCAOGiUTlM8SE3TxbJHrNiHUKL7wonujMOB6Fi1gQc00U91IscFORQHDga/eccqpbw==",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/sinon/-/sinon-5.0.0.tgz",
+ "integrity": "sha512-dMX7ZB2E1iQ5DOEOePoNJQp03uyhdMfb+kLXlNPbquv2FwfezD+0GbbHSgCw4MFhpSSS9NMoYJfOPMjCMJtXWA==",
"dev": true,
"requires": {
"diff": "3.3.1",
"formatio": "1.2.0",
"lodash.get": "4.4.2",
- "lolex": "2.3.1",
- "nise": "1.2.0",
+ "lolex": "2.3.2",
+ "nise": "1.3.2",
"supports-color": "4.5.0",
"type-detect": "4.0.5"
},
diff --git a/package.json b/package.json
index b53daeb83..6cd8f7f4e 100644
--- a/package.json
+++ b/package.json
@@ -109,7 +109,7 @@
"ethjs": "^0.2.8",
"ethjs-contract": "^0.1.9",
"ethjs-ens": "^2.0.0",
- "ethjs-query": "^0.3.1",
+ "ethjs-query": "^0.3.4",
"express": "^4.15.5",
"extension-link-enabler": "^1.0.0",
"extensionizer": "^1.0.0",
@@ -144,6 +144,7 @@
"obs-store": "^3.0.0",
"once": "^1.3.3",
"percentile": "^1.2.0",
+ "pify": "^3.0.0",
"ping-pong-stream": "^1.0.0",
"pojo-migrator": "^2.1.0",
"polyfill-crypto.getrandomvalues": "^1.0.0",
@@ -151,7 +152,6 @@
"promise-filter": "^1.1.0",
"promise-to-callback": "^1.0.0",
"pump": "^3.0.0",
- "pify": "^3.0.0",
"pumpify": "^1.3.4",
"qrcode-npm": "0.0.3",
"ramda": "^0.24.1",